lib_humus/lib.rs
1#![warn(missing_docs)]
2#![allow(clippy::needless_return)] // Explicit returning can improve readability
3#![allow(clippy::result_unit_err)] // Better than uing an Option …
4#![allow(clippy::to_string_trait_impl)] // Don't want to deal with reimplmenting as `Display` right now.
5#![allow(clippy::redundant_field_names)] // Those are okay
6#![allow(clippy::tabs_in_doc_comments)] // Tabs are just fine
7
8#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
9
10//! lib-humus helps with some fertile ground to build project on.
11//!
12//! It helps combining axum with tera and getting configuration from toml-files.
13//!
14//! The idea behind this is that all the data that gets rendered as html
15//! should also be available as a JSON-API (and other formats if useful).
16//! The html should also come from easily replaceable templates
17//! that are themselves configurable.
18//!
19//! The [HumusEngine] helps you with that,
20//! it gets handed a serde seralizable [View][HumusView]
21//! and some [HumusQuerySettings] and then generates an appropriate response.
22//! (How you generate those is currently completely up to you.)
23//!
24//! Loading the templates and the template configuration
25//! can be done using the [TemplateEngineLoader].
26//!
27//! And since you probably need configurtion for your own application
28//! the [read_toml_from_file] function is exported for public use.
29//!
30//! This library is derived from (and now used by) the
31//! [echoip-slatecave service](https://codeberg.org/slatian/service.echoip-slatecave).
32//!
33//! # Feature-flags
34//!
35//! Features enabled by default:
36//! * `axum-view`: Provides the [HumusEngine] and sourrounding utilities
37//! * `tera-loader`: Provides the [TemplateEngineLoader].
38//! * `toml` Provides the [read_toml_from_file] helper.
39//!
40//! Features disabled by default:
41//! * `axum-view+cookie`: Provides the [HumusView::get_cookie_header] helper for setting cookies.
42
43///////////////////////////////////////
44// Toml
45
46#[cfg(feature="toml")]
47mod toml_helper;
48
49#[cfg(feature="toml")]
50pub use self::toml_helper::*;
51
52///////////////////////////////////////
53// Tera-Loader
54
55#[cfg(feature="tera-loader")]
56mod template_loader;
57
58#[cfg(feature="tera-loader")]
59pub use self::template_loader::*;
60
61///////////////////////////////////////
62// Proto Engine
63
64
65#[cfg(any(feature="tera-loader",feature="axum-view"))]
66mod proto_engine;
67
68#[cfg(any(feature="tera-loader",feature="axum-view"))]
69pub use self::proto_engine::HumusProtoEngine;
70
71
72///////////////////////////////////////
73// Axum-View
74
75#[cfg(feature="axum-view")]
76mod engine;
77#[cfg(feature="axum-view")]
78mod format;
79#[cfg(feature="axum-view")]
80mod query_settings;
81#[cfg(feature="axum-view")]
82mod view;
83
84#[cfg(feature="axum-view")]
85pub use self::{
86 engine::*,
87 format::*,
88 query_settings::*,
89 view::*,
90};
91