Struct SocketBuilder

Source
pub struct SocketBuilder<I, O> { /* private fields */ }
Expand description

Builder for Socket Uses the DEFAULT_* consts for backoff and retry config

Implementations§

Source§

impl<I, O> SocketBuilder<I, O>

Source

pub fn new(url: String) -> Self

Create a new builder from the given url with other config set to defaults

Source

pub fn set_url(self, url: String) -> Self

Update the builder url

Source

pub fn set_backoff_min(self, backoff_min: Duration) -> Self

Update the minimum backoff duration (must be > 0 millis)

Source

pub fn set_backoff_max(self, backoff_max: Option<Duration>) -> Self

Update the maximum backoff duration (if set must be < u32::MAX millis)

Source

pub fn set_max_retries(self, max_retries: u32) -> Self

Update the maximum number of retry attempts

Source

pub fn set_stable_timeout(self, stable_timeout: Duration) -> Self

Update the stable timeout. Must be <= u32::MAX millis

This determines how long a connection needs to stay open after a retry before it is considered stable and the retry counter is reset to 0

Source

pub fn open(self) -> Result<Socket<I, O>, Error<I, O>>

Attempts to create a reconnecting websocket and do the initial open It’s set up to error at this poing because the kind of errors that can occur here are likely fatal (See gloo::net::websocket::futures::WebSocket::open for details). These could be panics but the consumer may want to display the error to the user or fallback to plain http

Trait Implementations§

Source§

impl<I: Debug, O: Debug> Debug for SocketBuilder<I, O>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I, O> Freeze for SocketBuilder<I, O>

§

impl<I, O> RefUnwindSafe for SocketBuilder<I, O>

§

impl<I, O> Send for SocketBuilder<I, O>
where I: Send, O: Send,

§

impl<I, O> Sync for SocketBuilder<I, O>
where I: Sync, O: Sync,

§

impl<I, O> Unpin for SocketBuilder<I, O>
where I: Unpin, O: Unpin,

§

impl<I, O> UnwindSafe for SocketBuilder<I, O>
where I: UnwindSafe, O: UnwindSafe,

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