Struct Client

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

The Relay WebSocket RPC client.

This provides the high-level access to all of the available RPC methods. For a lower-level RPC stream see ClientStream.

Implementations§

Source§

impl Client

Source

pub fn new<T>(handler: T) -> Self

Creates a new Client with the provided handler.

Source

pub fn publish( &self, topic: Topic, message: impl Into<Arc<str>>, attestation: impl Into<Option<Arc<str>>>, tag: u32, ttl: Duration, prompt: bool, ) -> EmptyResponseFuture<Publish>

Publishes a message over the network on given topic.

Source

pub fn subscribe(&self, topic: Topic) -> ResponseFuture<Subscribe>

Subscribes on topic to receive messages. The request is resolved optimistically as soon as the relay receives it.

Source

pub fn subscribe_blocking( &self, topic: Topic, ) -> ResponseFuture<SubscribeBlocking>

Subscribes on topic to receive messages. The request is resolved only when fully processed by the relay. Note: This function is experimental and will likely be removed in the future.

Source

pub fn unsubscribe(&self, topic: Topic) -> EmptyResponseFuture<Unsubscribe>

Unsubscribes from a topic.

Source

pub fn fetch(&self, topic: Topic) -> ResponseFuture<FetchMessages>

Fetch mailbox messages for a specific topic.

Source

pub fn fetch_stream(&self, topics: impl Into<Vec<Topic>>) -> FetchMessageStream

Fetch mailbox messages for a specific topic. Returns a [Stream].

Source

pub fn batch_subscribe( &self, topics: impl Into<Vec<Topic>>, ) -> ResponseFuture<BatchSubscribe>

Subscribes on multiple topics to receive messages. The request is resolved optimistically as soon as the relay receives it.

Source

pub fn batch_subscribe_blocking( &self, topics: impl Into<Vec<Topic>>, ) -> impl Future<Output = Result<Vec<Result<SubscriptionId, Error<SubscriptionError>>>, Error<SubscriptionError>>>

Subscribes on multiple topics to receive messages. The request is resolved only when fully processed by the relay. Note: This function is experimental and will likely be removed in the future.

Source

pub fn batch_unsubscribe( &self, subscriptions: impl Into<Vec<Unsubscribe>>, ) -> EmptyResponseFuture<BatchUnsubscribe>

Unsubscribes from multiple topics.

Source

pub fn batch_fetch( &self, topics: impl Into<Vec<Topic>>, ) -> ResponseFuture<BatchFetchMessages>

Fetch mailbox messages for multiple topics.

Source

pub async fn batch_receive( &self, receipts: impl Into<Vec<Receipt>>, ) -> ResponseFuture<BatchReceiveMessages>

Acknowledge receipt of messages from a subscribed client.

Source

pub async fn connect(&self, opts: &ConnectionOptions) -> Result<(), ClientError>

Opens a connection to the Relay.

Source

pub async fn disconnect(&self) -> Result<(), ClientError>

Closes the Relay connection.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> ErasedDestructor for T
where T: 'static,