pub struct ManifestQuery;Expand description
Query engine for extracting subtrees from manifest YAML values.
Implementations§
Source§impl ManifestQuery
impl ManifestQuery
Sourcepub fn query(
root: &Value,
path: &str,
manifest_id: &str,
) -> Result<Value, NapError>
pub fn query( root: &Value, path: &str, manifest_id: &str, ) -> Result<Value, NapError>
Traverse a dot-separated path into a YAML value tree.
§Arguments
root— The YAML value to traverse (typically a serialized Manifest).path— Dot-separated path. e.g.,"references.appears_in".
§Returns
The subtree at the given path, or an error if any segment is missing.
§Examples
use serde_yaml::Value;
use nap_core::query::ManifestQuery;
let yaml = "
name: Luke Skywalker
properties:
homeworld: tatooine
species: human
";
let root: Value = serde_yaml::from_str(yaml).unwrap();
let result = ManifestQuery::query(&root, "properties.homeworld", "test").unwrap();
assert_eq!(result, Value::String("tatooine".to_string()));Auto Trait Implementations§
impl Freeze for ManifestQuery
impl RefUnwindSafe for ManifestQuery
impl Send for ManifestQuery
impl Sync for ManifestQuery
impl Unpin for ManifestQuery
impl UnsafeUnpin for ManifestQuery
impl UnwindSafe for ManifestQuery
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request