@@ -11,10 +11,10 @@ export interface Repository<T> {
11
11
"# ;
12
12
13
13
macro_rules! create_wasm_repository {
14
- ( $name: ident, $ty: ty) => {
14
+ ( $name: ident, $ty: ty, $typescript_ty : literal ) => {
15
15
#[ wasm_bindgen]
16
16
extern "C" {
17
- #[ wasm_bindgen( js_name = $name, typescript_type = "Repository<Cipher>" ) ]
17
+ #[ wasm_bindgen( js_name = $name, typescript_type = $typescript_ty ) ]
18
18
pub type $name;
19
19
20
20
#[ wasm_bindgen( method, catch) ]
@@ -44,20 +44,20 @@ macro_rules! create_wasm_repository {
44
44
) -> :: std:: sync:: Arc <impl bitwarden_core:: client:: repository:: Repository <$ty>> {
45
45
use :: bitwarden_core:: client:: repository:: * ;
46
46
47
- use crate :: platform:: repository:: __macro_internal:: * ;
47
+ use $ crate:: platform:: repository:: __macro_internal:: * ;
48
48
49
- struct Store ( :: bitwarden_threading:: ThreadBoundRunner <CipherRepository >) ;
49
+ struct Store ( :: bitwarden_threading:: ThreadBoundRunner <$name >) ;
50
50
let store = Store ( :: bitwarden_threading:: ThreadBoundRunner :: new( self ) ) ;
51
51
52
52
#[ async_trait:: async_trait]
53
- impl Repository <Cipher > for Store {
54
- async fn get( & self , id: String ) -> Result <Option <Cipher >, RepositoryError > {
53
+ impl Repository <$ty > for Store {
54
+ async fn get( & self , id: String ) -> Result <Option <$ty >, RepositoryError > {
55
55
run_convert( & self . 0 , |s| async move { s. get( id) . await } ) . await
56
56
}
57
- async fn list( & self ) -> Result <Vec <Cipher >, RepositoryError > {
57
+ async fn list( & self ) -> Result <Vec <$ty >, RepositoryError > {
58
58
run_convert( & self . 0 , |s| async move { s. list( ) . await } ) . await
59
59
}
60
- async fn set( & self , id: String , value: Cipher ) -> Result <( ) , RepositoryError > {
60
+ async fn set( & self , id: String , value: $ty ) -> Result <( ) , RepositoryError > {
61
61
run_convert( & self . 0 , |s| async move { s. set( id, value) . await . and( UNIT ) } )
62
62
. await
63
63
}
0 commit comments