use crate::core::error::XmpResult;
use crate::core::metadata::XmpMeta;
use std::io::{Read, Seek, Write};
#[derive(Default, Clone, Copy, Debug)]
pub struct XmpOptions {
pub for_update: bool,
pub only_xmp: bool,
pub force_given_handler: bool,
pub strict: bool,
pub use_smart_handler: bool,
pub use_packet_scanning: bool,
pub limited_scanning: bool,
}
impl XmpOptions {
pub fn for_read(mut self) -> Self {
self.for_update = false;
self
}
pub fn for_update(mut self) -> Self {
self.for_update = true;
self
}
pub fn only_xmp(mut self) -> Self {
self.only_xmp = true;
self
}
pub fn force_given_handler(mut self) -> Self {
self.force_given_handler = true;
self
}
pub fn strict(mut self) -> Self {
self.strict = true;
self
}
pub fn use_smart_handler(mut self) -> Self {
self.use_smart_handler = true;
self
}
pub fn use_packet_scanning(mut self) -> Self {
self.use_packet_scanning = true;
self
}
pub fn limited_scanning(mut self) -> Self {
self.limited_scanning = true;
self
}
}
pub trait FileHandler: Send + Sync {
fn can_handle<R: Read + Seek>(&self, reader: &mut R) -> XmpResult<bool>;
fn read_xmp<R: Read + Seek>(
&self,
reader: &mut R,
options: &XmpOptions,
) -> XmpResult<Option<XmpMeta>>;
fn write_xmp<R: Read + Seek, W: Write + Seek>(
&self,
reader: &mut R,
writer: &mut W,
meta: &XmpMeta,
) -> XmpResult<()>;
fn format_name(&self) -> &'static str;
fn extensions(&self) -> &'static [&'static str];
}