pub trait Extension: Debug {
// Required methods
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>;
// Provided method
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
- All extensions should consider themselves as disabled but available.
- 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. - When sending back the response, for each extension whose
Extension::is_enabled
returns true, the extension name and its parameters (as returned byExtension::params
) will be included in the response.
Client
- All extensions should consider themselves as disabled but available.
- When creating the handshake request, all extensions and its parameters
(as returned by
Extension::params
) will be included in the request. - 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§
sourcefn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Is this extension enabled?
sourcefn configure(&mut self, params: &[Param<'_>]) -> Result<(), BoxedError>
fn configure(&mut self, params: &[Param<'_>]) -> Result<(), BoxedError>
Configure this extension with the parameters received from negotiation.
Provided Methods§
sourcefn reserved_bits(&self) -> (bool, bool, bool)
fn reserved_bits(&self) -> (bool, bool, bool)
The reserved bits this extension uses.