pub struct WebsocketClientConfig { /* private fields */ }Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new<U>(url: U) -> ClientConfig
pub fn new<U>(url: U) -> ClientConfig
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,
) -> ClientConfig
pub fn basic( self, username: impl Display, password: impl Display, ) -> ClientConfig
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) -> ClientConfig
pub fn bearer(self, token: impl Display) -> ClientConfig
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) -> ClientConfigwhere
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) -> ClientConfigwhere
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) -> ClientConfig
pub fn query_parameter(self, key: &str, value: &str) -> ClientConfig
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,
) -> ClientConfig
pub fn max_initial_connect_attempts( self, max_initial_connect_attempts: usize, ) -> ClientConfig
Set the maximum number of connection attempts when starting a client.
Defaults to infinite.
Sourcepub fn max_reconnect_attempts(
self,
max_reconnect_attempts: usize,
) -> ClientConfig
pub fn max_reconnect_attempts( self, max_reconnect_attempts: usize, ) -> ClientConfig
Set the maximum number of attempts when reconnecting.
Defaults to infinite.
Sourcepub fn reconnect_interval(self, reconnect_interval: Duration) -> ClientConfig
pub fn reconnect_interval(self, reconnect_interval: Duration) -> ClientConfig
Set the reconnect interval.
Sourcepub fn socket_config(self, socket_config: SocketConfig) -> ClientConfig
pub fn socket_config(self, socket_config: SocketConfig) -> ClientConfig
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.