diff --git a/src/v1.rs b/src/v1.rs index 42a0567..60b71fe 100644 --- a/src/v1.rs +++ b/src/v1.rs @@ -329,6 +329,10 @@ impl std::error::Error for Error{} #[brw(little)] #[derive(Debug,Clone,Copy)] pub struct BlockId(#[br(map=|i:u32|i-1)]u32); +#[binrw] +#[brw(little)] +#[derive(Debug,Clone,Copy)] +pub struct BlockPosition(#[br(map=|i:u32|i-1)]u32); #[binrw] #[brw(little)] @@ -358,7 +362,7 @@ pub struct FileHeader{ pub num_offline_events:u32, pub num_realtime_events:u32, #[br(count=num_offline_events+num_realtime_events+1)] - pub block_positions:Vec, + pub block_positions:Vec, #[br(count=num_offline_events)] pub offline_blocks_timeline:Vec, #[br(count=num_realtime_events)] @@ -373,8 +377,8 @@ impl FileHeader{ if self.block_positions.len() as u32<=block_id.0{ return Err(Error::InvalidBlockId(block_id)); } - let start=self.block_positions[block_id.0 as usize]; - let end=self.block_positions[block_id.0 as usize+1]; + let start=self.block_positions[block_id.0 as usize].0; + let end=self.block_positions[block_id.0 as usize+1].0; Ok(BlockInfo{start,length:end-start}) } }