1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
pub use crate::wire::{AuthErr, LobbyErr, MatchErr, RegErr};
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
/// A wrapper around the different RST node errors that can occur
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Error {
/// Failure in the registration process
Register(RegErr),
/// Failure in the authentication process
Auth(AuthErr),
/// Failure handling a lobby
Lobby(LobbyErr),
/// Failure in a match setting
Match(MatchErr),
}
impl std::error::Error for Error {}
impl Display for Error {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "An RST error")
}
}
/// A RST Node specific error
pub type Result<T> = std::result::Result<T, Error>;
impl From<RegErr> for Error {
fn from(e: RegErr) -> Self {
Error::Register(e)
}
}
impl From<AuthErr> for Error {
fn from(e: AuthErr) -> Self {
Error::Auth(e)
}
}
impl From<LobbyErr> for Error {
fn from(e: LobbyErr) -> Self {
Error::Lobby(e)
}
}
impl From<MatchErr> for Error {
fn from(e: MatchErr) -> Self {
Error::Match(e)
}
}
|