staticweaver/lib.rs
1#![forbid(unsafe_code)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3// Copyright © 2024-2026 StaticWeaver. All rights reserved.
4// SPDX-License-Identifier: Apache-2.0 OR MIT
5#![doc = include_str!("../README.md")]
6#![doc(
7 html_favicon_url = "https://cloudcdn.pro/staticweaver/v1/favicon.ico",
8 html_logo_url = "https://cloudcdn.pro/staticweaver/v1/logos/staticweaver.svg",
9 html_root_url = "https://docs.rs/staticweaver"
10)]
11#![crate_name = "staticweaver"]
12#![crate_type = "lib"]
13#![deny(missing_docs)]
14#![warn(rustdoc::missing_crate_level_docs)]
15
16/// Polymorphic key-value `Context` and the `Value` enum (`Null`,
17/// `Bool`, `Number`, `String`, `List`, `Map`) that templates substitute.
18/// Supports dot-notation lookup via [`context::Context::get_path`].
19pub use staticweaver_core::context;
20
21/// The [`engine::Engine`] struct: template parser, expression
22/// evaluator, partial loader, inheritance resolver, filter pipeline,
23/// and renderer for both in-memory strings and `.html` files on disk.
24pub mod engine;
25
26/// Error types ([`error::EngineError`] and [`error::TemplateError`])
27/// returned by every fallible operation in the crate.
28pub use staticweaver_core::error;
29
30/// Generic time-bounded LRU cache with TTL expiration. Used by
31/// [`engine::Engine::render_page`] to memoise rendered pages.
32pub mod cache;
33
34/// HTTPS-only transport policy for the remote-template fetcher.
35#[cfg(feature = "remote-templates")]
36mod transport;
37
38/// Async template-loading surface (issue #37). Gated behind the
39/// `async` feature so default builds stay sync-only. Exposes the
40/// [`loader_async::AsyncTemplateLoader`] trait and a reference
41/// [`loader_async::TokioFsLoader`] impl (under `async-tokio`).
42#[cfg(feature = "async")]
43#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
44pub use staticweaver_async as loader_async;
45
46/// Filesystem-watching loader (issue #52). Gated behind the `watch`
47/// feature: [`watch::WatchLoader`] wraps any loader, caches its
48/// templates, and invalidates them on debounced change events.
49#[cfg(feature = "watch")]
50#[cfg_attr(docsrs, doc(cfg(feature = "watch")))]
51pub mod watch;
52
53pub use context::Context;
54pub use engine::Engine;
55pub use error::{EngineError, TemplateError};
56
57/// Prelude module for convenient imports
58pub mod prelude {
59 pub use crate::{Context, Engine, EngineError, TemplateError};
60}