use std::{
fmt,
fs::File,
path::{Path, PathBuf},
sync::Arc,
};
#[cfg(feature = "zip")]
use std::sync::Mutex;
pub enum TypedArchive {
#[cfg(feature = "beth-archives")]
Bethesda(dream_archive::Archive),
#[cfg(feature = "zip")]
Zip(Mutex<zip::ZipArchive<File>>),
}
impl fmt::Debug for TypedArchive {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
#[cfg(feature = "beth-archives")]
Self::Bethesda(_) => f.write_str("TypedArchive::Bethesda"),
#[cfg(feature = "zip")]
Self::Zip(_) => f.write_str("TypedArchive::Zip"),
}
}
}
#[derive(Debug)]
pub struct StoredArchive {
#[allow(dead_code)]
pub(super) file_handle: Option<File>,
pub(super) archive: TypedArchive,
pub(super) path: PathBuf,
}
impl StoredArchive {
#[must_use]
pub fn handle(&self) -> &TypedArchive {
&self.archive
}
#[must_use]
pub fn path(&self) -> &Path {
&self.path
}
}
pub type ArchiveList = Vec<Arc<StoredArchive>>;