xref: /xiu/protocol/rtmp/src/cache/errors.rs (revision 37ccd32d)
1 use {crate::chunk::errors::PackError, failure::Fail, flvparser::errors::TagParseError, std::fmt};
2 
3 #[derive(Debug, Fail)]
4 pub enum CacheErrorValue {
5     #[fail(display = "tag parse error\n")]
6     TagParseError(TagParseError),
7     #[fail(display = "pack error\n")]
8     PackError(PackError),
9 }
10 
11 impl fmt::Display for CacheError {
12     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13         fmt::Display::fmt(&self.value, f)
14     }
15 }
16 #[derive(Debug)]
17 pub struct CacheError {
18     pub value: CacheErrorValue,
19 }
20 
21 impl From<TagParseError> for CacheError {
22     fn from(error: TagParseError) -> Self {
23         CacheError {
24             value: CacheErrorValue::TagParseError(error),
25         }
26     }
27 }
28 
29 impl From<PackError> for CacheError {
30     fn from(error: PackError) -> Self {
31         CacheError {
32             value: CacheErrorValue::PackError(error),
33         }
34     }
35 }
36 
37 #[derive(Debug, Fail)]
38 pub enum MetadataErrorValue {
39     #[fail(display = "tag parse error\n")]
40     TagParseError(TagParseError),
41     #[fail(display = "pack error\n")]
42     PackError(PackError),
43 }
44 #[derive(Debug)]
45 pub struct MetadataError {
46     pub value: CacheErrorValue,
47 }
48