Expand description
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 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.
§Feature-flags
Features enabled by default:
axum-view
: Provides the HumusEngine and sourrounding utilitiestera-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.
Structs§
- HumusEngine
axum-view
🌄 Tera based Templating Engine that writes out axum Response structs. - HumusProtoEngine
tera-loader
oraxum-view
A constructable version of HumusEngine without the types attached. - TemplateEngineLoader
tera-loader
Helps loading Templates from disk along with a handy configuration file.
Enums§
- HtmlTextJsonFormat
axum-view
- HumusFormatFamily
axum-view
Defines how the response should be rendered. - TemplateEngineLoaderError
tera-loader
Returned when loading a template using the TemplateEngineLoader fails. - TomlError
toml
Returned when read_toml_from_file() fails.
Traits§
- HumusFormat
axum-view
Provides information on what to render and how to deliver it to the HumusEngine. - HumusQuerySettings
axum-view
Provides context from the query for use in the HumusEngine. - HumusView
axum-view
👁 Provides data and logic for the HumusEngine and knows how to put information together.
Functions§
- Reads from a specified filepath, parses as toml and returns as the desired deserialized type.