pub struct Document { /* private fields */ }Expand description
Represents a queryable YAML document.
Implementations§
source§impl Document
impl Document
sourcepub fn new(source: impl Into<String>) -> Result<Self, QueryError>
pub fn new(source: impl Into<String>) -> Result<Self, QueryError>
Construct a new Document from the given YAML.
sourcepub fn root(&self) -> Feature<'_>
pub fn root(&self) -> Feature<'_>
Returns a Feature for this document’s root node.
This is typically useful as a “fallback” feature, e.g. for capturing a span of the entire document.
sourcepub fn query(&self, query: &Query) -> Result<Feature<'_>, QueryError>
pub fn query(&self, query: &Query) -> Result<Feature<'_>, QueryError>
Perform a query on the current document, returning a Feature
if the query succeeds.
sourcepub fn extract(&self, feature: &Feature<'_>) -> &str
pub fn extract(&self, feature: &Feature<'_>) -> &str
Returns a string slice of the original document corresponding to the given
Feature.
Important: The returned string here can be longer than the span
identified in the Feature. In particular, this API will return a
longer string if it identifies leading non-newline whitespace
ahead of the captured Feature, since this indicates indentation
not encapsulated by the feature itself.
Panics if the feature’s span is invalid.
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