Skip to main content

SupervisorEvent

Enum SupervisorEvent 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

ChildSpawned

An ssh child process was successfully spawned. Fires AFTER Command::spawn returns Ok(Child) (i.e., the child is reapable).

Fields

§pid: u32

OS-assigned process id.

§

ChildExited

The active ssh child exited and was reaped via child.wait().

Fields

§status: ExitStatus

Exit 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.

Fields

§attempts: u32

Number of consecutive spawn attempts before the cap was hit.

§

MaxLifetimeReached

AUTOSSH_MAXLIFETIME elapsed.

§

SignalReceived(SignalKind)

A signal was received by the supervisor.

Trait Implementations§

Source§

impl Debug for SupervisorEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.