1mod decode;
2mod encode;
3mod lzw;
4mod quant;
5
6pub use decode::{Animation, Decoder, Disposal, Frame, decode};
7pub use encode::{EncodeOptions, Encoder, PaletteMode, encode};
8pub use quant::{Dither, Histogram, Palette};
9
10use std::fmt;
11
12#[derive(Debug, Clone, PartialEq, Eq)]
13pub enum Error {
14 NotGif,
15 Truncated,
16 Invalid(&'static str),
17}
18
19impl fmt::Display for Error {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 Error::NotGif => f.write_str("not a GIF file"),
23 Error::Truncated => f.write_str("truncated GIF"),
24 Error::Invalid(s) => write!(f, "invalid GIF: {s}"),
25 }
26 }
27}
28
29impl std::error::Error for Error {}
30
31impl From<Error> for crate::media::Error {
32 fn from(e: Error) -> Self {
33 crate::media::Error::Invalid(format!("gif: {e}"))
34 }
35}
36
37pub type Result<T> = std::result::Result<T, Error>;
38
39#[cfg(test)]
40mod tests;