protosocket_server/
error.rs

1use std::sync::Arc;
2
3/// Result type for protosocket-server.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Error type for protosocket-server.
7#[derive(Clone, Debug, thiserror::Error)]
8pub enum Error {
9    /// Standard IO error
10    #[error("IO failure: {0}")]
11    IoFailure(#[from] Arc<std::io::Error>),
12    /// Address was not able to parse
13    #[error("Bad address: {0}")]
14    AddressError(#[from] core::net::AddrParseError),
15    /// Can not use this resource anymore
16    #[error("Requested resource was dead: ({0})")]
17    Dead(&'static str),
18}
19
20impl From<std::io::Error> for Error {
21    fn from(e: std::io::Error) -> Self {
22        Self::IoFailure(Arc::new(e))
23    }
24}