Trait libp2p_quic::Provider

source ·
pub trait Provider: Unpin + Send + Sized + 'static {
    type IfWatcher: Unpin + Send;

    // Required methods
    fn runtime() -> Runtime;
    fn new_if_watcher() -> Result<Self::IfWatcher>;
    fn poll_if_event(
        watcher: &mut Self::IfWatcher,
        cx: &mut Context<'_>
    ) -> Poll<Result<IfEvent>>;
    fn sleep(duration: Duration) -> BoxFuture<'static, ()>;
    fn send_to<'a>(
        udp_socket: &'a UdpSocket,
        buf: &'a [u8],
        target: SocketAddr
    ) -> BoxFuture<'a, Result<usize>>;
}
Expand description

Provider for a corresponding quinn runtime and spawning tasks.

Required Associated Types§

Required Methods§

source

fn runtime() -> Runtime

Run the corresponding runtime

source

fn new_if_watcher() -> Result<Self::IfWatcher>

Create a new if_watch watcher that reports IfEvents for network interface changes.

source

fn poll_if_event( watcher: &mut Self::IfWatcher, cx: &mut Context<'_> ) -> Poll<Result<IfEvent>>

Poll for an address change event.

source

fn sleep(duration: Duration) -> BoxFuture<'static, ()>

Sleep for specified amount of time.

source

fn send_to<'a>( udp_socket: &'a UdpSocket, buf: &'a [u8], target: SocketAddr ) -> BoxFuture<'a, Result<usize>>

Sends data on the socket to the given address. On success, returns the number of bytes written.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Provider for libp2p_quic::async_std::Provider

Available on crate feature async-std only.
§

type IfWatcher = IfWatcher<SmolSocket>

source§

impl Provider for libp2p_quic::tokio::Provider

Available on crate feature tokio only.
§

type IfWatcher = IfWatcher<TokioSocket>