pub struct AllocationMap { /* private fields */ }Expand description
Tracks which sectors are allocated in an image.
Uses a bitmap to efficiently track sector usage, supporting allocation and deallocation operations.
Implementations§
Source§impl AllocationMap
impl AllocationMap
Sourcepub fn new(total_sectors: u32) -> Self
pub fn new(total_sectors: u32) -> Self
Creates a new allocation map for the given number of sectors.
Sourcepub fn from_existing(
used_extents: &[Extent],
total_sectors: u32,
sector_size: u32,
) -> Self
pub fn from_existing( used_extents: &[Extent], total_sectors: u32, sector_size: u32, ) -> Self
Creates an allocation map from a list of existing used extents.
Sourcepub fn allocate(&mut self, size_bytes: u64, sector_size: u32) -> Option<Extent>
pub fn allocate(&mut self, size_bytes: u64, sector_size: u32) -> Option<Extent>
Allocates a contiguous region of the given size.
Returns None if there isn’t enough contiguous free space.
Sourcepub fn total_sectors(&self) -> u32
pub fn total_sectors(&self) -> u32
Returns the total number of sectors.
Sourcepub fn free_sectors(&self) -> u32
pub fn free_sectors(&self) -> u32
Returns the number of free sectors.
Sourcepub fn used_sectors(&self) -> u32
pub fn used_sectors(&self) -> u32
Returns the number of used sectors.
Sourcepub fn reserve_initial(&mut self, sectors: u32, sector_size: u32)
pub fn reserve_initial(&mut self, sectors: u32, sector_size: u32)
Reserves the first N sectors (typically for metadata).
Trait Implementations§
Source§impl Clone for AllocationMap
impl Clone for AllocationMap
Source§fn clone(&self) -> AllocationMap
fn clone(&self) -> AllocationMap
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for AllocationMap
impl RefUnwindSafe for AllocationMap
impl Send for AllocationMap
impl Sync for AllocationMap
impl Unpin for AllocationMap
impl UnsafeUnpin for AllocationMap
impl UnwindSafe for AllocationMap
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