@@ -57,7 +57,7 @@ use crate::util::dyn_signer::{
5757use crate :: util:: logger:: { Logger , Record } ;
5858#[ cfg( feature = "std" ) ]
5959use crate :: util:: mut_global:: MutGlobal ;
60- use crate :: util:: persist:: { KVStoreSync , MonitorName } ;
60+ use crate :: util:: persist:: { KVStore , KVStoreSync , MonitorName } ;
6161use crate :: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
6262use crate :: util:: test_channel_signer:: { EnforcementState , TestChannelSigner } ;
6363
@@ -84,7 +84,10 @@ use crate::io;
8484use crate :: prelude:: * ;
8585use crate :: sign:: { EntropySource , NodeSigner , RandomBytes , Recipient , SignerProvider } ;
8686use crate :: sync:: { Arc , Mutex } ;
87+ use alloc:: boxed:: Box ;
88+ use core:: future:: Future ;
8789use core:: mem;
90+ use core:: pin:: Pin ;
8891use core:: sync:: atomic:: { AtomicBool , AtomicUsize , Ordering } ;
8992use core:: time:: Duration ;
9093
@@ -864,6 +867,48 @@ impl TestStore {
864867 }
865868}
866869
870+ impl KVStore for TestStore {
871+ fn read (
872+ & self , primary_namespace : & str , secondary_namespace : & str , key : & str ,
873+ ) -> Pin < Box < dyn Future < Output = Result < Vec < u8 > , io:: Error > > + ' static + Send > > {
874+ let primary_namespace = primary_namespace. to_string ( ) ;
875+ let secondary_namespace = secondary_namespace. to_string ( ) ;
876+ let key = key. to_string ( ) ;
877+ let inner = Arc :: clone ( & self . inner ) ;
878+ Box :: pin ( async move { inner. read_internal ( & primary_namespace, & secondary_namespace, & key) } )
879+ }
880+ fn write (
881+ & self , primary_namespace : & str , secondary_namespace : & str , key : & str , buf : Vec < u8 > ,
882+ ) -> Pin < Box < dyn Future < Output = Result < ( ) , io:: Error > > + ' static + Send > > {
883+ let primary_namespace = primary_namespace. to_string ( ) ;
884+ let secondary_namespace = secondary_namespace. to_string ( ) ;
885+ let key = key. to_string ( ) ;
886+ let inner = Arc :: clone ( & self . inner ) ;
887+ Box :: pin ( async move {
888+ inner. write_internal ( & primary_namespace, & secondary_namespace, & key, buf)
889+ } )
890+ }
891+ fn remove (
892+ & self , primary_namespace : & str , secondary_namespace : & str , key : & str , lazy : bool ,
893+ ) -> Pin < Box < dyn Future < Output = Result < ( ) , io:: Error > > + ' static + Send > > {
894+ let primary_namespace = primary_namespace. to_string ( ) ;
895+ let secondary_namespace = secondary_namespace. to_string ( ) ;
896+ let key = key. to_string ( ) ;
897+ let inner = Arc :: clone ( & self . inner ) ;
898+ Box :: pin ( async move {
899+ inner. remove_internal ( & primary_namespace, & secondary_namespace, & key, lazy)
900+ } )
901+ }
902+ fn list (
903+ & self , primary_namespace : & str , secondary_namespace : & str ,
904+ ) -> Pin < Box < dyn Future < Output = Result < Vec < String > , io:: Error > > + ' static + Send > > {
905+ let primary_namespace = primary_namespace. to_string ( ) ;
906+ let secondary_namespace = secondary_namespace. to_string ( ) ;
907+ let inner = Arc :: clone ( & self . inner ) ;
908+ Box :: pin ( async move { inner. list_internal ( & primary_namespace, & secondary_namespace) } )
909+ }
910+ }
911+
867912impl KVStoreSync for TestStore {
868913 fn read (
869914 & self , primary_namespace : & str , secondary_namespace : & str , key : & str ,
0 commit comments