Skip to main content

BlockDevice

Trait BlockDevice 

Source
pub trait BlockDevice: BlockRead {
    // Provided methods
    fn write_at(&self, _offset: u64, _buf: &[u8]) -> Result<()> { ... }
    fn flush(&self) -> Result<()> { ... }
    fn is_writable(&self) -> bool { ... }
}
Expand description

Read-write random-access block device. Implementors that genuinely support writes override write_at / flush / is_writable. The defaults model a strict read-only device.

Provided Methods§

Source

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

Write exactly buf.len() bytes at offset. Default: returns Error::ReadOnly.

Source

fn flush(&self) -> Result<()>

Flush pending writes to stable storage. No-op by default.

Source

fn is_writable(&self) -> bool

Whether write_at is likely to succeed. Mount paths use this to decide whether to attempt journal replay or stay strict-read-only.

Implementations on Foreign Types§

Source§

impl<T: BlockDevice + ?Sized> BlockDevice for Box<T>

Source§

fn write_at(&self, offset: u64, buf: &[u8]) -> Result<()>

Source§

fn flush(&self) -> Result<()>

Source§

fn is_writable(&self) -> bool

Source§

impl<T: BlockDevice + ?Sized> BlockDevice for Arc<T>

Source§

fn write_at(&self, offset: u64, buf: &[u8]) -> Result<()>

Source§

fn flush(&self) -> Result<()>

Source§

fn is_writable(&self) -> bool

Implementors§

Source§

impl BlockDevice for CachingDevice

Source§

impl BlockDevice for CallbackDevice

Source§

impl BlockDevice for FileDevice

Source§

impl BlockDevice for OwnedSlice

Same rationale as SliceReader: read-only by default.

Source§

impl<'a> BlockDevice for SliceReader<'a>

Slices are read-only by default — even where the parent is writable, slicing is almost always paired with a read-only inspection or dispatch workflow.

Source§

impl<T: BlockRead> BlockDevice for ReadOnlyDevice<T>

BlockDevice impl uses the trait’s default (Err(ReadOnly) for write_at, no-op flush, is_writable() -> false). Even if T implements BlockDevice with full writes, the wrapper hides that.