[][src]Trait simd_json::value::MutableValue

pub trait MutableValue: IndexMut<usize> + Value + Sized {
    type Key;
    fn as_array_mut(&mut self) -> Option<&mut Vec<Self>>;
fn as_object_mut(&mut self) -> Option<&mut HashMap<Self::Key, Self>>; fn insert<K, V>(&mut self, k: K, v: V) -> Result<Option<Self>, AccessError>
    where
        K: Into<Self::Key>,
        V: Into<Self>,
        Self::Key: Hash + Eq
, { ... }
fn remove<Q: ?Sized>(&mut self, k: &Q) -> Result<Option<Self>, AccessError>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq
, { ... }
fn push<V>(&mut self, v: V) -> Result<(), AccessError>
    where
        V: Into<Self>
, { ... }
fn pop(&mut self) -> Result<Option<Self>, AccessError> { ... }
fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut Self>
    where
        Self::Key: Borrow<Q> + Hash + Eq,
        Q: Hash + Eq
, { ... }
fn get_idx_mut(&mut self, i: usize) -> Option<&mut Self> { ... } }

Mutatability for values

Associated Types

type Key

The type for Objects

Loading content...

Required methods

fn as_array_mut(&mut self) -> Option<&mut Vec<Self>>

Tries to represent the value as an array and returns a mutable refference to it

fn as_object_mut(&mut self) -> Option<&mut HashMap<Self::Key, Self>>

Tries to represent the value as an object and returns a mutable refference to it

Loading content...

Provided methods

fn insert<K, V>(&mut self, k: K, v: V) -> Result<Option<Self>, AccessError> where
    K: Into<Self::Key>,
    V: Into<Self>,
    Self::Key: Hash + Eq

Tries to insert into this Value as an Object. Will return an AccessError::NotAnObject if called on a Value that isn't an object - otherwise will behave the same as HashMap::insert

fn remove<Q: ?Sized>(&mut self, k: &Q) -> Result<Option<Self>, AccessError> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq

Tries to remove from this Value as an Object. Will return an AccessError::NotAnObject if called on a Value that isn't an object - otherwise will behave the same as HashMap::remove

fn push<V>(&mut self, v: V) -> Result<(), AccessError> where
    V: Into<Self>, 

Tries to push to this Value as an Array. Will return an AccessError::NotAnArrayif called on aValuethat isn't anArray- otherwise will behave the same asVec::push`

fn pop(&mut self) -> Result<Option<Self>, AccessError>

Tries to pop from this Value as an Array. Will return an AccessError::NotAnArrayif called on aValuethat isn't anArray- otherwise will behave the same asVec::pop`

fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut Self> where
    Self::Key: Borrow<Q> + Hash + Eq,
    Q: Hash + Eq

Same as get but returns a mutable ref instead

fn get_idx_mut(&mut self, i: usize) -> Option<&mut Self>

Same as get_idx but returns a mutable ref instead

Loading content...

Implementors

impl MutableValue for simd_json::value::owned::Value[src]

type Key = String

impl<'v> MutableValue for simd_json::value::borrowed::Value<'v>[src]

type Key = Cow<'v, str>

Loading content...