Skip to main content

Crate zincio_quinn

Crate zincio_quinn 

Source
Expand description

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

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

§Overview

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

quinn traitImplementation
quinn::RuntimeZincioRuntime struct
quinn::AsyncTimerInternal wrapper around zincio::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 zincio_quinn::ZincioRuntime;

let runtime = Arc::new(ZincioRuntime);

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

§Architecture notes

zincio 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 zincio 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 zincio runtime context.

Structs§

ZincioRuntime
A quinn::Runtime implementation for the zincio async runtime.