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: ClientThe pool of the account’s own relays, over the event store.
others: ClientThe pool of other people’s relays, over the same store.
private: PrivateRelayThe relay this runs itself, over the same store, for what is the account’s alone.
reach: ReachHow 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: InstantWhen the relays were first told to connect.
sightings: Arc<Mutex<Sightings>>Which relays each note was seen on, since then.
Implementations§
Source§impl NostrService
impl NostrService
Sourcepub async fn open(
store_path: PathBuf,
relays: Vec<String>,
) -> Result<Self, String>
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.
Sourcepub async fn open_reaching(
store_path: PathBuf,
relays: Vec<String>,
reach: Reach,
) -> Result<Self, String>
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.
Sourceasync fn reachable_relays(&self) -> Vec<RelayUrl>
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.
Sourcefn sightings(&self) -> MutexGuard<'_, Sightings>
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.
Sourcepub fn seen_on(&self, notes: &[EventId]) -> HashMap<EventId, Vec<RelayUrl>>
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.
Sourceasync fn ask(
&self,
pool: Pool,
relay: &RelayUrl,
filters: Vec<Filter>,
timeout: Duration,
) -> Result<Asked, String>
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.
Sourcefn leave_alone(&self, relay: &RelayUrl, why: &str)
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.
Sourcefn left_alone(&self) -> HashSet<RelayUrl>
fn left_alone(&self) -> HashSet<RelayUrl>
The relays that are being left alone, and those the account has blocked, which always are.
Sourceasync fn answering_relays(&self) -> Vec<RelayUrl>
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.
Sourceasync fn fetch(
&self,
filters: Vec<Filter>,
) -> Result<impl Iterator<Item = Event>, FetchError>
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.
Sourceasync fn fetch_within(
&self,
filters: Vec<Filter>,
timeout: Duration,
) -> Result<impl Iterator<Item = Event>, FetchError>
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.
Sourceasync fn fetch_from_each(
&self,
filters: Vec<Filter>,
timeout: Duration,
) -> Result<(Vec<Event>, bool), FetchError>
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.
Sourceasync fn gather(
&self,
pool: Pool,
asks: Vec<(RelayUrl, Vec<Filter>)>,
timeout: Duration,
) -> (Vec<Event>, usize, Option<String>)
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.
Sourcefn reached(&self) -> MutexGuard<'_, Reached>
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.
Sourceasync fn relays_of(
&self,
people: &[PublicKey],
listed: Listed,
patient: bool,
) -> HashMap<PublicKey, Vec<RelayUrl>>
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.
Sourcefn relay_lists_of(people: &[PublicKey]) -> Vec<Filter>
fn relay_lists_of(people: &[PublicKey]) -> Vec<Filter>
The filters that ask for the relay lists of people.
Sourceasync fn ask_for_relay_lists(&self, people: Vec<PublicKey>)
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.
Sourceasync fn stored_relay_lists(&self, people: &[PublicKey]) -> Vec<Event>
async fn stored_relay_lists(&self, people: &[PublicKey]) -> Vec<Event>
The newest relay list of each of people that the store has one of.
Sourceasync fn reach_for(
&self,
listed: &HashMap<PublicKey, Vec<RelayUrl>>,
) -> Vec<(RelayUrl, Vec<PublicKey>)>
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.
Sourceasync fn connected<T>(&self, planned: Vec<(RelayUrl, T)>) -> Vec<(RelayUrl, T)>
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.
Sourceasync fn ask_where_said(&self, said: &[(EventId, RelayUrl)]) -> Vec<Event>
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.
Sourceasync fn connect_to(&self, relay: &RelayUrl) -> bool
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.
Sourceasync fn let_go_of_unused(&self)
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.
Sourceasync fn ask_their_relays(
&self,
people: &[PublicKey],
listed: Listed,
patient: bool,
asking: impl Fn(&[PublicKey]) -> Vec<Filter>,
) -> Vec<Event>
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.
Sourcefn own(&self) -> MutexGuard<'_, Own>
fn own(&self) -> MutexGuard<'_, Own>
The account’s own relays and which are in use, whole after every
change, as Self::sightings is.
Sourcefn in_use(&self) -> Vec<RelayUrl>
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).
Sourcepub async fn use_relays_of(&self, account: Option<PublicKey>) -> usize
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.
Sourceasync fn join_account_relays(&self, writes: Vec<RelayUrl>) -> usize
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.
Sourceasync fn settle_config_relays(&self)
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.
Sourcepub async fn stored_event(&self, id: EventId) -> Option<Event>
pub async fn stored_event(&self, id: EventId) -> Option<Event>
The event id, if the store has it.
Sourcepub async fn event(&self, id: EventId, author: PublicKey) -> Option<Event>
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.
Sourcepub async fn sweep(
&self,
account: PublicKey,
bookmarked: &HashSet<EventId>,
before: Timestamp,
) -> Result<usize, String>
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.
Sourcepub async fn relay_holding(&self, id: EventId) -> Option<RelayUrl>
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.
Sourcepub async fn sign_and_publish(
&self,
signer: &Signer,
author: PublicKey,
unsigned: EventBuilder,
) -> Result<Event, PublishError>
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.
Sourcepub async fn standing(
&self,
source: Source,
notes: Vec<EventId>,
account: Option<PublicKey>,
) -> Result<Standing, FetchError>
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.
Sourcepub async fn who_did(
&self,
note: EventId,
what: Left,
) -> Result<Vec<Doer>, FetchError>
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.
Sourceasync fn receipts_until(
&self,
note: EventId,
is_it: &impl Fn(&Event) -> bool,
) -> bool
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.
Sourcepub async fn await_zap_receipt(&self, note: EventId, bolt11: String) -> bool
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.
Sourcepub async fn publish(&self, event: &Event) -> Result<usize, PublishError>
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.
Sourceasync fn send_home(&self, event: &Event) -> Result<Vec<RelayUrl>, PublishError>
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.
Sourceasync fn deliver(&self, event: &Event) -> Vec<RelayUrl>
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.
Sourceasync fn events(
&self,
source: Source,
filters: Vec<Filter>,
) -> Result<Vec<Event>, FetchError>
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.
Sourceasync fn notes_by_id(
&self,
wanted: &HashMap<EventId, Whereabouts>,
source: Source,
wait: Duration,
) -> HashMap<EventId, Note>
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.
Sourceasync fn events_elsewhere(
&self,
sought: &[(EventId, &Whereabouts)],
wait: Duration,
) -> Vec<Event>
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.
Sourceasync fn with_quotes(&self, notes: Vec<Note>, source: Source) -> Vec<Note>
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).
Sourcepub async fn notes_listed(
&self,
listed: Vec<(EventId, Whereabouts)>,
) -> Vec<Note>
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.
Sourcepub async fn note(&self, event: Event) -> Note
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.
Sourcepub async fn quoting(&self, note: Note) -> Note
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.
Sourcepub async fn thread(
&self,
source: Source,
focused: EventId,
whereabouts: &Whereabouts,
) -> Result<Vec<Note>, FetchError>
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.
Sourcepub async fn cached_feed(
&self,
authors: &[PublicKey],
limit: usize,
) -> Result<Vec<Note>, String>
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.
Sourcepub async fn fetch_feed(
&self,
authors: &[PublicKey],
until: Option<u64>,
limit: usize,
) -> Result<Vec<Note>, FetchError>
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.
Sourcepub async fn notifications(
&self,
source: Source,
account: PublicKey,
since: Option<u64>,
until: Option<u64>,
) -> Result<Notified, FetchError>
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).
Sourceasync fn stored_list(&self, kind: Kind, account: PublicKey) -> Option<Event>
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.
Sourceasync fn asked_list(
&self,
kind: Kind,
account: PublicKey,
) -> Result<(Option<Event>, bool), FetchError>
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.
Sourceasync fn newest_list(
&self,
kind: Kind,
account: PublicKey,
) -> Result<Option<Event>, FetchError>
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.
Sourceasync fn list_to_change(
&self,
kind: Kind,
account: PublicKey,
) -> Result<Option<Event>, FetchError>
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.
Sourcepub async fn cached_contacts(
&self,
account: PublicKey,
) -> Option<Vec<PublicKey>>
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.
Sourcepub async fn fetch_contacts(
&self,
account: PublicKey,
) -> Result<Option<Vec<PublicKey>>, FetchError>
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.
Sourcepub async fn set_following(
&self,
signer: &Signer,
account: PublicKey,
person: PublicKey,
follow: bool,
first_list: bool,
) -> Result<Vec<PublicKey>, FollowError>
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.
Sourceasync fn read_bookmarks(
&self,
signer: &Signer,
account: PublicKey,
list: Option<Event>,
known: Option<Bookmarks>,
) -> Result<Bookmarks, ListError>
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.
Sourceasync fn read_private(
signer: &Signer,
account: PublicKey,
list: &Event,
) -> Result<PrivateTags, ListError>
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.
Sourceasync fn written_private(
signer: &Signer,
account: PublicKey,
private: &PrivateTags,
) -> Result<String, ListError>
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.
Sourcepub async fn bookmarks(
&self,
source: Source,
signer: &Signer,
account: PublicKey,
known: Option<Bookmarks>,
) -> Result<Bookmarks, ListError>
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.
Sourcepub async fn set_bookmarked(
&self,
signer: &Signer,
account: PublicKey,
note: EventId,
bookmark: bool,
first_list: bool,
known: Option<Bookmarks>,
) -> Result<Bookmarks, ListError>
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.
Sourcepub async fn keep_draft(
&self,
signer: &Signer,
account: PublicKey,
target: Target,
text: &str,
said: &[Tag],
) -> Result<(), String>
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.
Sourcepub async fn kept_drafts(
&self,
signer: &Signer,
account: PublicKey,
) -> Result<Vec<(Target, String, Vec<Tag>)>, String>
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.
Sourceasync fn search_events(
&self,
relays: &[RelayUrl],
words: &str,
what: SearchFor,
) -> Result<Vec<Event>, FetchError>
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.
Sourceasync fn ask_named(
&self,
relays: &[RelayUrl],
filter: Filter,
) -> Result<Vec<Vec<Event>>, FetchError>
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.
Sourcepub async fn relay_notes(
&self,
relay: &RelayUrl,
) -> Result<Vec<Note>, FetchError>
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.
Sourcepub async fn search(
&self,
relays: &[RelayUrl],
words: &str,
what: SearchFor,
) -> Result<Found, FetchError>
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.
Sourceasync fn read_listed(
signer: &Signer,
account: PublicKey,
list: Option<Event>,
known: Option<&ListedRelays>,
open: bool,
) -> ListedRelays
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.
Sourceasync fn newest_lists(
&self,
kinds: &[Kind],
account: PublicKey,
) -> Result<HashMap<Kind, Event>, FetchError>
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.
Sourcepub async fn relay_lists(
&self,
source: Source,
signer: &Signer,
account: PublicKey,
known: Option<RelayLists>,
open: &[Section],
) -> Result<RelayLists, FetchError>
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.
Sourcepub async fn set_advertised_relays(
&self,
signer: &Signer,
account: PublicKey,
outbox: &[RelayUrl],
inbox: &[RelayUrl],
first_list: bool,
) -> Result<Option<Event>, ListError>
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.
Sourcepub async fn set_listed_relays(
&self,
signer: &Signer,
account: PublicKey,
section: Section,
relays: &[RelayUrl],
first_list: bool,
known: Option<ListedRelays>,
) -> Result<ListedRelays, ListError>
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.
Sourcepub async fn media_server_list(
&self,
source: Source,
account: PublicKey,
) -> Result<Option<Event>, FetchError>
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.
Sourcepub async fn set_media_servers(
&self,
signer: &Signer,
account: PublicKey,
servers: &[Url],
first_list: bool,
) -> Result<Option<Event>, ListError>
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.
Sourcepub async fn relay_use(&self) -> HashMap<RelayUrl, RelayUse>
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.
Sourcepub fn use_listed(&self, lookup: Vec<RelayUrl>, blocked: Vec<RelayUrl>)
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.
Sourceasync fn ask_lookup(&self, filters: Vec<Filter>) -> Vec<Event>
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.
Sourcepub async fn cached_profiles(
&self,
authors: Vec<PublicKey>,
) -> Vec<(PublicKey, Profile)>
pub async fn cached_profiles( &self, authors: Vec<PublicKey>, ) -> Vec<(PublicKey, Profile)>
The profiles of authors that are already in the store.
Sourcepub async fn fetch_profiles(
&self,
authors: Vec<PublicKey>,
) -> Vec<(PublicKey, Profile)>
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.
Sourcepub async fn fetch_profiles_where_written(
&self,
people: Vec<PublicKey>,
) -> Vec<(PublicKey, Profile)>
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
impl Clone for NostrService
Auto Trait Implementations§
impl !RefUnwindSafe for NostrService
impl !UnwindSafe for NostrService
impl Freeze for NostrService
impl Send for NostrService
impl Sync for NostrService
impl Unpin for NostrService
impl UnsafeUnpin for NostrService
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
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) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
Source§type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
Source§fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
§impl<T> Also for T
impl<T> Also for T
§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
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 Twhere
T: Send,
impl<T> MaybeSync for Twhere
T: Sync,
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more