miden_proving_service_client/
lib.rs1#![no_std]
2#![allow(unused_imports)]
6#[macro_use]
7extern crate alloc;
8
9use alloc::{
10 boxed::Box,
11 string::{String, ToString},
12};
13use core::error::Error as CoreError;
14
15#[cfg(feature = "std")]
16extern crate std;
17
18use thiserror::Error;
19
20pub mod proving_service;
21
22pub const PROVING_SERVICE_PROTO: &str = include_str!("../proto/proving_service.proto");
24
25#[derive(Debug, Error)]
29pub enum RemoteProverError {
30 #[error("invalid uri {0}")]
32 InvalidEndpoint(String),
33 #[error("failed to connect to prover {0}")]
34 ConnectionFailed(#[source] Box<dyn CoreError + Send + Sync + 'static>),
36 #[error("{error_msg}")]
38 Other {
39 error_msg: Box<str>,
40 source: Option<Box<dyn CoreError + Send + Sync + 'static>>,
42 },
43}
44
45impl From<RemoteProverError> for String {
46 fn from(err: RemoteProverError) -> Self {
47 err.to_string()
48 }
49}
50
51impl RemoteProverError {
52 pub fn other(message: impl Into<String>) -> Self {
55 let message: String = message.into();
56 Self::Other { error_msg: message.into(), source: None }
57 }
58
59 pub fn other_with_source(
62 message: impl Into<String>,
63 source: impl CoreError + Send + Sync + 'static,
64 ) -> Self {
65 let message: String = message.into();
66 Self::Other {
67 error_msg: message.into(),
68 source: Some(Box::new(source)),
69 }
70 }
71}