Skip to main content

SignalManager

Struct SignalManager 

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

Runtime signal manager.

Implementations§

Source§

impl SignalManager

Source

pub fn new() -> SignalManager

Create a new signal manager.

Source

pub fn handle<F>( &self, signal: i32, handler: F, ) -> Result<SignalRegistration, SignalManagerError>
where F: Fn() -> Result<(), Box<dyn Error + Send + Sync>> + Send + Sync + 'static,

Register a handler for a specific signal number.

Returns a registration guard that unregisters on drop.

Source

pub fn on_shutdown<F>(&self, hook: F)
where F: FnOnce() -> Result<(), Box<dyn Error + Send + Sync>> + Send + 'static,

Append a shutdown hook (executed in LIFO order).

Source

pub fn on_reload<F>(&self, hook: F)
where F: Fn() -> Result<(), Box<dyn Error + Send + Sync>> + Send + Sync + 'static,

Append a reload hook (executed in FIFO order).

Source

pub fn enable_double_tap(&self, config: DoubleTapConfig)

Enable SIGINT double-tap behavior.

Source

pub fn disable_double_tap(&self)

Disable SIGINT double-tap behavior.

Source

pub fn set_endpoint_logger<F>(&self, logger: F)
where F: Fn(&SignalEndpointLogEvent) + Send + Sync + 'static,

Install a callback invoked for every processed /admin/signal request.

Source

pub fn clear_endpoint_logger(&self)

Remove the endpoint request logger callback.

Source

pub fn handle_admin_signal_request( &self, request: SignalEndpointRequest, ) -> SignalEndpointResponse

Process a POST /admin/signal request body.

Source

pub fn handle_admin_signal_request_with_metadata( &self, request: SignalEndpointRequest, metadata: SignalEndpointMetadata, ) -> SignalEndpointResponse

Process a POST /admin/signal request body with HTTP-derived metadata.

Source

pub fn supports(&self, signal: i32) -> bool

Check whether a signal is supported on the current platform.

Source

pub fn listen(&self) -> Result<(), SignalManagerError>

Start listening for OS and injected signals.

This call blocks until SignalManager::stop is called or a shutdown signal is processed.

Source

pub fn stop(&self)

Stop the running listener loop.

Trait Implementations§

Source§

impl Clone for SignalManager

Source§

fn clone(&self) -> SignalManager

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for SignalManager

Source§

fn default() -> SignalManager

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.