Skip to main content

GenerationHooks

Trait GenerationHooks 

Source
pub trait GenerationHooks: Send + Sync {
    type Error: From<Error> + Send;

    // Provided methods
    fn rename(
        &self,
        _paths: &[String],
    ) -> impl Future<Output = Result<Option<Vec<String>>, Self::Error>> + Send { ... }
    fn has_css_context(&self) -> bool { ... }
    fn has_html_context(&self) -> bool { ... }
    fn css_context(
        &self,
        context: Map<String, Value>,
    ) -> impl Future<Output = Result<Map<String, Value>, Self::Error>> + Send { ... }
    fn html_context(
        &self,
        context: Map<String, Value>,
    ) -> impl Future<Output = Result<Map<String, Value>, Self::Error>> + Send { ... }
}
Expand description

Async hooks used by crate::generate_with_hooks.

Rename receives ordered paths after source loading, flattened in configured variant order. Return None to derive names from file stems. Context hooks run only when their matching has_*_context method returns true; CSS runs before HTML. Callback errors are preserved through the associated error type, while engine failures are converted from I/O errors.

Required Associated Types§

Source

type Error: From<Error> + Send

Error returned to the caller, including converted engine errors.

Provided Methods§

Source

fn rename( &self, _paths: &[String], ) -> impl Future<Output = Result<Option<Vec<String>>, Self::Error>> + Send

Resolve one glyph name per borrowed path, or use the engine’s defaults. Adapters that need an owned callback payload can copy paths inside this method.

Source

fn has_css_context(&self) -> bool

Whether CSS context mutation is enabled.

Source

fn has_html_context(&self) -> bool

Whether HTML context mutation is enabled.

Source

fn css_context( &self, context: Map<String, Value>, ) -> impl Future<Output = Result<Map<String, Value>, Self::Error>> + Send

Mutate the CSS template context before rendering.

Source

fn html_context( &self, context: Map<String, Value>, ) -> impl Future<Output = Result<Map<String, Value>, Self::Error>> + Send

Mutate the HTML context, including styles derived from the finalized CSS context.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl GenerationHooks for ()

Implementors§