32 lines
629 B
Rust
32 lines
629 B
Rust
use std::string::FromUtf8Error;
|
|
|
|
pub type Result<T> = std::result::Result<T, Error>;
|
|
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
Io(std::io::Error),
|
|
InvalidFrame(String),
|
|
HandshakeFailed(String),
|
|
Utf8(FromUtf8Error),
|
|
ConnectionClosed,
|
|
Elapsed,
|
|
}
|
|
|
|
impl From<std::io::Error> for Error {
|
|
fn from(value: std::io::Error) -> Self {
|
|
Self::Io(value)
|
|
}
|
|
}
|
|
|
|
impl From<FromUtf8Error> for Error {
|
|
fn from(value: FromUtf8Error) -> Self {
|
|
Self::Utf8(value)
|
|
}
|
|
}
|
|
|
|
impl From<tokio::time::error::Elapsed> for Error {
|
|
fn from(_: tokio::time::error::Elapsed) -> Self {
|
|
Self::Elapsed
|
|
}
|
|
}
|