From ce4f6eaf92e31115bdbf4482f70637d8c26bdf74 Mon Sep 17 00:00:00 2001 From: maxstrb Date: Thu, 30 Oct 2025 15:57:02 +0100 Subject: [PATCH] websocke_connection struct for one dataframe --- src/request.rs | 2 +- src/websoket_connection.rs | 39 +++++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/request.rs b/src/request.rs index 0af0c9c..2d06657 100644 --- a/src/request.rs +++ b/src/request.rs @@ -57,7 +57,7 @@ pub struct Upgrade { impl Upgrade { pub fn to_str(&self) -> Box { match self.version.as_ref() { - "" => format!("{}", self.protocol.to_str()).into(), + "" => self.protocol.to_str().into(), _ => format!("{}/{}", self.protocol.to_str(), self.version).into(), } } diff --git a/src/websoket_connection.rs b/src/websoket_connection.rs index 286f58e..a872309 100644 --- a/src/websoket_connection.rs +++ b/src/websoket_connection.rs @@ -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, + length: u64, + + mask_key: Option, + + 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 { + Err(io::Error::new(io::ErrorKind::InvalidData, "uncluky")) + } + pub async fn initialize_connection( req: Request, mut stream: TcpStream,