Trait kernel::devices::Device

source ·
pub trait Device: Sync + Send + Debug {
    // Required method
    fn name(&self) -> &str;

    // Provided methods
    fn read(
        &self,
        _offset: u64,
        _buf: &mut [u8]
    ) -> Result<u64, FileSystemError> { ... }
    fn write(&self, _offset: u64, _buf: &[u8]) -> Result<u64, FileSystemError> { ... }
    fn set_size(&self, _size: u64) -> Result<(), FileSystemError> { ... }
    fn close(&self) -> Result<(), FileSystemError> { ... }
    fn clone_device(&self) -> Result<(), FileSystemError> { ... }
    fn try_create(&self) -> Option<Result<Arc<dyn Device>, FileSystemError>> { ... }
}

Required Methods§

source

fn name(&self) -> &str

Provided Methods§

source

fn read(&self, _offset: u64, _buf: &mut [u8]) -> Result<u64, FileSystemError>

source

fn write(&self, _offset: u64, _buf: &[u8]) -> Result<u64, FileSystemError>

source

fn set_size(&self, _size: u64) -> Result<(), FileSystemError>

source

fn close(&self) -> Result<(), FileSystemError>

Informs the device that it is closed.

source

fn clone_device(&self) -> Result<(), FileSystemError>

Informs the device that it is cloned.

source

fn try_create(&self) -> Option<Result<Arc<dyn Device>, FileSystemError>>

Open the device. This tells the device manager that when opening a file with this device name, it should instead use the device returned by this function. if None, it will just use the device directly.

Implementors§