Struct SubprocChain

Source
pub struct SubprocChain { /* private fields */ }
Expand description

An event source that processes a sequence of commands.

Exactly one event will ever be generated, and it will be either at the successful completion of all the commands OR at the first failed subprocess. If an optional cleanup command is provided, that will be run before the event is generated, but only in the event of a failure.

Note that to avoid leaking file descriptors (or the memory associated with the event source itself), you must either honour the calloop::PostAction returned from process_events() yourself, or use this with TransientSource in calloop.

Implementations§

Source§

impl SubprocChain

Source

pub fn new<T>(commands: T, cleanup: Option<Command>) -> Result<Self>
where T: IntoIterator<Item = Command>,

Create a new subprocess event source from a sequence of commands and, optionally, a cleanup command to run in case of failure.

Trait Implementations§

Source§

impl EventSource for SubprocChain

Source§

fn process_events<F>( &mut self, readiness: Readiness, token: Token, callback: F, ) -> Result<PostAction, Self::Error>
where F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,

This event source is designed to fire exactly once, and the callback will receive the result. See the SubprocChain docs for more detail.

Even though the callback will only be called once, the API for calloop::EventSource requires it to be a FnMut. This can be worked around by wrapping a FnOnce in an Option type if necessary.

Source§

type Event = Result<(), ErrorEvent>

The type of events generated by your source.
Source§

type Metadata = ()

Some metadata of your event source Read more
Source§

type Ret = ()

The return type of the user callback Read more
Source§

type Error = LaunchError

The error type returned from process_events() (not the user callback!).
Source§

fn register( &mut self, poll: &mut Poll, token_factory: &mut TokenFactory, ) -> Result<()>

Register yourself to this poll instance Read more
Source§

fn reregister( &mut self, poll: &mut Poll, token_factory: &mut TokenFactory, ) -> Result<()>

Re-register your file descriptors Read more
Source§

fn unregister(&mut self, poll: &mut Poll) -> Result<()>

Unregister your file descriptors Read more
Source§

fn pre_run<F>(&mut self, _callback: F) -> Result<(), Error>
where F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,

Notification that a polling session is going to start Read more
Source§

fn post_run<F>(&mut self, _callback: F) -> Result<(), Error>
where F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,

Notification that the current polling session ended 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> 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, 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.
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