File tree 3 files changed +14
-3
lines changed
3 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 10
10
#![ allow( clippy:: mutable_key_type) ]
11
11
12
12
use std:: collections:: HashSet ;
13
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
13
14
use std:: path:: Path ;
14
15
15
16
use nostr_database:: prelude:: * ;
@@ -31,6 +32,7 @@ pub struct NostrRedb {
31
32
impl NostrRedb {
32
33
/// Persistent database
33
34
#[ inline]
35
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
34
36
pub fn persistent < P > ( path : P ) -> Result < Self , DatabaseError >
35
37
where
36
38
P : AsRef < Path > ,
@@ -55,7 +57,8 @@ impl NostrRedb {
55
57
}
56
58
}
57
59
58
- #[ async_trait]
60
+ #[ cfg_attr( target_arch = "wasm32" , async_trait( ?Send ) ) ]
61
+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait) ]
59
62
impl NostrDatabase for NostrRedb {
60
63
#[ inline]
61
64
fn backend ( & self ) -> Backend {
@@ -73,7 +76,8 @@ impl NostrDatabase for NostrRedb {
73
76
}
74
77
}
75
78
76
- #[ async_trait]
79
+ #[ cfg_attr( target_arch = "wasm32" , async_trait( ?Send ) ) ]
80
+ #[ cfg_attr( not( target_arch = "wasm32" ) , async_trait) ]
77
81
impl NostrEventsDatabase for NostrRedb {
78
82
#[ inline]
79
83
async fn save_event ( & self , event : & Event ) -> Result < SaveEventStatus , DatabaseError > {
Original file line number Diff line number Diff line change 4
4
// Distributed under the MIT software license
5
5
6
6
use std:: collections:: BTreeSet ;
7
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
8
+ use std:: fs;
9
+ use std:: iter;
7
10
use std:: ops:: Bound ;
11
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
8
12
use std:: path:: Path ;
9
13
use std:: sync:: Arc ;
10
- use std:: { fs, iter} ;
11
14
12
15
use nostr:: prelude:: * ;
13
16
use nostr_database:: flatbuffers:: FlatBufferDecodeBorrowed ;
@@ -58,6 +61,7 @@ impl Db {
58
61
Ok ( Self { env } )
59
62
}
60
63
64
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
61
65
pub ( crate ) fn persistent < P > ( path : P ) -> Result < Self , Error >
62
66
where
63
67
P : AsRef < Path > ,
@@ -72,6 +76,7 @@ impl Db {
72
76
Self :: new ( env)
73
77
}
74
78
79
+ // TODO: add support to in-memory with limited capacity?
75
80
pub ( crate ) fn in_memory ( ) -> Result < Self , Error > {
76
81
let backend = InMemoryBackend :: new ( ) ;
77
82
let env = Arc :: new ( Database :: builder ( ) . create_with_backend ( backend) ?) ;
Original file line number Diff line number Diff line change 4
4
// Distributed under the MIT software license
5
5
6
6
use std:: collections:: BTreeSet ;
7
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
7
8
use std:: path:: Path ;
8
9
use std:: sync:: Arc ;
9
10
@@ -30,6 +31,7 @@ pub struct Store {
30
31
}
31
32
32
33
impl Store {
34
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
33
35
pub fn persistent < P > ( path : P ) -> Result < Self , Error >
34
36
where
35
37
P : AsRef < Path > ,
You can’t perform that action at this time.
0 commit comments