Skip to main content

HoprSessionClientOperations

Trait HoprSessionClientOperations 

pub trait HoprSessionClientOperations: Send + Sync {
    type Session: AsyncRead + AsyncWrite + Send + Unpin;
    type SessionConfigurator: Send;
    type Target: Send;
    type Config: Send;
    type Error: Error + Send + Sync + 'static;

    // Required method
    fn connect_to<'life0, 'async_trait>(
        &'life0 self,
        destination: Address,
        target: Self::Target,
        config: Self::Config,
    ) -> Pin<Box<dyn Future<Output = Result<(Self::Session, Self::SessionConfigurator), Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

Trait for establishing HOPR sessions to remote destinations.

The concrete session, configurator, target, and config types are defined by the implementor (typically hopr-lib), keeping transport-level types out of the API crate.

Required Associated Types§

type Session: AsyncRead + AsyncWrite + Send + Unpin

An established session implementing async read/write.

type SessionConfigurator: Send

Handle for controlling a session after creation (e.g. keep-alive, SURB config).

type Target: Send

Describes the remote service to connect to.

type Config: Send

Configuration for the session (routing, capabilities, etc.).

type Error: Error + Send + Sync + 'static

Error type for session operations.

Required Methods§

fn connect_to<'life0, 'async_trait>( &'life0 self, destination: Address, target: Self::Target, config: Self::Config, ) -> Pin<Box<dyn Future<Output = Result<(Self::Session, Self::SessionConfigurator), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Establishes a new session to the given destination via the HOPR network.

Returns the session (implementing [AsyncRead] + [AsyncWrite]) and a configurator for controlling the session after creation.

Implementations may retry automatically on failure.

Implementations on Foreign Types§

§

impl<'a, T> HoprSessionClientOperations for &'a T

§

impl<T> HoprSessionClientOperations for Arc<T>

§

type Session = <T as HoprSessionClientOperations>::Session

§

type SessionConfigurator = <T as HoprSessionClientOperations>::SessionConfigurator

§

type Target = <T as HoprSessionClientOperations>::Target

§

type Config = <T as HoprSessionClientOperations>::Config

§

type Error = <T as HoprSessionClientOperations>::Error

§

fn connect_to<'life0, 'async_trait>( &'life0 self, destination: Address, target: <Arc<T> as HoprSessionClientOperations>::Target, config: <Arc<T> as HoprSessionClientOperations>::Config, ) -> Pin<Box<dyn Future<Output = Result<(<Arc<T> as HoprSessionClientOperations>::Session, <Arc<T> as HoprSessionClientOperations>::SessionConfigurator), <Arc<T> as HoprSessionClientOperations>::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Implementors§