use dig_nat::NatError;
use dig_rpc_protocol::RpcError;
pub type Result<T> = std::result::Result<T, DigPeerError>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum DigPeerError {
#[error("peer transport failed: {0}")]
Transport(#[from] NatError),
#[error("peer stream I/O failed: {0}")]
Io(#[from] std::io::Error),
#[error("peer returned an RPC error: {0:?}")]
Rpc(Box<RpcError>),
#[error("cannot send a directed sealed RPC: the peer presented no verified BLS-G1 identity")]
PeerNotSealable,
#[error("cannot seal a directed RPC: no local sealing identity configured")]
NoSealingIdentity,
#[error("message seal/open failed: {0}")]
Seal(String),
#[error("sealed response did not correlate with the request")]
Misdelivered,
#[error("could not (de)serialize an RPC payload: {0}")]
Codec(String),
#[error("operation invalid in state {0:?}")]
InvalidState(crate::state::PeerState),
}