Struct SubprocListen

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

An event source that runs a subprocess and generates events for lines of output.

This event source will run a command as a subprocess, generate ListenEvent::Line events for every line it prints to stdout, and one final ListenEvent::End event when it ends.

Processes that run indefinitely can be killed (using SIGKILL ie. 9 on Linux) by returning true from the callback provided to process_events() or by calling the kill() method. Note that there may be more Line events generated after this, depending on the order in which the kill request and remaining output are processed.

After the subprocess has been ended and the final End event has been delivered, this event source should be removed from the event loop.

Implementations§

Source§

impl SubprocListen

Source

pub fn new(command: Command) -> Result<Self>

Takes a command and schedules a subprocess to be run asychronously.

See the note on the root module regarding the trait bounds if they’re confusing.

Source

pub fn kill(&mut self)

Trait Implementations§

Source§

impl EventSource for SubprocListen

Source§

type Event = ListenEvent

The type of events generated by your source.
Source§

type Metadata = ()

Some metadata of your event source Read more
Source§

type Ret = bool

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 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,

Process any relevant events Read more
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