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
impl Client
Sourcepub fn new<T>(handler: T) -> Selfwhere
T: ConnectionHandler,
pub fn new<T>(handler: T) -> Selfwhere
T: ConnectionHandler,
Creates a new Client with the provided handler.
Sourcepub fn publish(
&self,
topic: Topic,
message: impl Into<Arc<str>>,
attestation: impl Into<Option<Arc<str>>>,
tag: u32,
ttl: Duration,
prompt: bool,
) -> EmptyResponseFuture<Publish> ⓘ
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.
Sourcepub fn subscribe(&self, topic: Topic) -> ResponseFuture<Subscribe> ⓘ
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.
Sourcepub fn subscribe_blocking(
&self,
topic: Topic,
) -> ResponseFuture<SubscribeBlocking> ⓘ
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.
Sourcepub fn unsubscribe(&self, topic: Topic) -> EmptyResponseFuture<Unsubscribe> ⓘ
pub fn unsubscribe(&self, topic: Topic) -> EmptyResponseFuture<Unsubscribe> ⓘ
Unsubscribes from a topic.
Sourcepub fn fetch(&self, topic: Topic) -> ResponseFuture<FetchMessages> ⓘ
pub fn fetch(&self, topic: Topic) -> ResponseFuture<FetchMessages> ⓘ
Fetch mailbox messages for a specific topic.
Sourcepub fn fetch_stream(&self, topics: impl Into<Vec<Topic>>) -> FetchMessageStream
pub fn fetch_stream(&self, topics: impl Into<Vec<Topic>>) -> FetchMessageStream
Fetch mailbox messages for a specific topic. Returns a [Stream].
Sourcepub fn batch_subscribe(
&self,
topics: impl Into<Vec<Topic>>,
) -> ResponseFuture<BatchSubscribe> ⓘ
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.
Sourcepub fn batch_subscribe_blocking(
&self,
topics: impl Into<Vec<Topic>>,
) -> impl Future<Output = Result<Vec<Result<SubscriptionId, Error<SubscriptionError>>>, Error<SubscriptionError>>>
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.
Sourcepub fn batch_unsubscribe(
&self,
subscriptions: impl Into<Vec<Unsubscribe>>,
) -> EmptyResponseFuture<BatchUnsubscribe> ⓘ
pub fn batch_unsubscribe( &self, subscriptions: impl Into<Vec<Unsubscribe>>, ) -> EmptyResponseFuture<BatchUnsubscribe> ⓘ
Unsubscribes from multiple topics.
Sourcepub fn batch_fetch(
&self,
topics: impl Into<Vec<Topic>>,
) -> ResponseFuture<BatchFetchMessages> ⓘ
pub fn batch_fetch( &self, topics: impl Into<Vec<Topic>>, ) -> ResponseFuture<BatchFetchMessages> ⓘ
Fetch mailbox messages for multiple topics.
Sourcepub async fn batch_receive(
&self,
receipts: impl Into<Vec<Receipt>>,
) -> ResponseFuture<BatchReceiveMessages> ⓘ
pub async fn batch_receive( &self, receipts: impl Into<Vec<Receipt>>, ) -> ResponseFuture<BatchReceiveMessages> ⓘ
Acknowledge receipt of messages from a subscribed client.
Sourcepub async fn connect(&self, opts: &ConnectionOptions) -> Result<(), ClientError>
pub async fn connect(&self, opts: &ConnectionOptions) -> Result<(), ClientError>
Opens a connection to the Relay.
Sourcepub async fn disconnect(&self) -> Result<(), ClientError>
pub async fn disconnect(&self) -> Result<(), ClientError>
Closes the Relay connection.