Skip to main content

weirdnet_sync/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4#[non_exhaustive]
5pub enum SyncError {
6    #[error("{0}")]
7    Crypto(String),
8    #[error("refused: {0}")]
9    Refused(String),
10    #[error("codec: {0}")]
11    Codec(String),
12    #[error("{0}")]
13    Protocol(String),
14    /// Reading or writing an [`crate::identity::Identity`]'s files.
15    #[error("{0}")]
16    Io(String),
17    /// An [`crate::identity::Identity`] that can't be created, adopted or opened as asked.
18    #[error("{0}")]
19    Identity(String),
20}
21
22impl From<weirdnet_keys::KeysError> for SyncError {
23    fn from(e: weirdnet_keys::KeysError) -> Self {
24        SyncError::Crypto(e.to_string())
25    }
26}
27
28impl From<weirdnet_net::NetError> for SyncError {
29    fn from(e: weirdnet_net::NetError) -> Self {
30        SyncError::Crypto(e.to_string())
31    }
32}
33
34pub type Result<T> = std::result::Result<T, SyncError>;