Skip to main content

Signal

Enum Signal 

Source
#[non_exhaustive]
pub enum Signal { Terminate, Interrupt, Quit, Hangup, Pipe, User1, User2, }
Expand description

A platform-neutral signal identifier.

Variants map to their nearest platform equivalent. On Unix the mapping is direct (SIGTERM, SIGINT, etc.). On Windows the mapping is to Windows console control events:

VariantUnixWindows
TerminateSIGTERMCTRL_CLOSE_EVENT
InterruptSIGINTCTRL_C_EVENT
QuitSIGQUITCTRL_BREAK_EVENT
HangupSIGHUPCTRL_SHUTDOWN_EVENT
PipeSIGPIPEinert
User1SIGUSR1inert
User2SIGUSR2inert

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Terminate

SIGTERM on Unix, CTRL_CLOSE_EVENT on Windows.

§

Interrupt

SIGINT (Ctrl+C) on Unix, CTRL_C_EVENT on Windows.

§

Quit

SIGQUIT on Unix, CTRL_BREAK_EVENT on Windows.

§

Hangup

SIGHUP on Unix, CTRL_SHUTDOWN_EVENT on Windows.

§

Pipe

SIGPIPE (Unix only; inert on Windows).

§

User1

SIGUSR1 (Unix only; inert on Windows).

§

User2

SIGUSR2 (Unix only; inert on Windows).

Implementations§

Source§

impl Signal

Source

pub const ALL: [Self; 7]

All defined variants, in canonical order.

Source

pub const fn description(self) -> &'static str

Human-readable description used by Display and logging.

Source

pub const fn unix_number(self) -> Option<i32>

Unix signal number for this variant. Returns None for variants that have no canonical Unix number (none currently, but the API reserves the right to add Windows-only variants).

Source

pub const fn is_unix_only(self) -> bool

Returns true for variants that have no Windows analog.

Source

pub const fn available_on_current_platform(self) -> bool

Returns true if installing a handler for this signal is expected to succeed on the platform this binary is running on.

Trait Implementations§

Source§

impl Clone for Signal

Source§

fn clone(&self) -> Signal

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 Debug for Signal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Signal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Signal

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Signal

Source§

fn eq(&self, other: &Signal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Signal

Source§

impl Eq for Signal

Source§

impl StructuralPartialEq for Signal

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.