Skip to main content

nxtquic_api/
connection.rs

1//! QUIC connection management.
2
3use crate::stream::{RecvStream, SendStream};
4
5/// A QUIC connection.
6pub struct Connection {
7    // Inner state
8}
9
10impl Connection {
11    /// Creates a new connection internally.
12    pub(crate) fn new() -> Self {
13        Self {}
14    }
15
16    /// Opens a bidirectional stream.
17    pub async fn open_bi(&self) -> std::io::Result<(SendStream, RecvStream)> {
18        Ok((SendStream::new(), RecvStream::new()))
19    }
20
21    /// Opens a unidirectional stream.
22    pub async fn open_uni(&self) -> std::io::Result<SendStream> {
23        Ok(SendStream::new())
24    }
25
26    /// Accepts an incoming bidirectional stream.
27    pub async fn accept_bi(&self) -> std::io::Result<(SendStream, RecvStream)> {
28        Ok((SendStream::new(), RecvStream::new()))
29    }
30
31    /// Accepts an incoming unidirectional stream.
32    pub async fn accept_uni(&self) -> std::io::Result<RecvStream> {
33        Ok(RecvStream::new())
34    }
35
36    /// Sends a datagram over the connection.
37    pub async fn send_datagram(&self, _data: bytes::Bytes) -> std::io::Result<()> {
38        Ok(())
39    }
40
41    /// Closes the connection.
42    pub async fn close(&self) {
43        // Close connection
44    }
45}