Struct signal_hook::iterator::backend::SignalDelivery[][src]

pub struct SignalDelivery<R, E: Exfiltrator> { /* fields omitted */ }
This is supported on non-Windows and crate feature iterator only.

A struct for delivering received signals to the main program flow. The self-pipe IO type is generic. See the with_pipe method for requirements for the IO type.

Implementations

impl<R, E: Exfiltrator> SignalDelivery<R, E> where
    R: 'static + AsRawFd + Send + Sync
[src]

pub fn with_pipe<I, S, W>(
    read: R,
    write: W,
    exfiltrator: E,
    signals: I
) -> Result<Self, Error> where
    I: IntoIterator<Item = S>,
    S: Borrow<c_int>,
    W: 'static + AsRawFd + Debug + Send + Sync
[src]

Creates the SignalDelivery structure.

The read and write arguments must be the ends of a suitable pipe type. These are used for communication between the signal handler and main program flow.

Registers all the signals listed. The same restrictions (panics, errors) apply as with add_signal.

Requirements for the pipe type

  • Must support send for asynchronously writing bytes to the write end
  • Must support recv for reading bytes from the read end

So UnixStream is a good choice for this.

pub fn get_read(&self) -> &R[src]

Get a reference to the read end of the self pipe

You may use this method to register the underlying file descriptor with an eventing system (e. g. epoll) to get notified if there are bytes in the pipe. If the event system reports the file descriptor ready for reading you can then call pending to get the arrived signals.

pub fn get_read_mut(&mut self) -> &mut R[src]

Get a mutable reference to the read end of the self pipe

See the get_read method for some additional information.

pub fn pending(&mut self) -> Pending<E>

Notable traits for Pending<E>

impl<E: Exfiltrator> Iterator for Pending<E> type Item = E::Output;
[src]

Returns an iterator of already received signals.

This returns an iterator over all the signal numbers of the signals received since last time they were read (out of the set registered by this SignalDelivery instance). Note that they are returned in arbitrary order and a signal number is returned only once even if it was received multiple times.

This method returns immediately (does not block) and may produce an empty iterator if there are no signals ready.

pub fn poll_pending<F>(
    &mut self,
    has_signals: &mut F
) -> Result<Option<Pending<E>>, Error> where
    F: FnMut(&mut R) -> Result<bool, Error>, 
[src]

Checks the reading end of the self pipe for available signals.

If there are no signals available or this instance was already closed it returns Option::None. If there are some signals it returns a Pending instance wrapped inside a Option::Some. However, due to implementation details, this still can produce an empty iterator.

This method doesn't check the reading end by itself but uses the passed in callback. This method blocks if and only if the callback blocks trying to read some bytes.

pub fn handle(&self) -> Handle[src]

Get a Handle for this SignalDelivery instance.

This can be used to add further signals or close the whole signal delivery mechanism.

Trait Implementations

impl<R: Debug, E: Debug + Exfiltrator> Debug for SignalDelivery<R, E>[src]

Auto Trait Implementations

impl<R, E> !RefUnwindSafe for SignalDelivery<R, E>[src]

impl<R, E> Send for SignalDelivery<R, E> where
    R: Send
[src]

impl<R, E> Sync for SignalDelivery<R, E> where
    R: Sync
[src]

impl<R, E> Unpin for SignalDelivery<R, E> where
    R: Unpin
[src]

impl<R, E> !UnwindSafe for SignalDelivery<R, E>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.