Struct Config

Source
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

Source

pub fn new() -> Self

Creates a Config with default values

Source

pub fn with_field_path_mode(self, mode: FieldPathMode) -> Self

Sets the FieldPathMode to use when serializing a Diff

Source

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

Source

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

Source

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

Source

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§

Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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.