pub struct Entry {
pub did: Did,
pub data: Vec<Encoded>,
pub kind: EntryKind,
pub crdt: EntryCrdt,
}Expand description
A DHT storage entry with an EntryKind and a ring key represented as Did.
An Entry is data stored by ChordStorage. It is not a
Chord node and does not participate in successor, predecessor, or finger-table
membership.
The Did of an Entry is in the following format:
- If kind value is EntryKind::Data, it’s sha1 of data topic.
- If kind value is EntryKind::Subring, it’s sha1 of Subring name.
- If kind value is EntryKind::RelayMessage, it’s the destination Did of message plus 1 (to ensure that the message is sent to the successor of destination), thus while destination node going online, it will sync message from its successor.
Fields§
§did: DidThe ring key of this entry. It has the same representation as a node DID, but a different domain meaning.
data: Vec<Encoded>The data entity of Entry, encoded by Encoder.
kind: EntryKindThe type indicates how the data is encoded and how the Did is generated.
crdt: EntryCrdtCRDT metadata that makes replicated merge a join-semilattice operation.
Implementations§
Source§impl Entry
impl Entry
Sourcepub fn join(&self, other: Self) -> Result<Self>
pub fn join(&self, other: Self) -> Result<Self>
Merge two entries from the same replicated carrier.
Law: for a fixed (did, kind) carrier, this is the state-based CRDT
join. Data entries are bounded LWW element sets with an LWW overwrite
register; subring entries are grow-only member sets; relay entries are
two-phase sets whose remove side is carried by tombstones.
Sourcepub fn affine(&self, scalar: u16) -> Result<Vec<Entry>>
pub fn affine(&self, scalar: u16) -> Result<Vec<Entry>>
Affine Transport entry to a list of affined did
Sourcepub fn clone_with_did(&self, did: Did) -> Self
pub fn clone_with_did(&self, did: Did) -> Self
Clone and setup with new DID
Sourcepub fn try_into_storage_entry(self) -> Result<Self>
pub fn try_into_storage_entry(self) -> Result<Self>
Normalize an entry immediately before it is persisted.
Post: normalization uses the same carrier materialization as
Self::join; there is no second cap strategy outside the CRDT.
Post: result.data.len() <= ENTRY_DATA_MAX_LEN.
Post: result.data.len() == result.crdt.dots.len() for Data and
RelayMessage entries.
Sourcepub fn operate(&self, op: EntryOperation, actor: Did) -> Result<Self>
pub fn operate(&self, op: EntryOperation, actor: Did) -> Result<Self>
The entry point of EntryOperation. Will dispatch to different operation handlers according to the variant.
Sourcepub fn overwrite(&self, other: Self, actor: Did) -> Result<Self>
pub fn overwrite(&self, other: Self, actor: Did) -> Result<Self>
Overwrite current data with new data.
Preservation: the replacement is represented as a CRDT join. A newly stamped overwrite carries a reset floor, and materialization keeps only dots at or after that floor, so older payload dots are removed without a non-monotone assignment.
The handler of EntryOperation::Overwrite.
Sourcepub fn extend(&self, other: Self, actor: Did) -> Result<Self>
pub fn extend(&self, other: Self, actor: Did) -> Result<Self>
This method is used to extend data to a Data kind Entry.
The handler of EntryOperation::Extend.
Sourcepub fn touch(&self, other: Self, actor: Did) -> Result<Self>
pub fn touch(&self, other: Self, actor: Did) -> Result<Self>
This method is used to extend data to a Data kind Entry uniquely.
If any element is already existed, move it to the end of the data vector.
The handler of EntryOperation::Touch.
Sourcepub fn join_subring(&self, did: Did) -> Result<Self>
pub fn join_subring(&self, did: Did) -> Result<Self>
This method is used to join a subring. The handler of EntryOperation::JoinSubring.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Entry
impl<'de> Deserialize<'de> for Entry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Entry
impl StructuralPartialEq for Entry
Source§impl TryFrom<MessagePayload> for Entry
impl TryFrom<MessagePayload> for Entry
Auto Trait Implementations§
impl Freeze for Entry
impl RefUnwindSafe for Entry
impl Send for Entry
impl Sync for Entry
impl Unpin for Entry
impl UnsafeUnpin for Entry
impl UnwindSafe for Entry
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.