pub struct Capability<NB> { /* private fields */ }Expand description
Representation of a set of delegated Capabilities.
Implementations§
Source§impl<NB> Capability<NB>
impl<NB> Capability<NB>
Sourcepub fn can<T, A>(
&self,
target: T,
action: A,
) -> ConvertResult<Option<&NotaBeneCollection<NB>>, UriString, Ability, T, A>
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.
Sourcepub fn can_do(
&self,
target: &UriString,
action: &Ability,
) -> Option<&NotaBeneCollection<NB>>
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.
Sourcepub fn merge<NB1, NB2>(self, other: Capability<NB1>) -> Capability<NB2>
pub fn merge<NB1, NB2>(self, other: Capability<NB1>) -> Capability<NB2>
Merge this Capabilities set with another
Sourcepub fn with_action(
&mut self,
target: UriString,
action: Ability,
nb: impl IntoIterator<Item = BTreeMap<String, NB>>,
) -> &mut Self
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
Sourcepub 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>>
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.
Sourcepub fn with_actions(
&mut self,
target: UriString,
abilities: impl IntoIterator<Item = (Ability, impl IntoIterator<Item = BTreeMap<String, NB>>)>,
) -> &mut Self
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
Sourcepub 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>>
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>>
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.
Sourcepub fn abilities(&self) -> &CapsInner<NB>
pub fn abilities(&self) -> &CapsInner<NB>
Read the set of abilities granted in this capabilities set
Sourcepub fn abilities_for<T>(
&self,
target: T,
) -> Result<Option<&BTreeMap<Ability, NotaBeneCollection<NB>>>, T::Error>
pub fn abilities_for<T>( &self, target: T, ) -> Result<Option<&BTreeMap<Ability, NotaBeneCollection<NB>>>, T::Error>
Read the set of abilities granted for a given target in this capabilities set
Sourcepub fn with_proof(self, proof: &Cid) -> Self
pub fn with_proof(self, proof: &Cid) -> Self
Add a supporting proof CID
Sourcepub fn with_proofs<'l>(self, proofs: impl IntoIterator<Item = &'l Cid>) -> Self
pub fn with_proofs<'l>(self, proofs: impl IntoIterator<Item = &'l Cid>) -> Self
Add a set of supporting proofs
pub fn into_inner(self) -> (Capabilities<NB>, Vec<Cid>)
Sourcepub fn to_statement(&self) -> String
pub fn to_statement(&self) -> String
Generate a ReCap statement from capabilities and URI (delegee).
Source§impl<NB> Capability<NB>where
NB: Serialize,
impl<NB> Capability<NB>where
NB: Serialize,
Sourcepub fn build_message(&self, message: Message) -> Result<Message, EncodingError>
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>,
impl<NB> Capability<NB>where
NB: for<'a> Deserialize<'a>,
Sourcepub fn extract_and_verify(
message: &Message,
) -> Result<Option<Self>, VerificationError>
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>
impl<NB: Clone> Clone for Capability<NB>
Source§fn clone(&self) -> Capability<NB>
fn clone(&self) -> Capability<NB>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more