pub struct Context<'a> { /* private fields */ }Expand description
A cheap, clonable handle threaded through every load impl.
Loaders use the as_* accessors to peek at the underlying save::Value kind
(e.g. Context::as_object, Context::as_array, Context::as_str) and
Context::load to recursively deserialize a nested value into a concrete type.
Implementations§
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn load<T>(&self) -> Result<T>where
T: Loadable<'a>,
pub fn load<T>(&self) -> Result<T>where
T: Loadable<'a>,
Recursively deserialize the underlying value into a T.
Equivalent to calling T::load(self.clone()). Use this from inner loaders that
want to delegate to another Loadable.
Sourcepub fn as_object(&self) -> Option<Object<'a>>
pub fn as_object(&self) -> Option<Object<'a>>
Returns Some(Object) if the value is a versioned object, else None.
Sourcepub fn as_array(&self) -> Option<Array<'a>>
pub fn as_array(&self) -> Option<Array<'a>>
Returns Some(Array) if the value is an array, else None.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Context<'a>
impl<'a> !Send for Context<'a>
impl<'a> !Sync for Context<'a>
impl<'a> !UnwindSafe for Context<'a>
impl<'a> Freeze for Context<'a>
impl<'a> Unpin for Context<'a>
impl<'a> UnsafeUnpin for Context<'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