pub trait ValueExt: Sized {
// Required methods
fn insert(
&mut self,
key: String,
value: impl Into<Self>,
) -> Result<Option<Self>, Error>;
fn pointer(&self, pointer: &Pointer<'_>) -> Option<&Self>;
fn pointer_mut(&mut self, pointer: &Pointer<'_>) -> Option<&mut Self>;
// Provided method
fn insert_at(
&mut self,
pointer: &Pointer<'_>,
value: impl Into<Self>,
) -> Result<Option<Self>, Error> { ... }
}
Expand description
An extension trait for any JSON value representation that provides a variety of manipulation methods.
Required Methods§
Sourcefn insert(
&mut self,
key: String,
value: impl Into<Self>,
) -> Result<Option<Self>, Error>
fn insert( &mut self, key: String, value: impl Into<Self>, ) -> Result<Option<Self>, Error>
Insert any data in the current JSON value.
If the JSON value already contains the given key, it will be overrided.
§Errors
This method may fail if the current JSON value is not a JSON object.
Sourcefn pointer_mut(&mut self, pointer: &Pointer<'_>) -> Option<&mut Self>
fn pointer_mut(&mut self, pointer: &Pointer<'_>) -> Option<&mut Self>
Looks up a value by a JSON pointer and returns a mutable reference to that value.
Provided Methods§
Sourcefn insert_at(
&mut self,
pointer: &Pointer<'_>,
value: impl Into<Self>,
) -> Result<Option<Self>, Error>
fn insert_at( &mut self, pointer: &Pointer<'_>, value: impl Into<Self>, ) -> Result<Option<Self>, Error>
Inserts any data at the given pointee JSON value.
If the JSON pointer’s key already exists in the JSON pointee value, it will be overrided.
§Arguments
pointer
: A JSON pointer.value
: A data to insert at the pointee JSON value.
§Errors
This method may fail if the pointee JSON value is not a JSON object or if it does not exist.
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.