Skip to main content

ReadOnlyDevice

Struct ReadOnlyDevice 

Source
pub struct ReadOnlyDevice<T> { /* private fields */ }
Expand description

Wraps any T: BlockRead and makes it read-only at the type level.

Implementations§

Source§

impl<T> ReadOnlyDevice<T>

Source

pub fn new(inner: T) -> Self

Source

pub fn inner(&self) -> &T

Borrow the wrapped device.

Source

pub fn into_inner(self) -> T

Consume the wrapper and return the inner device unchanged.

Trait Implementations§

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.

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.
Source§

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

Source§

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

Read exactly buf.len() bytes starting at offset (bytes from the start of the device).
Source§

fn size_bytes(&self) -> u64

Total device size in bytes. Used for bounds checks.

Auto Trait Implementations§

§

impl<T> Freeze for ReadOnlyDevice<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ReadOnlyDevice<T>
where T: RefUnwindSafe,

§

impl<T> Send for ReadOnlyDevice<T>
where T: Send,

§

impl<T> Sync for ReadOnlyDevice<T>
where T: Sync,

§

impl<T> Unpin for ReadOnlyDevice<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ReadOnlyDevice<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for ReadOnlyDevice<T>
where T: UnwindSafe,

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.