38 lines
820 B
Rust
38 lines
820 B
Rust
use std::convert::From;
|
|
|
|
pub type Result<T> = std::result::Result<T, SDLanError>;
|
|
|
|
#[derive(Debug)]
|
|
pub enum SDLanError {
|
|
IOError(std::io::Error),
|
|
NormalError(&'static str),
|
|
ConvertError(String),
|
|
SerializeError(String),
|
|
EncryptError(String),
|
|
DBError(String),
|
|
}
|
|
|
|
impl From<std::io::Error> for SDLanError {
|
|
fn from(value: std::io::Error) -> Self {
|
|
Self::IOError(value)
|
|
}
|
|
}
|
|
|
|
impl From<&'static str> for SDLanError {
|
|
fn from(value: &'static str) -> Self {
|
|
Self::NormalError(value)
|
|
}
|
|
}
|
|
|
|
impl From<serde_json::Error> for SDLanError {
|
|
fn from(value: serde_json::Error) -> Self {
|
|
Self::SerializeError(value.to_string())
|
|
}
|
|
}
|
|
|
|
impl From<sqlx::Error> for SDLanError {
|
|
fn from(value: sqlx::Error) -> Self {
|
|
Self::DBError(value.to_string())
|
|
}
|
|
}
|