signal_hook::iterator::backend

Struct SignalIterator

Source
pub struct SignalIterator<SD, E: Exfiltrator> { /* private fields */ }
Expand description

An infinite iterator of received signals.

Implementations§

Source§

impl<SD, E: Exfiltrator> SignalIterator<SD, E>

Source

pub fn new<R>(signals: SD) -> Self
where SD: BorrowMut<SignalDelivery<R, E>>, R: 'static + AsRawFd + Send + Sync,

Create a new infinite iterator for signals registered with the passed in SignalDelivery instance.

Source

pub fn poll_signal<R, F>( &mut self, has_signals: &mut F, ) -> PollResult<E::Output>
where SD: BorrowMut<SignalDelivery<R, E>>, R: 'static + AsRawFd + Send + Sync, F: FnMut(&mut R) -> Result<bool, Error>,

Return a signal if there is one or tell the caller that there is none at the moment.

You have to pass in a callback which checks the underlying reading end of the pipe if there may be any pending signals. This callback may or may not block. If the callback returns true this method will try to fetch the next signal and return it as a PollResult::Signal. If the callback returns false the method will return PollResult::Pending and assume it will be called again at a later point in time. The callback may be called any number of times by this function.

If the iterator was closed by the close method of the associated Handle this method will return PollResult::Closed.

Source

pub fn handle<R>(&self) -> Handle
where SD: Borrow<SignalDelivery<R, E>>, R: 'static + AsRawFd + Send + Sync,

Get a shareable Handle for this instance.

This can be used to add further signals or terminate the whole signal iteration using the close method.

Auto Trait Implementations§

§

impl<SD, E> Freeze for SignalIterator<SD, E>
where SD: Freeze,

§

impl<SD, E> RefUnwindSafe for SignalIterator<SD, E>
where SD: RefUnwindSafe, E: RefUnwindSafe, <E as Exfiltrator>::Storage: RefUnwindSafe,

§

impl<SD, E> Send for SignalIterator<SD, E>
where SD: Send,

§

impl<SD, E> Sync for SignalIterator<SD, E>
where SD: Sync,

§

impl<SD, E> Unpin for SignalIterator<SD, E>
where SD: Unpin,

§

impl<SD, E> UnwindSafe for SignalIterator<SD, E>
where SD: UnwindSafe, E: RefUnwindSafe, <E as Exfiltrator>::Storage: RefUnwindSafe,

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.