Trait soketto::extension::Extension[][src]

pub trait Extension: Debug {
    fn is_enabled(&self) -> bool;
fn name(&self) -> &str;
fn params(&self) -> &[Param<'_>];
fn configure(&mut self, params: &[Param<'_>]) -> Result<(), BoxedError>;
fn encode(
        &mut self,
        header: &mut Header,
        data: &mut Storage<'_>
    ) -> Result<(), BoxedError>;
fn decode(
        &mut self,
        header: &mut Header,
        data: &mut Vec<u8>
    ) -> Result<(), BoxedError>; fn reserved_bits(&self) -> (bool, bool, bool) { ... } }
Expand description

A websocket extension as per RFC 6455, section 9.

Extensions are invoked during handshake and subsequently during base frame encoding and decoding. The invocation during handshake differs on client and server side.

Server

  1. All extensions should consider themselves as disabled but available.
  2. When receiving a handshake request from a client, for each extension with a matching name, Extension::configure will be applied to the request parameters. The extension may internally enable itself.
  3. When sending back the response, for each extension whose Extension::is_enabled returns true, the extension name and its parameters (as returned by Extension::params) will be included in the response.

Client

  1. All extensions should consider themselves as disabled but available.
  2. When creating the handshake request, all extensions and its parameters (as returned by Extension::params) will be included in the request.
  3. When receiving the response from the server, for every extension with a matching name in the response, Extension::configure will be applied to the response parameters. The extension may internally enable itself.

After this handshake phase, extensions have been configured and are potentially enabled. Enabled extensions can then be used for further base frame processing.

Required methods

Is this extension enabled?

The name of this extension.

The parameters this extension wants to send for negotiation.

Configure this extension with the parameters received from negotiation.

Encode a frame, given as frame header and payload data.

Decode a frame.

The frame header is given, as well as the accumulated payload data, i.e. the concatenated payload data of all message fragments.

Provided methods

The reserved bits this extension uses.

Implementations on Foreign Types

Implementors