pub struct SessionModes { /* private fields */ }Expand description
One session’s mode, and what the client has already answered under it.
Cloneable and shared: the dispatch loop sets it while a spawned turn reads
it. The lock is sync and never held across an await, for the same reason
the cancellation token’s is — session/set_mode arrives during a turn,
and ACP says explicitly that it may.
Implementations§
Source§impl SessionModes
impl SessionModes
Sourcepub fn new(initial: ApprovalMode) -> Self
pub fn new(initial: ApprovalMode) -> Self
Opens a session at initial.
A session that starts at ApprovalMode::Never offers no other mode.
The other two both permit consequential work and differ only in
ceremony, so moving between them is the person at the client changing
their mind — the same authority they already exercise by answering a
permission request. Never is a prohibition the operator set outside
the protocol, and a client cannot lift what it was never given.
pub fn current(&self) -> ApprovalMode
Sourcepub fn state(&self) -> SessionModeState
pub fn state(&self) -> SessionModeState
The modes and the current one, as session/new and session/load
report them.
Sourcepub fn set(&self, id: &SessionModeId) -> Result<ApprovalMode, ModeError>
pub fn set(&self, id: &SessionModeId) -> Result<ApprovalMode, ModeError>
Switches to id, returning the mode now in force.
Every “…for this session” answer is forgotten: choosing a mode is a statement about how the rest of the session should behave, and a stale allow that outlived it would be exactly the override this design exists to prevent.
Trait Implementations§
Source§impl Clone for SessionModes
impl Clone for SessionModes
Source§fn clone(&self) -> SessionModes
fn clone(&self) -> SessionModes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more