mod fallback;
pub use fallback::*;
#[cfg(feature = "fs-embed")]
mod embed;
#[cfg(feature = "fs-embed")]
pub use embed::*;
#[cfg(feature = "fs-native")]
mod native;
#[cfg(feature = "fs-native")]
pub use native::*;
use async_trait::async_trait;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum FilesystemError {
#[error("I/O: {0}")]
Io(#[from] std::io::Error),
#[error("Writing is unsupported on this filesystem")]
WriteUnsupported,
#[error("Asset not found: {0}")]
NotFound(String),
#[error(transparent)]
Other(anyhow::Error),
}
#[async_trait]
pub trait Filesystem: Send + Sync {
async fn read_bytes(&self, asset_path: &str) -> Result<Vec<u8>, FilesystemError>;
#[allow(unused_variables)]
async fn write_bytes(&self, asset_path: &str, data: &[u8]) -> Result<(), FilesystemError> {
Err(FilesystemError::WriteUnsupported)
}
}