use crate::error::Result;
use crate::types::{DecodedFrame, GifMetadata};
use std::io::Read;
use std::path::Path;
pub trait GifDecoder: Send + Sync {
type FrameIter: Iterator<Item = Result<DecodedFrame>>;
fn decode_file(&self, path: impl AsRef<Path>) -> Result<Self::FrameIter>;
fn decode_bytes(&self, data: &[u8]) -> Result<Self::FrameIter>;
fn decode_reader<R: Read + Send>(&self, reader: R) -> Result<Self::FrameIter>;
fn metadata_from_bytes(&self, data: &[u8]) -> Result<GifMetadata>;
fn metadata_from_file(&self, path: impl AsRef<Path>) -> Result<GifMetadata>;
fn name(&self) -> &'static str;
}
pub trait BufferedGifDecoder: GifDecoder {
fn decode_all(&self, data: &[u8]) -> Result<Vec<DecodedFrame>> {
self.decode_bytes(data)?.collect()
}
fn decode_all_from_file(&self, path: impl AsRef<Path>) -> Result<Vec<DecodedFrame>> {
self.decode_file(path)?.collect()
}
}