#[repr(u8)]pub enum DocumentSpec {
Text(TextSpec),
Structured(StructuredSpec),
Markdown(MarkdownSpec),
}Expand description
A complete desired document or a source-preserving partial document.
Variants§
Text(TextSpec)
A plain text document, rendered node by node.
Structured(StructuredSpec)
A structured (JSON, JSON5, TOML, or YAML) document.
Markdown(MarkdownSpec)
A Markdown document.
Implementations§
Source§impl DocumentSpec
impl DocumentSpec
Sourcepub fn set_string(format: Format, key: &ManagedPath, value: &str) -> Self
pub fn set_string(format: Format, key: &ManagedPath, value: &str) -> Self
A structured document that sets the string at key to value and
leaves the rest of the source alone. It keeps the line ending of the
source.
fn payload(&self) -> &dyn Payload
Sourcepub const fn is_partial(&self) -> bool
pub const fn is_partial(&self) -> bool
Whether this document leaves any part of its source user-owned.
Sourcepub fn validate(&self) -> Result<(), DocumentError>
pub fn validate(&self) -> Result<(), DocumentError>
Check the document’s declaration without reading any source.
§Errors
Returns an error for invalid ownership paths, for comment nodes that cannot be rendered and for invalid Markdown selectors.
Sourcepub fn reconcile(
&self,
current: Option<&[u8]>,
) -> Result<Vec<u8>, DocumentError>
pub fn reconcile( &self, current: Option<&[u8]>, ) -> Result<Vec<u8>, DocumentError>
Reconcile one desired document against its current source bytes.
§Errors
Returns an error for invalid AST, unsupported partial ownership, malformed source, or a current source whose line endings cannot be resolved.
Trait Implementations§
Source§impl Clone for DocumentSpec
impl Clone for DocumentSpec
Source§fn clone(&self) -> DocumentSpec
fn clone(&self) -> DocumentSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more