ClientOptions

Struct ClientOptions 

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

Ably client options for initialising a REST or Realtime client.

Implementations§

Source§

impl ClientOptions

Source

pub fn new(s: &str) -> Self

Source

pub fn with_auth_url(url: Url) -> Self

Source

pub fn with_auth_callback(callback: Arc<dyn AuthCallback>) -> Self

Source

pub fn with_key(key: Key) -> Self

Sets the API key.

§Example
let client = ably::ClientOptions::new("aaaaaa.bbbbbb:cccccc").rest()?;
Source

pub fn with_token(token: String) -> Self

Source

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

Set the client ID, used for identifying this client when publishing messages or for presence purposes. Can be any utf-8 string except the reserved wildcard string ‘*’.

Source

pub fn use_token_auth(self, v: bool) -> Self

Indicates whether token authentication should be used even if an API key is present.

Source

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

Sets the environment. See [TO3k1].

§Example
let client = ably::ClientOptions::new("aaaaaa.bbbbbb:cccccc")
    .environment("sandbox")?
    .rest()?;
§Errors

Fails if rest_host is already set or if the environment cannot be used in the REST API URL.

Source

pub fn use_binary_protocol(self, v: bool) -> Self

Sets the message format to MessagePack if the argument is true, or JSON if the argument is false.

Source

pub fn default_token_params(self, params: TokenParams) -> Self

Set the default TokenParams.

Source

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

Sets the rest_host. See [TO3k2].

§Example
let client = ably::ClientOptions::new("aaaaaa.bbbbbb:cccccc")
    .rest_host("sandbox-rest.ably.io")?
    .rest()?;
§Errors

Fails if environment is already set or if the rest_host cannot be used in the REST API URL.

Source

pub fn fallback_hosts(self, hosts: Vec<String>) -> Self

Sets the fallback hosts.

Source

pub fn http_request_timeout(self, timeout: Duration) -> Self

Sets the HTTP request timeout.

Source

pub fn http_max_retry_count(self, count: usize) -> Self

Sets the maximum number of HTTP retries.

Source

pub fn rest(self) -> Result<Rest>

Returns a Rest client using the ClientOptions.

§Errors

This method fails if the ClientOptions are not valid:

  • the REST API URL must be valid
Source

pub fn token_source(token: Credential) -> Self

Trait Implementations§

Source§

impl Debug for ClientOptions

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

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

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

impl<T> ErasedDestructor for T
where T: 'static,