Skip to main content

Acl

Struct Acl 

Source
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: bool

true when entries have changed since last publish.

§cid: Option<Cid>

CID of the last successfully published DAG-CBOR node.

Implementations§

Source§

impl Acl

Source

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.

Source

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.

Source

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.

Source

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.

Source

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-URL
  • did: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.

Source

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).

Source

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).

Source

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§

Source§

impl Clone for Acl

Source§

fn clone(&self) -> Acl

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Acl

Source§

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

Formats the value using the given formatter. Read more

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more