Skip to content

Commit

Permalink
Make MemoryMaps non-exhaustive and add MMapExtension::is_empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
afranchuk committed Feb 1, 2023
1 parent 52103ac commit cbac452
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ impl MMapPath {
/// Represents all entries in a `/proc/<pid>/maps` or `/proc/<pid>/smaps` file.
#[derive(Debug, PartialEq, Eq, Clone)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[non_exhaustive]
pub struct MemoryMaps {
pub memory_maps: Vec<MemoryMap>,
}
Expand Down Expand Up @@ -733,6 +734,13 @@ pub struct MMapExtension {
pub vm_flags: VmFlags,
}

impl MMapExtension {
/// Return whether the extension information is empty.
pub fn is_empty(&self) -> bool {
self.map.is_empty() && self.vm_flags == VmFlags::NONE
}
}

impl Io {
pub fn from_reader<R: io::Read>(r: R) -> ProcResult<Io> {
let mut map = HashMap::new();
Expand Down
2 changes: 1 addition & 1 deletion src/process/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::StatFlags;
#[cfg(feature = "chrono")]
use crate::TICKS_PER_SECOND;
use crate::{from_iter, KernelVersion, ProcResult};
use crate::{ProcError, KERNEL, PAGESIZE};
use crate::{KERNEL, PAGESIZE};
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};

Expand Down

0 comments on commit cbac452

Please sign in to comment.