pub struct SessionManager { /* private fields */ }Expand description
Thread-safe manager for all active shell sessions.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(config: ShellConfig) -> Arc<Self>
pub fn new(config: ShellConfig) -> Arc<Self>
Create a new session manager backed by the given configuration.
Sourcepub async fn create_session(
&self,
opts: SessionOpts,
tx_delta: Option<&UnboundedSender<String>>,
) -> Result<(String, String, String)>
pub async fn create_session( &self, opts: SessionOpts, tx_delta: Option<&UnboundedSender<String>>, ) -> Result<(String, String, String)>
Create a new interactive shell session.
Returns (session_id, initial_output, status) on success.
Sourcepub async fn send_input(
&self,
id: &str,
input: &str,
timeout_ms: Option<u64>,
tx_delta: Option<&UnboundedSender<String>>,
) -> Result<SendResult>
pub async fn send_input( &self, id: &str, input: &str, timeout_ms: Option<u64>, tx_delta: Option<&UnboundedSender<String>>, ) -> Result<SendResult>
Send input to an active session and return the output produced.
Sourcepub async fn close_session(&self, id: &str) -> Result<String>
pub async fn close_session(&self, id: &str) -> Result<String>
Close a session, returning any final output.
Idempotent — closing a non-existent session returns Ok("").
Sourcepub fn reap_idle(&self) -> Vec<String>
pub fn reap_idle(&self) -> Vec<String>
Reap sessions that have been idle beyond their timeout.
Returns the IDs of sessions that were removed.
Sourcepub fn shutdown_all(&self)
pub fn shutdown_all(&self)
Shutdown all sessions immediately.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of sessions currently in the map.
Sourcepub fn list_sessions(&self) -> Vec<ShellSessionInfo>
pub fn list_sessions(&self) -> Vec<ShellSessionInfo>
Snapshot of all sessions.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SessionManager
impl RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
impl UnwindSafe for SessionManager
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.