#![forbid(unsafe_code)]
#![allow(unexpected_cfgs)]
extern crate alloc;
whereat::define_at_crate_info!();
pub mod classify;
#[allow(dead_code)]
pub mod color;
#[allow(dead_code)]
pub mod decode;
pub mod demosaic;
#[allow(dead_code)]
pub mod dng_render;
#[allow(dead_code)]
pub(crate) mod dt_sigmoid;
mod error;
#[allow(dead_code)]
mod orient;
mod simd;
#[allow(dead_code)]
pub(crate) mod tiff_ifd;
#[cfg(feature = "rawler")]
mod rawler_backend;
#[cfg(feature = "darktable")]
pub mod darktable;
#[cfg(feature = "exif")]
pub mod exif;
#[cfg(feature = "xmp")]
#[allow(dead_code)]
pub mod xmp;
#[cfg(feature = "apple")]
#[allow(dead_code)]
pub mod apple;
#[cfg(feature = "zencodec")]
mod zencodec_impl;
#[cfg(feature = "zencodec")]
pub use zencodec_impl::{DNG_FORMAT, RAW_FORMAT, RawDecoderConfig};
pub use classify::{FileFormat, classify};
pub use decode::{OutputMode, RawDecodeConfig, RawDecodeOutput, RawInfo, SensorLayout};
pub use demosaic::DemosaicMethod;
pub use dng_render::OutputPrimaries;
pub use error::RawError;
#[allow(clippy::needless_return)]
pub fn decode(
data: &[u8],
config: &decode::RawDecodeConfig,
stop: &dyn enough::Stop,
) -> crate::error::Result<decode::RawDecodeOutput> {
#[cfg(feature = "rawler")]
{
return rawler_backend::decode(data, config, stop);
}
#[cfg(all(feature = "rawloader", not(feature = "rawler")))]
{
return decode::decode(data, config, stop);
}
#[cfg(not(any(feature = "rawloader", feature = "rawler")))]
{
let _ = (data, config, stop);
Err(whereat::at!(RawError::Unsupported(
"no decode backend enabled — enable `rawloader` or `rawler` feature".into()
)))
}
}
#[allow(clippy::needless_return)]
pub fn probe(data: &[u8], stop: &dyn enough::Stop) -> crate::error::Result<decode::RawInfo> {
#[cfg(feature = "rawler")]
{
return rawler_backend::probe(data, stop);
}
#[cfg(all(feature = "rawloader", not(feature = "rawler")))]
{
return decode::probe(data, stop);
}
#[cfg(not(any(feature = "rawloader", feature = "rawler")))]
{
let _ = (data, stop);
Err(whereat::at!(RawError::Unsupported(
"no decode backend enabled — enable `rawloader` or `rawler` feature".into()
)))
}
}
pub fn is_raw_file(data: &[u8]) -> bool {
decode::is_raw_file(data)
}
pub type Result<T> = core::result::Result<T, whereat::At<RawError>>;