pub struct Document {
pub root: AstNode,
pub source_path: Option<String>,
pub source_text: Option<String>,
}
Expand description
Represents a complete NOML document with metadata
Fields§
§root: AstNode
Root value of the document (typically a table)
source_path: Option<String>
Source file path (if loaded from file)
source_text: Option<String>
Original source text (for error reporting and round-trip)
Implementations§
Source§impl Document
impl Document
Sourcepub fn with_source(
root: AstNode,
path: Option<String>,
text: Option<String>,
) -> Self
pub fn with_source( root: AstNode, path: Option<String>, text: Option<String>, ) -> Self
Create a document with source information
Sourcepub fn to_value(&self) -> Result<Value>
pub fn to_value(&self) -> Result<Value>
Convert the AST to a Value tree (losing source information)
Sourcepub fn source_text_for_span(&self, span: &Span) -> Option<&str>
pub fn source_text_for_span(&self, span: &Span) -> Option<&str>
Get the source text for a span
Sourcepub fn node_at_offset(&self, offset: usize) -> Option<&AstNode>
pub fn node_at_offset(&self, offset: usize) -> Option<&AstNode>
Find the AST node at a given byte offset
Sourcepub fn all_comments(&self) -> Vec<&Comment>
pub fn all_comments(&self) -> Vec<&Comment>
Get all comments in the document
Trait Implementations§
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
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
Mutably borrows from an owned value. Read more