Struct crdts::merkle_reg::MerkleReg [−][src]
pub struct MerkleReg<T> { /* fields omitted */ }
The MerkleReg is a Register CRDT that uses the Merkle DAG structure to track the current value(s) held by this register. The leaves of the Merkle DAG are the current values.
Implementations
impl<T> MerkleReg<T>
[src]
pub fn new() -> Self
[src]
Return a new instance of the MerkleReg
pub fn read(&self) -> Content<'_, T>
[src]
Read the current values held by the register
pub fn write(&self, value: T, parents: BTreeSet<Hash>) -> Node<T>
[src]
Write the given value on top of the given parents.
pub fn node(&self, hash: Hash) -> Option<&Node<T>>
[src]
Retrieve a node in the Merkle DAG by it’s hash.
Traverse the history the register by pair this method with the parents of the nodes retrieved in Content::nodes().
pub fn parents(&self, hash: Hash) -> Content<'_, T>
[src]
Returns the parents of a node
pub fn children(&self, hash: Hash) -> Content<'_, T>
[src]
Returns the children of a node
pub fn num_nodes(&self) -> usize
[src]
Returns the number of nodes who are visible, i.e. their parents have been seen.
pub fn num_orphans(&self) -> usize
[src]
Returns the number of nodes who are not visible due to missing parents.
Trait Implementations
impl<T: Arbitrary + Sha3Hash> Arbitrary for MerkleReg<T>
[src]
fn arbitrary<G: Gen>(g: &mut G) -> Self
[src]
pub fn shrink(&self) -> Box<dyn Iterator<Item = Self> + 'static, Global>
[src]
impl<T: Clone> Clone for MerkleReg<T>
[src]
impl<T: Sha3Hash> CmRDT for MerkleReg<T>
[src]
type Op = Node<T>
Op defines a mutation to the CRDT. As long as Op’s from one actor are replayed in exactly the same order they were generated by that actor, the CRDT will converge. In other words, we must have a total ordering on each actors operations, while requiring only a partial order over all ops. E.g. Read more
type Validation = ValidationError
The validation error returned by validate_op
.
fn validate_op(&self, op: &Self::Op) -> Result<(), Self::Validation>
[src]
fn apply(&mut self, node: Self::Op)
[src]
impl<T: Sha3Hash> CvRDT for MerkleReg<T>
[src]
type Validation = Infallible
The validation error returned by validate_merge
.
fn validate_merge(&self, _: &Self) -> Result<(), Self::Validation>
[src]
fn merge(&mut self, other: Self)
[src]
impl<T: Debug> Debug for MerkleReg<T>
[src]
impl<T> Default for MerkleReg<T>
[src]
impl<'de, T> Deserialize<'de> for MerkleReg<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<T: Eq> Eq for MerkleReg<T>
[src]
impl<T: Hash> Hash for MerkleReg<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Ord> Ord for MerkleReg<T>
[src]
fn cmp(&self, other: &MerkleReg<T>) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl<T: PartialEq> PartialEq<MerkleReg<T>> for MerkleReg<T>
[src]
impl<T: PartialOrd> PartialOrd<MerkleReg<T>> for MerkleReg<T>
[src]
fn partial_cmp(&self, other: &MerkleReg<T>) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T> Serialize for MerkleReg<T> where
T: Serialize,
[src]
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<T> StructuralEq for MerkleReg<T>
[src]
impl<T> StructuralPartialEq for MerkleReg<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for MerkleReg<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for MerkleReg<T> where
T: Send,
T: Send,
impl<T> Sync for MerkleReg<T> where
T: Sync,
T: Sync,
impl<T> Unpin for MerkleReg<T>
impl<T> UnwindSafe for MerkleReg<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,