Skip to main content

SessionFactory

Trait SessionFactory 

Source
pub trait SessionFactory:
    Clone
    + Send
    + Sync
    + 'static {
    type Cfg: Clone + Send + 'static;

    // Required methods
    fn create_session<'life0, 'async_trait>(
        &'life0 self,
        dest: Address,
        target: SessionTarget,
        cfg: Self::Cfg,
    ) -> Pin<Box<dyn Future<Output = Result<(HoprSession, HoprSessionConfigurator), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn routing_from_cfg(
        &self,
        cfg: &Self::Cfg,
    ) -> Result<(Routing, Routing), Error>;
    fn listener_limits(
        &self,
        cfg: &Self::Cfg,
    ) -> (Option<Bandwidth>, Option<ByteSize>);
    fn session_idle_timeout(&self) -> Option<Duration>;
}

Required Associated Types§

Source

type Cfg: Clone + Send + 'static

Required Methods§

Source

fn create_session<'life0, 'async_trait>( &'life0 self, dest: Address, target: SessionTarget, cfg: Self::Cfg, ) -> Pin<Box<dyn Future<Output = Result<(HoprSession, HoprSessionConfigurator), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Creates a new Session with the given destination, target and configuration.

Source

fn routing_from_cfg(&self, cfg: &Self::Cfg) -> Result<(Routing, Routing), Error>

Derives the forward and return routing options from the given configuration.

Source

fn listener_limits( &self, cfg: &Self::Cfg, ) -> (Option<Bandwidth>, Option<ByteSize>)

Derives the listener limits (max SURB upstream and response buffer) from the given configuration.

Source

fn session_idle_timeout(&self) -> Option<Duration>

Returns the idle timeout duration for sessions created by this factory, if any.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Chain, Graph, Net, TMgr> SessionFactory for HopSessionFactory<Chain, Graph, Net, TMgr>
where Chain: HoprChainApi + Clone + Send + Sync + 'static, Graph: NetworkGraphView<NodeId = OffchainPublicKey> + NetworkGraphUpdate + NetworkGraphWrite<NodeId = OffchainPublicKey> + NetworkGraphTraverse<NodeId = OffchainPublicKey> + Clone + Send + Sync + 'static, <Graph as NetworkGraphTraverse>::Observed: EdgeObservableRead + Send + 'static, <Graph as NetworkGraphWrite>::Observed: EdgeObservableWrite + Send, Net: NetworkView + NetworkStreamControl + Send + Sync + Clone + 'static, TMgr: Send + Sync + 'static,

Source§

type Cfg = HoprSessionClientConfig