Rocket/contrib/ws
Sergio Benitez c3520fb4a1 Pin I/O handlers. Allow 'FnOnce' in 'ws' handlers.
This modifies the 'IoHandler::io()' method so that it takes a
'Pin<Box<Self>>', allowing handlers to move internally and assume that
the data is pinned.

The change is then used in the 'ws' contrib crate to allow 'FnOnce'
handlers instead of 'FnMut'. The net effect is that streams, such as
those crated by 'Stream!', are now allowed to move internally.
2023-04-04 15:33:46 -07:00
..
src Pin I/O handlers. Allow 'FnOnce' in 'ws' handlers. 2023-04-04 15:33:46 -07:00
Cargo.toml Add initial implementation of 'rocket_ws'. 2023-04-01 15:02:24 -07:00
README.md Fully document the 'ws' contrib crate. 2023-04-03 16:09:45 -07:00

ws ci.svg crates.io docs.svg

This crate provides WebSocket support for Rocket via integration with Rocket's [connection upgrades] API.

Usage

  1. Depend on rocket_ws, renamed here to ws:

    [dependencies]
    ws = { package = "rocket_ws", version ="=0.1.0-rc.3" }
    
  2. Use it!

 ```rust
 #[get("/echo")]
 fn echo_stream(ws: ws::WebSocket) -> ws::Stream!['static] {
     ws::stream! { ws =>
         for await message in ws {
             yield message?;
         }
     }
 }
 ```

See the crate docs for full details.