glide_rs/
lib.rs

1#![forbid(unsafe_code)]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3#![doc = include_str!("../README.md")]
4
5pub use builder::Builder;
6pub use client::Client;
7pub(crate) use config::Config;
8
9mod builder;
10mod client;
11mod config;
12mod error;
13pub mod lang;
14
15pub mod types {
16    //! Request and response types.
17    //!
18
19    pub use super::error::{ErrorKind, ErrorResponse};
20}
21
22/// Error type for a [`Client`].
23#[must_use]
24#[derive(Debug, thiserror::Error)]
25pub enum Error {
26    /// Errors that may occur during the processing of an HTTP request.
27    #[error("http error: {0}")]
28    Http(#[from] reqwest::Error),
29
30    /// Errors that may occur during the processing of a WS request.
31    #[cfg(feature = "streaming")]
32    #[cfg_attr(docsrs, doc(cfg(feature = "streaming")))]
33    #[error("websocket error: {0}")]
34    Ws(#[from] reqwest_websocket::Error),
35
36    /// Errors that may occur during the processing of an API request.
37    #[error("api error: {0}")]
38    Api(#[from] types::ErrorResponse),
39}
40
41/// Specialized [`Result`] type for an [`Error`].
42///
43/// [`Result`]: std::result::Result
44pub type Result<T, E = Error> = std::result::Result<T, E>;