Skip to main content

Module slice

Module slice 

Source
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:

  • SliceReader borrows the parent, lifetime-tied. Cheaper when the parent outlives the slice and you can express that statically.
  • OwnedSlice holds an Arc to 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§

OwnedRwSlice
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) return Error::ShortRead / Error::OutOfBounds.
OwnedSlice
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.
SliceReader
Borrowed slice of a parent BlockRead.