use std::{fmt::Debug, io};
use super::{QuicConnState, QuicStream};
#[derive(Clone)]
pub struct QuicConn {
pub(super) state: QuicConnState,
}
impl Debug for QuicConn {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "trace_id={}", self.state.trace_id)
}
}
impl QuicConn {
pub(crate) fn new(state: QuicConnState) -> Self {
Self { state }
}
pub async fn accept(&self) -> Option<QuicStream> {
self.state.accept().await
}
pub async fn open_stream(&self) -> io::Result<QuicStream> {
Ok(self.state.open_stream())
}
pub async fn close(&self, app: bool, err: u64, reason: &[u8]) -> io::Result<()> {
self.state.close(app, err, reason).await
}
pub fn trace_id(&self) -> &str {
&self.state.trace_id
}
pub async fn is_closed(&self) -> bool {
self.state.is_closed().await
}
}