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§
Sourcefn 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 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.
Sourcefn get(&self, session_id: &str) -> Result<Arc<Mutex<Session>>, SessionError>
fn get(&self, session_id: &str) -> Result<Arc<Mutex<Session>>, SessionError>
Get a session by ID.
Sourcefn resolve(
&self,
session_id: Option<&str>,
) -> Result<Arc<Mutex<Session>>, SessionError>
fn resolve( &self, session_id: Option<&str>, ) -> Result<Arc<Mutex<Session>>, SessionError>
Resolve a session by ID, falling back to active session if None.
Sourcefn set_active(&self, session_id: &str) -> Result<(), SessionError>
fn set_active(&self, session_id: &str) -> Result<(), SessionError>
Set the active session.
Sourcefn list(&self) -> Vec<SessionInfo>
fn list(&self) -> Vec<SessionInfo>
List all sessions.
Sourcefn session_count(&self) -> usize
fn session_count(&self) -> usize
Get the count of sessions.
Sourcefn active_session_id(&self) -> Option<SessionId>
fn active_session_id(&self) -> Option<SessionId>
Get the active session ID.