SessionRepository

Trait SessionRepository 

Source
pub trait SessionRepository: Send + Sync {
    // Required methods
    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>;
    fn get(&self, session_id: &str) -> Result<Arc<Mutex<Session>>, SessionError>;
    fn active(&self) -> Result<Arc<Mutex<Session>>, SessionError>;
    fn resolve(
        &self,
        session_id: Option<&str>,
    ) -> Result<Arc<Mutex<Session>>, SessionError>;
    fn set_active(&self, session_id: &str) -> Result<(), SessionError>;
    fn list(&self) -> Vec<SessionInfo>;
    fn kill(&self, session_id: &str) -> Result<(), SessionError>;
    fn session_count(&self) -> usize;
    fn active_session_id(&self) -> Option<SessionId>;
}
Expand description

Repository trait for session access and management.

This trait abstracts the session storage and retrieval operations, enabling use cases to be testable without a real SessionManager.

Required Methods§

Source

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 with the given parameters.

Source

fn get(&self, session_id: &str) -> Result<Arc<Mutex<Session>>, SessionError>

Get a session by ID.

Source

fn active(&self) -> Result<Arc<Mutex<Session>>, SessionError>

Get the active session.

Source

fn resolve( &self, session_id: Option<&str>, ) -> Result<Arc<Mutex<Session>>, SessionError>

Resolve a session by ID, falling back to active session if None.

Source

fn set_active(&self, session_id: &str) -> Result<(), SessionError>

Set the active session.

Source

fn list(&self) -> Vec<SessionInfo>

List all sessions.

Source

fn kill(&self, session_id: &str) -> Result<(), SessionError>

Kill a session by ID.

Source

fn session_count(&self) -> usize

Get the count of sessions.

Source

fn active_session_id(&self) -> Option<SessionId>

Get the active session ID.

Implementors§