ros_fs::bitmap

Struct Bitmap

Source
pub struct Bitmap {
    start_block: usize,
    blocks: usize,
}
Expand description

位示图

用于管理块设备某一范围内的空闲块

位示图的每一位对应一个块,0 表示空闲,1 表示已分配

Fields§

§start_block: usize§blocks: usize

Implementations§

Source§

impl Bitmap

Source

pub fn new(start_block: usize, blocks: usize) -> Self

Source

pub fn alloc(&self, dev: &Arc<dyn BlockDevice>) -> Option<usize>

分配一个空闲块

从位示图中找到第一个空闲的块,并返回其在位示图中的偏移

§参数
  • dev:块设备
§返回

返回空闲块在位示图中的偏移,如果没有空闲块则返回 None

Source

fn extract_bit_position(bit: usize) -> (usize, usize, usize)

从位示图中提取块的位置

Source

pub fn free(&self, dev: &Arc<dyn BlockDevice>, bit: usize)

释放一个块

将指定块标记为空闲

§参数
  • dev:块设备
  • bit:块在位示图内的偏移
Source

pub fn maximum(&self) -> usize

获取位示图的最大块数

Auto Trait Implementations§

§

impl Freeze for Bitmap

§

impl RefUnwindSafe for Bitmap

§

impl Send for Bitmap

§

impl Sync for Bitmap

§

impl Unpin for Bitmap

§

impl UnwindSafe for Bitmap

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.