Skip to content

Commit

Permalink
parser: Add basic docs for Bmap methods
Browse files Browse the repository at this point in the history
Signed-off-by: Sjoerd Simons <[email protected]>
  • Loading branch information
sjoerdsimons committed Feb 24, 2024
1 parent e4479a4 commit e3aad32
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bmap-parser/src/bmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,42 @@ impl Bmap {
BmapBuilder::default()
}

/// Build from a .bmap xml file
pub fn from_xml(xml: &str) -> Result<Self, xml::XmlError> {
xml::from_xml(xml)
}

/// Image size in bytes
pub fn image_size(&self) -> u64 {
self.image_size
}

/// block size in bytes
pub const fn block_size(&self) -> u64 {
self.block_size
}

/// number of blocks in the image
pub fn blocks(&self) -> u64 {
self.blocks
}

/// number of mapped blocks in the image
pub fn mapped_blocks(&self) -> u64 {
self.mapped_blocks
}

/// checksum type used
pub fn checksum_type(&self) -> HashType {
self.checksum_type
}

/// Iterator over the block map
pub fn block_map(&self) -> impl ExactSizeIterator + Iterator<Item = &BlockRange> {
self.blockmap.iter()
}

/// Total mapped size in bytes
pub fn total_mapped_size(&self) -> u64 {
self.block_size * self.mapped_blocks
}
Expand Down

0 comments on commit e3aad32

Please sign in to comment.