pub struct ModeCatalog { /* private fields */ }Expand description
A set of mutually exclusive permission modes plus the currently selected one. Maps to
ACP’s SessionModeState.
Constructed once by the assembler (CLI) and flows into each session via
crate::session::AgentCore. Each session holds its own copy (current can be
switched independently); set_mode looks up the corresponding policy by id and swaps
it in.
Implementations§
Source§impl ModeCatalog
impl ModeCatalog
Sourcepub fn new(modes: Vec<PolicyMode>, current: impl Into<String>) -> Option<Self>
pub fn new(modes: Vec<PolicyMode>, current: impl Into<String>) -> Option<Self>
Constructs a catalog. current must match one of the ids in modes, otherwise
returns None
(assembly errors should fail loud, not silently fall back). An empty catalog also
returns None.
Sourcepub fn current_id(&self) -> &str
pub fn current_id(&self) -> &str
The ID of the currently selected mode.
Sourcepub fn current_policy(&self) -> Arc<dyn SandboxPolicy> ⓘ
pub fn current_policy(&self) -> Arc<dyn SandboxPolicy> ⓘ
The policy for the currently selected mode.
Sourcepub fn modes(&self) -> &[PolicyMode]
pub fn modes(&self) -> &[PolicyMode]
All available modes, in assembly order.
Sourcepub fn set_current(&mut self, id: &str) -> bool
pub fn set_current(&mut self, id: &str) -> bool
Switch the current mode. Returns false if id does not match any entry, leaving
current unchanged.
Trait Implementations§
Source§impl Clone for ModeCatalog
impl Clone for ModeCatalog
Source§fn clone(&self) -> ModeCatalog
fn clone(&self) -> ModeCatalog
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ModeCatalog
impl !UnwindSafe for ModeCatalog
impl Freeze for ModeCatalog
impl Send for ModeCatalog
impl Sync for ModeCatalog
impl Unpin for ModeCatalog
impl UnsafeUnpin for ModeCatalog
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