pub struct OffsetMap { /* private fields */ }Expand description
Remaps the offset of block requests based on an internal map of contiguous logical extents.
Implementations§
Source§impl OffsetMap
impl OffsetMap
Sourcepub fn new(mappings: Vec<BlockOffsetMapping>) -> Result<Self, Status>
pub fn new(mappings: Vec<BlockOffsetMapping>) -> Result<Self, Status>
Creates a new OffsetMap from a list of BlockOffsetMappings.
Returns INVALID_ARGS if any mapping length is zero, or if logical/target block offsets
overflow u64.
Sourcepub fn map(&self, logical_offset: u64) -> Option<(u64, u32)>
pub fn map(&self, logical_offset: u64) -> Option<(u64, u32)>
Maps logical_offset to (target_block_offset, len), where len is the total number of
blocks which can be addressed from target_block_offset onwards.
For example: if you have logical offset 0 pointing to physical extent 1000..1010, and you
search for offset 5, the return value will be Some((1005, 5)).
pub fn is_empty(&self) -> bool
pub fn total_blocks(&self) -> u64
Sourcepub fn are_blocks_within_source_range(
&self,
(offset, length): (u64, u32),
) -> bool
pub fn are_blocks_within_source_range( &self, (offset, length): (u64, u32), ) -> bool
Returns true if the block range [offset, offset + length) falls entirely within this
map’s total blocks. If the map is empty, returns true (no range restriction).
pub fn mappings(&self) -> &[BlockOffsetMapping]
Trait Implementations§
impl Eq for OffsetMap
impl StructuralPartialEq for OffsetMap
Auto Trait Implementations§
impl Freeze for OffsetMap
impl RefUnwindSafe for OffsetMap
impl Send for OffsetMap
impl Sync for OffsetMap
impl Unpin for OffsetMap
impl UnsafeUnpin for OffsetMap
impl UnwindSafe for OffsetMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more