@@ -4,9 +4,8 @@ use std::{
44    path:: PathBuf , 
55} ; 
66
7- use  generic_array:: typenum:: { U512 ,  U8 } ; 
87use  littlefs2:: { const_ram_storage,  driver:: Storage ,  object_safe:: DynStorageAlloc } ; 
9- use  littlefs2_core:: { DynFilesystem ,  Error ,   Result } ; 
8+ use  littlefs2_core:: { DynFilesystem ,  Result } ; 
109
1110use  crate :: store; 
1211
@@ -16,6 +15,8 @@ pub struct StoreConfig<'a> {
1615    pub  volatile :  StorageConfig < ' a > , 
1716} 
1817
18+ const  BLOCK_SIZE :  usize  = 512 ; 
19+ 
1920impl  StoreConfig < ' _ >  { 
2021    pub  fn  ram ( )  -> Self  { 
2122        Self  { 
@@ -97,15 +98,32 @@ const_ram_storage!(RamStorage, STORAGE_SIZE);
9798struct  FilesystemStorage ( PathBuf ) ; 
9899
99100impl  Storage  for  FilesystemStorage  { 
100-     const  READ_SIZE :  usize  = 16 ; 
101-     const  WRITE_SIZE :  usize  = 16 ; 
102-     const  BLOCK_SIZE :  usize  = 512 ; 
101+     fn  read_size ( & self )  -> usize  { 
102+         16 
103+     } 
104+     fn  write_size ( & self )  -> usize  { 
105+         16 
106+     } 
107+     fn  block_size ( & self )  -> usize  { 
108+         BLOCK_SIZE 
109+     } 
110+     fn  block_count ( & self )  -> usize  { 
111+         128 
112+     } 
113+     fn  block_cycles ( & self )  -> isize  { 
114+         -1 
115+     } 
116+ 
117+     fn  cache_size ( & self )  -> usize  { 
118+         512 
119+     } 
103120
104-     const  BLOCK_COUNT :  usize  = 128 ; 
105-     const  BLOCK_CYCLES :  isize  = -1 ; 
121+     fn  lookahead_size ( & self )  -> usize  { 
122+         8 
123+     } 
106124
107-     type  CACHE_SIZE  = U512 ; 
108-     type  LOOKAHEAD_SIZE  = U8 ; 
125+     type  CACHE_BUFFER  = [ u8 ;   512 ] ; 
126+     type  LOOKAHEAD_BUFFER  = [ u8 ;   64 ] ; 
109127
110128    fn  read ( & mut  self ,  offset :  usize ,  buffer :  & mut  [ u8 ] )  -> Result < usize >  { 
111129        debug ! ( "read: offset: {}, len: {}" ,  offset,  buffer. len( ) ) ; 
@@ -136,10 +154,10 @@ impl Storage for FilesystemStorage {
136154        } 
137155        let  mut  file = OpenOptions :: new ( ) . write ( true ) . open ( & self . 0 ) . unwrap ( ) ; 
138156        file. seek ( SeekFrom :: Start ( offset as  _ ) ) . unwrap ( ) ; 
139-         let  zero_block = [ 0xFFu8 ;  Self :: BLOCK_SIZE ] ; 
140-         for  _ in  0 ..( len / Self :: BLOCK_SIZE )  { 
157+         let  zero_block = [ 0xFFu8 ;  BLOCK_SIZE ] ; 
158+         for  _ in  0 ..( len / BLOCK_SIZE )  { 
141159            let  bytes_written = file. write ( & zero_block) . unwrap ( ) ; 
142-             assert_eq ! ( bytes_written,  Self :: BLOCK_SIZE ) ; 
160+             assert_eq ! ( bytes_written,  BLOCK_SIZE ) ; 
143161        } 
144162        file. flush ( ) . unwrap ( ) ; 
145163        Ok ( len) 
0 commit comments