pub struct Acl {
pub dirty: bool,
pub cid: Option<Cid>,
/* private fields */
}Expand description
An access control list for an ma entity.
Create with Acl::new_from_yaml or Acl::new_from_cid.
Fields§
§dirty: booltrue when entries have changed since last publish.
cid: Option<Cid>CID of the last successfully published DAG-CBOR node.
Implementations§
Source§impl Acl
impl Acl
Sourcepub fn new_from_yaml(yaml: &str) -> Result<Self>
pub fn new_from_yaml(yaml: &str) -> Result<Self>
Parse an ACL from a YAML string.
The YAML must contain an acl: key whose value is a sequence of
strings. Any unrecognised entry is a hard error (fail-fast).
§Errors
Returns Error::Acl if the YAML is malformed or any entry is invalid.
Sourcepub fn new_from_cid(cid: Cid, data: &[u8]) -> Result<Self>
pub fn new_from_cid(cid: Cid, data: &[u8]) -> Result<Self>
Reconstruct an ACL from a previously published YAML payload and its CID.
Marks the ACL as clean (dirty = false) and records the CID.
§Errors
Returns Error::Acl if the bytes are not valid UTF-8 or the YAML is
malformed.
Sourcepub fn allow(&mut self, did_str: &str) -> Result<()>
pub fn allow(&mut self, did_str: &str) -> Result<()>
Add an allow rule for did_str.
did_str may be a bare #fragment, did:ma:…, or did:ma:…#fragment.
§Errors
Returns Error::Acl if did_str cannot be parsed.
Sourcepub fn deny(&mut self, did_str: &str) -> Result<()>
pub fn deny(&mut self, did_str: &str) -> Result<()>
Add a deny rule for did_str.
Prefix with ! is optional — this method adds the deny semantics
regardless. did_str may be #fragment, did:ma:…, or
did:ma:…#fragment.
§Errors
Returns Error::Acl if did_str cannot be parsed as a DID or fragment.
Sourcepub fn is_allowed(&self, did_str: &str) -> bool
pub fn is_allowed(&self, did_str: &str) -> bool
Return true if did_str is permitted by this ACL.
did_str is matched as:
did:ma:…#fragment— full DID-URLdid:ma:…— bare identity#fragment— bare fragment (no identity context)
Deny always wins over allow. An identity-level deny blocks all DID-URLs under that identity.
Sourcepub fn to_yaml(&self) -> Result<String>
pub fn to_yaml(&self) -> Result<String>
Serialise the ACL to a canonical YAML string.
§Errors
Returns Error::Acl if serialisation fails (should not happen in
practice).
Sourcepub fn mark_published(&mut self, cid: Cid, gen: u64)
pub fn mark_published(&mut self, cid: Cid, gen: u64)
Record a successful publish.
Only updates Acl::cid and clears Acl::dirty when gen matches
the current generation (i.e. no mutations happened between the publish
call and this confirmation).
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Current generation counter.
Increments on every mutating operation. Pass this value to
Acl::mark_published to guard against race conditions.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Acl
impl RefUnwindSafe for Acl
impl Send for Acl
impl Sync for Acl
impl Unpin for Acl
impl UnsafeUnpin for Acl
impl UnwindSafe for Acl
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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