pub struct PermissionGate { /* private fields */ }Expand description
Application-layer access-control gate for Lore workspace paths.
§Usage
let gate = PermissionGate::load(workspace_path).await?;
gate.check_read("/context/secret.md", "alice")?; // Err if denied
gate.check_write("/entities/characters/bob.yaml", "alice")?; // Err if denied§Thread safety
PermissionGate is immutable after construction and safe to share
across threads (immutable &self check methods).
Implementations§
Source§impl PermissionGate
impl PermissionGate
Sourcepub fn load(workspace_root: &Path) -> Result<Self, NapError>
pub fn load(workspace_root: &Path) -> Result<Self, NapError>
Load the permission gate from context/nap-gate.toml inside the
workspace. If the file does not exist, returns a permissive gate
(default: write access for all principals). Use
PermissionGate::strict to enforce a closed-by-default gate
when no config is present.
Sourcepub fn strict(workspace_root: &Path) -> Self
pub fn strict(workspace_root: &Path) -> Self
Create a strict gate that denies everything by default, even when no config file is present. Useful for agents or untrusted contexts.
Sourcepub fn permissive(workspace_root: &Path) -> Self
pub fn permissive(workspace_root: &Path) -> Self
Create a fully permissive gate (any principal may read/write any path). Useful for local development or trusted automation.
Sourcepub fn from_permissions(
workspace_root: &Path,
permissions: &[Permission],
default: AccessLevel,
) -> Self
pub fn from_permissions( workspace_root: &Path, permissions: &[Permission], default: AccessLevel, ) -> Self
Build a gate from an explicit list of Permission entries.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PermissionGate
impl RefUnwindSafe for PermissionGate
impl Send for PermissionGate
impl Sync for PermissionGate
impl Unpin for PermissionGate
impl UnsafeUnpin for PermissionGate
impl UnwindSafe for PermissionGate
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request