lol-cal
terminal lolesports schedule viewer
git clone https://jhhm.no/repos/lol-cal.git
lol-cal/src/net/mod.rs
get raw file: mod.rs
1use reqwest::StatusCode; 2use std::fmt; 3 4pub mod leagues; 5pub mod schedule; 6 7const X_API_KEY_NAME: &str = "x-api-key"; 8const X_API_KEY_VALUE: &str = "0TvQnueqKa5mxJntVWt0w4LpLfEkrV1Ta8rQBb9Z"; 9 10#[derive(Debug)] 11pub enum Error { 12 Http(reqwest::Error), 13 Request(StatusCode), 14 Deserialize(String), 15} 16 17impl fmt::Display for Error { 18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 19 match self { 20 Error::Http(e) => write!(f, "HTTP error: {}", e), 21 Error::Request(e) => write!(f, "Request error: {}", e), 22 Error::Deserialize(e) => write!(f, "Deserialize error: {}", e), 23 } 24 } 25} 26 27impl std::error::Error for Error { 28 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { 29 match self { 30 Error::Http(e) => Some(e), 31 Error::Request(_) => None, 32 Error::Deserialize(_) => None, 33 } 34 } 35} 36 37impl From<reqwest::Error> for Error { 38 fn from(error: reqwest::Error) -> Self { 39 Error::Http(error) 40 } 41}