FieldState

Trait FieldState 

Source
pub trait FieldState: Sized {
    type Value;

    const CRDT_KIND: CrdtKind;

    // Required methods
    fn encode_state(&self) -> Result<Vec<u8>, RecordError>;
    fn decode_state(bytes: &[u8]) -> Result<Self, RecordError>;
    fn visible_values(&self) -> Result<Vec<Vec<u8>>, RecordError>;
    fn merge_state(&mut self, other: &Self) -> Result<(), RecordError>;
    fn canonicalize_for_commit(
        &self,
        author: AuthorId,
        sequence: u64,
        context: &VersionVector,
        next_operation: &mut u32,
    ) -> Result<Self, RecordError>;

    // Provided method
    fn value_type_name() -> &'static str { ... }
}
Expand description

Canonical state codec and schema metadata for a replicated field.

Required Associated Constants§

Source

const CRDT_KIND: CrdtKind

The deterministic merge strategy.

Required Associated Types§

Source

type Value

The application value carried by this field strategy.

Required Methods§

Source

fn encode_state(&self) -> Result<Vec<u8>, RecordError>

Encodes complete causal field state.

Source

fn decode_state(bytes: &[u8]) -> Result<Self, RecordError>

Strictly decodes complete causal field state.

Source

fn visible_values(&self) -> Result<Vec<Vec<u8>>, RecordError>

Encodes each currently visible application value for filtering and indexes.

Source

fn merge_state(&mut self, other: &Self) -> Result<(), RecordError>

Deterministically merges complete causal state from another replica.

Source

fn canonicalize_for_commit( &self, author: AuthorId, sequence: u64, context: &VersionVector, next_operation: &mut u32, ) -> Result<Self, RecordError>

Reissues all causal identities from one authenticated commit envelope.

Provided Methods§

Source

fn value_type_name() -> &'static str

Stable Rust logical value type used in schema compatibility checks.

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§

Source§

impl FieldState for BlobRef

Source§

const CRDT_KIND: CrdtKind = iroh_db_core::CrdtKind::Immutable

Source§

type Value = BlobRef

Source§

impl FieldState for PnCounter

Source§

const CRDT_KIND: CrdtKind = CrdtKind::PnCounter

Source§

type Value = i128

Source§

impl<T> FieldState for GrowOnlySet<T>
where T: Clone + Ord + Encode<()> + for<'bytes> Decode<'bytes, ()>,

Source§

const CRDT_KIND: CrdtKind = CrdtKind::GrowOnlySet

Source§

type Value = T

Source§

impl<T> FieldState for Immutable<T>
where T: Clone + Eq + Encode<()> + for<'bytes> Decode<'bytes, ()>,

Source§

const CRDT_KIND: CrdtKind = CrdtKind::Immutable

Source§

type Value = T

Source§

impl<T> FieldState for Lww<T>
where T: Clone + Eq + Encode<()> + for<'bytes> Decode<'bytes, ()>,

Source§

const CRDT_KIND: CrdtKind = CrdtKind::Lww

Source§

type Value = T

Source§

impl<T> FieldState for MultiValue<T>
where T: Clone + Eq + Encode<()> + for<'bytes> Decode<'bytes, ()>,

Source§

const CRDT_KIND: CrdtKind = CrdtKind::MultiValue

Source§

type Value = T

Source§

impl<T> FieldState for OrSet<T>
where T: Clone + Ord + Encode<()> + for<'bytes> Decode<'bytes, ()>,

Source§

const CRDT_KIND: CrdtKind = CrdtKind::OrSet

Source§

type Value = T

Source§

impl<T> FieldState for OrderedList<T>
where T: Clone + Eq + Encode<()> + for<'bytes> Decode<'bytes, ()>,

Source§

const CRDT_KIND: CrdtKind = CrdtKind::OrderedList

Source§

type Value = T