Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrysoliteAzalea committed Jul 22, 2024
1 parent aa2b84c commit 0c99d0a
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ pub enum SignalValue {

// Support for real-time signals
/// Operating system signal value
#[cfg(any(not(target_os = "linux"), all(target_os = "linux", target_arch = "mips")))]
#[cfg(any(
not(target_os = "linux"),
all(target_os = "linux", target_arch = "mips")
))]
#[cfg(any(feature = "signal", feature = "aio"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum SignalValue {
Expand All @@ -401,7 +404,10 @@ impl SignalValue {
}
}

#[cfg(any(not(target_os = "linux"), all(target_os = "linux", target_arch = "mips")))]
#[cfg(any(
not(target_os = "linux"),
all(target_os = "linux", target_arch = "mips")
))]
#[allow(dead_code)]
unsafe fn convert_to_int_unchecked(self) -> libc::c_int {
// Note: dead code is allowed, since this is a private method that can remain unused on some platforms
Expand All @@ -422,7 +428,10 @@ impl SignalValue {
}

/// Check whether this enum contains a valid signal for this operating system
#[cfg(any(not(target_os = "linux"), all(target_os = "linux", target_arch = "mips")))]
#[cfg(any(
not(target_os = "linux"),
all(target_os = "linux", target_arch = "mips")
))]
pub fn is_valid(&self) -> bool {
match self {
SignalValue::Standard(_) => true,
Expand All @@ -442,7 +451,10 @@ impl From<SignalValue> for String {
}
}

#[cfg(any(not(target_os = "linux"), all(target_os = "linux", target_arch = "mips")))]
#[cfg(any(
not(target_os = "linux"),
all(target_os = "linux", target_arch = "mips")
))]
fn from(x: SignalValue) -> Self {
match x {
SignalValue::Standard(s) => s.to_string(),
Expand All @@ -454,7 +466,7 @@ impl From<SignalValue> for String {
impl TryFrom<i32> for SignalValue {
type Error = Errno;

#[cfg(all(target_os = "linux", not(target_arch = "mips")))]
#[cfg(all(target_os = "linux", not(target_arch = "mips")))]
fn try_from(x: i32) -> Result<Self> {
if x < libc::SIGRTMIN() {
match Signal::try_from(x) {
Expand All @@ -466,7 +478,10 @@ impl TryFrom<i32> for SignalValue {
}
}

#[cfg(any(not(target_os = "linux"), all(target_os = "linux", target_arch = "mips")))]
#[cfg(any(
not(target_os = "linux"),
all(target_os = "linux", target_arch = "mips")
))]
fn try_from(x: i32) -> Result<Self> {
match Signal::try_from(x) {
Ok(s) => Ok(SignalValue::Standard(s)),
Expand All @@ -479,7 +494,7 @@ impl TryFrom<i32> for SignalValue {
impl TryFrom<SignalValue> for i32 {
type Error = Errno;

#[cfg(all(target_os = "linux", not(target_arch = "mips")))]
#[cfg(all(target_os = "linux", not(target_arch = "mips")))]
fn try_from(x: SignalValue) -> Result<Self> {
match x {
SignalValue::Standard(s) => Ok(s as i32),
Expand All @@ -494,7 +509,10 @@ impl TryFrom<SignalValue> for i32 {
}
}

#[cfg(any(not(target_os = "linux"), all(target_os = "linux", target_arch = "mips")))]
#[cfg(any(
not(target_os = "linux"),
all(target_os = "linux", target_arch = "mips")
))]
fn try_from(x: SignalValue) -> Result<Self> {
match x {
SignalValue::Standard(s) => Ok(s as i32),
Expand All @@ -513,15 +531,18 @@ impl From<Signal> for SignalValue {
impl TryFrom<SignalValue> for Signal {
type Error = Errno;

#[cfg(all(target_os = "linux", not(target_arch = "mips")))]
#[cfg(all(target_os = "linux", not(target_arch = "mips")))]
fn try_from(x: SignalValue) -> Result<Self> {
match x {
SignalValue::Standard(s) => Ok(s),
SignalValue::Realtime(_) => Err(Errno::EINVAL),
}
}

#[cfg(any(not(target_os = "linux"), all(target_os = "linux", target_arch = "mips")))]
#[cfg(any(
not(target_os = "linux"),
all(target_os = "linux", target_arch = "mips")
))]
fn try_from(x: SignalValue) -> Result<Self> {
match x {
SignalValue::Standard(s) => Ok(s),
Expand Down

0 comments on commit 0c99d0a

Please sign in to comment.