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