Skip to main content

Module block

Module block 

Source
Expand description

Block-device traits.

Two layers because not every consumer needs writes:

  • BlockRead is the minimum: positioned reads + size. Disk-image readers (qcow2 reading) and probes (partition table walk) only need this much.
  • BlockDevice extends BlockRead with optional write_at / flush / is_writable / set_len / can_grow. Read-only devices that opt into the larger trait inherit the default Err(ReadOnly) write path automatically, and every device that cannot change its own length inherits the same refusal for set_len.

Both traits are Send + Sync so callers can hold them behind Arc<dyn _> across thread boundaries.

Traits§

BlockDevice
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.
BlockRead
Read-only random-access block device.