Struct ezsockets::client::ClientConfig
source · pub struct ClientConfig { /* private fields */ }
client
only.Implementations§
source§impl ClientConfig
impl ClientConfig
sourcepub fn new<U>(url: U) -> Self
pub fn new<U>(url: U) -> Self
If invalid URL is passed, this function will panic.
In order to handle invalid URL, parse URL on your side, and pass url::Url
directly.
sourcepub fn basic(self, username: impl Display, password: impl Display) -> Self
pub fn basic(self, username: impl Display, password: impl Display) -> Self
Add ‘basic’ header. Note that additional headers are not supported by the websockets spec, so may not be supported by all implementations.
sourcepub fn bearer(self, token: impl Display) -> Self
pub fn bearer(self, token: impl Display) -> Self
Add ‘bearer’ header. If invalid(outside of visible ASCII characters ranged between 32-127) token is passed, this function will panic. Note that additional headers are not supported by the websockets spec, so may not be supported by all implementations.
sourcepub fn header<K, V>(self, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
pub fn header<K, V>(self, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Into<Error>,
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<Error>,
Add custom header.
If you suppose the header name or value might be invalid, create http::header::HeaderName
and
http::header::HeaderValue
on your side, and then pass it to this function.
Note that additional headers are not supported by the websockets spec, so may not be supported by all
implementations.
sourcepub fn query_parameter(self, key: &str, value: &str) -> Self
pub fn query_parameter(self, key: &str, value: &str) -> Self
Insert query parameters into the connection request URI.
Query parameters are supported by the websockets spec, so they will always be available to the connecting server.
Decode query parameters in ServerExt::on_connect()
with
form_urlencoded::parse(request.uri().query().unwrap().as_bytes())
using the form_urlencoded
crate.
sourcepub fn max_initial_connect_attempts(
self,
max_initial_connect_attempts: usize
) -> Self
pub fn max_initial_connect_attempts( self, max_initial_connect_attempts: usize ) -> Self
Set the maximum number of connection attempts when starting a client.
Defaults to infinite.
sourcepub fn max_reconnect_attempts(self, max_reconnect_attempts: usize) -> Self
pub fn max_reconnect_attempts(self, max_reconnect_attempts: usize) -> Self
Set the maximum number of attempts when reconnecting.
Defaults to infinite.
sourcepub fn reconnect_interval(self, reconnect_interval: Duration) -> Self
pub fn reconnect_interval(self, reconnect_interval: Duration) -> Self
Set the reconnect interval.
sourcepub fn socket_config(self, socket_config: SocketConfig) -> Self
pub fn socket_config(self, socket_config: SocketConfig) -> Self
Set the socket’s configuration.
sourcepub fn connect_http_request(&self) -> Request
pub fn connect_http_request(&self) -> Request
Extract a Websockets HTTP request.
sourcepub fn connect_url(&self) -> &str
pub fn connect_url(&self) -> &str
Extract the URL request.
This is needed for WASM clients, where building HTTP requests is deferred to the web_sys::Websocket
implementation.