Enum ValueMut

Source
pub enum ValueMut<'a, T: Json> {
    Null,
    Boolean(bool),
    Number(&'a mut T::Number),
    String(&'a mut T::String),
    Array(&'a mut T::Array),
    Object(&'a mut T::Object),
}
Expand description

Mutable JSON value reference.

Variants§

§

Null

§

Boolean(bool)

§

Number(&'a mut T::Number)

§

String(&'a mut T::String)

§

Array(&'a mut T::Array)

§

Object(&'a mut T::Object)

Implementations§

Source§

impl<'a, T: Json> ValueMut<'a, T>

Source

pub fn is_null(&self) -> bool

Returns true if the value is a Null. Returns false otherwise.

Source

pub fn is_bool(&self) -> bool

Returns true if the value is a boolean. Returns false otherwise.

For any value on which is_boolean returns true, as_bool is guaranteed to return the boolean value.

Source

pub fn is_number(&self) -> bool

Returns true if the value is a number. Returns false otherwise.

For any value on which is_number returns true, as_number is guaranteed to return the number value.

Source

pub fn as_u32(&self) -> Option<u32>

Returns this number as an u32 if it can be exactly represented as such.

Source

pub fn as_u64(&self) -> Option<u64>

Returns this number as an u64 if it can be exactly represented as such.

Source

pub fn as_i32(&self) -> Option<i32>

Returns this number as an i32 if it can be exactly represented as such.

Source

pub fn as_i64(&self) -> Option<i64>

Returns this number as an i64 if it can be exactly represented as such.

Source

pub fn as_f32(&self) -> Option<f32>

Returns this number as an f32 if it can be exactly represented as such.

Source

pub fn as_f32_lossy(&self) -> Option<f32>

Returns this number as an f32 if it is a number, potentially losing precision in the process.

Source

pub fn as_f64(&self) -> Option<f64>

Returns this number as an f64 if it can be exactly represented as such.

Source

pub fn as_f64_lossy(&self) -> Option<f64>

Returns this number as an f64 if it is a number, potentially losing precision in the process.

Source

pub fn is_string(&self) -> bool

Returns true if the value is a string. Returns false otherwise.

For any value on which is_string returns true, as_str is guaranteed to return the string value.

Source

pub fn is_array(&self) -> bool

Returns true if the value is an array. Returns false otherwise.

For any value on which is_array returns true, as_array is guaranteed to return the array value.

Source

pub fn is_object(&self) -> bool

Returns true if the value is an object. Returns false otherwise.

For any value on which is_object returns true, as_object is guaranteed to return the object value.

Source§

impl<'a, T: Json> ValueMut<'a, T>

Source

pub fn as_bool(&self) -> Option<bool>

If the value is a boolean, returns the associated bool. Returns None otherwise.

Source

pub fn as_number(&self) -> Option<&T::Number>

If the value is a number, returns a reference to it. Returns None otherwise.

Source

pub fn into_number(self) -> Option<&'a T::Number>

If the value is a number, returns a reference to it. Returns None otherwise.

Source

pub fn as_str(&self) -> Option<&str>

If the value is a string, returns its associated str. Returns None otherwise.

Source

pub fn as_array(&self) -> Option<&T::Array>

If the value is an array, returns a reference to it. Returns None otherwise.

Source

pub fn into_array(self) -> Option<&'a T::Array>

If the value is an array, returns a reference to it. Returns None otherwise.

Source

pub fn as_object(&self) -> Option<&T::Object>

If the value is an object, returns a reference to it. Returns None otherwise.

Source

pub fn into_object(self) -> Option<&'a T::Object>

If the value is an object, returns a reference to it. Returns None otherwise.

Source

pub fn as_array_mut(&mut self) -> Option<&mut T::Array>

If the value is an array, returns a mutable reference to it. Returns None otherwise.

Source

pub fn into_array_mut(self) -> Option<&'a mut T::Array>

If the value is an array, returns a mutable reference to it. Returns None otherwise.

Source

pub fn as_object_mut(&mut self) -> Option<&mut T::Object>

If the value is an object, returns a mutable reference to it. Returns None otherwise.

Source

pub fn into_object_mut(self) -> Option<&'a mut T::Object>

If the value is an object, returns a mutable reference to it. Returns None otherwise.

Source

pub fn cloned(&self) -> Value<T>
where T::Number: Clone, T::String: Clone, T::Array: Clone, T::Object: Clone,

Creates a new value by cloning the referenced value.

Auto Trait Implementations§

§

impl<'a, T> Freeze for ValueMut<'a, T>

§

impl<'a, T> RefUnwindSafe for ValueMut<'a, T>

§

impl<'a, T> Send for ValueMut<'a, T>
where <T as Json>::Number: Send, <T as Json>::String: Send, <T as Json>::Array: Send, <T as Json>::Object: Send,

§

impl<'a, T> Sync for ValueMut<'a, T>
where <T as Json>::Number: Sync, <T as Json>::String: Sync, <T as Json>::Array: Sync, <T as Json>::Object: Sync,

§

impl<'a, T> Unpin for ValueMut<'a, T>

§

impl<'a, T> !UnwindSafe for ValueMut<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.