pub struct ClientConfig { /* private fields */ }
Available on crate feature client only.

Implementations§

source§

impl ClientConfig

source

pub fn new<U>(url: U) -> Self
where U: TryInto<Url>, U::Error: Debug,

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.

source

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.

source

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.

source

pub fn header<K, V>(self, key: K, value: V) -> Self

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.

source

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.

source

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.

source

pub fn max_reconnect_attempts(self, max_reconnect_attempts: usize) -> Self

Set the maximum number of attempts when reconnecting.

Defaults to infinite.

source

pub fn reconnect_interval(self, reconnect_interval: Duration) -> Self

Set the reconnect interval.

source

pub fn socket_config(self, socket_config: SocketConfig) -> Self

Set the socket’s configuration.

source

pub fn headers(&self) -> &HeaderMap

Get the config’s headers.

source

pub fn connect_http_request(&self) -> Request

Extract a Websockets HTTP request.

source

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.

Trait Implementations§

source§

impl Debug for ClientConfig

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more