Register

Trait Register 

Source
pub trait Register
where Self: Sized,
{ // Provided methods fn register_helpers(self) -> Result<Self> { ... } fn load(self, config: &DTConfig) -> Result<Self> { ... } fn update<S: Serialize>(&mut self, name: &str, ctx: &S) -> Result<()> { ... } fn get(&self, name: &str) -> Result<Vec<u8>> { ... } }
Expand description

A registry should hold an environment of templates, and a cached storing the rendered contents.

Provided Methods§

Source

fn register_helpers(self) -> Result<Self>

Registers DT’s built-in helpers.

Source

fn load(self, config: &DTConfig) -> Result<Self>

Load templates and render them into cached storage, items that are not templated (see renderable) will not be registered into templates but directly stored into the rendered cache.

Source

fn update<S: Serialize>(&mut self, name: &str, ctx: &S) -> Result<()>

Renders the template addressed by name and store the rendered content into cache.

Rendering only happens if this item is considered as a plain text file. If this item is considered as a binary file, it’s original content is returned. The content type is inspected via the content_inspector crate. Although it can correctly determine if an item is binary or text mostly of the time, it is just a heuristic check and can fail in some cases, e.g. NUL byte in the first 1024 bytes of a UTF-8-encoded text file, etc.. See the crate’s home page for the full caveats.

Source

fn get(&self, name: &str) -> Result<Vec<u8>>

Looks up the rendered content of an item with given name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§