pub struct Destination { /* private fields */ }Expand description
A local I2P destination – an eepsite’s identity, reachable at a stable .b32.i2p address for
as long as this value is alive.
Create one via I2pRouter::create_transient_destination,
I2pRouter::create_persistent_destination, or
I2pRouter::destination_from_keys_file.
Implementations§
Source§impl Destination
impl Destination
Sourcepub fn b32_address(&self) -> &str
pub fn b32_address(&self) -> &str
This destination’s <52 chars>.b32.i2p address.
Sourcepub const fn ident_hash(&self) -> [u8; 32]
pub const fn ident_hash(&self) -> [u8; 32]
This destination’s raw 32-byte IdentHash, the form connect expects
for a remote destination. b32_address is derived from the same hash.
Sourcepub async fn accept(&mut self) -> Result<I2pStream, I2pError>
pub async fn accept(&mut self) -> Result<I2pStream, I2pError>
Waits for the next inbound stream. Unlike the underlying libi2pd accept callback this is
not a one-shot – call it in the usual loop { let stream = dest.accept().await?; } shape
for as long as the destination lives.
Takes &mut self, so accepts are drawn one at a time from a single owner. Streams
arriving while no call is pending are queued (up to 128) rather than dropped, so a caller
that hands each one to a spawned task doesn’t need concurrent accepts to keep up.
§Errors
Returns I2pError::DestinationClosed if this destination is dropped while a call is
pending.
Sourcepub async fn connect(
&self,
remote_ident_hash: [u8; 32],
timeout: Duration,
) -> Result<I2pStream, I2pError>
pub async fn connect( &self, remote_ident_hash: [u8; 32], timeout: Duration, ) -> Result<I2pStream, I2pError>
Opens an outbound stream to remote_ident_hash (the raw 32-byte IdentHash, not the
.b32.i2p string). Waits up to timeout, off the runtime thread, for the remote’s lease
set to become known and a tunnel to be built – seconds to minutes on a cold start.
timeout truncates to whole seconds, libi2pd’s retry-loop granularity. Anything under a
second, Duration::ZERO included, becomes zero, which
libi2pd treats as try-once rather than as almost a second of waiting.
§Errors
Returns I2pError::ConnectFailed on timeout or failure.