[][src]Struct websocket::server::upgrade::WsUpgrade

pub struct WsUpgrade<S, B> where
    S: Stream
{ pub headers: Headers, pub stream: S, pub request: Request, pub buffer: B, }

Intermediate representation of a half created websocket session. Should be used to examine the client's handshake accept the protocols requested, route the path, etc.

Users should then call accept or reject to complete the handshake and start a session. Note: if the stream in use is AsyncRead + AsyncWrite, then asynchronous functions will be available when completing the handshake. Otherwise if the stream is simply Read + Write blocking functions will be available to complete the handshake.

Fields

The headers that will be used in the handshake response.

The stream that will be used to read from / write to.

The handshake request, filled with useful metadata.

Some buffered data from the stream, if it exists.

Methods

impl<S> WsUpgrade<S, BytesMut> where
    S: Stream + Send + 'static, 
[src]

These are the extra functions given to WsUpgrade with the async feature turned on. A type alias for this specialization of WsUpgrade lives in this module under the name Upgrade.

Asynchronously accept the websocket handshake, then create a client. This will asynchronously send a response accepting the connection and create a websocket client.

Asynchronously accept the websocket handshake, then create a client. This will asynchronously send a response accepting the connection with custom headers in the response and create a websocket client.

Asynchronously send a rejection message and deconstruct self into it's original stream. The stream being returned is framed with the HttpServerCodec since that was used to send the rejection message.

Asynchronously send a rejection message with custom headers and deconstruct self into it's original stream. The stream being returned is framed with the HttpServerCodec since that was used to send the rejection message.

impl<S> WsUpgrade<S, Option<Buffer>> where
    S: Stream
[src]

These methods are the synchronous ways of accepting and rejecting a websocket handshake.

Accept the handshake request and send a response, if nothing goes wrong a client will be created.

Accept the handshake request and send a response while adding on a few headers. These headers are added before the required headers are, so some might be overwritten.

Reject the client's request to make a websocket connection.

Reject the client's request to make a websocket connection and send extra headers.

impl<S, B> WsUpgrade<S, B> where
    S: Stream + AsTcpStream
[src]

Important traits for TcpStream

Get a handle to the underlying TCP stream, useful to be able to set TCP options, etc.

impl<S, B> WsUpgrade<S, B> where
    S: Stream
[src]

Select a protocol to use in the handshake response.

Select an extension to use in the handshake response.

Select multiple extensions to use in the connection

Drop the connection without saying anything.

A list of protocols requested from the client.

A list of extensions requested from the client.

The client's websocket accept key.

The client's websocket version.

The original request URI.

Origin of the client

Auto Trait Implementations

impl<S, B> Send for WsUpgrade<S, B> where
    B: Send,
    S: Send

impl<S, B> !Sync for WsUpgrade<S, B>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Typeable for T where
    T: Any
[src]

Get the TypeId of this object.

impl<T> Erased for T
[src]