pub struct Entry<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> { /* private fields */ }Expand description
The metadata associated with each Willow Payload string.
Entries are the central concept in Willow. In order to make any bytestring of data accessible to Willow, you need to create an Entry describing its metadata. Specifically, an Entry consists of
- a namespace_id (roughly, this addresses a universe of Willow data, fully independent from all data (i.e., Entries) of different namespace ids) of type
N, - a subspace_id (roughly, a fully indendent part of a namespace, typically subspaces correspond to individual users) of type
S, - a path (roughly, a file-system-like way of arranging payloads hierarchically within a subspace) of type
Path, - a timestamp (newer Entries can overwrite certain older Entries),
- a payload_length (the length of the payload string), and
- a payload_digest (a secure hash of the payload string being inserted into Willow).
To access these six fields, use the methods of the Entrylike trait (which Entry implements). The EntrylikeExt trait provides additional helper methods, for example, methods to check which Entries can delete which other Entries.
To create Entries, use the Entry::builder or Entry::prefilled_builder functions.
§Example
use willow_data_model::prelude::*;
let entry = Entry::builder()
.namespace_id("family")
.subspace_id("alfie")
.path(Path::<4, 4, 4>::new())
.timestamp(12345)
.payload_digest("some_hash")
.payload_length(17)
.build().unwrap();
assert_eq!(*entry.wdm_subspace_id(), "alfie");
let newer = Entry::prefilled_builder(&entry).timestamp(99999).build().unwrap();
assert!(newer.wdm_prunes(&entry));Implementations§
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Entry<MCL, MCC, MPL, N, S, PD>
Sourcepub fn builder() -> EntryBuilder<MCL, MCC, MPL, N, S, PD>
pub fn builder() -> EntryBuilder<MCL, MCC, MPL, N, S, PD>
Creates a builder for Entry.
§Examples
use willow_data_model::prelude::*;
// Supplying incomplete data errors.
assert!(
Entry::builder()
.path(Path::<4, 4, 4>::new())
.namespace_id("family")
.subspace_id("alfie")
.payload_digest("some_hash")
// timestamp and payload_length are missing!
.build().is_err()
);
// Supplying all necessary data yields an entry.
let entry = Entry::builder()
.namespace_id("family")
.subspace_id("alfie")
.path(Path::<4, 4, 4>::new())
.timestamp(12345)
.payload_digest("some_hash")
.payload_length(17)
.build().unwrap();
assert_eq!(*entry.wdm_subspace_id(), "alfie");Sourcepub fn prefilled_builder<E>(source: &E) -> EntryBuilder<MCL, MCC, MPL, N, S, PD>
pub fn prefilled_builder<E>(source: &E) -> EntryBuilder<MCL, MCC, MPL, N, S, PD>
Creates a builder which is prefilled with the data from some other entry.
Use this function to create modified copies of entries.
§Examples
use willow_data_model::prelude::*;
// Supplying all necessary data yields an entry.
let first_entry = Entry::builder()
.namespace_id("family")
.subspace_id("alfie")
.path(Path::<4, 4, 4>::new())
.timestamp(12345)
.payload_digest("some_hash")
.payload_length(17)
.build().unwrap();
assert_eq!(*first_entry.wdm_payload_digest(), "some_hash");
let second_entry = Entry::prefilled_builder(&first_entry)
.timestamp(67890)
.payload_digest("another_hash")
.payload_length(4)
.build().unwrap();
assert_eq!(*second_entry.wdm_payload_digest(), "another_hash");Trait Implementations§
Source§impl<'arbitrary, const MCL: usize, const MCC: usize, const MPL: usize, N: Arbitrary<'arbitrary>, S: Arbitrary<'arbitrary>, PD: Arbitrary<'arbitrary>> Arbitrary<'arbitrary> for Entry<MCL, MCC, MPL, N, S, PD>
impl<'arbitrary, const MCL: usize, const MCC: usize, const MPL: usize, N: Arbitrary<'arbitrary>, S: Arbitrary<'arbitrary>, PD: Arbitrary<'arbitrary>> Arbitrary<'arbitrary> for Entry<MCL, MCC, MPL, N, S, PD>
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Clone, S: Clone, PD: Clone> Clone for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Clone, S: Clone, PD: Clone> Clone for Entry<MCL, MCC, MPL, N, S, PD>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Coordinatelike<MCL, MCC, MPL, S> for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Coordinatelike<MCL, MCC, MPL, S> for Entry<MCL, MCC, MPL, N, S, PD>
Source§fn wdm_timestamp(&self) -> Timestamp
fn wdm_timestamp(&self) -> Timestamp
Returns the timestamp of
self.Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Debug, S: Debug, PD: Debug> Debug for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Debug, S: Debug, PD: Debug> Debug for Entry<MCL, MCC, MPL, N, S, PD>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Entrylike<MCL, MCC, MPL, N, S, PD> for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Entrylike<MCL, MCC, MPL, N, S, PD> for Entry<MCL, MCC, MPL, N, S, PD>
Source§fn wdm_namespace_id(&self) -> &N
fn wdm_namespace_id(&self) -> &N
Returns the namespace_id of
self.Source§fn wdm_payload_length(&self) -> u64
fn wdm_payload_length(&self) -> u64
Returns the payload_length of
self.Source§fn wdm_payload_digest(&self) -> &PD
fn wdm_payload_digest(&self) -> &PD
Returns the payload_digest of
self.Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Hash, S: Hash, PD: Hash> Hash for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Hash, S: Hash, PD: Hash> Hash for Entry<MCL, MCC, MPL, N, S, PD>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Keylike<MCL, MCC, MPL, S> for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Keylike<MCL, MCC, MPL, S> for Entry<MCL, MCC, MPL, N, S, PD>
Source§fn wdm_subspace_id(&self) -> &S
fn wdm_subspace_id(&self) -> &S
Returns the subspace_id of
self.Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Ord, S: Ord, PD: Ord> Ord for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Ord, S: Ord, PD: Ord> Ord for Entry<MCL, MCC, MPL, N, S, PD>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N: PartialEq, S: PartialEq, PD: PartialEq> PartialEq for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N: PartialEq, S: PartialEq, PD: PartialEq> PartialEq for Entry<MCL, MCC, MPL, N, S, PD>
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, N: PartialOrd, S: PartialOrd, PD: PartialOrd> PartialOrd for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N: PartialOrd, S: PartialOrd, PD: PartialOrd> PartialOrd for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Eq, S: Eq, PD: Eq> Eq for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> StructuralPartialEq for Entry<MCL, MCC, MPL, N, S, PD>
Auto Trait Implementations§
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> !Freeze for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> RefUnwindSafe for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Send for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Sync for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Unpin for Entry<MCL, MCC, MPL, N, S, PD>
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> UnwindSafe for Entry<MCL, MCC, MPL, N, S, PD>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S, T> CoordinatelikeExt<MCL, MCC, MPL, S> for Twhere
T: Coordinatelike<MCL, MCC, MPL, S>,
impl<const MCL: usize, const MCC: usize, const MPL: usize, S, T> CoordinatelikeExt<MCL, MCC, MPL, S> for Twhere
T: Coordinatelike<MCL, MCC, MPL, S>,
Source§fn wdm_coordinate_eq<OtherCoordinate>(&self, other: &OtherCoordinate) -> boolwhere
OtherCoordinate: Coordinatelike<MCL, MCC, MPL, S>,
S: PartialEq,
fn wdm_coordinate_eq<OtherCoordinate>(&self, other: &OtherCoordinate) -> boolwhere
OtherCoordinate: Coordinatelike<MCL, MCC, MPL, S>,
S: PartialEq,
Returns whether
self and other describe equal coordinates, i.e., whether their subspace ids, paths, and timestamps are all equal. Read moreSource§fn wdm_coordinate_ne<OtherCoordinate>(&self, other: &OtherCoordinate) -> boolwhere
OtherCoordinate: Coordinatelike<MCL, MCC, MPL, S>,
S: PartialEq,
fn wdm_coordinate_ne<OtherCoordinate>(&self, other: &OtherCoordinate) -> boolwhere
OtherCoordinate: Coordinatelike<MCL, MCC, MPL, S>,
S: PartialEq,
Returns whether
self and other describe non-equal coordinates, i.e., whether their subspace ids, paths, and timestamps are not all equal. Read moreSource§impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, E> EntrylikeExt<MCL, MCC, MPL, N, S, PD> for Ewhere
E: Entrylike<MCL, MCC, MPL, N, S, PD>,
impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, E> EntrylikeExt<MCL, MCC, MPL, N, S, PD> for Ewhere
E: Entrylike<MCL, MCC, MPL, N, S, PD>,
Source§fn wdm_entry_eq<OtherEntry>(&self, other: &OtherEntry) -> bool
fn wdm_entry_eq<OtherEntry>(&self, other: &OtherEntry) -> bool
Source§fn wdm_entry_ne<OtherEntry>(&self, other: &OtherEntry) -> bool
fn wdm_entry_ne<OtherEntry>(&self, other: &OtherEntry) -> bool
Source§fn wdm_cmp_recency<OtherEntry>(&self, other: &OtherEntry) -> Ordering
fn wdm_cmp_recency<OtherEntry>(&self, other: &OtherEntry) -> Ordering
Compares
self to another entry by timestamp, payload_digest (in case of a tie), and payload_length third (in case of yet another tie). See also EntrylikeExt::wdm_is_newer_than and EntrylikeExt::wdm_is_older_than. Read moreSource§fn wdm_is_newer_than<OtherEntry>(&self, other: &OtherEntry) -> bool
fn wdm_is_newer_than<OtherEntry>(&self, other: &OtherEntry) -> bool
Returns whether this entry is strictly newer than another entry. See also
EntrylikeExt::wdm_cmp_recency and EntrylikeExt::wdm_is_older_than. Read moreSource§fn wdm_is_older_than<OtherEntry>(&self, other: &OtherEntry) -> bool
fn wdm_is_older_than<OtherEntry>(&self, other: &OtherEntry) -> bool
Returns whether this entry is strictly older than another entry. See also
EntrylikeExt::wdm_cmp_recency and EntrylikeExt::wdm_is_newer_than. Read moreSource§fn wdm_prunes<OtherEntry>(&self, other: &OtherEntry) -> bool
fn wdm_prunes<OtherEntry>(&self, other: &OtherEntry) -> bool
Returns whether this entry would prefix prune another entry. Read more
Source§fn wdm_is_pruned_by<OtherEntry>(&self, other: &OtherEntry) -> bool
fn wdm_is_pruned_by<OtherEntry>(&self, other: &OtherEntry) -> bool
Returns whether this entry would be prefix pruned by another entry. Read more
Source§impl<const MCL: usize, const MCC: usize, const MPL: usize, S, T> KeylikeExt<MCL, MCC, MPL, S> for Twhere
T: Keylike<MCL, MCC, MPL, S>,
impl<const MCL: usize, const MCC: usize, const MPL: usize, S, T> KeylikeExt<MCL, MCC, MPL, S> for Twhere
T: Keylike<MCL, MCC, MPL, S>,
Source§fn wdm_key_eq<OtherKey>(&self, other: &OtherKey) -> bool
fn wdm_key_eq<OtherKey>(&self, other: &OtherKey) -> bool
Returns whether
self and other describe equal keys, i.e., whether their subspace ids and paths are both equal. Read moreSource§fn wdm_key_ne<OtherKey>(&self, other: &OtherKey) -> bool
fn wdm_key_ne<OtherKey>(&self, other: &OtherKey) -> bool
Returns whether
self and other describe non-equal keys, i.e., whether their subspace ids and paths are not both equal. Read more