RealtimeClientBuilder

Struct RealtimeClientBuilder 

Source
pub struct RealtimeClientBuilder { /* private fields */ }
Expand description

Builder struct for [RealtimeClient]

Implementations§

Source§

impl RealtimeClientBuilder

Source

pub fn new(endpoint: impl Into<String>, anon_key: impl Into<String>) -> Self

Creates a new RealtimeClientBuilder

Source

pub fn access_token(self, access_token: impl Into<String>) -> Self

Source

pub fn set_headers(self, set_headers: HeaderMap) -> Self

Sets the client headers. Headers always contain “X-Client-Info: realtime-rs/{version}”.

Source

pub fn add_headers(self, headers: HeaderMap) -> Self

Merges provided HeaderMap with currently held headers

Source

pub fn params(self, params: HashMap<String, String>) -> Self

Set endpoint URL params

Source

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

Set Duration between heartbeat packets. Default 29 seconds.

Source

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

Set the function to provide time between reconnection attempts The provided function should take a count of reconnect attempts and return a Duration to wait until the next attempt is made.

Don’t implement an untested timing function here in prod or you might make a few too many requests.

Defaults to stepped backoff, as shown below

  fn backoff(attempts: usize) -> Duration {
      let times: Vec<u64> = vec![0, 1, 2, 5, 10];
      Duration::from_secs(times[attempts.min(times.len() - 1)])
  }
Source

pub fn reconnect_max_attempts(self, max_attempts: usize) -> Self

Configure the number of recconect attempts to be made before erroring

Source

pub fn encode(self, encode: Interceptor) -> Self

Source

pub fn decode(self, decode: Interceptor) -> Self

Source

pub fn connect(self) -> ClientManager

Consume the Self and return a configured ClientManager

Trait Implementations§

Source§

impl Debug for RealtimeClientBuilder

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

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

Source§

fn vzip(self) -> V