#[non_exhaustive]pub enum SupervisorEvent {
ChildSpawned {
pid: u32,
},
ChildExited {
status: ExitStatus,
},
ChildRespawned,
ProbeTimeout,
MaxStartReached {
attempts: u32,
},
MaxLifetimeReached,
SignalReceived(SignalKind),
}Expand description
Events emitted by SshSupervisor::run over the consumer’s
mpsc::Sender<SupervisorEvent> (set on the builder via
SshSupervisorBuilder::event_sender).
#[non_exhaustive] per AD-014 — additive variants in later releases are
not a breaking change.
Exhaustive matches without a wildcard arm fail to compile, guarding downstream consumers against future variant additions:
use rusty_autossh::SupervisorEvent;
fn handle(ev: SupervisorEvent) {
// Missing required wildcard `_` arm.
match ev {
SupervisorEvent::ChildSpawned { .. } => {}
SupervisorEvent::ChildExited { .. } => {}
SupervisorEvent::ChildRespawned => {}
SupervisorEvent::ProbeTimeout => {}
SupervisorEvent::MaxStartReached { .. } => {}
SupervisorEvent::MaxLifetimeReached => {}
SupervisorEvent::SignalReceived(_) => {}
}
}§Example — consume events from the supervisor channel
use rusty_autossh::SupervisorEvent;
// Library consumers MUST include a wildcard `_` arm because
// `SupervisorEvent` is `#[non_exhaustive]` (SemVer policy per AD-014).
fn classify(event: &SupervisorEvent) -> &'static str {
match event {
SupervisorEvent::ChildSpawned { .. } => "spawned",
SupervisorEvent::ChildExited { .. } => "exited",
SupervisorEvent::ChildRespawned => "respawned",
SupervisorEvent::ProbeTimeout => "probe-timeout",
SupervisorEvent::MaxStartReached { .. } => "max-start",
SupervisorEvent::MaxLifetimeReached => "max-lifetime",
SupervisorEvent::SignalReceived(_) => "signal",
_ => "unknown",
}
}
let e = SupervisorEvent::ChildSpawned { pid: 4242 };
assert_eq!(classify(&e), "spawned");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ChildSpawned
An ssh child process was successfully spawned. Fires AFTER
Command::spawn returns Ok(Child) (i.e., the child is reapable).
ChildExited
The active ssh child exited and was reaped via child.wait().
Fields
status: ExitStatusExit status observed by child.wait().
ChildRespawned
A replacement ssh child was spawned (kill + respawn cycle).
ProbeTimeout
Probe round-trip timed out on the monitor port.
MaxStartReached
Consecutive-retry counter reached the AUTOSSH_MAXSTART cap.
MaxLifetimeReached
AUTOSSH_MAXLIFETIME elapsed.
SignalReceived(SignalKind)
A signal was received by the supervisor.