Struct OwnedCapability

Source
pub struct OwnedCapability<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: McNamespacePublicKey + Verifier<NamespaceSignature>, NamespaceSignature: EncodableSync + EncodableKnownSize, UserPublicKey: McPublicUserKey<UserSignature>, UserSignature: EncodableSync + EncodableKnownSize,
{ /* private fields */ }
Expand description

A capability that implements owned namespaces.

Definition.

Implementations§

Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: McNamespacePublicKey + Verifier<NamespaceSignature>, NamespaceSignature: EncodableSync + EncodableKnownSize + Clone, UserPublicKey: McPublicUserKey<UserSignature>, UserSignature: EncodableSync + EncodableKnownSize + Clone,

Source

pub fn new<NamespaceSecret>( namespace_key: NamespacePublicKey, namespace_secret: &NamespaceSecret, user_key: UserPublicKey, access_mode: AccessMode, ) -> Result<Self, OwnedCapabilityCreationError<NamespacePublicKey>>
where NamespaceSecret: Signer<NamespaceSignature>,

Creates a new owned capability granting access to the full area of the namespace to the given UserPublicKey.

Source

pub fn from_existing( namespace_key: NamespacePublicKey, user_key: UserPublicKey, initial_authorisation: NamespaceSignature, access_mode: AccessMode, ) -> Result<Self, OwnedCapabilityCreationError<NamespacePublicKey>>

Creates an OwnedCapability using an existing authorisation (e.g. one received over the network), or return an error if the signature was not created by the namespace key.

Source

pub fn delegate<UserSecretKey>( &self, secret_key: &UserSecretKey, new_user: &UserPublicKey, new_area: &Area<MCL, MCC, MPL, UserPublicKey>, ) -> Result<Self, FailedDelegationError<MCL, MCC, MPL, UserPublicKey>>
where UserSecretKey: Signer<UserSignature>,

Delegates this capability to a new UserPublicKey for a given willow_data_model::grouping::Area. Will fail if the area is not included by this capability’s granted area, or if the given secret key does not correspond to the capability’s receiver.

Source

pub fn needs_subspace_cap(&self) -> bool

Returns whether this capability needs a complementing crate::McSubspaceCapability (definition) to in order to be fully authorised by the Willow General Sync Protocol.

Source

pub fn append_existing_delegation( &mut self, delegation: Delegation<MCL, MCC, MPL, UserPublicKey, UserSignature>, ) -> Result<(), InvalidDelegationError<MCL, MCC, MPL, UserPublicKey, UserSignature>>

Appends an existing delegation to an existing capability, or return an error if the delegation is invalid.

Source

pub fn access_mode(&self) -> AccessMode

Returns the kind of access this capability grants.

Definition

Source

pub fn receiver(&self) -> &UserPublicKey

Returns the public key of the user to whom this capability grants access.

Definition

Source

pub fn granted_namespace(&self) -> &NamespacePublicKey

Returns the public key of the namespace for which this capability grants access.

Definition

Source

pub fn granted_area(&self) -> Area<MCL, MCC, MPL, UserPublicKey>

Returns Area for which this capability grants access.

Definition

Source

pub fn delegations( &self, ) -> impl ExactSizeIterator<Item = &Delegation<MCL, MCC, MPL, UserPublicKey, UserSignature>>

Returns a slice of all Delegations made to this capability.

Source

pub fn delegations_len(&self) -> usize

Returns the number of delegations present on this capability.

Source

pub fn progenitor(&self) -> &UserPublicKey

Returns the public key of the very first user this capability was issued to.

Source

pub fn initial_authorisation(&self) -> &NamespaceSignature

Returns the original signature authorising this namespace capability.

Source

pub unsafe fn new_unchecked( access_mode: AccessMode, namespace_key: NamespacePublicKey, user_key: UserPublicKey, initial_authorisation: NamespaceSignature, delegations: Vec<Delegation<MCL, MCC, MPL, UserPublicKey, UserSignature>>, ) -> Self

Returns a OwnedCapability without checking if its initial authorisation or delegations are valid.

§Safety

Calling this method with an invalid initial authorisation or delegation is immediate undefined behaviour!

Trait Implementations§

Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Clone for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: McNamespacePublicKey + Verifier<NamespaceSignature> + Clone, NamespaceSignature: EncodableSync + EncodableKnownSize + Clone, UserPublicKey: McPublicUserKey<UserSignature> + Clone, UserSignature: EncodableSync + EncodableKnownSize + Clone,

Source§

fn clone( &self, ) -> OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>

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, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Debug for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: McNamespacePublicKey + Verifier<NamespaceSignature> + Debug, NamespaceSignature: EncodableSync + EncodableKnownSize + Debug, UserPublicKey: McPublicUserKey<UserSignature> + Debug, UserSignature: EncodableSync + EncodableKnownSize + Debug,

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, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Hash for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: McNamespacePublicKey + Verifier<NamespaceSignature> + Hash, NamespaceSignature: EncodableSync + EncodableKnownSize + Hash, UserPublicKey: McPublicUserKey<UserSignature> + Hash, UserSignature: EncodableSync + EncodableKnownSize + Hash,

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, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> PartialEq for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: McNamespacePublicKey + Verifier<NamespaceSignature> + PartialEq, NamespaceSignature: EncodableSync + EncodableKnownSize + PartialEq, UserPublicKey: McPublicUserKey<UserSignature> + PartialEq, UserSignature: EncodableSync + EncodableKnownSize + PartialEq,

Source§

fn eq( &self, other: &OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>, ) -> 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: McNamespacePublicKey + Verifier<NamespaceSignature>, NamespaceSignature: Decodable + EncodableSync + EncodableKnownSize + Clone, UserPublicKey: McPublicUserKey<UserSignature>, UserSignature: EncodableSync + EncodableKnownSize + Clone + Decodable> RelativeDecodable<PersonalPrivateInterest<MCL, MCC, MPL, N, UserPublicKey>, Blame> for OwnedCapability<MCL, MCC, MPL, N, NamespaceSignature, UserPublicKey, UserSignature>
where Blame: From<N::ErrorReason> + From<NamespaceSignature::ErrorReason> + From<UserPublicKey::ErrorReason> + From<UserSignature::ErrorReason>,

Source§

async fn relative_decode<P>( producer: &mut P, r: &PersonalPrivateInterest<MCL, MCC, MPL, N, UserPublicKey>, ) -> Result<Self, DecodeError<P::Final, P::Error, Blame>>
where P: BulkProducer<Item = u8>, Self: Sized,

Decodes the bytes produced by the given producer into a Self, or yields an error if the producer does not produce a valid encoding.
Source§

fn relative_decode_from_slice( enc: &[u8], r: &RelativeTo, ) -> impl Future<Output = Result<Self, DecodeError<(), Infallible, ErrorReason>>>

Decodes from a slice instead of a producer.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, N: McNamespacePublicKey + Verifier<NamespaceSignature>, NamespaceSignature: EncodableSync + EncodableKnownSize + Clone, UserPublicKey: McPublicUserKey<UserSignature> + Encodable, UserSignature: EncodableSync + EncodableKnownSize + Clone> RelativeEncodable<PersonalPrivateInterest<MCL, MCC, MPL, N, UserPublicKey>> for OwnedCapability<MCL, MCC, MPL, N, NamespaceSignature, UserPublicKey, UserSignature>

Source§

async fn relative_encode<C>( &self, consumer: &mut C, r: &PersonalPrivateInterest<MCL, MCC, MPL, N, UserPublicKey>, ) -> Result<(), C::Error>
where C: BulkConsumer<Item = u8>,

Writes an encoding of &self into the given consumer.
Source§

fn relative_encode_into_vec( &self, r: &RelativeTo, ) -> impl Future<Output = Vec<u8>>

Encodes into a Vec instead of a given consumer.
Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Eq for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: McNamespacePublicKey + Verifier<NamespaceSignature> + Eq, NamespaceSignature: EncodableSync + EncodableKnownSize + Eq, UserPublicKey: McPublicUserKey<UserSignature> + Eq, UserSignature: EncodableSync + EncodableKnownSize + Eq,

Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> StructuralPartialEq for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: McNamespacePublicKey + Verifier<NamespaceSignature>, NamespaceSignature: EncodableSync + EncodableKnownSize, UserPublicKey: McPublicUserKey<UserSignature>, UserSignature: EncodableSync + EncodableKnownSize,

Auto Trait Implementations§

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Freeze for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: Freeze, UserPublicKey: Freeze, NamespaceSignature: Freeze,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> RefUnwindSafe for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: RefUnwindSafe, UserPublicKey: RefUnwindSafe, NamespaceSignature: RefUnwindSafe, UserSignature: RefUnwindSafe,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Send for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: Send, UserPublicKey: Send, NamespaceSignature: Send, UserSignature: Send,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Sync for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: Sync, UserPublicKey: Sync, NamespaceSignature: Sync, UserSignature: Sync,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> Unpin for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: Unpin, UserPublicKey: Unpin, NamespaceSignature: Unpin, UserSignature: Unpin,

§

impl<const MCL: usize, const MCC: usize, const MPL: usize, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature> UnwindSafe for OwnedCapability<MCL, MCC, MPL, NamespacePublicKey, NamespaceSignature, UserPublicKey, UserSignature>
where NamespacePublicKey: UnwindSafe, UserPublicKey: UnwindSafe, NamespaceSignature: UnwindSafe, UserSignature: 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<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<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.