Skip to content

Commit f4a2efe

Browse files
committed
Fix clippy
1 parent 2d494d5 commit f4a2efe

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/catalog/loader/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ repository = { workspace = true }
1414
[dependencies]
1515
iceberg = { workspace = true }
1616
iceberg-catalog-rest = {workspace = true}
17+
tokio = { workspace = true }

crates/catalog/loader/src/lib.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
use std::future::Future;
2+
use std::pin::Pin;
23
use std::sync::Arc;
34

45
use iceberg::{Catalog, CatalogBuilder, Error, ErrorKind, Result};
56
use iceberg_catalog_rest::RestCatalogBuilder;
67

8+
type BoxedCatalogBuilderFuture = Pin<Box<dyn Future<Output = Result<Arc<dyn Catalog>>>>>;
9+
710
pub trait BoxedCatalogBuilder {
811
fn name(&mut self, name: String);
912
fn uri(&mut self, uri: String);
1013
fn warehouse(&mut self, warehouse: String);
1114
fn with_prop(&mut self, key: String, value: String);
1215

13-
fn build(self: Box<Self>) -> Box<dyn Future<Output = Result<Arc<dyn Catalog>>>>;
16+
fn build(self: Box<Self>) -> BoxedCatalogBuilderFuture;
1417
}
1518

1619
impl<T: CatalogBuilder + 'static> BoxedCatalogBuilder for T {
@@ -30,9 +33,9 @@ impl<T: CatalogBuilder + 'static> BoxedCatalogBuilder for T {
3033
self.with_prop(key, value);
3134
}
3235

33-
fn build(self: Box<Self>) -> Box<dyn Future<Output = Result<Arc<dyn Catalog>>>> {
36+
fn build(self: Box<Self>) -> BoxedCatalogBuilderFuture {
3437
let builder = *self;
35-
Box::new(async move { Ok(Arc::new(builder.build().await.unwrap()) as Arc<dyn Catalog>) })
38+
Box::pin(async move { Ok(Arc::new(builder.build().await.unwrap()) as Arc<dyn Catalog>) })
3639
}
3740
}
3841

@@ -45,3 +48,17 @@ pub fn load(r#type: &str) -> Result<Box<dyn BoxedCatalogBuilder>> {
4548
)),
4649
}
4750
}
51+
52+
#[cfg(test)]
53+
mod tests {
54+
use crate::load;
55+
56+
#[tokio::test]
57+
async fn test_load() {
58+
let mut catalog = load("rest").unwrap();
59+
catalog.name("rest".to_string());
60+
catalog.with_prop("key".to_string(), "value".to_string());
61+
62+
catalog.build().await.unwrap();
63+
}
64+
}

0 commit comments

Comments
 (0)