nxtquic-api 0.1.1

High-level async API for NxtQuic
Documentation
//! QUIC stream types implementing Tokio async I/O traits.

use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};

/// A stream that can be written to.
pub struct SendStream {
    // Inner state
}

impl SendStream {
    /// Creates a new send stream internally.
    pub(crate) fn new() -> Self {
        Self {}
    }
}

impl AsyncWrite for SendStream {
    fn poll_write(
        self: Pin<&mut Self>,
        _cx: &mut Context<'_>,
        buf: &[u8],
    ) -> Poll<Result<usize, std::io::Error>> {
        Poll::Ready(Ok(buf.len()))
    }

    fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<(), std::io::Error>> {
        Poll::Ready(Ok(()))
    }

    fn poll_shutdown(
        self: Pin<&mut Self>,
        _cx: &mut Context<'_>,
    ) -> Poll<Result<(), std::io::Error>> {
        Poll::Ready(Ok(()))
    }
}

/// A stream that can be read from.
pub struct RecvStream {
    // Inner state
}

impl RecvStream {
    /// Creates a new recv stream internally.
    pub(crate) fn new() -> Self {
        Self {}
    }
}

impl AsyncRead for RecvStream {
    fn poll_read(
        self: Pin<&mut Self>,
        _cx: &mut Context<'_>,
        _buf: &mut ReadBuf<'_>,
    ) -> Poll<std::io::Result<()>> {
        // Mocking read completion. Real implementation would copy data into buf.
        Poll::Ready(Ok(()))
    }
}