use crate::error_chirho::ResultChirho;
pub trait StorageBackendChirho: Send + Sync {
fn read_file_chirho(&self, path_chirho: &str) -> ResultChirho<Vec<u8>>;
fn read_range_chirho(
&self,
path_chirho: &str,
offset_chirho: u64,
len_chirho: usize,
) -> ResultChirho<Vec<u8>>;
fn write_file_chirho(&self, path_chirho: &str, data_chirho: &[u8]) -> ResultChirho<()>;
fn file_exists_chirho(&self, path_chirho: &str) -> bool;
fn list_dir_chirho(&self, path_chirho: &str) -> ResultChirho<Vec<String>>;
fn create_dir_chirho(&self, path_chirho: &str) -> ResultChirho<()>;
fn file_size_chirho(&self, path_chirho: &str) -> ResultChirho<u64>;
fn append_file_chirho(&self, path_chirho: &str, data_chirho: &[u8]) -> ResultChirho<()>;
}
#[cfg(not(target_arch = "wasm32"))]
pub fn get_default_backend_chirho() -> Box<dyn StorageBackendChirho> {
Box::new(super::native_backend_chirho::NativeBackendChirho::new_chirho())
}
#[cfg(target_arch = "wasm32")]
pub fn get_default_backend_chirho() -> Box<dyn StorageBackendChirho> {
Box::new(super::wasm_backend_chirho::WasmBackendChirho::new_chirho())
}
#[cfg(test)]
mod tests_chirho {
use super::*;
#[test]
fn test_backend_trait_object_safety_chirho() {
fn _takes_backend_chirho(_b_chirho: &dyn StorageBackendChirho) {}
}
}