v_exchanges_api_generics/lib.rs
1#![warn(future_incompatible, let_underscore, nonstandard_style)] //, missing_docs)]
2#![feature(slice_pattern)]
3#![feature(default_field_values)]
4#![feature(try_blocks)]
5#![feature(duration_constructors)]
6#![allow(clippy::result_large_err)]
7
8//! # Generic-API-Client
9//! This is a crate for interacting with HTTP/HTTPS/WebSocket APIs.
10//! It is named "generic" because you can use the **same** client to interact with **multiple different**
11//! APIs with, different authentication methods, data formats etc.
12//!
13//! This crate provides
14//! - [Client][http::Client] A HTTP/HTTPS client
15//! - [WebSocketConnection][websocket::WebSocketConnection] A `struct` to manage WebSocket connections
16//! - [RequestHandler][http::RequestHandler] A `trait` for implementing features like authentication on your requests
17//! - [WebSocketHandler][websocket::WebSocketHandler] A `trait` that is used to handle messages etc.. for a WebSocket Connection.
18//!
19//! For a more detailed documentation, see the links above.
20
21pub mod http;
22pub mod ws;
23pub extern crate reqwest;
24pub extern crate tokio_tungstenite;
25
26#[derive(Debug, derive_more::Display, thiserror::Error, derive_more::From)]
27#[non_exhaustive]
28pub enum AuthError {
29 MissingPubkey,
30 MissingSecret,
31 InvalidCharacterInApiKey(String),
32 Other(eyre::Report),
33}
34
35#[derive(Debug, thiserror::Error)]
36pub enum UrlError {
37 #[error("Failed to parse URL: {0}")]
38 Parse(#[from] url::ParseError),
39 #[error("Exchange does not provide testnet for requested endpoint: {0}")]
40 MissingTestnet(url::Url),
41}