pub struct ObjectRef<'a> { /* private fields */ }Expand description
Implementations§
Source§impl<'a> ObjectRef<'a>
impl<'a> ObjectRef<'a>
Sourcepub fn access_kind(&self) -> Option<AccessKind>
pub fn access_kind(&self) -> Option<AccessKind>
Returns the access kind of the referenced value, if any.
An option reports the access of its contained value.
Sourcepub fn option_value(&self) -> Option<ObjectRef<'a>>
pub fn option_value(&self) -> Option<ObjectRef<'a>>
Returns the contained value when this reference points to Some(value).
Sourcepub fn variant(&self, name: &str) -> Option<ObjectRef<'a>>
pub fn variant(&self, name: &str) -> Option<ObjectRef<'a>>
Returns the value when it is an enum whose active variant is name,
forwarding through options.
Sourcepub fn variant_name(&self) -> Option<&'static str>
pub fn variant_name(&self) -> Option<&'static str>
Returns the name of the active enum variant, forwarding through options.
Sourcepub fn field(&self, name: &str) -> Option<ObjectRef<'a>>
pub fn field(&self, name: &str) -> Option<ObjectRef<'a>>
Returns an exposed field by name; see Meta::field_dyn.
Sourcepub fn field_names(&self) -> &'static [&'static str]
pub fn field_names(&self) -> &'static [&'static str]
Returns the exposed field names in declaration order.
An enum exposes the fields of its active variant.
Sourcepub fn item(&self, index: usize) -> Option<ObjectRef<'a>>
pub fn item(&self, index: usize) -> Option<ObjectRef<'a>>
Returns an item at index; see Meta::item_dyn.
Sourcepub fn len(&self) -> Option<usize>
pub fn len(&self) -> Option<usize>
Returns the number of exposed structural items, when available.
For maps, this is the number of keyed entries. An option has one item when it holds a value.
Sourcepub fn is_empty(&self) -> Option<bool>
pub fn is_empty(&self) -> Option<bool>
Checks whether a value has no exposed structural items, when available.
Sourcepub fn key(&self, key: &str) -> Option<ObjectRef<'a>>
pub fn key(&self, key: &str) -> Option<ObjectRef<'a>>
Returns a value for a string-like key; see Meta::key_dyn.
Sourcepub fn keys(&self) -> Option<Vec<String>>
pub fn keys(&self) -> Option<Vec<String>>
Returns the keys as strings for map-like access or a keyed sequence.
Sourcepub fn visit_map_entries(&self, visitor: &mut MapEntryVisitor<'_>) -> bool
pub fn visit_map_entries(&self, visitor: &mut MapEntryVisitor<'_>) -> bool
Passes each map entry to visitor until it returns false.
Returns false when the value has no map-like access. Stopping early
still returns true.
Sourcepub fn field_path<Q: FieldPathQuery<'a>>(&self, query: Q) -> Option<Q::Output>
pub fn field_path<Q: FieldPathQuery<'a>>(&self, query: Q) -> Option<Q::Output>
Traverses a nested field, item or key path. Accepts a raw
&[PathSegment] (returns ObjectRef) or a typed TypedPath
(returns &'a Value); see FieldPathQuery.
Trait Implementations§
impl<'a> Copy for ObjectRef<'a>
Source§impl<'a> From<ObjectRefMut<'a>> for ObjectRef<'a>
Converts a mutable view into a shared view that keeps the lifetime 'a.
impl<'a> From<ObjectRefMut<'a>> for ObjectRef<'a>
Converts a mutable view into a shared view that keeps the lifetime 'a.