pub struct SignalDelivery<R, E: Exfiltrator> { /* private fields */ }
Expand description

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

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.

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.

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

See the get_read method for some additional information.

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.

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.

Get a Handle for this SignalDelivery instance.

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

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.