pub struct AccessGrants(/* private fields */);Expand description
A validated map from principal to rights, limited to
MAX_ACCESS_GRANT_ENTRIES entries and MAX_ACCESS_GRANTS_PRINCIPAL_BYTES
bytes of principal ids. No entry has an empty set of rights. Decoding
rejects repeated principals.
Implementations§
Source§impl AccessGrants
impl AccessGrants
Sourcepub fn new(
entries: BTreeMap<PrincipalId, AccessRights>,
) -> Result<Self, AccessGrantsError>
pub fn new( entries: BTreeMap<PrincipalId, AccessRights>, ) -> Result<Self, AccessGrantsError>
Validates entries against the caps and the no-empty-rights rule.
Sourcepub fn get(&self, principal_id: &PrincipalId) -> AccessRights
pub fn get(&self, principal_id: &PrincipalId) -> AccessRights
The rights granted to principal_id, empty when it has no entry.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&PrincipalId, AccessRights)>
pub fn iter(&self) -> impl Iterator<Item = (&PrincipalId, AccessRights)>
The entries in principal order.
Sourcepub fn as_map(&self) -> &BTreeMap<PrincipalId, AccessRights>
pub fn as_map(&self) -> &BTreeMap<PrincipalId, AccessRights>
The underlying map.
Sourcepub fn logical_bytes(&self) -> usize
pub fn logical_bytes(&self) -> usize
Bytes this map accounts for when decoded: every principal id plus one byte per right.
Trait Implementations§
Source§impl Clone for AccessGrants
impl Clone for AccessGrants
Source§impl Debug for AccessGrants
impl Debug for AccessGrants
Source§impl Default for AccessGrants
impl Default for AccessGrants
Source§impl<'de> Deserialize<'de> for AccessGrants
impl<'de> Deserialize<'de> for AccessGrants
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for AccessGrants
Source§impl PartialEq for AccessGrants
impl PartialEq for AccessGrants
Source§impl Serialize for AccessGrants
impl Serialize for AccessGrants
impl StructuralPartialEq for AccessGrants
Source§impl TryFrom<BTreeMap<PrincipalId, AccessRights>> for AccessGrants
impl TryFrom<BTreeMap<PrincipalId, AccessRights>> for AccessGrants
Source§type Error = AccessGrantsError
type Error = AccessGrantsError
The type returned in the event of a conversion error.
Source§fn try_from(
entries: BTreeMap<PrincipalId, AccessRights>,
) -> Result<Self, Self::Error>
fn try_from( entries: BTreeMap<PrincipalId, AccessRights>, ) -> Result<Self, Self::Error>
Performs the conversion.
Auto Trait Implementations§
impl Freeze for AccessGrants
impl RefUnwindSafe for AccessGrants
impl Send for AccessGrants
impl Sync for AccessGrants
impl Unpin for AccessGrants
impl UnsafeUnpin for AccessGrants
impl UnwindSafe for AccessGrants
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more