Capability

Struct Capability 

Source
pub struct Capability<NB> { /* private fields */ }
Expand description

Representation of a set of delegated Capabilities.

Implementations§

Source§

impl<NB> Capability<NB>

Source

pub fn new() -> Self

Create a new empty Capability.

Source

pub fn can<T, A>( &self, target: T, action: A, ) -> ConvertResult<Option<&NotaBeneCollection<NB>>, UriString, Ability, T, A>

Check if a particular action is allowed for the specified target, or is allowed globally.

Source

pub fn can_do( &self, target: &UriString, action: &Ability, ) -> Option<&NotaBeneCollection<NB>>

Check if a particular action is allowed for the specified target, or is allowed globally, without type conversion.

Source

pub fn merge<NB1, NB2>(self, other: Capability<NB1>) -> Capability<NB2>
where NB2: From<NB> + From<NB1>,

Merge this Capabilities set with another

Source

pub fn with_action( &mut self, target: UriString, action: Ability, nb: impl IntoIterator<Item = BTreeMap<String, NB>>, ) -> &mut Self

Add an allowed action for the given target, with a set of note-benes

Source

pub fn with_action_convert<T, A>( &mut self, target: T, action: A, nb: impl IntoIterator<Item = BTreeMap<String, NB>>, ) -> Result<&mut Self, ConvertError<T::Error, A::Error>>

Add an allowed action for the given target, with a set of note-benes.

This method automatically converts the provided args into the correct types for convenience.

Source

pub fn with_actions( &mut self, target: UriString, abilities: impl IntoIterator<Item = (Ability, impl IntoIterator<Item = BTreeMap<String, NB>>)>, ) -> &mut Self

Add a set of allowed action for the given target, with associated note-benes

Source

pub fn with_actions_convert<T, A, N>( &mut self, target: T, abilities: impl IntoIterator<Item = (A, N)>, ) -> Result<&mut Self, ConvertError<T::Error, A::Error>>
where T: TryInto<UriString>, A: TryInto<Ability>, N: IntoIterator<Item = BTreeMap<String, NB>>,

Add a set of allowed action for the given target, with associated note-benes.

This method automatically converts the provided args into the correct types for convenience.

Source

pub fn abilities(&self) -> &CapsInner<NB>

Read the set of abilities granted in this capabilities set

Source

pub fn abilities_for<T>( &self, target: T, ) -> Result<Option<&BTreeMap<Ability, NotaBeneCollection<NB>>>, T::Error>
where T: TryInto<UriString>,

Read the set of abilities granted for a given target in this capabilities set

Source

pub fn proof(&self) -> &[Cid]

Read the set of proofs which support the granted capabilities

Source

pub fn with_proof(self, proof: &Cid) -> Self

Add a supporting proof CID

Source

pub fn with_proofs<'l>(self, proofs: impl IntoIterator<Item = &'l Cid>) -> Self

Add a set of supporting proofs

Source

pub fn into_inner(self) -> (Capabilities<NB>, Vec<Cid>)

Source

pub fn to_statement(&self) -> String

Generate a ReCap statement from capabilities and URI (delegee).

Source§

impl<NB> Capability<NB>
where NB: Serialize,

Source

pub fn build_message(&self, message: Message) -> Result<Message, EncodingError>

Apply this capabilities set to a SIWE message by writing to it’s statement and resource list

Source§

impl<NB> Capability<NB>
where NB: for<'a> Deserialize<'a>,

Source

pub fn extract_and_verify( message: &Message, ) -> Result<Option<Self>, VerificationError>

Extract the encoded capabilities from a SIWE message and ensures the correctness of the statement.

Trait Implementations§

Source§

impl<NB: Clone> Clone for Capability<NB>

Source§

fn clone(&self) -> Capability<NB>

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<NB: Debug> Debug for Capability<NB>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<NB> Default for Capability<NB>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, NB> Deserialize<'de> for Capability<NB>
where NB: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<NB> Serialize for Capability<NB>
where NB: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<NB> TryFrom<&Capability<NB>> for UriString
where NB: Serialize,

Source§

type Error = EncodingError

The type returned in the event of a conversion error.
Source§

fn try_from(cap: &Capability<NB>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<NB> TryFrom<&RiString<UriSpec>> for Capability<NB>
where NB: for<'a> Deserialize<'a>,

Source§

type Error = DecodingError

The type returned in the event of a conversion error.
Source§

fn try_from(uri: &UriString) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<NB> Freeze for Capability<NB>

§

impl<NB> RefUnwindSafe for Capability<NB>
where NB: RefUnwindSafe,

§

impl<NB> Send for Capability<NB>
where NB: Send,

§

impl<NB> Sync for Capability<NB>
where NB: Sync,

§

impl<NB> Unpin for Capability<NB>

§

impl<NB> UnwindSafe for Capability<NB>
where NB: RefUnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,