Struct gray_matter::ParsedEntityStruct[][src]

pub struct ParsedEntityStruct<T: DeserializeOwned> {
    pub data: T,
    pub content: String,
    pub excerpt: Option<String>,
    pub orig: String,
    pub matter: String,
}
Expand description

ParsedEntityStruct stores the parsed result with the front matter deserialized into a struct T.

Examples

Basic usage:

#[derive(serde::Deserialize)]
struct FrontMatter {
    field: i32,
}

let text = r#"---
field: -134
---
Here is excerpt
---
Here is content"#;

let matter = Matter::<YAML>::new();
let result: ParsedEntityStruct<FrontMatter> = matter.parse_with_struct(text).unwrap();

assert_eq!(result.data.field, -134);
assert_eq!(result.excerpt, Some("Here is excerpt".to_owned()));
assert_eq!(result.content, "Here is excerpt\n---\nHere is content")

Fields

data: T

The front matter data, deserialized into T.

content: String

The full input, but with the front matter and delimiters stripped out. Any excerpt is also part of this field.

excerpt: Option<String>

A string containing the excerpt, if found. None otherwise.

orig: String

The original input.

matter: String

The raw front matter. Empty string if no front matter is found.

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Performs the conversion.

Performs the conversion.

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.