near_jsonrpc_client/methods/health.rs
1//! Requests the health status of the RPC node.
2//!
3//! ## Example
4//!
5//! Returns the current health stauts of the RPC node the client connects to.
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::health::RpcHealthRequest;
15//!
16//! let response = client.call(request).await?;
17//!
18//! assert!(matches!(
19//! response,
20//! methods::health::RpcHealthResponse
21//! ));
22//! # Ok(())
23//! # }
24//! ```
25use super::*;
26
27pub use near_jsonrpc_primitives::types::status::{RpcHealthResponse, RpcStatusError};
28
29#[derive(Debug)]
30pub struct RpcHealthRequest;
31
32impl RpcHandlerResponse for RpcHealthResponse {}
33
34impl RpcMethod for RpcHealthRequest {
35 type Response = RpcHealthResponse;
36 type Error = RpcStatusError;
37
38 fn method_name(&self) -> &str {
39 "health"
40 }
41
42 fn params(&self) -> Result<serde_json::Value, io::Error> {
43 Ok(json!(null))
44 }
45}
46
47impl private::Sealed for RpcHealthRequest {}