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
impl<T: PartialEq + DeserializeOwned> PartialEq<ParsedEntityStruct<T>> for ParsedEntityStruct<T>
impl<T: PartialEq + DeserializeOwned> PartialEq<ParsedEntityStruct<T>> for ParsedEntityStruct<T>
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.