mirror of
https://github.com/rwf2/Rocket.git
synced 2025-02-01 14:22:05 +00:00
c3520fb4a1
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. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |
ws
This crate provides WebSocket support for Rocket via integration with Rocket's [connection upgrades] API.
Usage
-
Depend on
rocket_ws
, renamed here tows
:[dependencies] ws = { package = "rocket_ws", version ="=0.1.0-rc.3" }
-
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.