pub struct OwnedRwSlice { /* private fields */ }Expand description
Owned, read-WRITE slice over an Arc<dyn BlockDevice>. Use when the
parent is writable and the slice should propagate writes (e.g. an
individual partition handed to a filesystem driver).
Reads outside [0, length) return Error::ShortRead with got: 0;
writes outside it return Error::OutOfBounds. The two directions
differ on purpose — see the module docs.
Implementations§
Source§impl OwnedRwSlice
impl OwnedRwSlice
Sourcepub fn new(parent: Arc<dyn BlockDevice>, start: u64, length: u64) -> Self
pub fn new(parent: Arc<dyn BlockDevice>, start: u64, length: u64) -> Self
length is clamped to what the parent can back, so
size_bytes() never exceeds it and a write past the parent’s end
is Error::OutOfBounds from this slice rather than whatever
the parent makes of an address beyond itself. See
window_on_parent.
Trait Implementations§
Source§impl BlockDevice for OwnedRwSlice
impl BlockDevice for OwnedRwSlice
Source§fn write_at(&self, offset: u64, buf: &[u8]) -> Result<()>
fn write_at(&self, offset: u64, buf: &[u8]) -> Result<()>
Range first, writability second: a write that is both out of range
and aimed at a read-only parent reports Error::OutOfBounds,
not Error::ReadOnly. The range is a property of this slice and
is knowable without asking the parent anything, so it is the more
specific of the two answers.
Source§fn is_writable(&self) -> bool
fn is_writable(&self) -> bool
write_at is likely to succeed. Mount paths use this to
decide whether to attempt journal replay or stay strict-read-only.