pub struct ParsedDocument { /* private fields */ }Expand description
A parsed markdown document with frontmatter
Implementations§
Source§impl ParsedDocument
impl ParsedDocument
Sourcepub fn new(fields: HashMap<String, QuillValue>) -> Self
pub fn new(fields: HashMap<String, QuillValue>) -> Self
Create a new ParsedDocument with the given fields
Sourcepub fn with_quill_tag(
fields: HashMap<String, QuillValue>,
quill_tag: String,
) -> Self
pub fn with_quill_tag( fields: HashMap<String, QuillValue>, quill_tag: String, ) -> Self
Create a ParsedDocument from fields and quill tag
Sourcepub fn from_markdown(markdown: &str) -> Result<Self, ParseError>
pub fn from_markdown(markdown: &str) -> Result<Self, ParseError>
Create a ParsedDocument from markdown string
Sourcepub fn quill_tag(&self) -> &str
pub fn quill_tag(&self) -> &str
Get the quill tag (from QUILL key, or “default” if not specified)
Sourcepub fn get_field(&self, name: &str) -> Option<&QuillValue>
pub fn get_field(&self, name: &str) -> Option<&QuillValue>
Get a specific field
Sourcepub fn fields(&self) -> &HashMap<String, QuillValue>
pub fn fields(&self) -> &HashMap<String, QuillValue>
Get all fields (including body)
Sourcepub fn with_defaults(&self, defaults: &HashMap<String, QuillValue>) -> Self
pub fn with_defaults(&self, defaults: &HashMap<String, QuillValue>) -> Self
Create a new ParsedDocument with default values applied
This method creates a new ParsedDocument with default values applied for any fields that are missing from the original document but have defaults specified. Existing fields are preserved and not overwritten.
§Arguments
defaults- A HashMap of field names to their default QuillValues
§Returns
A new ParsedDocument with defaults applied for missing fields
Sourcepub fn with_coercion(&self, schema: &QuillValue) -> Self
pub fn with_coercion(&self, schema: &QuillValue) -> Self
Create a new ParsedDocument with coerced field values
This method applies type coercions to field values based on the schema. Coercions include:
- Singular values to arrays when schema expects array
- String “true”/“false” to boolean
- Numbers to boolean (0=false, non-zero=true)
- String numbers to number type
- Boolean to number (true=1, false=0)
§Arguments
schema- A JSON Schema object defining expected field types
§Returns
A new ParsedDocument with coerced field values
Trait Implementations§
Source§impl Clone for ParsedDocument
impl Clone for ParsedDocument
Source§fn clone(&self) -> ParsedDocument
fn clone(&self) -> ParsedDocument
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ParsedDocument
impl RefUnwindSafe for ParsedDocument
impl Send for ParsedDocument
impl Sync for ParsedDocument
impl Unpin for ParsedDocument
impl UnwindSafe for ParsedDocument
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)