cometbft_rpc/lib.rs
1//! CometBFT RPC definitions and types.
2//!
3//! ## Client
4//!
5//! This crate optionally provides access to different types of RPC client
6//! functionality and different client transports based on which features you
7//! select when using it.
8//!
9//! Several client-related features are provided at present:
10//!
11//! * `http-client` - Provides [`HttpClient`], which is a basic RPC client that interacts with
12//! remote CometBFT nodes via **JSON-RPC over HTTP or HTTPS**. This client does not provide
13//! [`event::Event`] subscription functionality. See the [CometBFT RPC] for more details.
14//! * `websocket-client` - Provides [`WebSocketClient`], which provides full client functionality,
15//! including general RPC functionality as well as [`event::Event`] subscription functionality.
16//! Can be used over secure (`wss://`) and unsecure (`ws://`) connections.
17//!
18//! ### Mock Clients
19//!
20//! Mock clients are included when either of the `http-client` or
21//! `websocket-client` features are enabled to aid in testing. This includes
22//! [`MockClient`], which implements both [`Client`] and [`SubscriptionClient`]
23//! traits.
24//!
25//! [CometBFT RPC]: https://docs.cometbft.com/v1/rpc/
26//! [`/subscribe` endpoint]: https://docs.cometbft.com/v1/rpc/#/Websocket/subscribe
27
28#![no_std]
29
30extern crate alloc;
31extern crate std;
32
33mod prelude;
34
35pub mod client;
36
37#[cfg(any(feature = "http-client", feature = "websocket-client"))]
38pub use client::{
39 Client, MockClient, MockRequestMatcher, MockRequestMethodMatcher, Subscription,
40 SubscriptionClient,
41};
42#[cfg(feature = "http-client")]
43pub use client::{HttpClient, HttpClientUrl};
44#[cfg(feature = "websocket-client")]
45pub use client::{WebSocketClient, WebSocketClientDriver, WebSocketClientUrl, WebSocketConfig};
46
47pub mod dialect;
48pub mod endpoint;
49pub mod error;
50pub mod event;
51mod id;
52mod method;
53mod order;
54mod paging;
55pub mod query;
56pub mod request;
57pub mod response;
58pub mod response_error;
59mod rpc_url;
60pub mod serializers;
61mod utils;
62mod version;
63
64pub use error::Error;
65pub use id::Id;
66pub use method::Method;
67pub use order::Order;
68pub use paging::{PageNumber, Paging, PerPage};
69pub use request::{Request, SimpleRequest};
70pub use response::Response;
71pub use response_error::{Code, ResponseError};
72pub use rpc_url::{Scheme, Url};
73pub use version::Version;