RamDisk

Struct RamDisk 

Source
pub struct RamDisk {
    data: SpinLock<Vec<u8>>,
    block_size: usize,
    device_id: usize,
}
Expand description

内存模拟的块设备

用于测试和开发

Fields§

§data: SpinLock<Vec<u8>>

存储数据

§block_size: usize

块大小

§device_id: usize

设备 ID

Implementations§

Source§

impl RamDisk

Source

pub fn new(size: usize, block_size: usize, device_id: usize) -> Arc<Self>

创建指定大小的内存磁盘

Source

pub fn from_bytes( data: Vec<u8>, block_size: usize, device_id: usize, ) -> Arc<Self>

从字节数组创建

Source

pub fn raw_data(&self) -> Vec<u8>

获取原始数据(用于调试)

Source

pub fn device_id(&self) -> usize

获取设备 ID

Trait Implementations§

Source§

impl BlockDriver for RamDisk

Source§

fn read_block(&self, block_id: usize, buf: &mut [u8]) -> bool

读取块设备数据 Read more
Source§

fn write_block(&self, block_id: usize, buf: &[u8]) -> bool

写入块设备数据 Read more
Source§

fn flush(&self) -> bool

刷新到磁盘 Read more
Source§

fn block_size(&self) -> usize

获取块大小(字节) Read more
Source§

fn total_blocks(&self) -> usize

获取总块数 Read more
Source§

impl Driver for RamDisk

Source§

fn try_handle_interrupt(&self, _irq: Option<usize>) -> bool

Source§

fn device_type(&self) -> DeviceType

Source§

fn get_id(&self) -> String

Source§

fn as_block(&self) -> Option<&dyn BlockDriver>

将驱动程序转换为块设备驱动程序(如果适用)
Source§

fn as_net(&self) -> Option<&dyn NetDevice>

将驱动程序转换为网络驱动程序(如果适用)
Source§

fn as_net_arc(self: Arc<Self>) -> Option<Arc<dyn NetDevice>>

将驱动程序转换为网络驱动程序 Arc(如果适用)
Source§

fn as_block_arc(self: Arc<Self>) -> Option<Arc<dyn BlockDriver>>

将驱动程序转换为块设备驱动程序 Arc(如果适用)
Source§

fn as_rtc(&self) -> Option<&dyn RtcDriver>

将驱动程序转换为实时时钟驱动程序(如果适用)
Source§

fn as_rtc_arc(self: Arc<Self>) -> Option<Arc<dyn RtcDriver>>

将驱动程序转换为实时时钟驱动程序 Arc(如果适用)
Source§

fn as_serial(&self) -> Option<&dyn SerialDriver>

将驱动程序转换为串口驱动程序(如果适用)

Auto Trait Implementations§

§

impl !Freeze for RamDisk

§

impl !RefUnwindSafe for RamDisk

§

impl Send for RamDisk

§

impl Sync for RamDisk

§

impl Unpin for RamDisk

§

impl UnwindSafe for RamDisk

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.