#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum SignalHandlerMode {
#[cfg(not(feature = "libc-signal-mode"))]
#[cfg_attr(not(feature = "libc-signal-mode"), default)]
Direct,
#[cfg_attr(feature = "libc-signal-mode", default)]
Libc,
}
impl core::str::FromStr for SignalHandlerMode {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
match s {
#[cfg(not(feature = "libc-signal-mode"))]
"direct" => Ok(Self::Direct),
#[cfg(feature = "libc-signal-mode")]
"direct" => Err(()),
"libc" => Ok(Self::Libc),
_ => Err(()),
}
}
}
impl SignalHandlerMode {
pub fn as_str(self) -> &'static str {
match self {
#[cfg(not(feature = "libc-signal-mode"))]
Self::Direct => "direct",
Self::Libc => "libc",
}
}
}