Skip to main content

NostrService

Struct NostrService 

Source
pub struct NostrService {
    client: Client,
    others: Client,
    private: PrivateRelay,
    reach: Reach,
    reached: Arc<Mutex<Reached>>,
    reaching: Arc<Mutex<()>>,
    own: Arc<Mutex<Own>>,
    joining: Arc<Mutex<()>>,
    opened_at: Instant,
    sightings: Arc<Mutex<Sightings>>,
}
Expand description

The Nostr client: a relay pool over a local event store. Cheap to clone; clones share the pool and the store.

Fields§

§client: Client

The pool of the account’s own relays, over the event store.

§others: Client

The pool of other people’s relays, over the same store.

§private: PrivateRelay

The relay this runs itself, over the same store, for what is the account’s alone.

§reach: Reach

How far other people’s relays are reached for.

§reached: Arc<Mutex<Reached>>

What is remembered of reaching for them.

§reaching: Arc<Mutex<()>>

Held while relays are being connected to in the pool of other people’s: two questions that reach for the same relay at once would each take the other’s connecting for a relay that didn’t.

§own: Arc<Mutex<Own>>

The account’s own relays, and which are in use.

§joining: Arc<Mutex<()>>

Held while the account’s relays are changed, so that one account’s are out before another’s are in.

§opened_at: Instant

When the relays were first told to connect.

§sightings: Arc<Mutex<Sightings>>

Which relays each note was seen on, since then.

Implementations§

Source§

impl NostrService

Source

pub async fn open( store_path: PathBuf, relays: Vec<String>, ) -> Result<Self, String>

Open the event store at store_path and start connecting to relays. Returns once the store is open; relays connect in the background.

Source

pub async fn open_reaching( store_path: PathBuf, relays: Vec<String>, reach: Reach, ) -> Result<Self, String>

As Self::open, reaching for other people’s relays as far as reach says.

Source

async fn reachable_relays(&self) -> Vec<RelayUrl>

The relays a request can be sent to now: those that are connected.

A request is only sent to these. Sent to the whole pool, it would wait its full timeout on every relay that is down, and one dead relay would make every page slow.

With none connected, waits up to CONNECT_WAIT for the first. Just after startup it also gives relays that are still connecting until CONNECT_GRACE to join.

Source

fn sightings(&self) -> MutexGuard<'_, Sightings>

Which relays each note was seen on. What is kept there is whole after every change to it, so it is as good after a panic as before.

Source

pub fn seen_on(&self, notes: &[EventId]) -> HashMap<EventId, Vec<RelayUrl>>

The relays each of notes was seen on, for those that were seen on any.

Source

fn pool(&self, pool: Pool) -> &Client

The pool pool names.

Source

async fn ask( &self, pool: Pool, relay: &RelayUrl, filters: Vec<Filter>, timeout: Duration, ) -> Result<Asked, String>

What relay, of the pool pool, sends for filters, until it says that is all or timeout has passed. An event it sends that can’t be taken (a bad signature, say) is left out, and the rest still counts.

A relay that says no to the question (it wants to know who asks, it keeps no such events) and sends nothing is an error. One that ran out of time is not, and what it sent counts; that it did is said with what it sent.

Source

fn leave_alone(&self, relay: &RelayUrl, why: &str)

Leave relay alone for a while: it said no, or did not answer in time, and everything asked of it meanwhile would wait as long.

Source

fn left_alone(&self) -> HashSet<RelayUrl>

The relays that are being left alone, and those the account has blocked, which always are.

Source

async fn answering_relays(&self) -> Vec<RelayUrl>

The account’s own relays to ask: those that are connected, less the ones being left alone, unless that leaves none.

Source

async fn fetch( &self, filters: Vec<Filter>, ) -> Result<impl Iterator<Item = Event>, FetchError>

Ask the connected relays for the events any of filters matches, newest first, and note which relay sent which note.

Source

async fn fetch_within( &self, filters: Vec<Filter>, timeout: Duration, ) -> Result<impl Iterator<Item = Event>, FetchError>

As Self::fetch, giving the relays timeout to answer. A relay that fails is left out; if every one does, that is the error.

Source

async fn fetch_from_each( &self, filters: Vec<Filter>, timeout: Duration, ) -> Result<(Vec<Event>, bool), FetchError>

As Self::fetch_within, and whether every relay of the pool answered: whether what didn’t come is nowhere, as far as this client can know.

Source

async fn gather( &self, pool: Pool, asks: Vec<(RelayUrl, Vec<Filter>)>, timeout: Duration, ) -> (Vec<Event>, usize, Option<String>)

What the relays of asks, which are of the pool pool, send for the filters each is asked with, each event once and the newest first; how many of them answered; and what one that didn’t said. Which relay sent which note is noted, and a relay that said no, or ran out of time, is left alone for a while.

Source

fn reached(&self) -> MutexGuard<'_, Reached>

What is remembered of reaching for other people’s relays. Whole after every change to it, as Self::sightings is.

Source

async fn relays_of( &self, people: &[PublicKey], listed: Listed, patient: bool, ) -> HashMap<PublicKey, Vec<RelayUrl>>

The relays people list for listed, for those of them who have a relay list with any that may be connected to.

The account’s own relays are asked for the lists of those not asked about lately, and what they send is the store’s, which is what is read: a list seen once is known without a relay, and the newest seen is the one that counts. With patient, their answer is waited for; without, only when the store knows nobody’s list, and otherwise it serves the next time: a list of notes is not kept waiting for lists that seldom change.

Source

fn relay_lists_of(people: &[PublicKey]) -> Vec<Filter>

The filters that ask for the relay lists of people.

Source

async fn ask_for_relay_lists(&self, people: Vec<PublicKey>)

Ask the account’s own relays for the relay lists of people, for the store’s sake: it is what is read. If they can’t be asked, people count as not asked about.

Source

async fn stored_relay_lists(&self, people: &[PublicKey]) -> Vec<Event>

The newest relay list of each of people that the store has one of.

Source

async fn reach_for( &self, listed: &HashMap<PublicKey, Vec<RelayUrl>>, ) -> Vec<(RelayUrl, Vec<PublicKey>)>

The relays to ask about, or send to, the people of listed, beside the account’s own, and who is on each: so many for each person, as many in all as may be reached for, none that failed lately, and only those that are connected now. See outbox::plan.

Source

async fn connected<T>(&self, planned: Vec<(RelayUrl, T)>) -> Vec<(RelayUrl, T)>

Those of planned, each a relay and what it is wanted for, whose relay is in the pool of other people’s relays and connected, once all have been given the time to connect. The pool is then no bigger than it may be, but for the relays in use.

The only way into Self::connect_to, which is not to be in twice at once for the same relay.

Source

async fn ask_where_said(&self, said: &[(EventId, RelayUrl)]) -> Vec<Event>

What the relays said to have notes send of them: each relay is asked for the notes it is said to have. A relay that may not be connected to, or is being left alone, is not asked, and neither is one of the account’s own, which were asked; if there are more than may be reached for, the ones said to have the most are. Nothing, and never an error, when none is reached: this is on top of what was had.

Source

async fn connect_to(&self, relay: &RelayUrl) -> bool

Have relay in the pool of other people’s relays, connected. Returns whether it is. One that doesn’t connect is taken out again, and left alone for a while.

Source

async fn let_go_of_unused(&self)

Take out of the pool of other people’s relays those that have not been used for a while, and, if there are more than may be reached for, the ones used longest ago; but none used just now, which may be in the middle of answering.

Source

async fn ask_their_relays( &self, people: &[PublicKey], listed: Listed, patient: bool, asking: impl Fn(&[PublicKey]) -> Vec<Filter>, ) -> Vec<Event>

What the relays that people list for listed send about them, beside what the account’s own relays have: each relay reached for is asked with the filters asking makes for the people who list it. Nothing, when nobody lists a relay that is reached; never an error, since what is asked for here is on top of what was had. See Self::relays_of for patient.

Source

fn own(&self) -> MutexGuard<'_, Own>

The account’s own relays and which are in use, whole after every change, as Self::sightings is.

Source

fn in_use(&self) -> Vec<RelayUrl>

The account’s own relays that are in use, connected or not: those its relay list says it writes to, and those the config names unless they stand down (see Own).

Source

pub async fn use_relays_of(&self, account: Option<PublicKey>) -> usize

Have the relays that the relay list of account says it writes to, so many of them, be its own: where what it wrote is and where what it writes goes, in place of those the config names once one of them is connected (see Own). Those of the account before, if any, are taken out first; with no account, that is all, and the config’s relays are the ones in use. Returns how many joined the pool.

The list the store has is gone by at once, and the newest the relays have when they have answered.

Source

async fn join_account_relays(&self, writes: Vec<RelayUrl>) -> usize

Have writes, so many of them, be the relays the account’s relay list names as its own: those that were put in the pool for it and are not among them are taken out, those that are stay as they are, connected, and the new ones get a moment to connect. Whether the config’s relays stand down is settled by whether any of writes is connected then. Returns how many are in the pool for the account’s list.

Source

async fn settle_config_relays(&self)

Have the config’s relays that are in use connected, and hang up on those that stand down: after a while, so that what was asked of them before they did is answered.

Source

pub async fn stored_event(&self, id: EventId) -> Option<Event>

The event id, if the store has it.

Source

pub async fn event(&self, id: EventId, author: PublicKey) -> Option<Event>

The event id, which is a note on show: the store’s, or, since the store lets go of what is old while it may still be showing (see sweep), the one the relays send again: the account’s own, and then the ones author writes to. None if none of them has it.

Source

pub async fn sweep( &self, account: PublicKey, bookmarked: &HashSet<EventId>, before: Timestamp, ) -> Result<usize, String>

Have the store let go of what was written at before or earlier and can be asked of the relays again (see sweep): not what account wrote or bookmarked. Returns how many events went.

Source

pub async fn relay_holding(&self, id: EventId) -> Option<RelayUrl>

A connected relay that has the event id: where someone else can be told to look for it. The first to send it; None if none does before long.

Source

pub async fn sign_and_publish( &self, signer: &Signer, author: PublicKey, unsigned: EventBuilder, ) -> Result<Event, PublishError>

Have signer sign the event unsigned describes as author, and send it to the connected relays.

Source

pub async fn standing( &self, source: Source, notes: Vec<EventId>, account: Option<PublicKey>, ) -> Result<Standing, FetchError>

How notes stand, as far as source knows: what was made of them, with the likes and reposts of account told apart, and which relays they were seen on.

The count is always of what the store holds. Asking the relays brings what they have into the store first, so an answer from them is never less than the store’s own.

The relays are asked for the notes themselves as well: each that sends one has it, and is one of those it was seen on.

Source

pub async fn who_did( &self, note: EventId, what: Left, ) -> Result<Vec<Doer>, FetchError>

Who left what on note, as far as the store holds: the same events its count is of (see Self::standing), so that who is listed is who was counted.

Source

async fn receipts_until( &self, note: EventId, is_it: &impl Fn(&Event) -> bool, ) -> bool

Listen on the connected relays for the receipts of note until one of them is_it. Returns whether one was; false when the relays stopped sending first.

Source

pub async fn await_zap_receipt(&self, note: EventId, bolt11: String) -> bool

Wait for the receipt that says the invoice bolt11, which zaps note, was paid. Returns whether it came within RECEIPT_WAIT.

The receipt is kept in the store as everything a relay sends is, so the note’s count has it afterwards.

Source

pub async fn publish(&self, event: &Event) -> Result<usize, PublishError>

Send event to the connected relays. It has gone out when at least one took it, and is then kept in the store as well, as anything a relay sends is. Returns how many took it.

An event no relay took is not kept: the store would show as published what nobody else can see.

Source

async fn send_home(&self, event: &Event) -> Result<Vec<RelayUrl>, PublishError>

Send event to the account’s own relays that are connected: those that took it, or why none did.

Source

async fn deliver(&self, event: &Event) -> Vec<RelayUrl>

Send event to the people it names, if it is of a kind that is meant for them: to the relays they read, as their relay lists have them, so many for each and no more in all than may be reached for. Returns those that took it. That none did is no error: it is on the account’s own relays, where anyone can find it.

Source

async fn events( &self, source: Source, filters: Vec<Filter>, ) -> Result<Vec<Event>, FetchError>

The events any of filters matches, according to source. A store that can’t be read knows of none.

Source

async fn notes_by_id( &self, wanted: &HashMap<EventId, Whereabouts>, source: Source, wait: Duration, ) -> HashMap<EventId, Note>

The notes wanted, each as a row shows it, as far as source has them: the store, and for the relays’ turn the relays as well, for the ones the store doesn’t have, which get wait to send them: the account’s own, and then, for a note wanted knows more of, the relays its author writes to and the relay it is said to be on. One that isn’t found is left out, and so is one that is no note a row shows.

Source

async fn events_elsewhere( &self, sought: &[(EventId, &Whereabouts)], wait: Duration, ) -> Vec<Event>

Those of the events sought that the relays they may be on have, beside the account’s own: the relays an event’s author writes to, if who that is is known, and the relay it is said to be on. They get wait between them; nothing, if that runs out, or if nothing is known of where any is.

Source

async fn with_quotes(&self, notes: Vec<Note>, source: Source) -> Vec<Note>

notes, each with the notes its row shows it quoting, and those with the notes they quote in turn, QUOTE_DEPTH notes deep and no deeper, as far as source has them (see Self::notes_by_id).

Source

pub async fn notes_listed( &self, listed: Vec<(EventId, Whereabouts)>, ) -> Vec<Note>

The notes listed names, in its order, each as a row shows it, with the notes it quotes: from the store, and from the relays for those the store doesn’t have, the account’s own and then wherever listed says each may be. One that nobody has is left out, and so is one that is no note a row shows.

Source

pub async fn note(&self, event: Event) -> Note

event, which the store just got, as a row shows it: with the notes it quotes, if the store has them.

Source

pub async fn quoting(&self, note: Note) -> Note

note, which is being written, with the notes it quotes: from the store, and from the relays for those the store doesn’t have, as a list of notes would look for them.

Source

pub async fn thread( &self, source: Source, focused: EventId, whereabouts: &Whereabouts, ) -> Result<Vec<Note>, FetchError>

The conversation the note focused is part of, as far as source knows it: the note in full, and the others as rows show them. Empty if the note itself is not to be found.

Three questions are asked, as Vega asks them. Which notes name the conversation’s root (and the root itself), which is asked of the relays of those whose conversation it is as well; then, if those are few, which notes name any of them, since some clients tag only the note they answer; and last, one at a time, the notes between the focused one and the root that neither brought.

Naming a note is not answering it: a note that only cites one of these is no part of the conversation, and is left out.

Source

pub async fn cached_feed( &self, authors: &[PublicKey], limit: usize, ) -> Result<Vec<Note>, String>

The newest notes of authors that are already in the store.

Source

pub async fn fetch_feed( &self, authors: &[PublicKey], until: Option<u64>, limit: usize, ) -> Result<Vec<Note>, FetchError>

One page of the notes of authors from the relays: the limit newest written at or before until, or the newest of all, of what the account’s own relays have and what the relays the authors write to have. Nobody’s notes are none, without asking.

Source

pub async fn notifications( &self, source: Source, account: PublicKey, since: Option<u64>, until: Option<u64>, ) -> Result<Notified, FetchError>

What source has to tell account of: one page of the events that name it, the newest written after since and at or before until where those are given, each read with the note it is about (see notifications).

The relays asked are the account’s own and the ones its relay list says it reads: where others send what they write to it (NIP-65).

Source

async fn stored_list(&self, kind: Kind, account: PublicKey) -> Option<Event>

The newest list of kind that account wrote, of those in the store, if it has one: a contact list, a bookmark list.

Source

async fn asked_list( &self, kind: Kind, account: PublicKey, ) -> Result<(Option<Event>, bool), FetchError>

The newest list of kind that account wrote, after asking the relays for it, and whether every relay of the pool answered. What the relays send is kept in the store, which only ever keeps the newest list, so the store is read as well: a relay that is behind doesn’t undo a newer list already seen.

Source

async fn newest_list( &self, kind: Kind, account: PublicKey, ) -> Result<Option<Event>, FetchError>

The newest list of kind that account wrote, after asking the relays for it. None if none of those that answered has one.

Source

async fn list_to_change( &self, kind: Kind, account: PublicKey, ) -> Result<Option<Event>, FetchError>

The newest list of kind that account wrote, to be written again with a change. None, which is leave to write a first one, only if every relay of the pool answered and none has one: a relay that didn’t answer may be the one that does, and a first list would replace it there as everywhere.

Source

pub async fn cached_contacts( &self, account: PublicKey, ) -> Option<Vec<PublicKey>>

Who account follows, by the contact list already in the store. None if the store has no list of theirs.

Source

pub async fn fetch_contacts( &self, account: PublicKey, ) -> Result<Option<Vec<PublicKey>>, FetchError>

Who account follows, after asking the relays for their contact list. None if nobody has a list of theirs.

Source

pub async fn set_following( &self, signer: &Signer, account: PublicKey, person: PublicKey, follow: bool, first_list: bool, ) -> Result<Vec<PublicKey>, FollowError>

Have account follow person (follow) or stop following them: its newest contact list, asked of the relays just now, signed again with that one change and sent out. Returns who account follows after it.

With no list anywhere, a first one is only written if first_list says so; otherwise that is the error, and nothing is sent.

Source

async fn read_bookmarks( &self, signer: &Signer, account: PublicKey, list: Option<Event>, known: Option<Bookmarks>, ) -> Result<Bookmarks, ListError>

The bookmarks of account that list, its newest bookmark list, keeps to itself, which signer decrypts.

known is what was read before. If it was read from this very list, it is the answer, and nothing is decrypted again: a remote signer may ask a person about each request.

Source

async fn read_private( signer: &Signer, account: PublicKey, list: &Event, ) -> Result<PrivateTags, ListError>

The tags list keeps to itself (NIP-51), which signer decrypts. A list that keeps nothing to itself has no content, and is not taken to the signer.

Source

async fn written_private( signer: &Signer, account: PublicKey, private: &PrivateTags, ) -> Result<String, ListError>

private, the tags a list keeps to itself, as its content: encrypted by signer to account itself, or nothing at all when there are none.

Source

pub async fn bookmarks( &self, source: Source, signer: &Signer, account: PublicKey, known: Option<Bookmarks>, ) -> Result<Bookmarks, ListError>

The bookmarks of account, as far as source knows: by the list in the store, or by the newest the relays have. An account with no list has none. See Self::read_bookmarks for known.

Source

pub async fn set_bookmarked( &self, signer: &Signer, account: PublicKey, note: EventId, bookmark: bool, first_list: bool, known: Option<Bookmarks>, ) -> Result<Bookmarks, ListError>

Have account bookmark note (bookmark), privately, or take its bookmark off: its newest bookmark list, asked of the relays just now, with that one change to what it keeps to itself, encrypted anew, signed and sent out. What the list says to anyone goes out as it came. Returns the account’s bookmarks after it. See Self::read_bookmarks for known.

With no list anywhere, a first one is only written if first_list says so; otherwise that is the error, and nothing is sent. Nor is anything sent when what the list keeps to itself can’t be read.

Source

pub async fn keep_draft( &self, signer: &Signer, account: PublicKey, target: Target, text: &str, said: &[Tag], ) -> Result<(), String>

Have the relay of this machine keep text as the draft of account for target: a draft wrap (see kept_drafts), which signer encrypts to the account itself and signs, in place of the one it had, with said for what it says of the files it links to. A blank text is a draft done with, and is kept as that. It goes to that relay and to no other.

Source

pub async fn kept_drafts( &self, signer: &Signer, account: PublicKey, ) -> Result<Vec<(Target, String, Vec<Tag>)>, String>

The drafts of account that the relay of this machine keeps, each with what it is a draft of and what it says of the files it links to: those of this client’s that are not done with, which signer decrypts. One that can’t be read is left out.

Source

async fn search_events( &self, relays: &[RelayUrl], words: &str, what: SearchFor, ) -> Result<Vec<Event>, FetchError>

What relays, the account’s search relays, find of what for words (NIP-50), the best matches first, as each relay had them (see search::ranked).

The relays are the account’s own word, and any it names is asked: where it is, if it is one of the account’s own, and otherwise among other people’s relays, where it is let go of when it is not used. What was searched for goes to those relays and nowhere else: it is not logged, and not kept.

Source

async fn ask_named( &self, relays: &[RelayUrl], filter: Filter, ) -> Result<Vec<Vec<Event>>, FetchError>

What each of relays, which the account itself named, sends for filter: one answer for each that gave one, as it gave it. That none of them is reached, or that none answers, is the error.

Source

pub async fn relay_notes( &self, relay: &RelayUrl, ) -> Result<Vec<Note>, FetchError>

The notes relay got last, as rows show them, the newest first: what a relay is like, for whoever typed its address. The account’s own word, as its search relays are; and as with those, a relay it has blocked is not connected to.

Source

pub async fn search( &self, relays: &[RelayUrl], words: &str, what: SearchFor, ) -> Result<Found, FetchError>

What the account’s search relays relays find of what for words: people with their profiles, or notes as rows show them, with the notes they quote. See Self::search_events.

Source

async fn read_listed( signer: &Signer, account: PublicKey, list: Option<Event>, known: Option<&ListedRelays>, open: bool, ) -> ListedRelays

The relays of account that list, its newest list of one kind, names, with those it keeps to itself if open says to read them: that takes the signer, which may ask a person about each request. A list with no content keeps nothing, and is not taken to the signer. If known was read from this very list, it is the answer, and nothing is decrypted again.

Source

async fn newest_lists( &self, kinds: &[Kind], account: PublicKey, ) -> Result<HashMap<Kind, Event>, FetchError>

The newest list of each of kinds that account wrote, after asking the relays for them in one question. As Self::newest_list, for several.

Source

pub async fn relay_lists( &self, source: Source, signer: &Signer, account: PublicKey, known: Option<RelayLists>, open: &[Section], ) -> Result<RelayLists, FetchError>

The relay lists of account, as far as source knows: its relay list (NIP-65) and its other lists of relays (see relay_lists), by the lists in the store or by the newest the relays have. What the lists of open keep to themselves is read, and the others’ is left unread. known is what was read before: nothing is decrypted twice.

A list whose private part can’t be read is no error: the relays it names for anyone are there, with why the others aren’t.

Source

pub async fn set_advertised_relays( &self, signer: &Signer, account: PublicKey, outbox: &[RelayUrl], inbox: &[RelayUrl], first_list: bool, ) -> Result<Option<Event>, ListError>

Have the relay list (NIP-65) of account name outbox for the relays it writes to and inbox for those it reads: its newest list, asked of the relays just now, with its relays replaced and the rest as it was, signed and sent out, to the relays it wrote to before and to those it writes to now, which are its own from then on. Returns the list after it; nothing is sent when it says so already.

With no list anywhere, a first one is only written if first_list says so; otherwise that is the error, and nothing is sent.

Source

pub async fn set_listed_relays( &self, signer: &Signer, account: PublicKey, section: Section, relays: &[RelayUrl], first_list: bool, known: Option<ListedRelays>, ) -> Result<ListedRelays, ListError>

Have the relays of section, one of the lists of relay tags of account, be relays: its newest list of that kind, asked of the relays just now, with that change (see ListedRelays::changed), what it keeps to itself encrypted anew, signed and sent out. Returns the list’s relays after it. See Self::read_listed for known.

With no list anywhere, a first one is only written if first_list says so; otherwise that is the error, and nothing is sent. Nor is anything sent when what the list keeps to itself can’t be read.

Source

pub async fn media_server_list( &self, source: Source, account: PublicKey, ) -> Result<Option<Event>, FetchError>

The media server list of account (BUD-03, kind 10063), as far as source knows: its newest. None if it has none there.

Source

pub async fn set_media_servers( &self, signer: &Signer, account: PublicKey, servers: &[Url], first_list: bool, ) -> Result<Option<Event>, ListError>

Have the media servers of account be servers, the one files are sent to first at the head: its newest server list, asked of the relays just now, with its servers replaced and the rest as it was, signed and sent out. Returns the list after it; nothing is sent when it says so already.

With no list anywhere, a first one is only written if first_list says so; otherwise that is the error, and nothing is sent.

Source

pub async fn relay_use(&self) -> HashMap<RelayUrl, RelayUse>

How every relay this is connected to has been doing: the account’s own, and other people’s that are in their pool now. A relay that is in both counts as the account’s own.

Source

pub fn use_listed(&self, lookup: Vec<RelayUrl>, blocked: Vec<RelayUrl>)

Go by these of the account’s relays from now on: lookup, where profiles and relay lists that its own relays don’t have are looked up, and blocked, which are never connected to on anyone’s word. Relay lists are looked for again when there are other relays to look on.

Source

async fn ask_lookup(&self, filters: Vec<Filter>) -> Vec<Event>

What the relays that look things up send for filters, beside what the account’s own have: those of them that are not its own, which were asked. Nothing, and never an error, when there are none, or none answers.

Source

pub async fn cached_profiles( &self, authors: Vec<PublicKey>, ) -> Vec<(PublicKey, Profile)>

The profiles of authors that are already in the store.

Source

pub async fn fetch_profiles( &self, authors: Vec<PublicKey>, ) -> Vec<(PublicKey, Profile)>

The profiles of authors, after asking the relays for them. As with a contact list, what the relays send is kept in the store, which only ever keeps the newest, and the answer is read back from there: a relay that is behind doesn’t undo a newer profile already seen.

Source

pub async fn fetch_profiles_where_written( &self, people: Vec<PublicKey>, ) -> Vec<(PublicKey, Profile)>

The profiles of those of people that the account’s own relays don’t have, after asking the relays those people write to. Asked for beside Self::fetch_profiles, which answers sooner for most: who is still missing is seen once the relay lists are known, by when the account’s own relays have had their say.

Trait Implementations§

Source§

impl Clone for NostrService

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NostrService

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
§

impl<T> Also for T

§

fn also<F>(self, block: F) -> Self
where F: FnOnce(&mut Self),

Apply a function to this value and return the (possibly) modified value.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T, Res> Apply<Res> for T
where T: ?Sized,

§

fn apply<F>(self, f: F) -> Res
where F: FnOnce(Self) -> Res, Self: Sized,

Apply a function which takes the parameter by value.
§

fn apply_ref<F>(&self, f: F) -> Res
where F: FnOnce(&Self) -> Res,

Apply a function which takes the parameter by reference.
§

fn apply_mut<F>(&mut self, f: F) -> Res
where F: FnOnce(&mut Self) -> Res,

Apply a function which takes the parameter by mutable reference.
Source§

impl<T, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
§

impl<T> Downcast for T
where T: Any,

§

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

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

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

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

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

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

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

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

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

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

§

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
§

impl<State, Message> IntoBoot<State, Message> for State

§

fn into_boot(self) -> (State, Task<Message>)

Turns some type into the initial state of some [Application].
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
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> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
§

impl<T> MaybeClone for T

§

impl<T> MaybeDebug for T

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more