pub struct Entry {
pub hash: String,
pub id: String,
pub payload: String,
pub next: Vec<String>,
pub v: u32,
pub clock: LamportClock,
pub identity: Option<Arc<Identity>>,
}Expand description
An entry containing data payload, a hash to locate it in IPFS,
and pointers to its parents.
Fields§
§hash: String§id: String§payload: String§next: Vec<String>§v: u32§clock: LamportClock§identity: Option<Arc<Identity>>Implementations§
Source§impl Entry
impl Entry
Sourcepub fn create(
ipfs: &IpfsClient,
identity: Identity,
log_id: &str,
data: &str,
nexts: &[EntryOrHash<'_>],
clock: Option<LamportClock>,
) -> Arc<Entry>
pub fn create( ipfs: &IpfsClient, identity: Identity, log_id: &str, data: &str, nexts: &[EntryOrHash<'_>], clock: Option<LamportClock>, ) -> Arc<Entry>
Locally creates an entry owned by identity .
The created entry is part of the log with the id log_id,
holds payload of data and can be assigned to point to
at most two parents with their hashes in nexts. Providing a
Lamport clock via clock is optional.
Returns a reference-counting pointer to the created entry.
Sourcepub async fn multihash(
ipfs: &IpfsClient,
entry: &Entry,
) -> Result<String, Error>
pub async fn multihash( ipfs: &IpfsClient, entry: &Entry, ) -> Result<String, Error>
Stores entry in the IPFS client ipfs and returns a future containing its multihash.
N.B. At the moment stores the entry as JSON, not CBOR DAG.
Sourcepub async fn from_multihash(
ipfs: &IpfsClient,
hash: &str,
) -> Result<Entry, Error>
pub async fn from_multihash( ipfs: &IpfsClient, hash: &str, ) -> Result<Entry, Error>
Returns the future containing the entry stored in the IPFS client ipfs with the multihash hash.
N.B. At the moment converts the entry from JSON, not CBOR DAG.
Sourcepub fn fetch_entries(ipfs: &IpfsClient, hashes: &[String]) -> Vec<Entry>
pub fn fetch_entries(ipfs: &IpfsClient, hashes: &[String]) -> Vec<Entry>
Fetches all the entries with the hashes in hashes and all their parents from the IPFS client ipfs.
Returns a vector of entries.
Sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
Returns the identifier of the entry that is the same as of the containing log.
Sourcepub fn next(&self) -> &[String]
pub fn next(&self) -> &[String]
Returns the hashes of the parents.
The length of the returned slice is either:
- 0 — no parents
- 2 — two identical strings for one parent, two distinct strings for two different parents
Sourcepub fn clock(&self) -> &LamportClock
pub fn clock(&self) -> &LamportClock
Returns the Lamport clock of the entry.
Sourcepub fn is_parent(e1: &Entry, e2: &Entry) -> bool
pub fn is_parent(e1: &Entry, e2: &Entry) -> bool
Returns true if e1 is the parent of e2, otherwise returns false.
Sourcepub fn find_children(entry: &Entry, entries: &[Arc<Entry>]) -> Vec<Arc<Entry>>
pub fn find_children(entry: &Entry, entries: &[Arc<Entry>]) -> Vec<Arc<Entry>>
Returns a vector of pointers to all direct and indirect children of entry in entries.
Sourcepub fn last_write_wins(a: &Entry, b: &Entry) -> Ordering
pub fn last_write_wins(a: &Entry, b: &Entry) -> Ordering
A sorting function to pick the more recently written entry.
Uses sort_step_by_step, resolving unsorted cases in the manner defined in it.
Returns an ordering.
Sourcepub fn sort_by_entry_hash(a: &Entry, b: &Entry) -> Ordering
pub fn sort_by_entry_hash(a: &Entry, b: &Entry) -> Ordering
A sorting function to pick the entry with the greater hash.
Uses sort_step_by_step, resolving unsorted cases in the manner defined in it.
Returns an ordering.
Sourcepub fn sort_step_by_step<F>(resolve: F) -> impl Fn(&Entry, &Entry) -> Ordering
pub fn sort_step_by_step<F>(resolve: F) -> impl Fn(&Entry, &Entry) -> Ordering
A sorting helper function to
- first try to sort the two entries using
resolve, - if still unsorted (equal), try to sort based on the Lamport clock identifiers of the respective entries,
- sort by the Lamport clocks of the respective entries.
Returns a closure that can be used as a sorting function.
Sourcepub fn sort_by_clocks<F>(resolve: F) -> impl Fn(&Entry, &Entry) -> Ordering
pub fn sort_by_clocks<F>(resolve: F) -> impl Fn(&Entry, &Entry) -> Ordering
A sorting helper function to sort by the Lamport clocks of the respective entries.
In the case the Lamport clocks are equal, tries to sort using resolve.
Returns a closure that can be used as a sorting function.
Sourcepub fn sort_by_clock_ids<F>(resolve: F) -> impl Fn(&Entry, &Entry) -> Ordering
pub fn sort_by_clock_ids<F>(resolve: F) -> impl Fn(&Entry, &Entry) -> Ordering
A sorting helper function to sort by the Lamport clock identifiers of the respective entries.
In the case the Lamport clocks identifiers are equal, tries to sort using resolve.
Returns a closure that can be used as a sorting function.
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>,
Source§impl LogEntry for Entry
impl LogEntry for Entry
fn get_payload(&self) -> &[u8] ⓘ
fn get_identity(&self) -> &Identity
Source§impl Ord for Entry
impl Ord for Entry
Source§impl PartialOrd for Entry
impl PartialOrd for Entry
impl Eq for Entry
impl Send for Entry
impl Sync for Entry
Auto Trait Implementations§
Blanket Implementations§
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> 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<'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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> 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 more