Skip to main content

rostra_p2p/
lib.rs

1pub mod connection;
2pub mod error;
3pub mod util;
4
5pub use connection::Connection;
6use rostra_core::event::VerifiedEventError;
7use rostra_util_error::BoxedError;
8use snafu::Snafu;
9pub const ROSTRA_P2P_V0_ALPN: &[u8] = b"rostra-p2p-v0";
10
11pub const LOG_TARGET: &str = "rostra::p2p";
12
13#[derive(Debug, Snafu)]
14pub enum RpcError {
15    #[snafu(visibility(pub))]
16    Connection {
17        source: iroh::endpoint::ConnectError,
18    },
19    StreamConnection {
20        source: iroh::endpoint::ConnectionError,
21    },
22    Write {
23        source: iroh::endpoint::WriteError,
24    },
25    Read {
26        source: BoxedError,
27    },
28    MessageTooLarge {
29        len: u32,
30        limit: u32,
31    },
32    Decoding {
33        source: bincode::error::DecodeError,
34    },
35    DecodingBao {
36        source: bao_tree::io::DecodeError,
37    },
38    EncodingBao {
39        source: bao_tree::io::EncodeError,
40    },
41    Trailer {
42        source: BoxedError,
43    },
44    EventVerification {
45        source: VerifiedEventError,
46    },
47    /// Other side responded with rpc failure
48    Failed {
49        return_code: u8,
50    },
51}
52type RpcResult<T> = std::result::Result<T, RpcError>;