pub trait ExtensionProvider {
    type Extension: Extension;
    type Error: 'static + Error + Sync + Send;
    fn apply_headers(&self, headers: &mut HeaderMap<HeaderValue>);
fn negotiate_client(
        &self,
        headers: &[Header<'_>]
    ) -> Result<Option<Self::Extension>, Self::Error>;
fn negotiate_server(
        &self,
        headers: &[Header<'_>]
    ) -> Result<Option<(Self::Extension, HeaderValue)>, Self::Error>; }
Expand description

A trait for negotiating an extension during a WebSocket handshake.

Extension providers allow for a single configuration to be used to negotiate multiple peers.

Associated Types

The extension produced by this provider if the negotiation was successful.

The error produced by this extension if the handshake failed.

Required methods

Apply this extension’s headers to a request.

Negotiate the headers that the server responded with.

If it is possible to negotiate this extension, then this should return an initialised extension.

If it is not possible to negotiate an extension then this should return None, not Err. An error should only be returned if the server responded with a malformatted header or a value that was not expected.

Returning Err from this will fail the connection with the reason being the error’s to_string() value.

Negotiate the headers that a client has sent.

If it is possible to negotiate this extension, then this should return a pair containing an initialised extension and a HeaderValue to return to the client.

If it is not possible to negotiate an extension then this should return None, not Err. An error should only be returned if the server responded with a malformatted header or a value that was not expected.

Returning Err from this will fail the connection with the reason being the error’s to_string() value.

Implementations on Foreign Types

Implementors