Skip to main content

Crate vibeio_quinn

Crate vibeio_quinn 

Source
Expand description

A compatibility layer for using quinn with the vibeio async runtime.

This crate provides the necessary runtime adapters to run QUIC-based applications built on quinn on top of vibeio. It implements the traits required by quinn’s runtime abstraction:

§Overview

VibeioRuntime satisfies all three abstract interfaces that quinn requires from a runtime:

quinn traitImplementation
quinn::RuntimeVibeioRuntime struct
quinn::AsyncTimerInternal wrapper around vibeio::time::Sleep
quinn::AsyncUdpSocketInternal wrapper combining PollUdpSocket + quinn-udp batching
quinn::UdpPollerInternal type backed by AsyncWritePoll readiness

§Usage

ⓘ
use quinn::{Endpoint, EndpointConfig, ServerConfig};
use std::sync::Arc;
use vibeio_quinn::VibeioRuntime;

let runtime = Arc::new(VibeioRuntime);

let mut endpoint = Endpoint::new(
    EndpointConfig::default(),
    None,
    runtime,
)?;

§Architecture notes

vibeio is a single-threaded runtime. All spawned futures and I/O operations execute on the thread that owns the runtime. The internal I/O handle types use Rc<AnyDriver> internally and are therefore !Send and !Sync. To satisfy quinn’s Send + Sync + 'static bounds on its runtime traits, the adapters in this crate use unsafe impl Send + Sync under the justification that the runtime’s single-threaded architecture prevents data races.

Each quinn Endpoint should be driven from a single vibeio task (e.g. via endpoint.run_until_stopped() or manual polling). The UDP socket, timer, and task spawn implementations all assume they are used from the thread associated with the current vibeio runtime context.

Structs§

VibeioRuntime
A quinn::Runtime implementation for the vibeio async runtime.