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: Option<String>,
) -> Self
pub fn with_quill_tag( fields: HashMap<String, QuillValue>, quill_tag: Option<String>, ) -> Self
Create a ParsedDocument from fields and optional 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 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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more