diff --git a/src/lib.rs b/src/lib.rs index a9303c6..56560f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,16 +54,10 @@ pub trait Storage: ReadStorage { fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error>; } -/// The size in bytes of a single block read or written by a [`BlockDevice`]. -pub const BLOCK_SIZE: usize = 512; - -/// A single block which may be read or written by a [`BlockDevice`]. -/// -/// Also referred to as a sector in some contexts. -pub type Block = [u8; BLOCK_SIZE]; - /// A device which can read and write whole numbers of blocks. -pub trait BlockDevice { +/// +/// Blocks are also referred to as sectors in some contexts. +pub trait BlockDevice { /// The error type returned by methods on this trait. type Error; @@ -74,11 +68,19 @@ pub trait BlockDevice { /// /// `first_block_index + blocks.len()` must not be greater than the size returned by /// `block_count`. - fn read(&mut self, first_block_index: u64, blocks: &mut [Block]) -> Result<(), Self::Error>; + fn read( + &mut self, + first_block_index: u64, + blocks: &mut [[u8; BLOCK_SIZE]], + ) -> Result<(), Self::Error>; /// Writes some number of blocks to the device, starting at `first_block_index`. /// /// `first_block_index + blocks.len()` must not be greater than the size returned by /// `block_count`. - fn write(&mut self, first_block_index: u64, blocks: &[Block]) -> Result<(), Self::Error>; + fn write( + &mut self, + first_block_index: u64, + blocks: &[[u8; BLOCK_SIZE]], + ) -> Result<(), Self::Error>; }