serverside done except it deadlocks

This commit is contained in:
Toshit Chawda 2024-01-22 20:11:58 -08:00
parent 1f23c26db6
commit 24d145cc66
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
8 changed files with 176 additions and 24 deletions

View file

@ -1,3 +1,5 @@
#[cfg(feature = "fastwebsockets")]
mod fastwebsockets;
mod packet;
pub mod ws;
@ -9,12 +11,14 @@ pub enum Role {
Server,
}
#[derive(Debug)]
pub enum WispError {
PacketTooSmall,
InvalidPacketType,
WsFrameInvalidType,
WsFrameNotFinished,
WsImplError(Box<dyn std::error::Error>),
WsImplNotSupported,
Utf8Error(std::str::Utf8Error),
}
@ -23,3 +27,20 @@ impl From<std::str::Utf8Error> for WispError {
WispError::Utf8Error(err)
}
}
impl std::fmt::Display for WispError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
use WispError::*;
match self {
PacketTooSmall => write!(f, "Packet too small"),
InvalidPacketType => write!(f, "Invalid packet type"),
WsFrameInvalidType => write!(f, "Invalid websocket frame type"),
WsFrameNotFinished => write!(f, "Unfinished websocket frame"),
WsImplError(err) => write!(f, "Websocket implementation error: {:?}", err),
WsImplNotSupported => write!(f, "Websocket implementation error: unsupported feature"),
Utf8Error(err) => write!(f, "UTF-8 error: {:?}", err),
}
}
}
impl std::error::Error for WispError {}