pub struct SessionManager { /* private fields */ }Expand description
Session manager
Implementations§
Source§impl SessionManager
impl SessionManager
pub fn new() -> Self
Sourcepub fn spawn(
&self,
command: &str,
args: &[String],
cwd: Option<&str>,
env: Option<&HashMap<String, String>>,
session_id: Option<String>,
cols: u16,
rows: u16,
) -> Result<(SessionId, u32), SessionError>
pub fn spawn( &self, command: &str, args: &[String], cwd: Option<&str>, env: Option<&HashMap<String, String>>, session_id: Option<String>, cols: u16, rows: u16, ) -> Result<(SessionId, u32), SessionError>
Spawn a new session
Sourcepub fn get(&self, session_id: &str) -> Result<Arc<Mutex<Session>>, SessionError>
pub fn get(&self, session_id: &str) -> Result<Arc<Mutex<Session>>, SessionError>
Get a session by ID
Sourcepub fn resolve(
&self,
session_id: Option<&str>,
) -> Result<Arc<Mutex<Session>>, SessionError>
pub fn resolve( &self, session_id: Option<&str>, ) -> Result<Arc<Mutex<Session>>, SessionError>
Get session, using provided ID or falling back to active session
Sourcepub fn set_active(&self, session_id: &str) -> Result<(), SessionError>
pub fn set_active(&self, session_id: &str) -> Result<(), SessionError>
Set active session
Sourcepub fn list(&self) -> Vec<SessionInfo>
pub fn list(&self) -> Vec<SessionInfo>
List all sessions Note: Uses try_lock to avoid blocking; sessions that can’t be locked are reported with status “busy” via the running field.
Sourcepub fn kill(&self, session_id: &str) -> Result<(), SessionError>
pub fn kill(&self, session_id: &str) -> Result<(), SessionError>
Kill a session
Lock ordering: sessions.write() -> active_session.write() -> session.lock() This order prevents deadlock with list() which acquires sessions.read() first.
Sourcepub fn get_persisted_sessions(&self) -> Vec<PersistedSession>
pub fn get_persisted_sessions(&self) -> Vec<PersistedSession>
Get persisted sessions from previous daemon runs
Sourcepub fn cleanup_persisted(&self) -> Result<usize>
pub fn cleanup_persisted(&self) -> Result<usize>
Clean up stale persisted sessions
Sourcepub fn session_count(&self) -> usize
pub fn session_count(&self) -> usize
Get session count
Sourcepub fn active_session_id(&self) -> Option<SessionId>
pub fn active_session_id(&self) -> Option<SessionId>
Get active session ID
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.