use crate::draft::Draft;
use crate::error::Result;
use crate::format::Format;
use crate::options::ConvertOptions;
macro_rules! front_ends {
($($feature:literal => $format:ident in $module:ident,)*) => {
$(
#[cfg(feature = $feature)]
mod $module;
)*
pub(crate) fn read(
format: Format,
source: &[u8],
options: &ConvertOptions,
) -> Result<Draft> {
#[cfg(not(any($(feature = $feature),*)))]
let _ = (source, options);
match format {
$(
#[cfg(feature = $feature)]
Format::$format => $module::read(source, options),
#[cfg(not(feature = $feature))]
Format::$format => Err(crate::error::Error::FormatDisabled(format)),
)*
}
}
};
}
front_ends! {
"epub" => Epub in epub,
"fb2" => Fb2 in fb2,
"pdf" => Pdf in pdf,
"cbz" => Cbz in cbz,
"docx" => Docx in docx,
"html" => Html in html,
"md" => Markdown in md,
"txt" => Text in txt,
}