pub struct Client { /* private fields */ }
Expand description
A client connection to a relay.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Is connected
Sourcepub async fn disconnect(&self) -> Result<(), Error>
pub async fn disconnect(&self) -> Result<(), Error>
Disconnect from the relay
Sourcepub async fn get_auth_state(&self) -> Result<AuthState, Error>
pub async fn get_auth_state(&self) -> Result<AuthState, Error>
Get auth state
Sourcepub async fn wait_for_auth_state_change(
&self,
timeout: Duration,
) -> Result<AuthState, Error>
pub async fn wait_for_auth_state_change( &self, timeout: Duration, ) -> Result<AuthState, Error>
Wait for auth state
Sourcepub async fn send_authenticate(
&self,
challenge: String,
signer: Arc<dyn Signer>,
reconnect_timeout: Duration,
) -> Result<Id, Error>
pub async fn send_authenticate( &self, challenge: String, signer: Arc<dyn Signer>, reconnect_timeout: Duration, ) -> Result<Id, Error>
Authenticate This does not wait for any reply.
Sourcepub async fn full_authenticate(
&self,
signer: Arc<dyn Signer>,
timeout: Duration,
) -> Result<(), Error>
pub async fn full_authenticate( &self, signer: Arc<dyn Signer>, timeout: Duration, ) -> Result<(), Error>
Full Authentication process. Run this when you get “auth-required” in an OK or CLOSED message if you wish to authenticate.
Sourcepub async fn post_event(
&self,
event: Event,
reconnect_timeout: Duration,
) -> Result<(), Error>
pub async fn post_event( &self, event: Event, reconnect_timeout: Duration, ) -> Result<(), Error>
Post an event to the relay
Sourcepub async fn post_raw_event(
&self,
json: String,
reconnect_timeout: Duration,
) -> Result<(), Error>
pub async fn post_raw_event( &self, json: String, reconnect_timeout: Duration, ) -> Result<(), Error>
Post a raw event to the relay
Sourcepub async fn post_event_and_wait_for_result(
&self,
event: Event,
timeout: Duration,
auth: Option<Arc<dyn Signer>>,
) -> Result<(bool, String), Error>
pub async fn post_event_and_wait_for_result( &self, event: Event, timeout: Duration, auth: Option<Arc<dyn Signer>>, ) -> Result<(bool, String), Error>
This posts the event, and waits for the OK result, authenticating if requested if auth is Some.
Sourcepub async fn wait_for_ok(
&self,
id: Id,
timeout: Duration,
) -> Result<(bool, String), Error>
pub async fn wait_for_ok( &self, id: Id, timeout: Duration, ) -> Result<(bool, String), Error>
Wait for an Ok
Sourcepub async fn subscribe(
&self,
filter: Filter,
reconnect_timeout: Duration,
) -> Result<SubscriptionId, Error>
pub async fn subscribe( &self, filter: Filter, reconnect_timeout: Duration, ) -> Result<SubscriptionId, Error>
Subscribe to a filter. This does not wait for results.
Sourcepub async fn close_subscription(
&self,
sub_id: SubscriptionId,
) -> Result<(), Error>
pub async fn close_subscription( &self, sub_id: SubscriptionId, ) -> Result<(), Error>
Close a subscription
Sourcepub async fn wait_for_subscribed_event(
&self,
sub_id: SubscriptionId,
timeout: Duration,
) -> Result<Event, Error>
pub async fn wait_for_subscribed_event( &self, sub_id: SubscriptionId, timeout: Duration, ) -> Result<Event, Error>
Wait for an event on the given subscription
Sourcepub async fn wait_for_subscribed_event_or_eose(
&self,
sub_id: SubscriptionId,
timeout: Duration,
) -> Result<Option<Event>, Error>
pub async fn wait_for_subscribed_event_or_eose( &self, sub_id: SubscriptionId, timeout: Duration, ) -> Result<Option<Event>, Error>
Wait for an event on the given subscription
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more