Skip to main content

frontend

Macro frontend 

Source
macro_rules! frontend {
    ($handler:expr) => { ... };
}
Expand description

Define a front-end worm. It takes source text and returns transformed source.

The closure takes the contents of the file and the [config.<name>] table of the worm, serialized again as TOML. It returns the transformed source. Each error type that implements Display works, so anyhow::Result<String> is valid.

larvae_worm::frontend!(|source: &str, _config: &str| -> Result<String, String> {
    Ok(source.replace("<>", "{}"))
});

The macro expands to the three exports in the module docs. Use it once per worm.