Skip to main content

hyli_client_sdk/
lib.rs

1#[cfg(feature = "axum")]
2use axum::{
3    http::StatusCode,
4    response::{IntoResponse, Response},
5};
6#[cfg(not(feature = "axum"))]
7use hyli_net::http::StatusCode;
8
9/// Error type for REST API handlers, wrapping `anyhow::Error` with a status code.
10pub struct AppError(pub StatusCode, pub anyhow::Error);
11
12#[cfg(feature = "axum")]
13impl IntoResponse for AppError {
14    fn into_response(self) -> Response {
15        (self.0, format!("{}", self.1)).into_response()
16    }
17}
18
19impl<E> From<E> for AppError
20where
21    E: Into<anyhow::Error>,
22{
23    fn from(err: E) -> Self {
24        Self(StatusCode::INTERNAL_SERVER_ERROR, err.into())
25    }
26}
27
28#[cfg(feature = "csi")]
29pub mod contract_indexer;
30pub mod helpers;
31pub mod light_executor;
32#[cfg(feature = "rest")]
33pub mod rest_client;
34pub mod tcp_client;
35/// Helper modules for testing contracts
36pub mod tests;
37pub mod transaction_builder;