Skip to main content

weirdnet_sync/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum SyncError {
5    #[error("{0}")]
6    Crypto(String),
7    #[error("refused: {0}")]
8    Refused(String),
9    #[error("codec: {0}")]
10    Codec(String),
11    #[error("{0}")]
12    Protocol(String),
13}
14
15impl From<weirdnet_keys::KeysError> for SyncError {
16    fn from(e: weirdnet_keys::KeysError) -> Self {
17        SyncError::Crypto(e.to_string())
18    }
19}
20
21impl From<weirdnet_net::NetError> for SyncError {
22    fn from(e: weirdnet_net::NetError) -> Self {
23        SyncError::Crypto(e.to_string())
24    }
25}
26
27pub type Result<T> = std::result::Result<T, SyncError>;