Expand description
Slice adapters — view a byte sub-range of any BlockRead as its own
device. Useful any time you want to feed a fragment of a larger
device to a consumer that expects a whole block source — partition
probes, image-file extents, mmap-style views, fuzzer harnesses.
Two variants:
SliceReaderborrows the parent, lifetime-tied. Cheaper when the parent outlives the slice and you can express that statically.OwnedSliceholds anArcto the parent. Use when the parent’s lifetime can’t be expressed in a borrow (FFI handles, slice handed across thread boundaries, etc.).
Both treat the slice as read-only — reads inside the range are
forwarded to the parent, reads outside return Error::ShortRead.
The default Err(ReadOnly) write path from BlockDevice applies.
Structs§
- Owned
RwSlice - 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 + writes outside[0, length)returnError::ShortRead/Error::OutOfBounds. - Owned
Slice - Owned slice over an
Arc<dyn BlockRead>. Use when the parent’s lifetime can’t be expressed in a borrow — e.g. when the slice is handed across an FFI boundary or stored in a long-lived struct. - Slice
Reader - Borrowed slice of a parent
BlockRead.