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 = std::result::Result; impl From for Error { fn from(e: RegErr) -> Self { Error::Register(e) } } impl From for Error { fn from(e: AuthErr) -> Self { Error::Auth(e) } } impl From for Error { fn from(e: LobbyErr) -> Self { Error::Lobby(e) } } impl From for Error { fn from(e: MatchErr) -> Self { Error::Match(e) } }