1 use bytesio::bits_errors::BitError; 2 use failure::{Backtrace, Fail}; 3 use std::fmt; 4 5 #[derive(Debug, Fail)] 6 pub enum H264ErrorValue { 7 #[fail(display = "bit error")] 8 BitError(BitError), 9 } 10 #[derive(Debug)] 11 pub struct H264Error { 12 pub value: H264ErrorValue, 13 } 14 15 impl From<BitError> for H264Error { from(error: BitError) -> Self16 fn from(error: BitError) -> Self { 17 H264Error { 18 value: H264ErrorValue::BitError(error), 19 } 20 } 21 } 22 23 impl fmt::Display for H264Error { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result24 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 25 fmt::Display::fmt(&self.value, f) 26 } 27 } 28 29 impl Fail for H264Error { cause(&self) -> Option<&dyn Fail>30 fn cause(&self) -> Option<&dyn Fail> { 31 self.value.cause() 32 } 33 backtrace(&self) -> Option<&Backtrace>34 fn backtrace(&self) -> Option<&Backtrace> { 35 self.value.backtrace() 36 } 37 } 38