1
0
This commit is contained in:
EAimTY 2023-02-05 18:12:06 +09:00
parent b6770387ed
commit d1382b5d56
2 changed files with 9 additions and 1 deletions

View File

@ -8,7 +8,7 @@ A thin layer on top of [quinn](https://github.com/quinn-rs/quinn) to provide fun
## Overview ## Overview
This crate provides a wrapper [`Connection`](https://docs.rs/tuic-quinn/latest/tuic-quinn/struct.Connection.html) around [`quinn::Connection`](https://docs.rs/quinn/latest/quinn/struct.Connection.html). It can be used to perform TUIC operations. This crate provides a wrapper [`Connection`](https://docs.rs/tuic-quinn/latest/tuic_quinn/struct.Connection.html) around [`quinn::Connection`](https://docs.rs/quinn/latest/quinn/struct.Connection.html). It can be used to perform TUIC operations.
Note that there is no TUIC protocol flow state machine abstraction in this crate. You need to implement it yourself. Note that there is no TUIC protocol flow state machine abstraction in this crate. You need to implement it yourself.

View File

@ -40,7 +40,9 @@ pub mod side {
} }
/// The TUIC Connection. /// The TUIC Connection.
///
/// This struct takes a clone of `quinn::Connection` for performing TUIC operations. /// This struct takes a clone of `quinn::Connection` for performing TUIC operations.
///
/// See more details about the TUIC protocol at [SPEC.md](https://github.com/EAimTY/tuic/blob/dev/tuic/SPEC.md) /// See more details about the TUIC protocol at [SPEC.md](https://github.com/EAimTY/tuic/blob/dev/tuic/SPEC.md)
#[derive(Clone)] #[derive(Clone)]
pub struct Connection<Side> { pub struct Connection<Side> {
@ -161,6 +163,7 @@ impl Connection<side::Client> {
} }
/// Try to parse a `quinn::RecvStream` as a TUIC command. /// Try to parse a `quinn::RecvStream` as a TUIC command.
///
/// The `quinn::RecvStream` should be accepted by `quinn::Connection::accept_uni()` from the same `quinn::Connection`. /// The `quinn::RecvStream` should be accepted by `quinn::Connection::accept_uni()` from the same `quinn::Connection`.
pub async fn accept_uni_stream(&self, mut recv: RecvStream) -> Result<Task, Error> { pub async fn accept_uni_stream(&self, mut recv: RecvStream) -> Result<Task, Error> {
let header = match Header::async_unmarshal(&mut recv).await { let header = match Header::async_unmarshal(&mut recv).await {
@ -186,6 +189,7 @@ impl Connection<side::Client> {
} }
/// Try to parse a pair of `quinn::SendStream` and `quinn::RecvStream` as a TUIC command. /// Try to parse a pair of `quinn::SendStream` and `quinn::RecvStream` as a TUIC command.
///
/// The pair of stream should be accepted by `quinn::Connection::accept_bi()` from the same `quinn::Connection`. /// The pair of stream should be accepted by `quinn::Connection::accept_bi()` from the same `quinn::Connection`.
pub async fn accept_bi_stream( pub async fn accept_bi_stream(
&self, &self,
@ -208,6 +212,7 @@ impl Connection<side::Client> {
} }
/// Try to parse a QUIC Datagram as a TUIC command. /// Try to parse a QUIC Datagram as a TUIC command.
///
/// The Datagram should be accepted by `quinn::Connection::read_datagram()` from the same `quinn::Connection`. /// The Datagram should be accepted by `quinn::Connection::read_datagram()` from the same `quinn::Connection`.
pub fn accept_datagram(&self, dg: Bytes) -> Result<Task, Error> { pub fn accept_datagram(&self, dg: Bytes) -> Result<Task, Error> {
let mut dg = Cursor::new(dg); let mut dg = Cursor::new(dg);
@ -255,6 +260,7 @@ impl Connection<side::Server> {
} }
/// Try to parse a `quinn::RecvStream` as a TUIC command. /// Try to parse a `quinn::RecvStream` as a TUIC command.
///
/// The `quinn::RecvStream` should be accepted by `quinn::Connection::accept_uni()` from the same `quinn::Connection`. /// The `quinn::RecvStream` should be accepted by `quinn::Connection::accept_uni()` from the same `quinn::Connection`.
pub async fn accept_uni_stream(&self, mut recv: RecvStream) -> Result<Task, Error> { pub async fn accept_uni_stream(&self, mut recv: RecvStream) -> Result<Task, Error> {
let header = match Header::async_unmarshal(&mut recv).await { let header = match Header::async_unmarshal(&mut recv).await {
@ -285,6 +291,7 @@ impl Connection<side::Server> {
} }
/// Try to parse a pair of `quinn::SendStream` and `quinn::RecvStream` as a TUIC command. /// Try to parse a pair of `quinn::SendStream` and `quinn::RecvStream` as a TUIC command.
///
/// The pair of stream should be accepted by `quinn::Connection::accept_bi()` from the same `quinn::Connection`. /// The pair of stream should be accepted by `quinn::Connection::accept_bi()` from the same `quinn::Connection`.
pub async fn accept_bi_stream( pub async fn accept_bi_stream(
&self, &self,
@ -310,6 +317,7 @@ impl Connection<side::Server> {
} }
/// Try to parse a QUIC Datagram as a TUIC command. /// Try to parse a QUIC Datagram as a TUIC command.
///
/// The Datagram should be accepted by `quinn::Connection::read_datagram()` from the same `quinn::Connection`. /// The Datagram should be accepted by `quinn::Connection::read_datagram()` from the same `quinn::Connection`.
pub fn accept_datagram(&self, dg: Bytes) -> Result<Task, Error> { pub fn accept_datagram(&self, dg: Bytes) -> Result<Task, Error> {
let mut dg = Cursor::new(dg); let mut dg = Cursor::new(dg);