swf_emitter/
error.rs

1use std::fmt;
2use std::error::Error;
3use std::io;
4
5use swf_types::CompressionMethod;
6
7#[derive(Debug)]
8pub enum SwfEmitError {
9    Io(io::Error),
10    UnsupportedCompression(CompressionMethod),
11}
12
13impl Error for SwfEmitError {
14    fn source(&self) -> Option<&(dyn Error + 'static)> {
15        match self {
16            Self::Io(err) => Some(err),
17            _ => None,
18        }
19    }
20}
21
22impl fmt::Display for SwfEmitError {
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        match self {
25            Self::Io(err) => fmt::Display::fmt(err, f),
26            Self::UnsupportedCompression(method) => write!(f, "Unsupported compression method: {:?}", method),
27        }
28    }
29}