use crate::dataset::Result;
use async_trait::async_trait;
use vantage_core::Entity;
#[async_trait]
pub trait DataSetSource: Send + Sync {
async fn list_datasets(&self) -> Result<Vec<String>>;
async fn get_dataset_info(&self, name: &str) -> Result<Option<serde_json::Value>>;
async fn has_dataset(&self, name: &str) -> Result<bool> {
let candidates = self.list_datasets().await?;
Ok(candidates.contains(&name.to_string()))
}
}
#[async_trait]
pub trait ReadableDataSetSource: DataSetSource {
type DataSet<E: Entity>: crate::dataset::ReadableDataSet<E> + Send + Sync;
async fn get_readable<E: Entity>(&self, name: &str) -> Result<Option<Self::DataSet<E>>>;
}
#[async_trait]
pub trait InsertableDataSetSource: DataSetSource {
type DataSet<E: Entity>: crate::dataset::InsertableDataSet<E> + Send + Sync;
async fn get_insertable<E: Entity>(&self, name: &str) -> Result<Option<Self::DataSet<E>>>;
}
#[async_trait]
pub trait WritableDataSetSource: DataSetSource {
type DataSet<E: Entity>: crate::dataset::WritableDataSet<E> + Send + Sync;
async fn get_writable<E: Entity>(&self, name: &str) -> Result<Option<Self::DataSet<E>>>;
}