From 7aa7b9ec5f9fba03914b1e614d72e1cc1ace91a7 Mon Sep 17 00:00:00 2001 From: ruben Date: Sat, 29 Jun 2024 14:13:09 +0200 Subject: [PATCH] Make h3-quinn types Sync --- h3-quinn/src/lib.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/h3-quinn/src/lib.rs b/h3-quinn/src/lib.rs index a05ce813..dd374a3e 100644 --- a/h3-quinn/src/lib.rs +++ b/h3-quinn/src/lib.rs @@ -16,8 +16,8 @@ use bytes::{Buf, Bytes, BytesMut}; use futures::{ ready, - stream::{self, BoxStream}, - StreamExt, + stream::{self}, + Stream, StreamExt, }; pub use quinn::{self, AcceptBi, AcceptUni, Endpoint, OpenBi, OpenUni, VarInt, WriteError}; use quinn::{ApplicationClose, ClosedStream, ReadDatagram}; @@ -31,16 +31,19 @@ use tokio_util::sync::ReusableBoxFuture; #[cfg(feature = "tracing")] use tracing::instrument; +/// BoxStream with Sync trait +type BoxStreamSync<'a, T> = Pin + Sync + Send + 'a>>; + /// A QUIC connection backed by Quinn /// /// Implements a [`quic::Connection`] backed by a [`quinn::Connection`]. pub struct Connection { conn: quinn::Connection, - incoming_bi: BoxStream<'static, as Future>::Output>, - opening_bi: Option as Future>::Output>>, - incoming_uni: BoxStream<'static, as Future>::Output>, - opening_uni: Option as Future>::Output>>, - datagrams: BoxStream<'static, as Future>::Output>, + incoming_bi: BoxStreamSync<'static, as Future>::Output>, + opening_bi: Option as Future>::Output>>, + incoming_uni: BoxStreamSync<'static, as Future>::Output>, + opening_uni: Option as Future>::Output>>, + datagrams: BoxStreamSync<'static, as Future>::Output>, } impl Connection { @@ -287,8 +290,8 @@ impl quic::RecvDatagramExt for Connection { /// [`quinn::OpenBi`], [`quinn::OpenUni`]. pub struct OpenStreams { conn: quinn::Connection, - opening_bi: Option as Future>::Output>>, - opening_uni: Option as Future>::Output>>, + opening_bi: Option as Future>::Output>>, + opening_uni: Option as Future>::Output>>, } impl quic::OpenStreams for OpenStreams