pub struct RunspacePoolStateMachine { /* private fields */ }Expand description
Pure state machine for the runspace pool lifecycle.
The driver calls open once to start the handshake, then
feeds every server-originated message through
on_message. The machine produces a list of
Actions to execute and transitions its internal state accordingly.
Implementations§
Source§impl RunspacePoolStateMachine
impl RunspacePoolStateMachine
Sourcepub fn new(rpid: Uuid, min_runspaces: i32, max_runspaces: i32) -> Result<Self>
pub fn new(rpid: Uuid, min_runspaces: i32, max_runspaces: i32) -> Result<Self>
Build a new machine. rpid should typically be a freshly-generated v4 UUID.
Sourcepub fn state(&self) -> RunspacePoolState
pub fn state(&self) -> RunspacePoolState
Current lifecycle state.
Sourcepub fn min_runspaces(&self) -> i32
pub fn min_runspaces(&self) -> i32
Configured minimum runspaces.
Sourcepub fn max_runspaces(&self) -> i32
pub fn max_runspaces(&self) -> i32
Configured maximum runspaces.
Sourcepub fn open(&mut self) -> Vec<Action>
pub fn open(&mut self) -> Vec<Action>
Produce the actions required to start the opening handshake.
Transitions the state from BeforeOpen to NegotiationSent.
Sourcepub fn connect(&mut self) -> Vec<Action>
pub fn connect(&mut self) -> Vec<Action>
Produce the actions required to reconnect to a previously disconnected runspace pool.
PSRP §3.1.4.1 — the client sends a ConnectRunspacePool (0x0002_100B)
message and the server responds with the current pool state. We
re-emit the SessionCapability first to renegotiate protocol
versions.
Sourcepub fn on_message(&mut self, msg: &PsrpMessage) -> Result<()>
pub fn on_message(&mut self, msg: &PsrpMessage) -> Result<()>
Feed a server-originated message into the machine.
Returns Ok(()) on a valid transition. Unknown message types are
silently ignored. A RunspacePoolState=Broken/Closed received
during the opening handshake is reported as a protocol error.
Sourcepub fn is_opened(&self) -> bool
pub fn is_opened(&self) -> bool
True once the machine has reached RunspacePoolState::Opened.
Sourcepub fn mark_closed(&mut self)
pub fn mark_closed(&mut self)
Mark the machine as fully closed (after the transport has torn down).