procfs_core/
sysvipc_shm.rsuse std::io;
use super::{expect, ProcResult};
use std::str::FromStr;
#[cfg(feature = "serde1")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
#[allow(non_snake_case)]
pub struct Shm {
pub key: i32,
pub shmid: u64,
pub perms: u16,
pub size: u64,
pub cpid: i32,
pub lpid: i32,
pub nattch: u32,
pub uid: u16,
pub gid: u16,
pub cuid: u16,
pub cgid: u16,
pub atime: u64,
pub dtime: u64,
pub ctime: u64,
pub rss: u64,
pub swap: u64,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
pub struct SharedMemorySegments(pub Vec<Shm>);
impl super::FromBufRead for SharedMemorySegments {
fn from_buf_read<R: io::BufRead>(r: R) -> ProcResult<Self> {
let mut vec = Vec::new();
for line in r.lines().skip(1) {
let line = expect!(line);
let mut s = line.split_whitespace();
let key = expect!(i32::from_str(expect!(s.next())));
let shmid = expect!(u64::from_str(expect!(s.next())));
let perms = expect!(u16::from_str(expect!(s.next())));
let size = expect!(u64::from_str(expect!(s.next())));
let cpid = expect!(i32::from_str(expect!(s.next())));
let lpid = expect!(i32::from_str(expect!(s.next())));
let nattch = expect!(u32::from_str(expect!(s.next())));
let uid = expect!(u16::from_str(expect!(s.next())));
let gid = expect!(u16::from_str(expect!(s.next())));
let cuid = expect!(u16::from_str(expect!(s.next())));
let cgid = expect!(u16::from_str(expect!(s.next())));
let atime = expect!(u64::from_str(expect!(s.next())));
let dtime = expect!(u64::from_str(expect!(s.next())));
let ctime = expect!(u64::from_str(expect!(s.next())));
let rss = expect!(u64::from_str(expect!(s.next())));
let swap = expect!(u64::from_str(expect!(s.next())));
let shm = Shm {
key,
shmid,
perms,
size,
cpid,
lpid,
nattch,
uid,
gid,
cuid,
cgid,
atime,
dtime,
ctime,
rss,
swap,
};
vec.push(shm);
}
Ok(SharedMemorySegments(vec))
}
}