Struct pkarr::PkarrClient
source · pub struct PkarrClient { /* private fields */ }
Expand description
Pkarr client for publishing and resolving SignedPackets over mainline.
Implementations§
source§impl PkarrClient
impl PkarrClient
pub fn new(settings: Settings) -> Result<PkarrClient>
sourcepub fn builder() -> PkarrClientBuilder
pub fn builder() -> PkarrClientBuilder
Returns a builder to edit settings before creating PkarrClient.
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 fn publish(&self, signed_packet: &SignedPacket) -> Result<()>
pub 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 fn resolve(&self, public_key: &PublicKey) -> Result<Option<SignedPacket>>
pub fn resolve(&self, public_key: &PublicKey) -> Result<Option<SignedPacket>>
Returns a SignedPacket from cache if it is not expired, otherwise, it will query the Dht, and return the first valid response, which may or may not be expired itself.
If the Dht was called, in the background, it continues receiving responses and updating the cache with any more recent valid packets it receives.
§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).
source§impl PkarrClient
impl PkarrClient
sourcepub fn as_async(self) -> PkarrClientAsync
pub fn as_async(self) -> PkarrClientAsync
Returns PkarrClientAsync
Trait Implementations§
source§impl Clone for PkarrClient
impl Clone for PkarrClient
source§fn clone(&self) -> PkarrClient
fn clone(&self) -> PkarrClient
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 PkarrClient
impl !RefUnwindSafe for PkarrClient
impl Send for PkarrClient
impl Sync for PkarrClient
impl Unpin for PkarrClient
impl !UnwindSafe for PkarrClient
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