1
+ use async_trait:: async_trait;
1
2
use std:: collections:: HashMap ;
2
3
use std:: future:: Future ;
3
- use std:: pin:: Pin ;
4
4
use std:: sync:: Arc ;
5
5
6
6
use iceberg:: { Catalog , CatalogBuilder , Error , ErrorKind , Result } ;
7
7
use iceberg_catalog_rest:: RestCatalogBuilder ;
8
8
9
- type BoxedCatalogBuilderFuture = Pin < Box < dyn Future < Output = Result < Arc < dyn Catalog > > > > > ;
10
-
9
+ #[ async_trait]
11
10
pub trait BoxedCatalogBuilder {
12
- fn load ( self : Box < Self > , name : String , props : HashMap < String , String > ) -> BoxedCatalogBuilderFuture ;
11
+ async fn load ( self : Box < Self > , name : String , props : HashMap < String , String > ) -> Result < Arc < dyn Catalog > > ;
13
12
}
14
13
14
+ #[ async_trait]
15
15
impl < T : CatalogBuilder + ' static > BoxedCatalogBuilder for T {
16
- fn load ( self : Box < Self > , name : String , props : HashMap < String , String > ) -> BoxedCatalogBuilderFuture {
16
+ async fn load ( self : Box < Self > , name : String , props : HashMap < String , String > ) -> Result < Arc < dyn Catalog > > {
17
17
let builder = * self ;
18
- Box :: pin ( async move { Ok ( Arc :: new ( builder. load ( name, props) . await . unwrap ( ) ) as Arc < dyn Catalog > ) } )
18
+ Ok ( Arc :: new ( builder. load ( name, props) . await . unwrap ( ) ) as Arc < dyn Catalog > )
19
19
}
20
20
}
21
21
@@ -36,7 +36,7 @@ mod tests {
36
36
37
37
#[ tokio:: test]
38
38
async fn test_load ( ) {
39
- let mut catalog = load ( "rest" ) . unwrap ( ) ;
39
+ let catalog = load ( "rest" ) . unwrap ( ) ;
40
40
catalog. load ( "rest" . to_string ( ) , HashMap :: from (
41
41
[ ( "key" . to_string ( ) , "value" . to_string ( ) ) ]
42
42
) ) . await . unwrap ( ) ;
0 commit comments