Module twist::client
[−]
[src]
Client API
Decode PONG Base Frame from server
let ping_vec = PONG.to_vec(); let mut eb = BytesMut::with_capacity(256); eb.extend(ping_vec); let mut fc: BaseFrameCodec = Default::default(); fc.set_client(true); let mut encoded = BytesMut::with_capacity(256); if let Ok(Some(frame)) = fc.decode(&mut eb) { assert!(frame.fin()); assert!(!frame.rsv1()); assert!(!frame.rsv2()); assert!(!frame.rsv3()); // All frames from server must not be masked. assert!(!frame.masked()); assert!(frame.opcode() == OpCode::Pong); assert!(frame.mask() == 0); assert!(frame.payload_length() == 0); assert!(frame.extension_data().is_none()); assert!(frame.application_data().is_empty()); if fc.encode(frame, &mut encoded).is_ok() { for (a, b) in encoded.iter().zip(PONG.to_vec().iter()) { assert!(a == b); } } } else { assert!(false); }
Structs
BaseFrame |
Represents the parts of a base frame. |
BaseFrameCodec |
Codec for encoding/decoding websocket base frames. |
HandshakeRequestFrame |
A websocket handshake client-side frame. |
HandshakeResponseFrame |
A server handshake response to a client handshake request. |
HanshakeCodec |
Codec for decoding/encoding websocket client handshake frames. |
TwistCodec |
Codec for use with the |
WebSocketFrame |
A |
WebSocketProtocol |
The protocol that can bu use to run on a tokio-proto
|
Enums
OpCode |
Operation codes defined in RFC6455. |