Struct pkarr::PkarrClientAsync
source · pub struct PkarrClientAsync(/* private fields */);
Expand description
Async version of PkarrClient
Implementations§
source§impl PkarrClientAsync
impl PkarrClientAsync
sourcepub fn local_addr(&self) -> Option<SocketAddr>
pub fn local_addr(&self) -> Option<SocketAddr>
Returns the local address of the udp socket this node is listening on.
Returns None
if the node is shutdown
sourcepub fn cache(&self) -> &dyn PkarrCache
pub fn cache(&self) -> &dyn PkarrCache
Returns a reference to the internal cache.
sourcepub async fn publish(&self, signed_packet: &SignedPacket) -> Result<()>
pub async fn publish(&self, signed_packet: &SignedPacket) -> Result<()>
Publishes a SignedPacket to the Dht.
§Errors
- Returns a Error::DhtIsShutdown if PkarrClient::shutdown was called, or the loop in the actor thread is stopped for any reason (like thread panic).
- Returns a Error::PublishInflight if the client is currently publishing the same public_key.
- Returns a Error::NotMostRecent if the provided signed packet is older than most recent.
- Returns a Error::MainlineError if the Dht received an unexpected error otherwise.
sourcepub async fn resolve(
&self,
public_key: &PublicKey
) -> Result<Option<SignedPacket>>
pub async fn resolve( &self, public_key: &PublicKey ) -> Result<Option<SignedPacket>>
Returns the first valid SignedPacket available from cache, or the Dht.
If the Dht was called, in the background, it continues receiving responses and updating the cache.
§Errors
- Returns a Error::DhtIsShutdown if PkarrClient::shutdown was called, or the loop in the actor thread is stopped for any reason (like thread panic).
Trait Implementations§
source§impl Clone for PkarrClientAsync
impl Clone for PkarrClientAsync
source§fn clone(&self) -> PkarrClientAsync
fn clone(&self) -> PkarrClientAsync
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for PkarrClientAsync
impl !RefUnwindSafe for PkarrClientAsync
impl Send for PkarrClientAsync
impl Sync for PkarrClientAsync
impl Unpin for PkarrClientAsync
impl !UnwindSafe for PkarrClientAsync
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more