Skip to main content

miden_node_utils/
lib.rs

1// Required by code generated by the upstream `#[instrument]` macro.
2extern crate miden_node_tracing as tracing;
3
4pub mod block_cache;
5pub mod clap;
6pub mod cors;
7#[cfg(feature = "testing")]
8pub mod fee;
9pub mod formatting;
10pub mod fs;
11pub mod genesis;
12pub mod grpc;
13pub mod limiter;
14pub mod lru_cache;
15pub mod retry;
16pub mod shutdown;
17pub mod tasks;
18#[cfg(feature = "testing-prover")]
19pub mod testing;
20
21/// Extends nested results types, allowing them to be flattened.
22///
23/// Adapted from: <https://stackoverflow.com/a/77543839>
24pub trait FlattenResult<V, OuterError, InnerError>
25where
26    InnerError: Into<OuterError>,
27{
28    fn flatten_result(self) -> Result<V, OuterError>;
29}
30
31impl<V, OuterError, InnerError> FlattenResult<V, OuterError, InnerError>
32    for Result<Result<V, InnerError>, OuterError>
33where
34    OuterError: From<InnerError>,
35{
36    fn flatten_result(self) -> Result<V, OuterError> {
37        match self {
38            Ok(Ok(value)) => Ok(value),
39            Ok(Err(inner)) => Err(inner.into()),
40            Err(outer) => Err(outer),
41        }
42    }
43}