#[cfg(feature = "cb7")]
#[cfg_attr(docsrs, doc(cfg(feature = "cb7")))]
pub mod cb7;
#[cfg(feature = "cbt")]
#[cfg_attr(docsrs, doc(cfg(feature = "cbt")))]
pub mod cbt;
#[cfg(feature = "cbz")]
#[cfg_attr(docsrs, doc(cfg(feature = "cbz")))]
pub mod cbz;
#[cfg(feature = "comicinfo")]
#[cfg_attr(docsrs, doc(cfg(feature = "comicinfo")))]
pub mod comicinfo;
pub trait ComicBookReader {
type Error;
fn pages_unordered(&self) -> Vec<String>;
fn pages(&self) -> Vec<String> {
let mut images = self.pages_unordered();
images.sort_by_key(|s| s.to_lowercase());
images
}
fn get_file(&mut self, file: &str) -> Result<Vec<u8>, Self::Error>;
fn get_page_by_path(&mut self, image: &str) -> Result<Vec<u8>, Self::Error> {
self.get_file(image)
}
fn get_page_by_index(&mut self, index: usize) -> Result<Option<Vec<u8>>, Self::Error> {
let images = self.pages();
let Some(image_path) = images.get(index) else {
return Ok(None);
};
Ok(Some(self.get_page_by_path(image_path)?))
}
fn get_page_by_index_unordered(
&mut self,
index: usize,
) -> Result<Option<Vec<u8>>, Self::Error> {
let images = self.pages_unordered();
let Some(image_path) = images.get(index) else {
return Ok(None);
};
Ok(Some(self.get_page_by_path(image_path)?))
}
}