@@ -54,16 +54,10 @@ pub trait Storage: ReadStorage {
54
54
fn write ( & mut self , offset : u32 , bytes : & [ u8 ] ) -> Result < ( ) , Self :: Error > ;
55
55
}
56
56
57
- /// The size in bytes of a single block read or written by a [`BlockDevice`].
58
- pub const BLOCK_SIZE : usize = 512 ;
59
-
60
- /// A single block which may be read or written by a [`BlockDevice`].
61
- ///
62
- /// Also referred to as a sector in some contexts.
63
- pub type Block = [ u8 ; BLOCK_SIZE ] ;
64
-
65
57
/// A device which can read and write whole numbers of blocks.
66
- pub trait BlockDevice {
58
+ ///
59
+ /// Blocks are also referred to as sectors in some contexts.
60
+ pub trait BlockDevice < const BLOCK_SIZE : usize = 512 > {
67
61
/// The error type returned by methods on this trait.
68
62
type Error ;
69
63
@@ -74,11 +68,19 @@ pub trait BlockDevice {
74
68
///
75
69
/// `first_block_index + blocks.len()` must not be greater than the size returned by
76
70
/// `block_count`.
77
- fn read ( & mut self , first_block_index : u64 , blocks : & mut [ Block ] ) -> Result < ( ) , Self :: Error > ;
71
+ fn read (
72
+ & mut self ,
73
+ first_block_index : u64 ,
74
+ blocks : & mut [ [ u8 ; BLOCK_SIZE ] ] ,
75
+ ) -> Result < ( ) , Self :: Error > ;
78
76
79
77
/// Writes some number of blocks to the device, starting at `first_block_index`.
80
78
///
81
79
/// `first_block_index + blocks.len()` must not be greater than the size returned by
82
80
/// `block_count`.
83
- fn write ( & mut self , first_block_index : u64 , blocks : & [ Block ] ) -> Result < ( ) , Self :: Error > ;
81
+ fn write (
82
+ & mut self ,
83
+ first_block_index : u64 ,
84
+ blocks : & [ [ u8 ; BLOCK_SIZE ] ] ,
85
+ ) -> Result < ( ) , Self :: Error > ;
84
86
}
0 commit comments