Skip to main content

Destination

Struct Destination 

Source
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

Source

pub fn b32_address(&self) -> &str

This destination’s <52 chars>.b32.i2p address.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Destination

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.