#websocket #pipebuf #async

pipebuf_websocket

PipeBuf support for websockets

3 unstable releases

new 0.2.0 Apr 15, 2024
0.1.1 Jul 17, 2023
0.1.0 Jun 7, 2023

#568 in Asynchronous

46 downloads per month

MIT/Apache

17KB
160 lines

PipeBuf support for websockets

This handles the websocket protocol only, and is independent of the transport or any other protocol layers below it (such as TLS). So this can be combined with other crates such as pipebuf_mio or pipebuf_rustls to meet different needs. It also supports protocol detection, so that if the data does not appear to be a valid websocket connection then it can be passed off to another protocol handler such as HTTP.

Documentation

See the crate documentation.

License

This project is licensed under either the Apache License version 2 or the MIT license, at your option. (See LICENSE-APACHE and LICENSE-MIT).

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

PipeBuf wrapper for embedded-websocket

This handles websocket protocol only, independent of the transport. So this can be combined with pipebuf_mio or pipebuf_rustls or other crates to meet different needs.

This is efficient because embedded-websocket exposes a slice-based interface and works between buffers provided by the caller. So it is ideal to be wrapped by PipeBuf. Since websocket permits streaming of message data via fragments, a message is here handled as a pipe-buffer allowing the caller to also stream the data if they wish.

On the sending side, a "push" is indicated after each message sent.

TODO: Support client-side with a WebsocketClient wrapper. (Similar to existing code but would need testing.)

TODO: Rewrite this as a native PipeBuf-based websocket implementation that for Ping/Pong/Close consumes only whole frames (with limits), to simplify things. The message content can still be streamed, though. Also see Autobahn testsuite.

Dependencies

~1MB
~23K SLoC