helius_rust_client/client/
mod.rs

1use reqwest::{Error as ReqwestError, Response};
2use serde::Deserialize;
3use solana_client::client_error::{ClientError, ClientErrorKind, Result as ClientResult};
4
5pub mod init;
6pub mod names;
7pub mod tokens;
8pub mod transactions;
9pub mod webhooks;
10
11pub async fn parse_response<T: for<'a> Deserialize<'a>>(
12    response: Result<Response, ReqwestError>,
13) -> ClientResult<T> {
14    match response {
15        Ok(res) => {
16            let payload = res.json().await;
17            match payload {
18                Ok(j) => Ok(j),
19                Err(e) => Err(ClientError::from(ClientErrorKind::Reqwest(e))),
20            }
21        }
22        Err(e) => Err(ClientError::from(ClientErrorKind::Reqwest(e))),
23    }
24}
25
26pub fn api_commitment_error<T>() -> ClientResult<T> {
27    Err(ClientError::from(ClientErrorKind::Custom(
28        "Only Confirmed and Finalized commitments are supported by this API".to_string(),
29    )))
30}