[−][src]Struct websocket::server::upgrade::WsUpgrade
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
headers: Headers
The headers that will be used in the handshake response.
stream: S
The stream that will be used to read from / write to.
request: Request
The handshake request, filled with useful metadata.
buffer: B
Some buffered data from the stream, if it exists.
Methods
impl<S> WsUpgrade<S, BytesMut> where
S: Stream + Send + 'static,
[src]
impl<S> WsUpgrade<S, BytesMut> where
S: Stream + Send + 'static,
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
.
pub fn accept(self) -> ClientNew<S>
[src]
pub fn accept(self) -> ClientNew<S>
Asynchronously accept the websocket handshake, then create a client. This will asynchronously send a response accepting the connection and create a websocket client.
pub fn accept_with(self, custom_headers: &Headers) -> ClientNew<S>
[src]
pub fn accept_with(self, custom_headers: &Headers) -> ClientNew<S>
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.
pub fn reject(self) -> SinkSend<Framed<S, HttpServerCodec>>
[src]
pub fn reject(self) -> SinkSend<Framed<S, HttpServerCodec>>
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.
pub fn reject_with(
self,
headers: &Headers
) -> SinkSend<Framed<S, HttpServerCodec>>
[src]
pub fn reject_with(
self,
headers: &Headers
) -> SinkSend<Framed<S, HttpServerCodec>>
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]
impl<S> WsUpgrade<S, Option<Buffer>> where
S: Stream,
These methods are the synchronous ways of accepting and rejecting a websocket handshake.
pub fn accept(self) -> Result<Client<S>, (S, Error)>
[src]
pub fn accept(self) -> Result<Client<S>, (S, Error)>
Accept the handshake request and send a response, if nothing goes wrong a client will be created.
pub fn accept_with(
self,
custom_headers: &Headers
) -> Result<Client<S>, (S, Error)>
[src]
pub fn accept_with(
self,
custom_headers: &Headers
) -> Result<Client<S>, (S, Error)>
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.
pub fn reject(self) -> Result<S, (S, Error)>
[src]
pub fn reject(self) -> Result<S, (S, Error)>
Reject the client's request to make a websocket connection.
pub fn reject_with(self, headers: &Headers) -> Result<S, (S, Error)>
[src]
pub fn reject_with(self, headers: &Headers) -> Result<S, (S, Error)>
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]
impl<S, B> WsUpgrade<S, B> where
S: Stream + AsTcpStream,
ⓘImportant traits for TcpStreampub fn tcp_stream(&self) -> &TcpStream
[src]
pub fn tcp_stream(&self) -> &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]
impl<S, B> WsUpgrade<S, B> where
S: Stream,
pub fn use_protocol<P>(self, protocol: P) -> Self where
P: Into<String>,
[src]
pub fn use_protocol<P>(self, protocol: P) -> Self where
P: Into<String>,
Select a protocol to use in the handshake response.
pub fn use_extension(self, extension: Extension) -> Self
[src]
pub fn use_extension(self, extension: Extension) -> Self
Select an extension to use in the handshake response.
pub fn use_extensions<I>(self, extensions: I) -> Self where
I: IntoIterator<Item = Extension>,
[src]
pub fn use_extensions<I>(self, extensions: I) -> Self where
I: IntoIterator<Item = Extension>,
Select multiple extensions to use in the connection
pub fn drop(self)
[src]
pub fn drop(self)
Drop the connection without saying anything.
pub fn protocols(&self) -> &[String]
[src]
pub fn protocols(&self) -> &[String]
A list of protocols requested from the client.
pub fn extensions(&self) -> &[Extension]
[src]
pub fn extensions(&self) -> &[Extension]
A list of extensions requested from the client.
pub fn key(&self) -> Option<&[u8; 16]>
[src]
pub fn key(&self) -> Option<&[u8; 16]>
The client's websocket accept key.
pub fn version(&self) -> Option<&WebSocketVersion>
[src]
pub fn version(&self) -> Option<&WebSocketVersion>
The client's websocket version.
pub fn uri(&self) -> String
[src]
pub fn uri(&self) -> String
The original request URI.
pub fn origin(&self) -> Option<&str>
[src]
pub fn origin(&self) -> Option<&str>
Origin of the client
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 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]
impl<T> Typeable for T where
T: Any,
impl<T> Erased for T
[src]
impl<T> Erased for T