pub struct SessionState { /* private fields */ }Expand description
One session: a set of attachments fanned the same output, with serialized input and per-driver authority.
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn new(id: SessionId, ring_cap: usize) -> Self
pub fn new(id: SessionId, ring_cap: usize) -> Self
ring_cap bounds the per-session resume buffer (recent chunks replayed to
an attachment that reconnects — §6.3). Clamped to at least 1.
pub fn id(&self) -> SessionId
Sourcepub fn attach(
&mut self,
role: AttachRole,
caveats: Caveats,
sink: Box<dyn OutputSink>,
) -> AttachId
pub fn attach( &mut self, role: AttachRole, caveats: Caveats, sink: Box<dyn OutputSink>, ) -> AttachId
Attach a console/peer/observer; returns its handle. The caller supplies the
attachment’s caveats — for a Driver, its worker-delegated down-set; for
an Observer, an attenuated read-only set (though the role, not the
caveats, is what structurally prevents an observer from mutating).
Sourcepub fn detach(&mut self, id: AttachId) -> bool
pub fn detach(&mut self, id: AttachId) -> bool
Detach an attachment; future output no longer fans out to it. Returns whether it was present.
pub fn attachment_count(&self) -> usize
pub fn driver_count(&self) -> usize
pub fn turn_in_flight(&self) -> bool
Sourcepub fn effective_caveats(&self) -> Option<&Caveats>
pub fn effective_caveats(&self) -> Option<&Caveats>
The caveats governing the in-flight turn (the active driver’s), or None
when idle. A turn never runs under more authority than the driver that
submitted it.
Sourcepub fn submit_input(
&mut self,
from: AttachId,
text: impl Into<String>,
) -> Result<AcceptedTurn, InputRefused>
pub fn submit_input( &mut self, from: AttachId, text: impl Into<String>, ) -> Result<AcceptedTurn, InputRefused>
Submit a human/peer input. Enforces the two structural invariants: driver-only, and one turn at a time. On accept, opens a new turn and returns it (with the active driver’s caveats) for the harness to run.
Sourcepub fn emit(
&mut self,
stream: OutputStream,
data: impl Into<String>,
last: bool,
)
pub fn emit( &mut self, stream: OutputStream, data: impl Into<String>, last: bool, )
Emit one output chunk for the in-flight turn: buffer it (bounded by
ring_cap) and fan it out to every attachment. No-op if idle.
Sourcepub fn complete_turn(&mut self) -> bool
pub fn complete_turn(&mut self) -> bool
End the in-flight turn (success). Returns whether one was in flight.
Sourcepub fn cancel_turn(&mut self) -> bool
pub fn cancel_turn(&mut self) -> bool
Cancel the in-flight turn (a ControlC from any attachment). Returns
whether one was in flight.
Sourcepub fn replay_from(&self, from_seq: u64) -> Vec<OutputChunk>
pub fn replay_from(&self, from_seq: u64) -> Vec<OutputChunk>
Replay buffered chunks with seq >= from_seq to a reconnecting attachment
(§6.3 resume). Bounded by ring_cap, so a long-gone attachment may miss
the head — it gets the retained tail.
Auto Trait Implementations§
impl !RefUnwindSafe for SessionState
impl !Sync for SessionState
impl !UnwindSafe for SessionState
impl Freeze for SessionState
impl Send for SessionState
impl Unpin for SessionState
impl UnsafeUnpin for SessionState
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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