use async_trait::async_trait;
use std::collections::HashMap;
use crate::error::Result;
use crate::spec::{NamespaceIdent, TableCreation, TableIdent};
use crate::table::Table;
#[cfg_attr(not(target_family = "wasm"), async_trait)]
#[cfg_attr(target_family = "wasm", async_trait(?Send))]
pub trait Catalog: Send + Sync {
async fn create_namespace(
&self,
namespace: &NamespaceIdent,
properties: HashMap<String, String>,
) -> Result<()>;
async fn namespace_exists(&self, namespace: &NamespaceIdent) -> Result<bool>;
async fn list_tables(&self, namespace: &NamespaceIdent) -> Result<Vec<TableIdent>>;
async fn table_exists(&self, identifier: &TableIdent) -> Result<bool>;
async fn create_table(
&self,
namespace: &NamespaceIdent,
creation: TableCreation,
) -> Result<Table>;
async fn load_table(&self, identifier: &TableIdent) -> Result<Table>;
async fn drop_table(&self, identifier: &TableIdent) -> Result<()>;
async fn update_table_metadata(
&self,
identifier: &TableIdent,
old_metadata_location: &str,
new_metadata_location: &str,
) -> Result<()>;
}