Trait State

Source
pub trait State:
    Default
    + Debug
    + Serialize
    + DeserializeOwned
    + Send
    + 'static {
    // Required methods
    fn is_dirty(&self) -> bool;
    fn reset_dirty(&mut self);
    fn write_with_partitioned_adapter<PA: PartitionedAdapter>(
        &self,
        adapter: &PA,
    ) -> Result<(), JoydbError>;
    fn load_with_partitioned_adapter<PA: PartitionedAdapter>(
        adapter: &PA,
    ) -> Result<Self, JoydbError>;
}
Expand description

A trait that represents a state that can be (de)serialized to/from JSON or any other format supported by an adapter.

A state must be defined with the state! macro.

Required Methods§

Source

fn is_dirty(&self) -> bool

Are there any unsaved changes in the state?

Source

fn reset_dirty(&mut self)

Reset the dirty flag to false.

Source

fn write_with_partitioned_adapter<PA: PartitionedAdapter>( &self, adapter: &PA, ) -> Result<(), JoydbError>

For every dirty relation in the state, write the relation using the given partitioned adapter.

The method exists to facilitate work of partitioned adapters. Since partitioned adapters cannot know which relations they need to work with, this method is essentially the bridge, that calls PartitionedAdapter::write_relation for every dirty relation in the state.

Source

fn load_with_partitioned_adapter<PA: PartitionedAdapter>( adapter: &PA, ) -> Result<Self, JoydbError>

Load the entire state using the given partitioned adapter.

The method exists to facilitate work of partitioned adapters. Since partitioned adapters cannot know which relations they need to work with, this method is essentially the bridge, that calls PartitionedAdapter::load_relation for every relation in the state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§