@@ -18,7 +18,7 @@ pub struct State {
1818 pub root : Cid ,
1919}
2020
21- // TODO: (@ carsonfarmer) We'll likely want to define the metadata type that will actually be placed in the Hamt
21+ // TODO:( carsonfarmer) We'll likely want to define the metadata type that will actually be placed in the Hamt
2222
2323impl State {
2424 pub fn new < BS : Blockstore > ( store : & BS ) -> anyhow:: Result < Self > {
@@ -45,7 +45,6 @@ impl State {
4545
4646 let new_content = match hamt. get ( & key) ? {
4747 Some ( existing) => {
48- // Append the object to the existing object
4948 let mut new_content = existing. clone ( ) ;
5049 new_content. extend ( content) ;
5150 new_content
@@ -66,15 +65,14 @@ impl State {
6665 ) -> anyhow:: Result < ( ) > {
6766 let mut hamt = Hamt :: < _ , Vec < u8 > > :: load_with_bit_width ( & self . root , store, BIT_WIDTH ) ?;
6867
69- // TODO: We could use set_if_absent here to avoid overwriting existing objects.
68+ // TODO:(carsonfarmer) We could use set_if_absent here to avoid overwriting existing objects.
7069 hamt. set ( key, content) ?;
7170 self . root = hamt. flush ( ) ?;
7271 Ok ( ( ) )
7372 }
7473
7574 pub fn delete < BS : Blockstore > ( & mut self , store : & BS , key : & BytesKey ) -> anyhow:: Result < ( ) > {
7675 let mut hamt = Hamt :: < _ , Vec < u8 > > :: load_with_bit_width ( & self . root , store, BIT_WIDTH ) ?;
77-
7876 hamt. delete ( key) ?;
7977 self . root = hamt. flush ( ) ?;
8078 Ok ( ( ) )
@@ -86,20 +84,17 @@ impl State {
8684 key : & BytesKey ,
8785 ) -> anyhow:: Result < Option < Vec < u8 > > > {
8886 let hamt = Hamt :: < _ , Vec < u8 > > :: load_with_bit_width ( & self . root , store, BIT_WIDTH ) ?;
89-
9087 let value = hamt. get ( key) . map ( |v| v. map ( |inner| inner. to_owned ( ) ) ) ?;
9188 Ok ( value)
9289 }
9390
9491 pub fn list < BS : Blockstore > ( & self , store : & BS ) -> anyhow:: Result < Vec < Vec < u8 > > > {
9592 let hamt = Hamt :: < _ , Vec < u8 > > :: load_with_bit_width ( & self . root , store, BIT_WIDTH ) ?;
96-
9793 let mut keys = Vec :: new ( ) ;
9894 hamt. for_each ( |k, _| {
9995 keys. push ( k. 0 . to_owned ( ) ) ;
10096 Ok ( ( ) )
10197 } ) ?;
102-
10398 Ok ( keys)
10499 }
105100}
@@ -130,9 +125,8 @@ pub enum Method {
130125
131126#[ cfg( test) ]
132127mod tests {
133- use std:: str:: FromStr ;
134-
135128 use super :: * ;
129+ use std:: str:: FromStr ;
136130
137131 #[ test]
138132 fn test_constructor ( ) {
0 commit comments