websocke_connection struct for one dataframe

This commit is contained in:
maxstrb 2025-10-30 15:57:02 +01:00
parent 8f12a03e46
commit ce4f6eaf92
2 changed files with 31 additions and 10 deletions

View file

@ -57,7 +57,7 @@ pub struct Upgrade {
impl Upgrade {
pub fn to_str(&self) -> Box<str> {
match self.version.as_ref() {
"" => format!("{}", self.protocol.to_str()).into(),
"" => self.protocol.to_str().into(),
_ => format!("{}/{}", self.protocol.to_str(), self.version).into(),
}
}

View file

@ -13,30 +13,51 @@ pub struct WebsocketConnection {
stream: TcpStream,
}
struct DataFrame {
struct DataBlock {
is_final: bool,
extension_1: bool,
extension_2: bool,
extension_3: bool,
e1: bool,
e2: bool,
e3: bool,
frame_type: FrameType,
message_type: FrameType,
is_masked: bool,
data: Vec<u8>,
length: u64,
mask_key: Option<u32>,
data: Box<[u8]>,
}
enum FrameType {}
struct DataFrame {
frame_type: FrameType,
data: Box<[u8]>,
}
enum FrameType {
Continuation,
TextFrame,
BinaryFrame,
ConnectionClose,
Ping,
Pong,
Other(u8),
}
impl WebsocketConnection {
pub async fn send_message() -> io::Result<()> {
pub async fn send_message(&self) -> io::Result<()> {
todo!()
}
pub async fn read_next_message() {
pub async fn read_next_message(&self) {
todo!()
}
async fn parse_single_block(&self) -> io::Result<DataBlock> {
Err(io::Error::new(io::ErrorKind::InvalidData, "uncluky"))
}
pub async fn initialize_connection(
req: Request,
mut stream: TcpStream,