pub struct LibdcafEncodedScope(/* private fields */);Expand description
A scope encoded using the Authorization Information Format (AIF) for ACE
as in AifEncodedScope, but only consisting of a single AifEncodedScopeElement
instead of an array of them.
This is done to provide interoperability support for the
libdcaf implementation,
which currently uses this format to describe its scopes.
This struct is only provided to allow compatability with the
libdcaf implementation—if you don’t
require this, simply use the spec-compliant AifEncodedScope instead, as it provides a
superset of the functionality of this type.
Refer to AifEncodedScope for details on the format, and “Difference to AifEncodedScope”
for details on the difference to it.
§Example
To create a scope allowing only the GET and FETCH methods to be called the local URI readonly:
let scope = LibdcafEncodedScope::new("readonly", AifRestMethod::Get | AifRestMethod::Fetch);
assert_eq!(scope.element().permissions.bits(), u64::pow(2, 0) + u64::pow(2, 4));§Difference to AifEncodedScope
The only difference here is that while AifEncodedScope would encode the above example
like so (given as JSON):
[["readonly", 17]]LibdcafEncodedScope would encode it like so:
["readonly", 17]Note that this implies that the latter only allows a single scope element (i.e. a single row
in the access matrix) to be specified, while the former allows multiple elements.
As mentioned in the beginning, only use this struct if you need to communicate with libdcaf,
use AifEncodedScope in all other cases.
Implementations§
Source§impl LibdcafEncodedScope
impl LibdcafEncodedScope
Sourcepub fn new<T>(
path: T,
permissions: BitFlags<AifRestMethod>,
) -> LibdcafEncodedScope
pub fn new<T>( path: T, permissions: BitFlags<AifRestMethod>, ) -> LibdcafEncodedScope
Creates a new libdcaf-encoded scope from the given path and permissions.
Refer to AifEncodedScopeElement::new for details and
an example applicable to this method.
Sourcepub fn from_element(element: AifEncodedScopeElement) -> LibdcafEncodedScope
pub fn from_element(element: AifEncodedScopeElement) -> LibdcafEncodedScope
Creates a new libdcaf-encoded scope from the given element.
Refer to AifEncodedScopeElement and LibdcafEncodedScope for details.
Sourcepub fn try_from_bits<T>(
path: T,
permissions: u64,
) -> Result<LibdcafEncodedScope, InvalidAifEncodedScopeError>
pub fn try_from_bits<T>( path: T, permissions: u64, ) -> Result<LibdcafEncodedScope, InvalidAifEncodedScopeError>
Tries to create a new libdcaf-encoded scope from the given path and permissions.
The given permissions must be a valid bitmask of the allowed REST methods,
as defined in section 3 of RFC 9237.
§Errors
Refer to AifEncodedScopeElement::try_from_bits.
§Example
Refer to AifEncodedScopeElement::try_from_bits.
Sourcepub fn element(&self) -> &AifEncodedScopeElement
pub fn element(&self) -> &AifEncodedScopeElement
Returns a reference to the single element contained in this scope.
Sourcepub fn to_element(self) -> AifEncodedScopeElement
pub fn to_element(self) -> AifEncodedScopeElement
Returns the single element contained in this scope.
Sourcepub fn elements(&self) -> Vec<&AifEncodedScopeElement>
pub fn elements(&self) -> Vec<&AifEncodedScopeElement>
Returns a vector of a reference to the single element in this scope.
Sourcepub fn to_elements(self) -> Vec<AifEncodedScopeElement>
pub fn to_elements(self) -> Vec<AifEncodedScopeElement>
Returns a vector of the single element in this scope.
Trait Implementations§
Source§impl Clone for LibdcafEncodedScope
impl Clone for LibdcafEncodedScope
Source§fn clone(&self) -> LibdcafEncodedScope
fn clone(&self) -> LibdcafEncodedScope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more