rak_rs/error/
server.rs

1//! Server errors
2//! Server errors are errors that can occur when using the [`Listener`](crate::server::Listener) api.
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
4pub enum ServerError {
5    /// The server is unable to bind to the given address.
6    AddrBindErr,
7    /// The server is already online and can not be started again.
8    AlreadyOnline,
9    /// The server is offline and can not send packets.
10    NotListening,
11    /// The server has been closed.
12    Killed,
13    /// The server has been closed, and can not be used again.
14    Reset,
15}
16
17impl std::fmt::Display for ServerError {
18    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19        write!(
20            f,
21            "{}",
22            match self {
23                ServerError::AddrBindErr => "Unable to bind to address",
24                ServerError::AlreadyOnline => "Already online",
25                ServerError::NotListening => "Not listening",
26                ServerError::Killed => "Killed",
27                ServerError::Reset => "Reset",
28            }
29        )
30    }
31}
32
33impl std::error::Error for ServerError {}