Struct WebSocketOptions

Source
pub struct WebSocketOptions<'a> {
    pub path: &'a str,
    pub host: &'a str,
    pub origin: &'a str,
    pub sub_protocols: Option<&'a [&'a str]>,
    pub additional_headers: Option<&'a [&'a str]>,
}
Expand description

Websocket options used by a websocket client to initiate an opening handshake with a websocket server

Fields§

§path: &'a str

The request uri (e.g. /chat?id=123) of the GET method used to identify the endpoint of the websocket connection. This allows multiple domains to be served by a single server. This could also be used to send identifiable information about the client

§host: &'a str

The hostname (e.g. server.example.com) is used so that both the client and the server can verify that they agree on which host is in use

§origin: &'a str

The origin (e.g. http://example.com) is used to protect against unauthorized cross-origin use of a WebSocket server by scripts using the WebSocket API in a web browser. This field is usually only set by browser clients but servers may require it so it has been exposed here.

§sub_protocols: Option<&'a [&'a str]>

A list of requested sub protocols in order of preference. The server should return the first sub protocol it supports or none at all. A sub protocol can be anything agreed between the server and client

§additional_headers: Option<&'a [&'a str]>

Any additional headers the server may require that are not part of the websocket spec. These should be fully formed http headers without the \r\n (e.g. MyHeader: foo)

Auto Trait Implementations§

§

impl<'a> Freeze for WebSocketOptions<'a>

§

impl<'a> RefUnwindSafe for WebSocketOptions<'a>

§

impl<'a> Send for WebSocketOptions<'a>

§

impl<'a> Sync for WebSocketOptions<'a>

§

impl<'a> Unpin for WebSocketOptions<'a>

§

impl<'a> UnwindSafe for WebSocketOptions<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.