pub struct Schema {
pub opts: SchemaOpts,
pub frontmatter: Vec<FieldSchema>,
pub body: Vec<Node>,
}Expand description
A parsed schema: per-schema options, the frontmatter field schemas, and the body node tree.
Fields§
§opts: SchemaOpts§frontmatter: Vec<FieldSchema>§body: Vec<Node>Implementations§
Source§impl Schema
impl Schema
Sourcepub fn edit(
&self,
md: &str,
target: &str,
new_value: &str,
) -> Result<String, EditError>
pub fn edit( &self, md: &str, target: &str, new_value: &str, ) -> Result<String, EditError>
Replace the content of the node at target (a .-separated alias
path, e.g. "plan.cases.2") with new_value and return the modified
markdown.
target mirrors the key path of Schema::extract’s output; a
trailing numeric segment (.2) picks the N-th element of a list.
Only leaf string nodes (list items and prose paragraphs) are editable;
for list items the bullet/marker and any checkbox prefix are preserved.
Returns EditError::TargetNotFound if the path does not resolve, or
EditError::IndexOutOfRange if a numeric index exceeds the list.
Source§impl Schema
impl Schema
Sourcepub fn scaffold(&self) -> String
pub fn scaffold(&self) -> String
Emit a conforming starter document: required frontmatter keys with typed
placeholders, headings, and one placeholder item per required list.
Optional nodes (?/*/min-0) are omitted.
Sourcepub fn render(&self, data: &Value) -> Result<String, RenderError>
pub fn render(&self, data: &Value) -> Result<String, RenderError>
Render a conforming markdown document from data — the inverse of
Schema::extract. data is a JSON object keyed by the capture aliases
declared in the schema.
Returns RenderError::MissingField if a required field is absent from
data, or RenderError::WrongType if a value has an incompatible JSON
type.
Trait Implementations§
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more