pub struct Relay { /* private fields */ }
Expand description
Relay
Implementations§
source§impl Relay
impl Relay
sourcepub fn new(
url: Url,
pool_sender: Sender<RelayPoolMessage>,
notification_sender: Sender<RelayPoolNotification>,
proxy: Option<SocketAddr>,
opts: RelayOptions
) -> Self
pub fn new( url: Url, pool_sender: Sender<RelayPoolMessage>, notification_sender: Sender<RelayPoolNotification>, proxy: Option<SocketAddr>, opts: RelayOptions ) -> Self
Create new Relay
sourcepub fn proxy(&self) -> Option<SocketAddr>
pub fn proxy(&self) -> Option<SocketAddr>
Get proxy
sourcepub async fn status(&self) -> RelayStatus
pub async fn status(&self) -> RelayStatus
Get RelayStatus
sourcepub fn status_blocking(&self) -> RelayStatus
pub fn status_blocking(&self) -> RelayStatus
Get RelayStatus
sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if Relay
is connected
sourcepub async fn document(&self) -> RelayInformationDocument
pub async fn document(&self) -> RelayInformationDocument
sourcepub fn document_blocking(&self) -> RelayInformationDocument
pub fn document_blocking(&self) -> RelayInformationDocument
sourcepub async fn subscriptions(
&self
) -> HashMap<InternalSubscriptionId, ActiveSubscription>
pub async fn subscriptions( &self ) -> HashMap<InternalSubscriptionId, ActiveSubscription>
sourcepub async fn update_subscription_filters(
&self,
internal_id: InternalSubscriptionId,
filters: Vec<Filter>
)
pub async fn update_subscription_filters( &self, internal_id: InternalSubscriptionId, filters: Vec<Filter> )
Update ActiveSubscription
sourcepub fn opts(&self) -> RelayOptions
pub fn opts(&self) -> RelayOptions
Get RelayOptions
sourcepub fn stats(&self) -> RelayConnectionStats
pub fn stats(&self) -> RelayConnectionStats
sourcepub async fn connect(&self, wait_for_connection: bool)
pub async fn connect(&self, wait_for_connection: bool)
Connect to relay and keep alive connection
sourcepub async fn stop(&self) -> Result<(), Error>
pub async fn stop(&self) -> Result<(), Error>
Disconnect from relay and set status to ‘Stopped’
sourcepub async fn terminate(&self) -> Result<(), Error>
pub async fn terminate(&self) -> Result<(), Error>
Disconnect from relay and set status to ‘Terminated’
sourcepub async fn send_msg(
&self,
msg: ClientMessage,
wait: Option<Duration>
) -> Result<(), Error>
pub async fn send_msg( &self, msg: ClientMessage, wait: Option<Duration> ) -> Result<(), Error>
Send msg to relay
sourcepub async fn batch_msg(
&self,
msgs: Vec<ClientMessage>,
wait: Option<Duration>
) -> Result<(), Error>
pub async fn batch_msg( &self, msgs: Vec<ClientMessage>, wait: Option<Duration> ) -> Result<(), Error>
Send multiple ClientMessage
at once
sourcepub async fn send_event(
&self,
event: Event,
opts: RelaySendOptions
) -> Result<EventId, Error>
pub async fn send_event( &self, event: Event, opts: RelaySendOptions ) -> Result<EventId, Error>
Send event and wait for OK
relay msg
sourcepub async fn batch_event(
&self,
events: Vec<Event>,
opts: RelaySendOptions
) -> Result<(), Error>
pub async fn batch_event( &self, events: Vec<Event>, opts: RelaySendOptions ) -> Result<(), Error>
Send multiple Event
at once
sourcepub async fn subscribe(
&self,
filters: Vec<Filter>,
wait: Option<Duration>
) -> Result<(), Error>
pub async fn subscribe( &self, filters: Vec<Filter>, wait: Option<Duration> ) -> Result<(), Error>
Subscribe to filter with internal ID set to InternalSubscriptionId::Default
sourcepub async fn subscribe_with_internal_id(
&self,
internal_id: InternalSubscriptionId,
filters: Vec<Filter>,
wait: Option<Duration>
) -> Result<(), Error>
pub async fn subscribe_with_internal_id( &self, internal_id: InternalSubscriptionId, filters: Vec<Filter>, wait: Option<Duration> ) -> Result<(), Error>
Subscribe with custom internal ID
sourcepub async fn unsubscribe_with_internal_id(
&self,
internal_id: InternalSubscriptionId,
wait: Option<Duration>
) -> Result<(), Error>
pub async fn unsubscribe_with_internal_id( &self, internal_id: InternalSubscriptionId, wait: Option<Duration> ) -> Result<(), Error>
Unsubscribe with custom internal id
sourcepub async fn unsubscribe_all(&self, wait: Option<Duration>) -> Result<(), Error>
pub async fn unsubscribe_all(&self, wait: Option<Duration>) -> Result<(), Error>
Unsubscribe from all subscriptions
sourcepub async fn get_events_of_with_callback<F>(
&self,
filters: Vec<Filter>,
timeout: Duration,
opts: FilterOptions,
callback: impl Fn(Event) -> F
) -> Result<(), Error>where
F: Future<Output = ()>,
pub async fn get_events_of_with_callback<F>( &self, filters: Vec<Filter>, timeout: Duration, opts: FilterOptions, callback: impl Fn(Event) -> F ) -> Result<(), Error>where F: Future<Output = ()>,
Get events of filters with custom callback
sourcepub async fn get_events_of(
&self,
filters: Vec<Filter>,
timeout: Duration,
opts: FilterOptions
) -> Result<Vec<Event>, Error>
pub async fn get_events_of( &self, filters: Vec<Filter>, timeout: Duration, opts: FilterOptions ) -> Result<Vec<Event>, Error>
Get events of filters
sourcepub fn req_events_of(
&self,
filters: Vec<Filter>,
timeout: Duration,
opts: FilterOptions
)
pub fn req_events_of( &self, filters: Vec<Filter>, timeout: Duration, opts: FilterOptions )
Request events of filter. All events will be sent to notification listener, until the EOSE “end of stored events” message is received from the relay.