pub struct Json(pub Option<Mutation<Value>>);Available on crate feature
json only.Expand description
JSON adapter for morphix mutation serialization.
Json implements the Adapter trait using serde_json::Value for both
Replace and Append operations. This adapter
is available when the json feature is enabled.
§Example
use morphix::adapter::Json;
use morphix::{Observe, observe};
use serde::Serialize;
#[derive(Serialize, Observe)]
struct Data {
value: i32,
}
let mut data = Data { value: 42 };
let Json(mutation) = observe!(data => {
data.value += 1;
}).unwrap();Tuple Fields§
§0: Option<Mutation<Value>>Trait Implementations§
Source§impl Adapter for Json
impl Adapter for Json
Source§fn from_mutation(mutation: Option<Mutation<Self::Value>>) -> Self
fn from_mutation(mutation: Option<Mutation<Self::Value>>) -> Self
Constructs the adapter from an optional mutation.
Source§fn serialize_value<T: Serialize + ?Sized>(
value: &T,
) -> Result<Self::Value, Self::Error>
fn serialize_value<T: Serialize + ?Sized>( value: &T, ) -> Result<Self::Value, Self::Error>
Serializes a value into the adapter’s Value type.
Source§fn get_mut<'a>(
value: &'a mut Self::Value,
segment: &PathSegment,
allow_create: bool,
) -> Option<&'a mut Self::Value>
fn get_mut<'a>( value: &'a mut Self::Value, segment: &PathSegment, allow_create: bool, ) -> Option<&'a mut Self::Value>
Gets a mutable reference to a nested value by path segment. Read more
Source§fn append(value: &mut Self::Value, append_value: Self::Value) -> Option<usize>
fn append(value: &mut Self::Value, append_value: Self::Value) -> Option<usize>
Available on crate feature
append only.Appends a value to the end of another value. Read more
Source§fn len(value: &Self::Value) -> Option<usize>
fn len(value: &Self::Value) -> Option<usize>
Available on crate feature
append only.Returns the appendable length of a value. Read more
impl Eq for Json
impl StructuralPartialEq for Json
Auto Trait Implementations§
impl Freeze for Json
impl RefUnwindSafe for Json
impl Send for Json
impl Sync for Json
impl Unpin for Json
impl UnwindSafe for Json
Blanket Implementations§
Source§impl<T> AsDerefCoinductive<Zero> for Twhere
T: ?Sized,
impl<T> AsDerefCoinductive<Zero> for Twhere
T: ?Sized,
Source§impl<T> AsDerefMut<Zero> for Twhere
T: ?Sized,
impl<T> AsDerefMut<Zero> for Twhere
T: ?Sized,
Source§fn as_deref_mut(&mut self) -> &mut T
fn as_deref_mut(&mut self) -> &mut T
Mutably dereferences self
N times.Source§impl<T> AsDerefMutCoinductive<Zero> for Twhere
T: ?Sized,
impl<T> AsDerefMutCoinductive<Zero> for Twhere
T: ?Sized,
Source§fn as_deref_mut_coinductive(&mut self) -> &mut T
fn as_deref_mut_coinductive(&mut self) -> &mut T
Mutably dereferences self
N times.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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.