pub enum SessionState {
Created,
Active,
Idle,
Terminated,
}Expand description
Represents the lifecycle state of a shell session.
Variants§
Created
Session has been created but not yet activated.
Active
Session is actively processing commands.
Idle
Session is idle, waiting for commands.
Terminated
Session has been terminated and cannot be reused.
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn can_transition_to(&self, target: SessionState) -> bool
pub fn can_transition_to(&self, target: SessionState) -> bool
Check if transition to target state is valid.
Valid transitions:
- Created -> Active
- Created -> Idle (session created and immediately ready for commands)
- Active -> Idle
- Active -> Terminated
- Idle -> Active
- Idle -> Terminated
Note: Created -> Idle exists because a freshly created session holds no
persistent PTY (each command spawns its own), so it is ready to accept
commands the moment it is created. This keeps the create→execute flow
working out-of-the-box without the consumer having to drive an explicit
activation step (thin-API principle).
Sourcepub fn transition_to(&mut self, target: SessionState) -> Result<()>
pub fn transition_to(&mut self, target: SessionState) -> Result<()>
Attempt to transition to a new state.
Returns Ok(()) if the transition is valid, or an error otherwise.
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if this is a terminal state (no further transitions possible).
Sourcepub fn can_execute(&self) -> bool
pub fn can_execute(&self) -> bool
Check if session can accept commands.
Trait Implementations§
Source§impl Clone for SessionState
impl Clone for SessionState
Source§fn clone(&self) -> SessionState
fn clone(&self) -> SessionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more