@@ -57,7 +57,7 @@ use crate::util::dyn_signer::{
57
57
use crate :: util:: logger:: { Logger , Record } ;
58
58
#[ cfg( feature = "std" ) ]
59
59
use crate :: util:: mut_global:: MutGlobal ;
60
- use crate :: util:: persist:: { KVStoreSync , MonitorName } ;
60
+ use crate :: util:: persist:: { KVStore , KVStoreSync , MonitorName } ;
61
61
use crate :: util:: ser:: { Readable , ReadableArgs , Writeable , Writer } ;
62
62
use crate :: util:: test_channel_signer:: { EnforcementState , TestChannelSigner } ;
63
63
@@ -84,7 +84,10 @@ use crate::io;
84
84
use crate :: prelude:: * ;
85
85
use crate :: sign:: { EntropySource , NodeSigner , RandomBytes , Recipient , SignerProvider } ;
86
86
use crate :: sync:: { Arc , Mutex } ;
87
+ use alloc:: boxed:: Box ;
88
+ use core:: future:: Future ;
87
89
use core:: mem;
90
+ use core:: pin:: Pin ;
88
91
use core:: sync:: atomic:: { AtomicBool , AtomicUsize , Ordering } ;
89
92
use core:: time:: Duration ;
90
93
@@ -864,6 +867,48 @@ impl TestStore {
864
867
}
865
868
}
866
869
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
+
867
912
impl KVStoreSync for TestStore {
868
913
fn read (
869
914
& self , primary_namespace : & str , secondary_namespace : & str , key : & str ,
0 commit comments