#[repr(transparent)]pub struct LogicalBlockAddress(NonZeroU64);Expand description
Represents a logical block address (LBA) on disk.
This structure stores the block index used to locate data blocks on a physical storage device. The actual size of a block depends on the filesystem’s configuration.
Tuple Fields§
§0: NonZeroU64Implementations§
Source§impl LogicalBlockAddress
impl LogicalBlockAddress
Sourcepub const fn new(n: u64) -> Option<Self>
pub const fn new(n: u64) -> Option<Self>
Creates a LogicalBlockAddress if the given value is not zero.
Sourcepub const fn into_sector(self) -> Sector
pub const fn into_sector(self) -> Sector
Converts a logical block address (LBA) to a sector number.
In the Fast File System (FFS), logical blocks are 4 KiB (0x1000) in
size, while sectors are 512 bytes. Since LBA numbering starts at 1
(with 0 being invalid), this function calculates the corresponding
sector.
§Returns
- A
Sectorcorresponding to the given logical block.
Sourcepub fn into_bitmap_lba_offset(
self,
ffs: &FastFileSystemInner,
) -> Option<(LogicalBlockAddress, usize)>
pub fn into_bitmap_lba_offset( self, ffs: &FastFileSystemInner, ) -> Option<(LogicalBlockAddress, usize)>
Converts this logical block address into the corresponding location in the block allocation bitmap.
§Arguments
fs: Reference to the file system’s internal metadata layout.
§Returns
Some((lba, index)): if the block address is valid, which includes:lba: the logical block address of the bitmap block that tracks this data block.index: the index within the bitmap block where the relevant bit resides.
None: if the logical block address is out of bounds or outside the data region.
Trait Implementations§
Source§impl Add<usize> for LogicalBlockAddress
impl Add<usize> for LogicalBlockAddress
Source§impl Clone for LogicalBlockAddress
impl Clone for LogicalBlockAddress
Source§fn clone(&self) -> LogicalBlockAddress
fn clone(&self) -> LogicalBlockAddress
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LogicalBlockAddress
impl Debug for LogicalBlockAddress
Source§impl Ord for LogicalBlockAddress
impl Ord for LogicalBlockAddress
Source§impl PartialEq for LogicalBlockAddress
impl PartialEq for LogicalBlockAddress
Source§impl PartialOrd for LogicalBlockAddress
impl PartialOrd for LogicalBlockAddress
Source§fn partial_cmp(&self, other: &LogicalBlockAddress) -> Option<Ordering>
fn partial_cmp(&self, other: &LogicalBlockAddress) -> Option<Ordering>
Source§impl Step for LogicalBlockAddress
impl Step for LogicalBlockAddress
Source§fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>)
fn steps_between(start: &Self, end: &Self) -> (usize, Option<usize>)
🔬This is a nightly-only experimental API. (
step_trait)Returns the bounds on the number of successor steps required to get from
start to end
like [Iterator::size_hint()][Iterator::size_hint()]. Read moreSource§fn forward_checked(start: Self, count: usize) -> Option<Self>
fn forward_checked(start: Self, count: usize) -> Option<Self>
🔬This is a nightly-only experimental API. (
step_trait)Source§fn backward_checked(start: Self, count: usize) -> Option<Self>
fn backward_checked(start: Self, count: usize) -> Option<Self>
🔬This is a nightly-only experimental API. (
step_trait)§fn forward(start: Self, count: usize) -> Self
fn forward(start: Self, count: usize) -> Self
🔬This is a nightly-only experimental API. (
step_trait)§unsafe fn forward_unchecked(start: Self, count: usize) -> Self
unsafe fn forward_unchecked(start: Self, count: usize) -> Self
🔬This is a nightly-only experimental API. (
step_trait)§fn backward(start: Self, count: usize) -> Self
fn backward(start: Self, count: usize) -> Self
🔬This is a nightly-only experimental API. (
step_trait)§unsafe fn backward_unchecked(start: Self, count: usize) -> Self
unsafe fn backward_unchecked(start: Self, count: usize) -> Self
🔬This is a nightly-only experimental API. (
step_trait)impl Copy for LogicalBlockAddress
impl Eq for LogicalBlockAddress
impl StructuralPartialEq for LogicalBlockAddress
Auto Trait Implementations§
impl Freeze for LogicalBlockAddress
impl RefUnwindSafe for LogicalBlockAddress
impl Send for LogicalBlockAddress
impl Sync for LogicalBlockAddress
impl Unpin for LogicalBlockAddress
impl UnwindSafe for LogicalBlockAddress
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)