pub trait Query<'v>: Sized {
type ItemRef: Sized + 'v;
type Item: Sized;
// Required methods
fn lookup<'p, P>(&'v self, path: P) -> Option<Self::ItemRef>
where P: Path<'p>;
fn take<'p, P>(self, path: P) -> (Option<Self>, Option<Self::Item>)
where P: Path<'p>;
fn insert<'p, P>(
&mut self,
path: P,
insertee: Self::Item,
) -> Result<(), Self::Item>
where P: Path<'p>;
}
Required Associated Types§
Required Methods§
Sourcefn lookup<'p, P>(&'v self, path: P) -> Option<Self::ItemRef>where
P: Path<'p>,
fn lookup<'p, P>(&'v self, path: P) -> Option<Self::ItemRef>where
P: Path<'p>,
Lookup for an element under the specified path. Returns an optional reference to the sought element.
Sourcefn take<'p, P>(self, path: P) -> (Option<Self>, Option<Self::Item>)where
P: Path<'p>,
fn take<'p, P>(self, path: P) -> (Option<Self>, Option<Self::Item>)where
P: Path<'p>,
Takes the element under the specified path out of the queried node. Returns a tuple of two items:
- optinal remainder of the queried node;
- optinal taken away element.
Sourcefn insert<'p, P>(
&mut self,
path: P,
insertee: Self::Item,
) -> Result<(), Self::Item>where
P: Path<'p>,
fn insert<'p, P>(
&mut self,
path: P,
insertee: Self::Item,
) -> Result<(), Self::Item>where
P: Path<'p>,
Inserts an element into the queried node under the specified path. Returns Ok(()) if inserted or Err(rejected_element) if could not perform insertion (e.g. path leads to a child of a non-object sub-node).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.