21 lines
482 B
Rust
21 lines
482 B
Rust
use std::path::PathBuf;
|
|
use std::sync::Arc;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub enum ZipSource {
|
|
Local(&'static [u8]),
|
|
File(PathBuf),
|
|
}
|
|
|
|
impl ZipSource {
|
|
pub async fn load(self) -> Result<Arc<[u8]>, std::io::Error> {
|
|
match self {
|
|
ZipSource::Local(bytes) => Ok(Arc::from(bytes)),
|
|
ZipSource::File(path) => {
|
|
let bytes = tokio::fs::read(&path).await?;
|
|
Ok(Arc::from(bytes.as_slice()))
|
|
}
|
|
}
|
|
}
|
|
}
|