Code review of src/pdata/array*

This commit is contained in:
Joe Thornber
2021-03-03 10:27:57 +00:00
parent fdcc09c27e
commit e6c6275aea
4 changed files with 22 additions and 84 deletions

View File

@@ -1,39 +0,0 @@
use nom::{number::complete::*, IResult};
use std::fmt;
use crate::pdata::unpack::*;
//------------------------------------------
// TODO: build a data structure representating an array?
// FIXME: rename this struct
pub struct ArrayBlockEntry {
pub block: u64,
}
impl Unpack for ArrayBlockEntry {
fn disk_size() -> u32 {
8
}
fn unpack(i: &[u8]) -> IResult<&[u8], ArrayBlockEntry> {
let (i, n) = le_u64(i)?;
let block = n;
Ok((
i,
ArrayBlockEntry {
block,
}
))
}
}
impl fmt::Display for ArrayBlockEntry {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.block)
}
}
//------------------------------------------