Struct crdts::ctx::ReadCtx

source ·
pub struct ReadCtx<V, A: Ord> {
    pub add_clock: VClock<A>,
    pub rm_clock: VClock<A>,
    pub val: V,
}
Expand description

ReadCtx’s are used to extract data from CRDT’s while maintaining some causal history. You should store ReadCtx’s close to where mutation is exposed to the user.

e.g. Ship ReadCtx to the clients, then derive an Add/RmCtx and ship that back to where the CRDT is stored to perform the mutation operation.

Fields§

§add_clock: VClock<A>

clock used to derive an AddCtx

§rm_clock: VClock<A>

clock used to derive an RmCtx

§val: V

the data read from the CRDT

Implementations§

source§

impl<V, A: Ord + Clone + Debug> ReadCtx<V, A>

source

pub fn derive_add_ctx(self, actor: A) -> AddCtx<A>

Derives an AddCtx for a given actor from a ReadCtx

source

pub fn derive_rm_ctx(self) -> RmCtx<A>

Derives a RmCtx from a ReadCtx

source

pub fn split(self) -> (V, ReadCtx<(), A>)

Splits this ReadCtx into its data and an empty ReadCtx

Trait Implementations§

source§

impl<V: Debug, A: Debug + Ord> Debug for ReadCtx<V, A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, V, A> Deserialize<'de> for ReadCtx<V, A>where V: Deserialize<'de>, A: Deserialize<'de> + Ord,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<V: PartialEq, A: PartialEq + Ord> PartialEq<ReadCtx<V, A>> for ReadCtx<V, A>

source§

fn eq(&self, other: &ReadCtx<V, A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<V, A> Serialize for ReadCtx<V, A>where V: Serialize, A: Serialize + Ord,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<V: Eq, A: Eq + Ord> Eq for ReadCtx<V, A>

source§

impl<V, A: Ord> StructuralEq for ReadCtx<V, A>

source§

impl<V, A: Ord> StructuralPartialEq for ReadCtx<V, A>

Auto Trait Implementations§

§

impl<V, A> RefUnwindSafe for ReadCtx<V, A>where A: RefUnwindSafe, V: RefUnwindSafe,

§

impl<V, A> Send for ReadCtx<V, A>where A: Send, V: Send,

§

impl<V, A> Sync for ReadCtx<V, A>where A: Sync, V: Sync,

§

impl<V, A> Unpin for ReadCtx<V, A>where V: Unpin,

§

impl<V, A> UnwindSafe for ReadCtx<V, A>where A: RefUnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,