2020-10-15 16:23:09 +05:30
|
|
|
use std::fmt;
|
|
|
|
|
2020-09-25 14:29:16 +05:30
|
|
|
use crate::pdata::unpack::*;
|
|
|
|
use nom::{number::complete::*, IResult};
|
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
pub struct DeviceDetail {
|
|
|
|
pub mapped_blocks: u64,
|
|
|
|
pub transaction_id: u64,
|
|
|
|
pub creation_time: u32,
|
|
|
|
pub snapshotted_time: u32,
|
|
|
|
}
|
|
|
|
|
2020-10-15 16:23:09 +05:30
|
|
|
impl fmt::Display for DeviceDetail {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
write!(f, "mapped = {}, trans = {}, create = {}, snap = {}",
|
|
|
|
self.mapped_blocks,
|
|
|
|
self.transaction_id,
|
|
|
|
self.creation_time,
|
2020-10-26 17:35:27 +05:30
|
|
|
self.snapshotted_time)?;
|
2020-10-15 16:23:09 +05:30
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-25 14:29:16 +05:30
|
|
|
impl Unpack for DeviceDetail {
|
|
|
|
fn disk_size() -> u32 {
|
|
|
|
24
|
|
|
|
}
|
|
|
|
|
|
|
|
fn unpack(i: &[u8]) -> IResult<&[u8], DeviceDetail> {
|
|
|
|
let (i, mapped_blocks) = le_u64(i)?;
|
|
|
|
let (i, transaction_id) = le_u64(i)?;
|
|
|
|
let (i, creation_time) = le_u32(i)?;
|
|
|
|
let (i, snapshotted_time) = le_u32(i)?;
|
|
|
|
|
|
|
|
Ok((
|
|
|
|
i,
|
|
|
|
DeviceDetail {
|
|
|
|
mapped_blocks,
|
|
|
|
transaction_id,
|
|
|
|
creation_time,
|
|
|
|
snapshotted_time,
|
|
|
|
},
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------
|