[][src]Trait libp2p::TransportExt

pub trait TransportExt: Transport {
    fn with_rate_limit(
        self,
        max_read_bytes_per_sec: usize,
        max_write_bytes_per_sec: usize
    ) -> Result<RateLimited<Self>>
    where
        Self: Sized
, { ... }
fn with_bandwidth_logging(
        self,
        period: Duration
    ) -> (BandwidthLogging<Self>, Arc<BandwidthSinks>)
    where
        Self: Sized
, { ... } }

Trait automatically implemented on all objects that implement Transport. Provides some additional utilities.

Example

use libp2p::TransportExt;
use libp2p::tcp::TcpConfig;
use std::time::Duration;

let _transport = TcpConfig::new()
    .with_rate_limit(1024 * 1024, 1024 * 1024);

Provided methods

fn with_rate_limit(
    self,
    max_read_bytes_per_sec: usize,
    max_write_bytes_per_sec: usize
) -> Result<RateLimited<Self>> where
    Self: Sized

Adds a maximum transfer rate to the sockets created with the transport.

fn with_bandwidth_logging(
    self,
    period: Duration
) -> (BandwidthLogging<Self>, Arc<BandwidthSinks>) where
    Self: Sized

Adds a layer on the Transport that logs all trafic that passes through the sockets created by it.

This method returns an Arc<BandwidthSinks> that can be used to retreive the bandwidth values.

Loading content...

Implementors

impl<TTransport> TransportExt for TTransport where
    TTransport: Transport
[src]

fn with_rate_limit(
    self,
    max_read_bytes_per_sec: usize,
    max_write_bytes_per_sec: usize
) -> Result<RateLimited<Self>> where
    Self: Sized
[src]

fn with_bandwidth_logging(
    self,
    period: Duration
) -> (BandwidthLogging<Self>, Arc<BandwidthSinks>) where
    Self: Sized
[src]

Loading content...