pub struct Matter<T: Engine> {
    pub delimiter: String,
    pub excerpt_delimiter: Option<String>,
    /* private fields */
}
Expand description

Coupled with an Engine of choice, Matter stores delimiter(s) and handles parsing.

Fields

delimiter: Stringexcerpt_delimiter: Option<String>

Implementations

Runs parsing on the input. Uses the engine contained in self to parse any front matter detected.

Examples

Basic usage:

let matter: Matter<YAML> = Matter::new();
let input = "---\ntitle: Home\n---\nOther stuff";
let parsed_entity = matter.parse(input);

assert_eq!(parsed_entity.content, "Other stuff");

Wrapper around parse, that deserializes any front matter into a custom struct. Supplied as an ease-of-use function to prevent having to deserialize manually.

Returns None if no front matter is found, or if the front matter is not deserializable into the custom struct.

Examples

Basic usage:

#[derive(serde::Deserialize)]
struct Config {
    title: String,
}

let matter: Matter<YAML> = Matter::new();
let input = "---\ntitle: Home\n---\nOther stuff";
let parsed_entity =  matter.parse_with_struct::<Config>(input).unwrap();

assert_eq!(parsed_entity.data.title, "Home");

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.