WTX

CI crates.io Documentation License Rustc

Intended to group different web transport implementations.

WebSocket

fastwebsockets served as an initial inspiration for the skeleton of this implementation so thanks to the authors.

```rust use wtx::{Stream, web_socket::{Frame, FrameBufferVec, OpCode, WebSocketClient}};

pub async fn handleclientframes(ws: &mut WebSocketClient) -> wtx::Result<()> { let mut fb = FrameBufferVec::default(); loop { let frame = match ws.readmsg(&mut fb).await { Err(err) => { println!("Error: {err}"); ws.writeframe(Frame::newfin(fb, OpCode::Close, &[])?).await?; break; } Ok(elem) => elem, }; match (frame.opcode(), frame.textpayload()) { (, Some(elem)) => println!("{elem}"), (OpCode::Close, _) => break, _ => {} } } Ok(()) } ```

See the examples directory for more suggestions.