use std::path::PathBuf;
#[derive(Debug, Clone, Default)]
pub enum StorageMode {
#[default]
InMemory,
ArrowIpc {
path: PathBuf,
},
Parquet {
path: PathBuf,
},
#[cfg(feature = "cloud-storage")]
S3Parquet {
url: String,
},
#[cfg(feature = "cloud-storage")]
GcsParquet {
url: String,
},
}
impl StorageMode {
pub fn base_path(&self) -> Option<&PathBuf> {
match self {
Self::InMemory => None,
Self::ArrowIpc { path } | Self::Parquet { path } => Some(path),
#[cfg(feature = "cloud-storage")]
Self::S3Parquet { .. } | Self::GcsParquet { .. } => None,
}
}
pub fn file_extension(&self) -> &'static str {
match self {
Self::InMemory => "",
Self::ArrowIpc { .. } => "arrow",
Self::Parquet { .. } => "parquet",
#[cfg(feature = "cloud-storage")]
Self::S3Parquet { .. } | Self::GcsParquet { .. } => "parquet",
}
}
#[cfg(feature = "cloud-storage")]
pub fn cloud_base_url(&self) -> Option<&str> {
match self {
Self::S3Parquet { url } | Self::GcsParquet { url } => Some(url.as_str()),
_ => None,
}
}
pub fn is_cloud(&self) -> bool {
#[cfg(feature = "cloud-storage")]
{
matches!(self, Self::S3Parquet { .. } | Self::GcsParquet { .. })
}
#[cfg(not(feature = "cloud-storage"))]
{
false
}
}
}