essential_rest_client/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#![deny(missing_docs)]

//! Client libraries for interacting with the Essential builder and the Essential node.

/// Client library for sending requests to the Essential builder.
pub mod builder_client;

/// Client library for sending requests to the Essential node.
pub mod node_client;

/// Map `reqwest::Response` into `anyhow::Result`.
async fn handle_response(response: reqwest::Response) -> anyhow::Result<reqwest::Response> {
    let status = response.status();
    if status.is_success() {
        Ok(response)
    } else {
        let text = response.text().await?;
        Err(anyhow::anyhow!("{}: {}", status, text))
    }
}