Trait soket::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) { ... } }

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

fn is_enabled(&self) -> bool[src]

Is this extension enabled?

fn name(&self) -> &str[src]

The name of this extension.

fn params(&self) -> &[Param<'_>][src]

The parameters this extension wants to send for negotiation.

fn configure(&mut self, params: &[Param<'_>]) -> Result<(), BoxedError>[src]

Configure this extension with the parameters received from negotiation.

fn encode(
    &mut self,
    header: &mut Header,
    data: &mut Storage<'_>
) -> Result<(), BoxedError>
[src]

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

fn decode(
    &mut self,
    header: &mut Header,
    data: &mut Vec<u8>
) -> Result<(), BoxedError>
[src]

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.

Loading content...

Provided methods

fn reserved_bits(&self) -> (bool, bool, bool)[src]

The reserved bits this extension uses.

Loading content...

Implementations on Foreign Types

impl<E: Extension + ?Sized> Extension for Box<E>[src]

Loading content...

Implementors

impl Extension for Deflate[src]

Loading content...