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