grip-control
A Rust library for working with the GRIP (Generic Realtime Intermediary Protocol) WebSocket-over-HTTP wire format, as used by Fastly Fanout and compatible proxies.
Overview
grip-control handles the two directions of GRIP WebSocket communication:
- Parsing — decode inbound WebSocket event frames arriving from a GRIP proxy
- Building — encode outbound control frames to send back through the proxy
Zero external dependencies. The parser borrows directly from the input bytes — no heap allocation for frame payloads.
Usage
Add to Cargo.toml:
[]
= "0.6"
Parsing inbound frames
use WebsocketEvent;
let body: & = /* request body from GRIP proxy */;
match parse_frame?
Building outbound frames
use ;
// Subscribe the connection to a channel
let frame = ws_sub;
// Send a text message
let frame = ws_text;
// Unsubscribe
let frame = ws_unsub;
// Raw control frame (e.g. "keep-alive\r\n")
let frame = ws_control;
Wire format
Frames follow the GRIP WebSocket-over-HTTP encoding:
COMMAND [HEX_LEN]\r\n[BODY]\r\n
Channel subscription/unsubscription frames are JSON-encoded GRIP control messages wrapped in a TEXT frame:
TEXT <len>\r\nc:{"type":"subscribe","channel":"<ch>"}\r\n
License
Licensed under either of MIT or Apache-2.0 at your option.