Struct gray_matter::ParsedEntityStruct
source · [−]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
sourceimpl<T: Debug + DeserializeOwned> Debug for ParsedEntityStruct<T>
impl<T: Debug + DeserializeOwned> Debug for ParsedEntityStruct<T>
sourceimpl<T: PartialEq + DeserializeOwned> PartialEq<ParsedEntityStruct<T>> for ParsedEntityStruct<T>
impl<T: PartialEq + DeserializeOwned> PartialEq<ParsedEntityStruct<T>> for ParsedEntityStruct<T>
sourcefn eq(&self, other: &ParsedEntityStruct<T>) -> bool
fn eq(&self, other: &ParsedEntityStruct<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ParsedEntityStruct<T>) -> bool
fn ne(&self, other: &ParsedEntityStruct<T>) -> bool
This method tests for !=
.
impl<T: DeserializeOwned> StructuralPartialEq for ParsedEntityStruct<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for ParsedEntityStruct<T> where
T: RefUnwindSafe,
impl<T> Send for ParsedEntityStruct<T> where
T: Send,
impl<T> Sync for ParsedEntityStruct<T> where
T: Sync,
impl<T> Unpin for ParsedEntityStruct<T> where
T: Unpin,
impl<T> UnwindSafe for ParsedEntityStruct<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more