Skip to main content

CatalogBuilder

Trait CatalogBuilder 

Source
pub trait CatalogBuilder:
    Default
    + Debug
    + Send
    + Sync {
    type C: Catalog;

    // Required methods
    fn with_storage_factory(
        self,
        storage_factory: Arc<dyn StorageFactory>,
    ) -> Self;
    fn with_kms_client_factory(
        self,
        kms_client_factory: Arc<dyn KmsClientFactory>,
    ) -> Self;
    fn with_runtime(self, runtime: Runtime) -> Self;
    fn load(
        self,
        name: impl Into<String>,
        props: HashMap<String, String>,
    ) -> impl Future<Output = Result<Self::C>> + Send;
}
Expand description

Common interface for all catalog builders.

Required Associated Types§

Source

type C: Catalog

The catalog type that this builder creates.

Required Methods§

Source

fn with_storage_factory(self, storage_factory: Arc<dyn StorageFactory>) -> Self

Set a custom StorageFactory to use for storage operations.

When a StorageFactory is provided, the catalog will use it to build FileIO instances for all storage operations instead of using the default factory.

§Arguments
  • storage_factory - The StorageFactory to use for creating storage instances
§Example
use iceberg::CatalogBuilder;
use iceberg::io::StorageFactory;
use iceberg_storage_opendal::OpenDalStorageFactory;
use std::sync::Arc;

let catalog = MyCatalogBuilder::default()
    .with_storage_factory(Arc::new(OpenDalStorageFactory::S3 {
        customized_credential_load: None,
    }))
    .load("my_catalog", props)
    .await?;
Source

fn with_kms_client_factory( self, kms_client_factory: Arc<dyn KmsClientFactory>, ) -> Self

Set a KmsClientFactory to enable table encryption.

When provided, the catalog calls the factory once during load with the catalog properties to create a shared KeyManagementClient. That client is then passed to each table’s TableBuilder so tables with encryption.key-id set can construct an EncryptionManager.

§Example
use iceberg::CatalogBuilder;
use iceberg::encryption::kms::KmsClientFactory;
use std::sync::Arc;

let catalog = MyCatalogBuilder::default()
    .with_kms_client_factory(Arc::new(MyKmsClientFactory))
    .load("my_catalog", props)
    .await?;
Source

fn with_runtime(self, runtime: Runtime) -> Self

Set a custom tokio Runtime to use for spawning async tasks.

When a Runtime is provided, the catalog will propagate it to all tables it creates. Tasks such as scan planning and delete file processing will be spawned on this runtime.

Source

fn load( self, name: impl Into<String>, props: HashMap<String, String>, ) -> impl Future<Output = Result<Self::C>> + Send

Create a new catalog instance.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§