pub struct SectionQuery<'a> { /* private fields */ }Expand description
Allows chained queries deep down into a document hierarchy without having to manually handle possibly missing sections in between. If the terminal/leaf element/value of a query chain is required, the first missing element in the chain will be “bubbled” up as the cause of the error.
Note that chaining still returns a Result<*, enolib::Error>
at every step, due to the fact that a query step may not only
fail due to a (potentially graceful) missing element, but also
due to ambiguous results (e.g. two sections with the same key),
which is an immediate hard error. Hint: Use the idiomatic approach
with the ? operator to create nicely readable code with this API.
Implementations§
Source§impl<'a> SectionQuery<'a>
impl<'a> SectionQuery<'a>
pub fn elements(&self) -> &[Box<dyn SectionElement>]
pub fn embed(&self, key: &str) -> Result<EmbedQuery<'_>, Error>
pub fn field(&self, key: &str) -> Result<FieldQuery<'_>, Error>
pub fn flag(&self, key: &str) -> Result<FlagQuery<'_>, Error>
pub fn missing_error(&self) -> Error
pub fn section(&self, key: &str) -> Result<SectionQuery<'_>, Error>
pub fn snippet(&self) -> Result<String, Error>
pub fn snippet_with_options( &self, printer: &dyn Printer, gutter: bool, ) -> Result<String, Error>
Auto Trait Implementations§
impl<'a> Freeze for SectionQuery<'a>
impl<'a> !RefUnwindSafe for SectionQuery<'a>
impl<'a> !Send for SectionQuery<'a>
impl<'a> !Sync for SectionQuery<'a>
impl<'a> Unpin for SectionQuery<'a>
impl<'a> !UnwindSafe for SectionQuery<'a>
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