pub struct Config { /* private fields */ }
Expand description
Configures creation of Apply
and Diff
§Examples
use serde_diff::{SerdeDiff, Config, FieldPathMode};
use serde::{Serialize, Deserialize};
#[derive(SerdeDiff, Serialize, Deserialize, PartialEq)]
struct Test {
a: i32,
}
let diff = Config::new()
.with_field_path_mode(FieldPathMode::Index)
.serializable_diff(&Test { a: 3 }, &Test { a: 5 });
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_field_path_mode(self, mode: FieldPathMode) -> Self
pub fn with_field_path_mode(self, mode: FieldPathMode) -> Self
Sets the FieldPathMode
to use when serializing a Diff
Sourcepub fn serializable_diff<'a, 'b, T: SerdeDiff + 'a + 'b>(
self,
old: &'a T,
new: &'b T,
) -> Diff<'a, 'b, T>
pub fn serializable_diff<'a, 'b, T: SerdeDiff + 'a + 'b>( self, old: &'a T, new: &'b T, ) -> Diff<'a, 'b, T>
Create a serializable Diff, which when serialized will write the differences between the old and new value into the serializer in the form of a sequence of diff commands
Sourcepub fn diff<'a, 'b, S: Serializer, T: SerdeDiff + 'a + 'b>(
self,
serializer: S,
old: &'a T,
new: &'b T,
) -> Result<S::Ok, S::Error>
pub fn diff<'a, 'b, S: Serializer, T: SerdeDiff + 'a + 'b>( self, serializer: S, old: &'a T, new: &'b T, ) -> Result<S::Ok, S::Error>
Writes the differences between the old and new value into the given serializer in the form of a sequence of diff commands
Sourcepub fn deserializable_apply<'a, T: SerdeDiff>(
self,
target: &'a mut T,
) -> Apply<'a, T>
pub fn deserializable_apply<'a, T: SerdeDiff>( self, target: &'a mut T, ) -> Apply<'a, T>
Create a deserializable Apply, where the given target will be changed when the resulting Apply struct is deserialized
Sourcepub fn apply<'de, D, T: SerdeDiff>(
self,
deserializer: D,
target: &mut T,
) -> Result<(), <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
pub fn apply<'de, D, T: SerdeDiff>(
self,
deserializer: D,
target: &mut T,
) -> Result<(), <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Applies a sequence of diff commands to the target, as read by the deserializer
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
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