pub struct Yaml(pub Option<Mutation<Value>>);Available on crate feature
yaml only.Expand description
YAML adapter for morphix mutation serialization.
Yaml implements the Adapter trait using serde_yaml_ng::Value for both
Replace and Append
operations. This adapter is available when the yaml feature is enabled.
§Example
use morphix::adapter::Yaml;
use morphix::{Observe, observe};
use serde::Serialize;
#[derive(Serialize, Observe)]
struct Config {
host: String,
port: u16,
tags: Vec<String>,
}
let mut config = Config {
host: "localhost".to_string(),
port: 8080,
tags: vec!["web".to_string()],
};
let Yaml(mutation) = observe!(config => {
config.port = 8081;
config.tags.push("api".to_string());
}).unwrap();Tuple Fields§
§0: Option<Mutation<Value>>Trait Implementations§
Source§impl Adapter for Yaml
impl Adapter for Yaml
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 Yaml
impl StructuralPartialEq for Yaml
Auto Trait Implementations§
impl Freeze for Yaml
impl RefUnwindSafe for Yaml
impl Send for Yaml
impl Sync for Yaml
impl Unpin for Yaml
impl UnwindSafe for Yaml
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.