Skip to main content

Node

Trait Node 

Source
pub trait Node:
    Clone
    + Default
    + PartialEq {
    type Update;
    type Diff;

    const IS_CONTAINER: bool;

    // Required methods
    fn apply_update(&mut self, update: Self::Update);
    fn as_update(&self) -> Self::Update;
    fn compute_diff(&self, other: &Self) -> Option<Self::Diff>;
    fn apply_diff(&mut self, diff: Self::Diff);
    fn as_diff(&self) -> Self::Diff;
    fn merge(&self, merge: &mut Self);
    fn is_empty(&self) -> bool;
}
Expand description

A trait implemented by datastructures that can be mutated by applying a succession of updates.

Required Associated Constants§

Required Associated Types§

Source

type Update

The update type is the set of operations that can be applied to this datastructure to modify it.

Source

type Diff

The diff type is a representation of the difference between to instances of this datastructure.

Required Methods§

Source

fn apply_update(&mut self, update: Self::Update)

Apply the given update to this struct

Source

fn as_update(&self) -> Self::Update

Get the update corresponding to this struct, that is the update to be applied to the default instance to obtain this struct.

Source

fn compute_diff(&self, other: &Self) -> Option<Self::Diff>

Get the differences between self and other.

The returned diff type represents the changes to apply to self to obtain other.

Source

fn apply_diff(&mut self, diff: Self::Diff)

Apply the given diff to this struct

Source

fn as_diff(&self) -> Self::Diff

Return the diff object to apply to obtain this current updatable value.

Source

fn merge(&self, merge: &mut Self)

Overwrite the merge struct with the values from self.

This can be used for templating.

Source

fn is_empty(&self) -> bool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K, R> Node for RecordMap<K, R>
where K: PartialEq + Eq + Hash + Clone, R: Node + PartialEq,

Source§

impl<K, V> Node for ValueMap<K, V>
where K: PartialEq + Eq + Hash + Clone, V: Clone + PartialEq,

Source§

impl<K> Node for ValueSet<K>
where K: PartialEq + Eq + Hash + Clone,

Source§

impl<R> Node for OptRecord<R>
where R: Node,

A config item for amending a mandatory value

Source§

impl<V> Node for OptValue<V>
where V: Clone + PartialEq,

A config item for amending a mandatory value

Source§

impl<V> Node for Value<V>
where V: Clone + Default + PartialEq,

Source§

impl<V> Node for ValueList<V>
where V: Clone + PartialEq,