Skip to main content

ExecResult

Struct ExecResult 

Source
pub struct ExecResult {
    pub exec_id: String,
    pub phase: Phase,
    pub outcome: Option<Outcome>,
    pub client_deadline: Option<ClientDeadline>,
}
Expand description

An exec’s phase and, once it has one, its outcome.

A thin wrapper over the daemon’s protocol::exec::PollResponse rather than a re-modelling of it, so the two cannot disagree. What it adds is ExecResult::done, which is the question every caller actually asks.

Fields§

§exec_id: String§phase: Phase§outcome: Option<Outcome>

None while running. Present once the child has exited.

§client_deadline: Option<ClientDeadline>

What the client did when its own deadline expired, for a result super::complete::CompletionPlan::drive returned after one (BIND-9, BIND-10). None for every other result: a poll, a wait, an ack, and a run that finished in time.

Implementations§

Source§

impl ExecResult

Source

pub fn done(&self) -> bool

Whether the exec has finished, whichever way.

Source

pub fn exit_code(&self) -> Option<i32>

The exit code, when the child exited with one rather than dying to a signal.

Source

pub fn succeeded(&self) -> bool

Whether the command succeeded. false for a signal death and for a still-running exec, since neither is a success.

Source

pub fn stdout(&self) -> &str

Source

pub fn stderr(&self) -> &str

Source

pub fn posix_exit_code(&self) -> Option<i32>

The exit code a POSIX shell would report for this exec (BIND-6).

  • 124 when a deadline ended the command: the daemon’s own (timed_out), the client’s kill of a live process group after its deadline, or a result synthesized because nothing came back after that kill. 124 is GNU timeout(1)’s code, which is what harnesses built on docker exec and friends already report.
  • 128 + signal for any other signal death, the shell’s convention: an out-of-memory kill (SIGKILL, 137) is not a timeout.
  • The exit code otherwise.

timed_out wins over an exit code on purpose. A child that traps SIGTERM and exits 0 after the deadline fired has an exit code, and reporting it would call a timed-out command a success while Self::succeeded says it failed. crates/model/src/run.rs checks this rule and finds that case against the “exit code first” alternative.

None only when there is nothing to report: a running exec with no client deadline.

Source

pub fn deadline_ended(&self) -> bool

Whether a deadline ended the command, which is when Self::posix_exit_code is 124 (BIND-6): the daemon’s own (timed_out), the client’s kill of a live process group after its deadline, or a result synthesized because nothing came back after that kill.

A kill that found the group already gone doesn’t count: the command ended by itself, and its own exit status is the answer.

Source

pub fn notes(&self) -> Vec<String>

Human-readable annotations on how to read this result, one per condition (BIND-7).

For a caller that appends them to stderr without knowing the field names: truncated output, an expired daemon deadline, writers left alive past the linger deadline, and the client deadline (a kill, or a synthesized result). Empty for a clean result.

Source

pub fn synthesized(&self) -> bool

Whether this result was synthesized after the client deadline (BIND-10).

Trait Implementations§

Source§

impl Debug for ExecResult

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<PollResponse> for ExecResult

Source§

fn from(response: PollResponse) -> ExecResult

Converts to this type from the input type.

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more