use alloc::boxed::Box;
use alloc::string::{String, ToString};
use core::error::Error as CoreError;
use thiserror::Error;
mod api_client;
mod generated;
mod tx_prover;
pub use tx_prover::RemoteTransactionProver;
#[derive(Debug, Error)]
pub enum RemoteProverClientError {
#[error("invalid uri {0}")]
InvalidEndpoint(String),
#[error("failed to connect to prover {0}")]
ConnectionFailed(#[source] Box<dyn CoreError + Send + Sync + 'static>),
#[error("{error_msg}")]
Other {
error_msg: Box<str>,
source: Option<Box<dyn CoreError + Send + Sync + 'static>>,
},
}
impl From<RemoteProverClientError> for String {
fn from(err: RemoteProverClientError) -> Self {
err.to_string()
}
}
impl RemoteProverClientError {
pub fn other(message: impl Into<String>) -> Self {
let message: String = message.into();
Self::Other { error_msg: message.into(), source: None }
}
pub fn other_with_source(
message: impl Into<String>,
source: impl CoreError + Send + Sync + 'static,
) -> Self {
let message: String = message.into();
Self::Other {
error_msg: message.into(),
source: Some(Box::new(source)),
}
}
}