nxtquic-api 0.1.1

High-level async API for NxtQuic
Documentation
//! QUIC connection management.

use crate::stream::{RecvStream, SendStream};

/// A QUIC connection.
pub struct Connection {
    // Inner state
}

impl Connection {
    /// Creates a new connection internally.
    pub(crate) fn new() -> Self {
        Self {}
    }

    /// Opens a bidirectional stream.
    pub async fn open_bi(&self) -> std::io::Result<(SendStream, RecvStream)> {
        Ok((SendStream::new(), RecvStream::new()))
    }

    /// Opens a unidirectional stream.
    pub async fn open_uni(&self) -> std::io::Result<SendStream> {
        Ok(SendStream::new())
    }

    /// Accepts an incoming bidirectional stream.
    pub async fn accept_bi(&self) -> std::io::Result<(SendStream, RecvStream)> {
        Ok((SendStream::new(), RecvStream::new()))
    }

    /// Accepts an incoming unidirectional stream.
    pub async fn accept_uni(&self) -> std::io::Result<RecvStream> {
        Ok(RecvStream::new())
    }

    /// Sends a datagram over the connection.
    pub async fn send_datagram(&self, _data: bytes::Bytes) -> std::io::Result<()> {
        Ok(())
    }

    /// Closes the connection.
    pub async fn close(&self) {
        // Close connection
    }
}