Struct Client

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

Nostr client

Implementations§

Source§

impl Client

Source

pub fn new<T>(signer: T) -> Self
where T: IntoNostrSigner,

Construct client with signer

To construct a client without signer use Client::default.

§Example
use nostr_sdk::prelude::*;

let keys = Keys::generate();
let client = Client::new(keys);
Source

pub fn builder() -> ClientBuilder

Construct client

§Example
use std::time::Duration;

use nostr_sdk::prelude::*;

let signer = Keys::generate();
let opts = ClientOptions::default().gossip(true);
let client: Client = Client::builder().signer(signer).opts(opts).build();
Source

pub fn update_min_pow_difficulty(&self, _difficulty: u8)

👎Deprecated since 0.40.0: This no longer works, please use AdmitPolicy instead.

Update minimum POW difficulty for received events

Events with a POW lower than the current value will be ignored to prevent resources exhaustion.

Source

pub fn automatic_authentication(&self, enable: bool)

Auto authenticate to relays (default: true)

https://github.com/nostr-protocol/nips/blob/master/42.md

Source

pub async fn has_signer(&self) -> bool

Check if signer is configured

Source

pub async fn signer(&self) -> Result<Arc<dyn NostrSigner>, Error>

Get current nostr signer

§Errors

Returns an error if the signer isn’t set.

Source

pub async fn set_signer<T>(&self, signer: T)
where T: IntoNostrSigner,

Set nostr signer

Source

pub async fn unset_signer(&self)

Unset nostr signer

Source

pub fn pool(&self) -> &RelayPool

Source

pub fn database(&self) -> &Arc<dyn NostrDatabase>

Get database

Source

pub fn monitor(&self) -> Option<&Monitor>

Get the relay monitor

Source

pub async fn reset(&self)

Reset the client

This method resets the client to simplify the switch to another account.

This method will:

  • unsubscribe from all subscriptions
  • disconnect and force remove all relays
  • unset the signer

This method will NOT:

Source

pub async fn shutdown(&self)

Completely shutdown client

Source

pub fn notifications(&self) -> Receiver<RelayPoolNotification>

Get new notification listener

When you call this method, you subscribe to the notifications channel from that precise moment. Anything received by relay/s before that moment is not included in the channel!
Source

pub async fn relays(&self) -> HashMap<RelayUrl, Relay>

Get relays with RelayServiceFlags::READ or RelayServiceFlags::WRITE flags

Call RelayPool::all_relays to get all relays or RelayPool::relays_with_flag to get relays with specific RelayServiceFlags.

Source

pub async fn relay<U>(&self, url: U) -> Result<Relay, Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Get a previously added Relay

Source

pub async fn add_relay<U>(&self, url: U) -> Result<bool, Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Add relay

Relays added with this method will have both RelayServiceFlags::READ and RelayServiceFlags::WRITE flags enabled.

If the relay already exists, the flags will be updated and false returned.

If are set pool subscriptions, the new added relay will inherit them. Use Client::subscribe_to method instead of Client::subscribe, to avoid to set pool subscriptions.

This method use previously set or default ClientOptions to configure the Relay (ex. set proxy, set min POW, set relay limits, …). To use custom RelayOptions use RelayPool::add_relay.

Connection is NOT automatically started with relay, remember to call Client::connect!

Source

pub async fn add_discovery_relay<U>(&self, url: U) -> Result<bool, Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Add discovery relay

If relay already exists, this method automatically add the RelayServiceFlags::DISCOVERY flag to it and return false.

https://github.com/nostr-protocol/nips/blob/master/65.md

Source

pub async fn add_read_relay<U>(&self, url: U) -> Result<bool, Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Add read relay

If relay already exists, this method add the RelayServiceFlags::READ flag to it and return false.

If are set pool subscriptions, the new added relay will inherit them. Use subscribe_to method instead of subscribe, to avoid to set pool subscriptions.

Source

pub async fn add_write_relay<U>(&self, url: U) -> Result<bool, Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Add write relay

If relay already exists, this method add the RelayServiceFlags::WRITE flag to it and return false.

Source

pub async fn remove_relay<U>(&self, url: U) -> Result<(), Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Remove and disconnect relay

If the relay has RelayServiceFlags::GOSSIP, it will not be removed from the pool and its flags will be updated (remove RelayServiceFlags::READ, RelayServiceFlags::WRITE and RelayServiceFlags::DISCOVERY flags).

To force remove the relay, use Client::force_remove_relay.

Source

pub async fn force_remove_relay<U>(&self, url: U) -> Result<(), Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Force remove and disconnect relay

Note: this method will remove the relay, also if it’s in use for the gossip model or other service!

Source

pub async fn remove_all_relays(&self)

Disconnect and remove all relays

Some relays used by some services could not be disconnected with this method (like the ones used for gossip). Use Client::force_remove_all_relays to remove every relay.

Source

pub async fn force_remove_all_relays(&self)

Disconnect and force remove all relays

Source

pub async fn connect_relay<U>(&self, url: U) -> Result<(), Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Connect to a previously added relay

Check RelayPool::connect_relay docs to learn more.

Source

pub async fn try_connect_relay<U>( &self, url: U, timeout: Duration, ) -> Result<(), Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Try to connect to a previously added relay

For further details, see the documentation of RelayPool::try_connect_relay.

Source

pub async fn disconnect_relay<U>(&self, url: U) -> Result<(), Error>
where U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Disconnect relay

Source

pub async fn connect(&self)

Connect to all added relays

Attempts to initiate a connection for every relay currently in RelayStatus::Initialized or RelayStatus::Terminated. A background connection task is spawned for each such relay, which then tries to establish the connection. Any relay not in one of these two statuses is skipped.

For further details, see the documentation of Relay::connect.

Source

pub async fn wait_for_connection(&self, timeout: Duration)

Waits for relays connections

Wait for relays connections at most for the specified timeout. The code continues when the relays are connected or the timeout is reached.

Source

pub async fn try_connect(&self, timeout: Duration) -> Output<()>

Try to establish a connection with the relays.

Attempts to establish a connection for every relay currently in RelayStatus::Initialized or RelayStatus::Terminated without spawning the connection task if it fails. This means that if the connection fails, no automatic retries are scheduled. Use Client::connect if you want to immediately spawn a connection task, regardless of whether the initial connection succeeds.

For further details, see the documentation of Relay::try_connect.

Source

pub async fn connect_with_timeout(&self, timeout: Duration)

👎Deprecated since 0.39.0: Use connect + wait_for_connection instead.

Connect to all added relays

Try to connect to the relays and wait for them to be connected at most for the specified timeout. The code continues if the timeout is reached or if all relays connect.

Source

pub async fn disconnect(&self)

Disconnect from all relays

Source

pub async fn subscriptions( &self, ) -> HashMap<SubscriptionId, HashMap<RelayUrl, Filter>>

Get subscriptions

Source

pub async fn subscription( &self, id: &SubscriptionId, ) -> HashMap<RelayUrl, Filter>

Get subscription

Source

pub async fn subscribe( &self, filter: Filter, opts: Option<SubscribeAutoCloseOptions>, ) -> Result<Output<SubscriptionId>, Error>

Subscribe to filters

This method create a new subscription. None of the previous subscriptions will be edited/closed when you call this! So remember to unsubscribe when you no longer need it. You can get all your active (non-auto-closing) subscriptions by calling client.subscriptions().await.

If gossip is enabled (see ClientOptions::gossip) the events will be requested also to NIP65 relays (automatically discovered) of public keys included in filters (if any).

§Auto-closing subscription

It’s possible to automatically close a subscription by configuring the SubscribeAutoCloseOptions.

Note: auto-closing subscriptions aren’t saved in subscriptions map!

§Example
// Compose filter
let subscription = Filter::new()
    .pubkeys(vec![keys.public_key()])
    .since(Timestamp::now());

// Subscribe
let output = client.subscribe(subscription, None).await?;
println!("Subscription ID: {}", output.val);

// Auto-closing subscription
let id = SubscriptionId::generate();
let subscription = Filter::new().kind(Kind::TextNote).limit(10);
let opts = SubscribeAutoCloseOptions::default().exit_policy(ReqExitPolicy::ExitOnEOSE);
let output = client.subscribe(subscription, Some(opts)).await?;
println!("Subscription ID: {} [auto-closing]", output.val);
Source

pub async fn subscribe_with_id( &self, id: SubscriptionId, filter: Filter, opts: Option<SubscribeAutoCloseOptions>, ) -> Result<Output<()>, Error>

Subscribe to filters with custom SubscriptionId

If gossip is enabled (see ClientOptions::gossip) the events will be requested also to NIP65 relays (automatically discovered) of public keys included in filters (if any).

§Auto-closing subscription

It’s possible to automatically close a subscription by configuring the SubscribeAutoCloseOptions.

Note: auto-closing subscriptions aren’t saved in subscriptions map!

Source

pub async fn subscribe_to<I, U>( &self, urls: I, filter: Filter, opts: Option<SubscribeAutoCloseOptions>, ) -> Result<Output<SubscriptionId>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Subscribe to filters to specific relays

This method create a new subscription. None of the previous subscriptions will be edited/closed when you call this! So remember to unsubscribe when you no longer need it.

§Auto-closing subscription

It’s possible to automatically close a subscription by configuring the SubscribeAutoCloseOptions.

Source

pub async fn subscribe_with_id_to<I, U>( &self, urls: I, id: SubscriptionId, filter: Filter, opts: Option<SubscribeAutoCloseOptions>, ) -> Result<Output<()>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Subscribe to filter with custom SubscriptionId to specific relays

§Auto-closing subscription

It’s possible to automatically close a subscription by configuring the SubscribeAutoCloseOptions.

Source

pub async fn subscribe_targeted<I, U>( &self, id: SubscriptionId, targets: I, opts: SubscribeOptions, ) -> Result<Output<()>, Error>
where I: IntoIterator<Item = (U, Filter)>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Targeted subscription

Subscribe to specific relays with specific filters

Source

pub async fn unsubscribe(&self, id: &SubscriptionId)

Unsubscribe

Source

pub async fn unsubscribe_all(&self)

Unsubscribe from all subscriptions

Source

pub async fn sync( &self, filter: Filter, opts: &SyncOptions, ) -> Result<Output<Reconciliation>, Error>

Sync events with relays (negentropy reconciliation)

If gossip is enabled (see ClientOptions::gossip) the events will be reconciled also from NIP65 relays (automatically discovered) of public keys included in filters (if any).

https://github.com/hoytech/negentropy

Source

pub async fn sync_with<I, U>( &self, urls: I, filter: Filter, opts: &SyncOptions, ) -> Result<Output<Reconciliation>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Sync events with specific relays (negentropy reconciliation)

https://github.com/hoytech/negentropy

Source

pub async fn fetch_events( &self, filter: Filter, timeout: Duration, ) -> Result<Events, Error>

Fetch events from relays

§Overview

This is an auto-closing subscription and will be closed automatically on EOSE. To use another exit policy, check RelayPool::fetch_events. For long-lived subscriptions, check Client::subscribe.

§Gossip

If gossip is enabled (see ClientOptions::gossip) the events will be requested also to NIP65 relays (automatically discovered) of public keys included in filters (if any).

§Example
let subscription = Filter::new()
    .pubkeys(vec![keys.public_key()])
    .since(Timestamp::now());

let _events = client
    .fetch_events(subscription, Duration::from_secs(10))
    .await
    .unwrap();
Source

pub async fn fetch_events_from<I, U>( &self, urls: I, filter: Filter, timeout: Duration, ) -> Result<Events, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Fetch events from specific relays

§Overview

This is an auto-closing subscription and will be closed automatically on EOSE. To use another exit policy, check RelayPool::fetch_events_from. For long-lived subscriptions, check Client::subscribe_to.

Source

pub async fn fetch_combined_events( &self, filter: Filter, timeout: Duration, ) -> Result<Events, Error>

Get events both from database and relays

§Overview

This is an auto-closing subscription and will be closed automatically on EOSE. For long-lived subscriptions, check Client::subscribe.

§Gossip

If gossip is enabled (see ClientOptions::gossip) the events will be requested also to NIP65 relays (automatically discovered) of public keys included in filters (if any).

§Notes and alternative example

This method will be deprecated in the future! This is a temporary solution for who still want to query events both from database and relays and merge the result. The optimal solution is to execute a Client::sync to reconcile missing events, Client::subscribe to get all new future events, NostrDatabase::query to query stored events and Client::handle_notifications to listen-for/handle new events (i.e. to know when update the UI). This will allow very fast queries, low bandwidth usage (depending on how many events the client have to reconcile) and a lower load on the relays.

You can obtain the same result with:

// Query database
let stored_events: Events = client.database().query(filter.clone()).await?;

// Query relays
let fetched_events: Events = client.fetch_events(filter, Duration::from_secs(10)).await?;

// Merge result
let events: Events = stored_events.merge(fetched_events);

// Iter and print result
for event in events.into_iter() {
    println!("{}", event.as_json());
}
Source

pub async fn stream_events( &self, filter: Filter, timeout: Duration, ) -> Result<ReceiverStream<Event>, Error>

Stream events from relays

§Overview

This is an auto-closing subscription and will be closed automatically on EOSE. To use another exit policy, check RelayPool::stream_events. For long-lived subscriptions, check Client::subscribe.

§Gossip

If gossip is enabled (see ClientOptions::gossip) the events will be streamed also from NIP65 relays (automatically discovered) of public keys included in filters (if any).

Source

pub async fn stream_events_from<I, U>( &self, urls: I, filter: Filter, timeout: Duration, ) -> Result<ReceiverStream<Event>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Stream events from specific relays

§Overview

This is an auto-closing subscription and will be closed automatically on EOSE. To use another exit policy, check RelayPool::stream_events_from. For long-lived subscriptions, check Client::subscribe_to.

Source

pub async fn stream_events_targeted( &self, targets: HashMap<RelayUrl, Filter>, timeout: Duration, ) -> Result<ReceiverStream<Event>, Error>

Stream events from specific relays with specific filters

§Overview

This is an auto-closing subscription and will be closed automatically on EOSE. To use another exit policy, check RelayPool::stream_events_targeted. For long-lived subscriptions, check Client::subscribe_targeted.

Source

pub async fn send_msg_to<I, U>( &self, urls: I, msg: ClientMessage<'_>, ) -> Result<Output<()>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Send the client message to a specific relays

Source

pub async fn batch_msg_to<I, U>( &self, urls: I, msgs: Vec<ClientMessage<'_>>, ) -> Result<Output<()>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Batch send client messages to specific relays

Source

pub async fn send_event(&self, event: &Event) -> Result<Output<EventId>, Error>

Send the event to relays

§Overview

Send the Event to all relays with RelayServiceFlags::WRITE flag.

§Gossip

If gossip is enabled (see ClientOptions::gossip):

  • the Event will be sent also to NIP65 relays (automatically discovered);
  • the gossip data will be updated, if the Event is a NIP17/NIP65 relay list.
Source

pub async fn send_event_to<I, U>( &self, urls: I, event: &Event, ) -> Result<Output<EventId>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Send event to specific relays

§Gossip

If gossip is enabled (see ClientOptions::gossip) and the Event is a NIP17/NIP65 relay list, the gossip data will be updated.

Source

pub async fn sign_event_builder( &self, builder: EventBuilder, ) -> Result<Event, Error>

Build, sign and return Event

This method requires a NostrSigner.

Source

pub async fn send_event_builder( &self, builder: EventBuilder, ) -> Result<Output<EventId>, Error>

Take an EventBuilder, sign it by using the NostrSigner and broadcast to relays.

This method requires a NostrSigner.

Check Client::send_event from more details.

Source

pub async fn send_event_builder_to<I, U>( &self, urls: I, builder: EventBuilder, ) -> Result<Output<EventId>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, Error: From<<U as TryIntoUrl>::Err>,

Take an EventBuilder, sign it by using the NostrSigner and broadcast to specific relays.

This method requires a NostrSigner.

Check Client::send_event_to from more details.

Source

pub async fn fetch_metadata( &self, public_key: PublicKey, timeout: Duration, ) -> Result<Option<Metadata>, Error>

Fetch the newest public key metadata from relays.

Returns None if the Metadata of the PublicKey has not been found.

Check Client::fetch_events for more details.

If you only want to consult stored data, consider client.database().profile(PUBKEY).

https://github.com/nostr-protocol/nips/blob/master/01.md

Source

pub async fn set_metadata( &self, metadata: &Metadata, ) -> Result<Output<EventId>, Error>

Update metadata

This method requires a NostrSigner.

https://github.com/nostr-protocol/nips/blob/master/01.md

§Example
let metadata = Metadata::new()
    .name("username")
    .display_name("My Username")
    .about("Description")
    .picture(Url::parse("https://example.com/avatar.png").unwrap())
    .nip05("username@example.com");

client.set_metadata(&metadata).await.unwrap();
Source

pub async fn get_contact_list( &self, timeout: Duration, ) -> Result<Vec<Contact>, Error>

Get the contact list from relays.

This method requires a NostrSigner.

https://github.com/nostr-protocol/nips/blob/master/02.md

Source

pub async fn get_contact_list_public_keys( &self, timeout: Duration, ) -> Result<Vec<PublicKey>, Error>

Get contact list public keys from relays.

This method requires a NostrSigner.

https://github.com/nostr-protocol/nips/blob/master/02.md

Source

pub async fn get_contact_list_metadata( &self, timeout: Duration, ) -> Result<HashMap<PublicKey, Metadata>, Error>

Get contact list Metadata from relays.

This method requires a NostrSigner.

Source

pub async fn send_private_msg<S, I>( &self, receiver: PublicKey, message: S, rumor_extra_tags: I, ) -> Result<Output<EventId>, Error>
where S: Into<String>, I: IntoIterator<Item = Tag>,

Available on crate feature nip59 only.

Send a private direct message

If gossip is enabled (see ClientOptions::gossip) the message will be sent to the NIP17 relays (automatically discovered). If gossip is not enabled will be sent to all relays with RelayServiceFlags::WRITE flag.

This method requires a NostrSigner.

§Errors

Returns Error::PrivateMsgRelaysNotFound if the receiver hasn’t set the NIP17 list, meaning that is not ready to receive private messages.

https://github.com/nostr-protocol/nips/blob/master/17.md

Source

pub async fn send_private_msg_to<I, S, U, IT>( &self, urls: I, receiver: PublicKey, message: S, rumor_extra_tags: IT, ) -> Result<Output<EventId>, Error>
where I: IntoIterator<Item = U>, S: Into<String>, U: TryIntoUrl, IT: IntoIterator<Item = Tag>, Error: From<<U as TryIntoUrl>::Err>,

Available on crate feature nip59 only.

Send a private direct message to specific relays

This method requires a NostrSigner.

https://github.com/nostr-protocol/nips/blob/master/17.md

Source

pub async fn gift_wrap<I>( &self, receiver: &PublicKey, rumor: UnsignedEvent, extra_tags: I, ) -> Result<Output<EventId>, Error>
where I: IntoIterator<Item = Tag>,

Available on crate feature nip59 only.

Construct Gift Wrap and send to relays

This method requires a NostrSigner.

Check Client::send_event to know how sending events works.

https://github.com/nostr-protocol/nips/blob/master/59.md

Source

pub async fn gift_wrap_to<I, U, IT>( &self, urls: I, receiver: &PublicKey, rumor: UnsignedEvent, extra_tags: IT, ) -> Result<Output<EventId>, Error>
where I: IntoIterator<Item = U>, U: TryIntoUrl, IT: IntoIterator<Item = Tag>, Error: From<<U as TryIntoUrl>::Err>,

Available on crate feature nip59 only.

Construct Gift Wrap and send to specific relays

This method requires a NostrSigner.

https://github.com/nostr-protocol/nips/blob/master/59.md

Source

pub async fn unwrap_gift_wrap( &self, gift_wrap: &Event, ) -> Result<UnwrappedGift, Error>

Available on crate feature nip59 only.

Unwrap Gift Wrap event

This method requires a NostrSigner.

Check UnwrappedGift::from_gift_wrap to learn more.

https://github.com/nostr-protocol/nips/blob/master/59.md

Source

pub async fn handle_notifications<F, Fut>(&self, func: F) -> Result<(), Error>
where F: Fn(RelayPoolNotification) -> Fut, Fut: Future<Output = Result<bool>>,

Handle notifications

The closure function expects a bool as output: return true to exit from the notification loop.

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

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a type. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> 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,