near_jsonrpc_client/methods/network_info.rs
1//! Queries the current state of node network connections.
2//!
3//! This includes information about active peers, transmitted data, known producers, etc.
4//!
5//! ## Example
6//!
7//! ```
8//! use near_jsonrpc_client::{methods, JsonRpcClient};
9//!
10//! # #[tokio::main]
11//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
12//! let client = JsonRpcClient::connect("https://rpc.testnet.near.org");
13//!
14//! let request = methods::network_info::RpcNetworkInfoRequest;
15//!
16//! let response = client.call(request).await;
17//!
18//! assert!(matches!(
19//! response,
20//! Ok(methods::network_info::RpcNetworkInfoResponse { .. })
21//! ));
22//! # Ok(())
23//! # }
24//! ```
25use super::*;
26
27pub use near_jsonrpc_primitives::types::network_info::{
28 RpcNetworkInfoError, RpcNetworkInfoResponse,
29};
30
31#[derive(Debug)]
32pub struct RpcNetworkInfoRequest;
33
34impl RpcHandlerResponse for RpcNetworkInfoResponse {}
35
36impl RpcHandlerError for RpcNetworkInfoError {}
37
38impl RpcMethod for RpcNetworkInfoRequest {
39 type Response = RpcNetworkInfoResponse;
40 type Error = RpcNetworkInfoError;
41
42 fn method_name(&self) -> &str {
43 "network_info"
44 }
45
46 fn params(&self) -> Result<serde_json::Value, io::Error> {
47 Ok(json!(null))
48 }
49}
50
51impl private::Sealed for RpcNetworkInfoRequest {}