PossiblyAuthorisedEntry

Struct PossiblyAuthorisedEntry 

Source
pub struct PossiblyAuthorisedEntry<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT> {
    pub entry: Entry<MCL, MCC, MPL, N, S, PD>,
    pub authorisation_token: AT,
}
Expand description

An entry, together with an authorisation token that may or may not authorise the entry.

use willow_data_model::prelude::*;
use willow_data_model::test_parameters::*;

let entry = Entry::builder()
    .namespace_id(Family)
    .subspace_id(Alfie)
    .path(Path::<4, 4, 4>::new())
    .timestamp(12345)
    .payload_digest(Spades)
    .payload_length(2)
    .build().unwrap();

let pae = PossiblyAuthorisedEntry {
    entry: entry.clone(),
    authorisation_token: TestSubspaceSignature::new_for_entry(&entry, &AlfieSecret).unwrap(),
};
assert!(pae.into_authorised_entry().is_ok());

Specification

Fields§

§entry: Entry<MCL, MCC, MPL, N, S, PD>

The entry.

§authorisation_token: AT

The authorisation token, which may or may not authorise the entry.

Implementations§

Source§

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

Source

pub fn into_authorised_entry( self, ) -> Result<AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, Self>
where AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD>,

Checks whether self.authorisation_token authorise self.entry. If so, converts self into an AuthorisedEntry, otherwise returns Err(self).

use willow_data_model::prelude::*;
use willow_data_model::test_parameters::*;

let entry = Entry::builder()
    .namespace_id(Family)
    .subspace_id(Alfie)
    .path(Path::<4, 4, 4>::new())
    .timestamp(12345)
    .payload_digest(Spades)
    .payload_length(2)
    .build().unwrap();

let pae1 = PossiblyAuthorisedEntry {
    entry: entry.clone(),
    authorisation_token: TestSubspaceSignature::new_for_entry(&entry, &AlfieSecret).unwrap(),
};
assert!(pae1.into_authorised_entry().is_ok());

let pae2 = PossiblyAuthorisedEntry {
    entry: entry.clone(),
    authorisation_token: BettySignature,
};
assert!(pae2.into_authorised_entry().is_err());
Source

pub unsafe fn into_authorised_entry_unchecked( self, ) -> AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

Converts self into an AuthorisedEntry, without checking if self.authorisation_token authorise self.entry.

use willow_data_model::prelude::*;
use willow_data_model::test_parameters::*;

let entry = Entry::builder()
    .namespace_id(Family)
    .subspace_id(Alfie)
    .path(Path::<4, 4, 4>::new())
    .timestamp(12345)
    .payload_digest(Spades)
    .payload_length(2)
    .build().unwrap();

let pae = PossiblyAuthorisedEntry {
    entry: entry.clone(),
    authorisation_token: TestSubspaceSignature::new_for_entry(&entry, &AlfieSecret).unwrap(),
};
let authed = unsafe { pae.into_authorised_entry_unchecked() };
assert_eq!(authed.as_entry(), &entry);
assert_eq!(authed.as_authorisation_token(), &AlfieSignature);
§Safety

Undefined behaviour may occur if self.authorisation_token.does_authorise(&self.entry) is false. If it returns true, this method is safe to call.

Trait Implementations§

Source§

impl<'arbitrary, const MCL: usize, const MCC: usize, const MPL: usize, N: Arbitrary<'arbitrary>, S: Arbitrary<'arbitrary>, PD: Arbitrary<'arbitrary>, AT: Arbitrary<'arbitrary>> Arbitrary<'arbitrary> for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

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, AT: Clone> Clone for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

Source§

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

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, AT> Coordinatelike<MCL, MCC, MPL, S> for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

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, AT: Debug> Debug for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

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, AT> Entrylike<MCL, MCC, MPL, N, S, PD> for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

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, AT: Hash> Hash for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

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, AT> Keylike<MCL, MCC, MPL, S> for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

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, S, PD, AT> Namespaced<N> for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

Source§

fn wdm_namespace_id(&self) -> &N

Returns the namespace id of self.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N: Ord, S: Ord, PD: Ord, AT: Ord> Ord for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

Source§

fn cmp( &self, other: &PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, ) -> 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, AT: PartialEq> PartialEq for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

Source§

fn eq( &self, other: &PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, ) -> 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, AT: PartialOrd> PartialOrd for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

Source§

fn partial_cmp( &self, other: &PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, ) -> 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, AT: Eq> Eq for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT> StructuralPartialEq for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

Auto Trait Implementations§

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT> !Freeze for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT> RefUnwindSafe for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT> Send for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>
where AT: Send, N: Send, S: Send, PD: Send,

§

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

§

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

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N, S, PD, AT> UnwindSafe for PossiblyAuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>
where AT: UnwindSafe, 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§

fn wdm_authorise<AT>( &self, ingredients: &AT::Ingredients, ) -> Result<AuthorisedEntry<MCL, MCC, MPL, N, S, PD, AT>, AT::CreationError>
where AT: AuthorisationToken<MCL, MCC, MPL, N, S, PD> + Debug, N: Clone + Debug, S: Clone + Debug, PD: Clone + Debug,

Turns self into an AuthorisedEntry by creating an authorisation token for it. Read more
Source§

async fn wdm_encode_entry<C>(&self, consumer: &mut C) -> Result<(), C::Error>
where C: BulkConsumer<Item = u8> + ?Sized, N: Encodable, S: Encodable, PD: Encodable,

Encodes self according to the encode_entry encoding function.
Source§

fn wdm_length_of_entry_encoding(&self) -> usize

Computes the length of the encoding of self according to the encode_entry encoding function.
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.