pub struct Session {
pub terminal: Terminal,
scrollback: Mutex<VecDeque<ScrollbackEvent>>,
scrollback_bytes: Mutex<usize>,
scrollback_limit: usize,
clients: AtomicUsize,
detached_at: Mutex<Option<Instant>>,
window_size: Sender<(u16, u16)>,
}Expand description
A persistent terminal session.
Tracks connected clients, buffers recent output for replay on reconnect, and detects when the session becomes orphaned.
Fields§
§terminal: Terminal§scrollback: Mutex<VecDeque<ScrollbackEvent>>§scrollback_bytes: Mutex<usize>§scrollback_limit: usize§clients: AtomicUsize§detached_at: Mutex<Option<Instant>>§window_size: Sender<(u16, u16)>Implementations§
Source§impl Session
impl Session
Sourcepub fn new(
terminal: Terminal,
output_rx: Receiver<Vec<u8>>,
scrollback_limit: usize,
) -> Arc<Self>
pub fn new( terminal: Terminal, output_rx: Receiver<Vec<u8>>, scrollback_limit: usize, ) -> Arc<Self>
Create a new session and spawn a background scrollback collector task.
Sourcefn push_scrollback(&self, event: ScrollbackEvent)
fn push_scrollback(&self, event: ScrollbackEvent)
Push an event into the scrollback ring buffer, evicting old events when the byte budget is exceeded.
Sourcepub fn attach(
&self,
) -> (Vec<ScrollbackEvent>, Receiver<Vec<u8>>, Receiver<(u16, u16)>)
pub fn attach( &self, ) -> (Vec<ScrollbackEvent>, Receiver<Vec<u8>>, Receiver<(u16, u16)>)
Attach a client: increment the counter, subscribe to live output, and return the scrollback event log. The subscription and snapshot are taken under the same lock so no output is lost.
Sourcepub fn set_window_size(&self, rows: u16, cols: u16)
pub fn set_window_size(&self, rows: u16, cols: u16)
Update the current PTY window size (broadcast to viewers) and record the resize in the scrollback log so replay clients see it too.
fn is_orphaned(&self) -> bool
Auto Trait Implementations§
impl !Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl !UnwindSafe for Session
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