newsdata_io_api/
lib.rs

1use std::fmt::{self, Display, Formatter};
2use ureq::serde_json;
3
4pub mod apis;
5pub mod newsdata_io;
6pub use newsdata_io::NewsdataIO;
7
8pub type Json = serde_json::Value;
9pub type ApiResult<T> = Result<T, Error>;
10
11#[derive(Debug)]
12pub enum Error {
13    /// An Error returned by the API
14    ApiError(String),
15    /// An Error not related to the API
16    RequestError(String),
17}
18
19impl Display for Error {
20    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
21        match self {
22            Error::ApiError(msg) => write!(f, "API error: {}", msg),
23            Error::RequestError(msg) => write!(f, "Request error: {}", msg),
24        }
25    }
26}