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