jsonrpsee_http_client/
lib.rs

1// Copyright 2019-2021 Parity Technologies (UK) Ltd.
2//
3// Permission is hereby granted, free of charge, to any
4// person obtaining a copy of this software and associated
5// documentation files (the "Software"), to deal in the
6// Software without restriction, including without
7// limitation the rights to use, copy, modify, merge,
8// publish, distribute, sublicense, and/or sell copies of
9// the Software, and to permit persons to whom the Software
10// is furnished to do so, subject to the following
11// conditions:
12//
13// The above copyright notice and this permission notice
14// shall be included in all copies or substantial portions
15// of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25// DEALINGS IN THE SOFTWARE.
26
27//! # jsonrpsee-http-client
28//!
29//! `jsonrpsee-http-client` is [JSON RPC](https://www.jsonrpc.org/specification) HTTP client library that's is built for `async/await`.
30//!
31//! It is tightly-coupled to [`tokio`](https://docs.rs/tokio) because [`hyper`](https://docs.rs/hyper) is used as transport client,
32//! which is not compatible with other async runtimes such as
33//! [`async-std`](https://docs.rs/async-std/), [`smol`](https://docs.rs/smol) and similar.
34
35#![cfg_attr(not(test), warn(unused_crate_dependencies))]
36#![cfg_attr(docsrs, feature(doc_cfg))]
37
38mod client;
39mod rpc_service;
40
41/// HTTP transport.
42pub mod transport;
43
44#[cfg(test)]
45mod tests;
46
47pub use client::{HttpClient, HttpClientBuilder};
48pub use hyper::http::{HeaderMap, HeaderValue};
49pub use jsonrpsee_types as types;
50
51/// Default HTTP body for the client.
52pub type HttpBody = jsonrpsee_core::http_helpers::Body;
53/// HTTP request with default body.
54pub type HttpRequest<T = HttpBody> = jsonrpsee_core::http_helpers::Request<T>;
55/// HTTP response with default body.
56pub type HttpResponse<T = HttpBody> = jsonrpsee_core::http_helpers::Response<T>;
57
58/// Custom TLS configuration.
59#[cfg(feature = "tls")]
60pub type CustomCertStore = rustls::ClientConfig;
61
62#[cfg(feature = "tls")]
63// rustls needs the concrete `ClientConfig` type so we can't Box it here.
64#[allow(clippy::large_enum_variant)]
65#[derive(Clone, Debug)]
66pub(crate) enum CertificateStore {
67	Native,
68	Custom(CustomCertStore),
69}