Skip to main content

Crate ringline_quic

Crate ringline_quic 

Source
Expand description

ringline-quic — QUIC protocol support via quinn-proto.

This crate wraps quinn-proto’s sans-IO QUIC state machine and exposes an event-based QuicEndpoint API.

§Example

use ringline_quic::{QuicConfig, QuicEndpoint, QuicEvent};

// Feed incoming datagrams:
quic.handle_datagram(Instant::now(), data, peer);
while let Some(event) = quic.poll_event() {
    match event {
        QuicEvent::NewConnection(conn) => { /* ... */ }
        QuicEvent::StreamReadable { conn, stream } => {
            let mut buf = [0u8; 4096];
            let (n, fin) = quic.stream_recv(conn, stream, &mut buf)?;
            quic.stream_send(conn, stream, &buf[..n])?;
        }
        _ => {}
    }
}
// Drain outgoing packets:
while let Some(pkt) = quic.poll_send() {
    match pkt.segment_size {
        Some(seg) => udp.send_to_gso(pkt.destination, &pkt.data, seg)?,
        None => udp.send_to(pkt.destination, &pkt.data)?,
    }
}

Re-exports§

pub use config::QuicConfig;
pub use endpoint::BatchGuard;
pub use endpoint::Datagrams;
pub use endpoint::OutgoingPacket;
pub use endpoint::QuicEndpoint;
pub use error::Error;
pub use event::QuicConnId;
pub use event::QuicEvent;

Modules§

config
endpoint
error
event

Structs§

ConnectionStats
Connection statistics
FrameStats
Number of frames transmitted or received of each frame type
PathStats
Statistics related to a transmission path
StreamId
Identifier for a stream within a particular connection
UdpStats
Statistics about UDP datagrams transmitted or received on a connection
VarInt
An integer less than 2^62

Enums§

Dir
Whether a stream communicates data in both directions or only from the initiator
ReadError
Errors triggered when reading from a recv stream
WriteError
Errors triggered while writing to a send stream