Entry

Struct Entry 

Source
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));

Spec definition.

Implementations§

Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Entry<MCL, MCC, MPL, N, S, PD>

Source

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");
Source

pub fn prefilled_builder<E>(source: &E) -> EntryBuilder<MCL, MCC, MPL, N, S, PD>
where E: Entrylike<MCL, MCC, MPL, N, S, PD>, N: Clone, S: Clone, PD: Clone,

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>

Source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

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 more
Source§

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 more
Source§

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§

fn clone(&self) -> Entry<MCL, MCC, MPL, N, S, PD>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
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>

Source§

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>

Source§

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

Formats the value using the given formatter. Read more
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>

Source§

fn wdm_namespace_id(&self) -> &N

Returns the namespace_id of self.
Source§

fn wdm_payload_length(&self) -> u64

Returns the payload_length of self.
Source§

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>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
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>

Source§

fn wdm_subspace_id(&self) -> &S

Returns the subspace_id of self.
Source§

fn wdm_path(&self) -> &Path<MCL, MCC, MPL>

Returns the path 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>

Source§

fn cmp(&self, other: &Entry<MCL, MCC, MPL, N, S, PD>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. 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>

Source§

fn eq(&self, other: &Entry<MCL, MCC, MPL, N, S, PD>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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>

Source§

fn partial_cmp( &self, other: &Entry<MCL, MCC, MPL, N, S, PD>, ) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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>

Source§

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>
where N: Send, S: Send, PD: Send,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Sync for Entry<MCL, MCC, MPL, N, S, PD>
where N: Sync, S: Sync, PD: Sync,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> Unpin for Entry<MCL, MCC, MPL, N, S, PD>
where N: Unpin, S: Unpin, PD: Unpin,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD> UnwindSafe for Entry<MCL, MCC, MPL, N, S, PD>
where N: UnwindSafe, S: UnwindSafe, PD: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, S, T> CoordinatelikeExt<MCL, MCC, MPL, S> for T
where T: Coordinatelike<MCL, MCC, MPL, S>,

Source§

fn wdm_coordinate_eq<OtherCoordinate>(&self, other: &OtherCoordinate) -> bool
where 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 more
Source§

fn wdm_coordinate_ne<OtherCoordinate>(&self, other: &OtherCoordinate) -> bool
where 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 more
Source§

fn wdm_is_in<G>(&self, grouping: &G) -> bool
where G: Grouping<MCL, MCC, MPL, S>,

Returns whether self is included in the given Grouping. Read more
Source§

fn wdm_is_in_intersection<G>(&self, grouping1: &G, grouping2: &G) -> bool
where G: Grouping<MCL, MCC, MPL, S>,

Returns whether self is included in the intersection of the two given Groupings. Read more
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, E> EntrylikeExt<MCL, MCC, MPL, N, S, PD> for E
where E: Entrylike<MCL, MCC, MPL, N, S, PD>,

Source§

fn wdm_entry_eq<OtherEntry>(&self, other: &OtherEntry) -> bool
where OtherEntry: Entrylike<MCL, MCC, MPL, N, S, PD>, N: PartialEq, S: PartialEq, PD: PartialEq,

Returns whether self and other describe equal entries. Read more
Source§

fn wdm_entry_ne<OtherEntry>(&self, other: &OtherEntry) -> bool
where OtherEntry: Entrylike<MCL, MCC, MPL, N, S, PD>, N: PartialEq, S: PartialEq, PD: PartialEq,

Returns whether self and other describe non-equal entries. Read more
Source§

fn wdm_cmp_recency<OtherEntry>(&self, other: &OtherEntry) -> Ordering
where OtherEntry: Entrylike<MCL, MCC, MPL, N, S, PD>, PD: Ord,

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 more
Source§

fn wdm_is_newer_than<OtherEntry>(&self, other: &OtherEntry) -> bool
where OtherEntry: Entrylike<MCL, MCC, MPL, N, S, PD>, PD: Ord,

Returns whether this entry is strictly newer than another entry. See also EntrylikeExt::wdm_cmp_recency and EntrylikeExt::wdm_is_older_than. Read more
Source§

fn wdm_is_older_than<OtherEntry>(&self, other: &OtherEntry) -> bool
where OtherEntry: Entrylike<MCL, MCC, MPL, N, S, PD>, PD: Ord,

Returns whether this entry is strictly older than another entry. See also EntrylikeExt::wdm_cmp_recency and EntrylikeExt::wdm_is_newer_than. Read more
Source§

fn wdm_prunes<OtherEntry>(&self, other: &OtherEntry) -> bool
where OtherEntry: Entrylike<MCL, MCC, MPL, N, S, PD>, N: PartialEq, S: PartialEq, PD: Ord,

Returns whether this entry would prefix prune another entry. Read more
Source§

fn wdm_is_pruned_by<OtherEntry>(&self, other: &OtherEntry) -> bool
where OtherEntry: Entrylike<MCL, MCC, MPL, N, S, PD>, N: PartialEq, S: PartialEq, PD: Ord, Self: Sized,

Returns whether this entry would be prefix pruned by another entry. 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 T
where 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<const MCL: usize, const MCC: usize, const MPL: usize, S, T> KeylikeExt<MCL, MCC, MPL, S> for T
where T: Keylike<MCL, MCC, MPL, S>,

Source§

fn wdm_key_eq<OtherKey>(&self, other: &OtherKey) -> bool
where OtherKey: Keylike<MCL, MCC, MPL, S>, S: PartialEq,

Returns whether self and other describe equal keys, i.e., whether their subspace ids and paths are both equal. Read more
Source§

fn wdm_key_ne<OtherKey>(&self, other: &OtherKey) -> bool
where OtherKey: Keylike<MCL, MCC, MPL, S>, S: PartialEq,

Returns whether self and other describe non-equal keys, i.e., whether their subspace ids and paths are not both equal. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.