pub struct IndexPos(/* private fields */);Expand description
A position index representing an 8-byte aligned offset in a block device.
IndexPos is a type-safe wrapper around a u64 that represents positions
in units of 8 bytes. This is used throughout the library to ensure proper
alignment and avoid confusion between byte offsets and index positions.
§Examples
use test_bd::IndexPos;
// Create a position at index 100 (which is byte offset 800)
let pos = IndexPos::new(100);
assert_eq!(pos.as_u64(), 100);
assert_eq!(pos.as_abs_byte_offset(), 800);Implementations§
Source§impl IndexPos
impl IndexPos
Sourcepub const fn as_u64(self) -> u64
pub const fn as_u64(self) -> u64
Returns the raw index value as a u64.
§Examples
use test_bd::IndexPos;
let pos = IndexPos::new(100);
assert_eq!(pos.as_u64(), 100);Sourcepub const fn as_abs_byte_offset(self) -> u64
pub const fn as_abs_byte_offset(self) -> u64
Converts the index position to an absolute byte offset.
Since each index represents 8 bytes, this returns index * 8.
However, this could change, so use this method.
§Examples
use test_bd::IndexPos;
let pos = IndexPos::new(100);
assert_eq!(pos.as_abs_byte_offset(), 800);Trait Implementations§
Source§impl AddAssign for IndexPos
impl AddAssign for IndexPos
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl<'de> Deserialize<'de> for IndexPos
impl<'de> Deserialize<'de> for IndexPos
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for IndexPos
impl Ord for IndexPos
Source§impl PartialOrd for IndexPos
impl PartialOrd for IndexPos
impl Copy for IndexPos
impl Eq for IndexPos
impl StructuralPartialEq for IndexPos
Auto Trait Implementations§
impl Freeze for IndexPos
impl RefUnwindSafe for IndexPos
impl Send for IndexPos
impl Sync for IndexPos
impl Unpin for IndexPos
impl UnwindSafe for IndexPos
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