grab_meta/
meta_error.rs

1
2/*
3*  MetaError is an enum contains all error for this lib
4*/
5#[derive(Debug)]
6pub enum MetaError {
7    RequestError(reqwest::Error),
8    ParseError(serde_json::Error),
9    SomeError(&'static str),
10}
11
12/*
13* implement From for MetaError -> serde_json::Error
14*/
15impl From<serde_json::Error> for MetaError {
16    fn from(e: serde_json::Error) -> Self {
17        MetaError::ParseError(e)
18    }
19}
20
21/*
22* implement From for MetaError -> reqwest::Error
23*/
24impl From<reqwest::Error> for MetaError {
25    fn from(e: reqwest::Error) -> Self {
26        MetaError::RequestError(e)
27    }
28}
29
30/*
31* implement From for MetaError -> String / any error
32*/
33impl From<&'static str> for MetaError {
34    fn from(e: &'static str) -> Self {
35        MetaError::SomeError(e)
36    }
37}