Crate lib_humus

Source
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:

Features disabled by default:

Structs§

HumusEngineaxum-view
🌄 Tera based Templating Engine that writes out axum Response structs.
HumusProtoEnginetera-loader or axum-view
A constructable version of HumusEngine without the types attached.
TemplateEngineLoadertera-loader
Helps loading Templates from disk along with a handy configuration file.

Enums§

HtmlTextJsonFormataxum-view
Ready to use example implementation of a HumusFormat featuring html, text and json.
HumusFormatFamilyaxum-view
Defines how the response should be rendered.
TemplateEngineLoaderErrortera-loader
Returned when loading a template using the TemplateEngineLoader fails.
TomlErrortoml
Returned when read_toml_from_file() fails.

Traits§

HumusFormataxum-view
Provides information on what to render and how to deliver it to the HumusEngine.
HumusQuerySettingsaxum-view
Provides context from the query for use in the HumusEngine.
HumusViewaxum-view
👁 Provides data and logic for the HumusEngine and knows how to put information together.

Functions§

read_toml_from_filetoml
Reads from a specified filepath, parses as toml and returns as the desired deserialized type.