Skip to main content

BlockDevice

Trait BlockDevice 

Source
pub trait BlockDevice: BlockRead {
    // Provided methods
    fn write_at(&self, _offset: u64, _buf: &[u8]) -> Result<(), Error> { ... }
    fn flush(&self) -> Result<(), Error> { ... }
    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<(), Error>

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

Source

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

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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

Source§

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

Source§

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

Source§

fn is_writable(&self) -> bool

Source§

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

Source§

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

Source§

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

Source§

fn is_writable(&self) -> bool

Implementors§

Source§

impl BlockDevice for CachingDevice

Source§

impl BlockDevice for CallbackDevice

Source§

impl BlockDevice for OwnedRwSlice

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> BlockDevice for ReadOnlyDevice<T>
where T: BlockRead,

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.