use crate::{LibraryError, LibraryResult}; use serde::Deserialize; #[derive(serde::Deserialize)] #[serde(rename_all = "snake_case")] pub enum APIErrorType { InvalidGrant, } #[derive(Deserialize)] pub(crate) struct APIError { pub error: APIErrorType, pub error_description: String, } // mostly used in the aggregated endpoint #[derive(serde::Deserialize)] #[serde(untagged)] pub(crate) enum APIResult { APIError(APIError), Okay(T), } impl Into> for APIResult { fn into(self) -> LibraryResult { match self { APIResult::APIError(err) => { return Err(LibraryError::from(err)); } APIResult::Okay(res) => { return Ok(res); } } } }