Skip to content

Commit

Permalink
Merge pull request #1457 from GuillaumeGomez/deserialize
Browse files Browse the repository at this point in the history
Implement `Deserialize` on `DiskKind`, `MacAddr`, `IpNetwork`, `Signal`, `ProcessStatus` and `ThreadKind`
  • Loading branch information
GuillaumeGomez authored Jan 16, 2025
2 parents 58ddac0 + ad02d02 commit 8a7dc24
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ rustdoc-args = ["--generate-link-to-definition"]
[dependencies]
memchr = { version = "2.5", optional = true }
rayon = { version = "^1.8", optional = true }
serde = { version = "^1.0.190", optional = true }
serde = { version = "^1.0.190", optional = true, features = ["derive"] }

[target.'cfg(windows)'.dependencies]
ntapi = { version = "0.4", optional = true }
Expand Down
1 change: 1 addition & 0 deletions src/common/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ impl std::ops::DerefMut for Disks {
/// }
/// ```
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub enum DiskKind {
/// HDD type.
HDD,
Expand Down
2 changes: 2 additions & 0 deletions src/common/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ impl NetworkData {
///
/// It is returned by [`NetworkData::mac_address`][crate::NetworkData::mac_address].
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub struct MacAddr(pub [u8; 6]);

impl MacAddr {
Expand Down Expand Up @@ -483,6 +484,7 @@ impl FromStr for MacAddr {
///
/// It is returned by [`NetworkData::ip_networks`][crate::NetworkData::ip_networks].
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub struct IpNetwork {
/// The IP of the network interface.
pub addr: IpAddr,
Expand Down
3 changes: 3 additions & 0 deletions src/common/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ pub struct LoadAvg {
/// If you want the list of the supported signals on the current system, use
/// [`SUPPORTED_SIGNALS`][crate::SUPPORTED_SIGNALS].
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub enum Signal {
/// Hangup detected on controlling terminal or death of controlling process.
Hangup,
Expand Down Expand Up @@ -985,6 +986,7 @@ pub struct CGroupLimits {

/// Enum describing the different status of a process.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub enum ProcessStatus {
/// ## Linux
///
Expand Down Expand Up @@ -1102,6 +1104,7 @@ pub enum ProcessStatus {

/// Enum describing the different kind of threads.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
pub enum ThreadKind {
/// Kernel thread.
Kernel,
Expand Down

0 comments on commit 8a7dc24

Please sign in to comment.