1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::error::ErrorKind;
use crate::{serialization::SerializationStrategy, SerdeDiff};
use std::fmt::Debug;

/// Applies modified values to a type.
pub struct Apply;

impl Apply {
    /// Applies modified values to a type.
    ///
    /// * `type`: the type to which you want to apply the modified values.
    /// * `data`: the buffer with the modified type values.
    /// * `strategy`: the strategy used to deserialize the given `data` into the given `type`.
    pub fn apply_to<
        C: Clone + SerdeDiff + Debug + Send + Sync + SerdeDiff + 'static,
        S: SerializationStrategy,
    >(
        component: &mut C,
        data: &[u8],
        strategy: S,
    ) -> Result<(), ErrorKind> {
        strategy.apply_to(component, data)
    }
}