#![warn(missing_docs)]
use feldera_types::config::StorageCacheConfig;
use std::{fs::OpenOptions, path::PathBuf};
use tempfile::TempDir;
use tracing::warn;
pub mod memory_impl;
pub mod posixio_impl;
#[cfg(test)]
mod tests;
pub use feldera_storage::{
FileReader, FileRw, FileWriter, StorageBackend, StorageFileType, StoragePath, StoragePathPart,
block::{BlockLocation, InvalidBlockLocation},
error::StorageError,
file::FileId,
};
const MUTABLE_EXTENSION: &str = ".mut";
pub fn tempdir_for_thread() -> PathBuf {
thread_local! {
pub static TEMPDIR: TempDir = tempfile::tempdir().unwrap();
}
TEMPDIR.with(|dir| dir.path().to_path_buf())
}
trait StorageCacheFlags {
fn cache_flags(&mut self, cache: &StorageCacheConfig) -> &mut Self;
}
impl StorageCacheFlags for OpenOptions {
fn cache_flags(&mut self, cache: &StorageCacheConfig) -> &mut Self {
#[cfg(unix)]
{
use std::os::unix::fs::OpenOptionsExt;
self.custom_flags(cache.to_custom_open_flags());
}
self
}
}