Skip to content

Commit fa30e8a

Browse files
authored
fix(s2n-quic-dc): adjust trait bounds for providers (#2774)
1 parent 625be88 commit fa30e8a

File tree

9 files changed

+43
-13
lines changed

9 files changed

+43
-13
lines changed

dc/s2n-quic-dc/src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub mod metrics {
4747
}
4848

4949
pub mod disabled {
50-
#[derive(Debug, Default)]
50+
#[derive(Clone, Debug, Default)]
5151
pub struct Subscriber(());
5252

5353
impl super::Subscriber for Subscriber {

dc/s2n-quic-dc/src/psk/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fn make_runtime() -> (Arc<Runtime>, DropGuard) {
5454

5555
impl State {
5656
fn new_runtime<
57-
Provider: Prov + Clone + Send + Sync + 'static,
57+
Provider: Prov + Send + Sync + 'static,
5858
Subscriber: Sub + Send + Sync + 'static,
5959
Event: s2n_quic::provider::event::Subscriber,
6060
>(
@@ -91,7 +91,7 @@ impl Provider {
9191
}
9292

9393
pub fn new<
94-
Provider: Prov + Clone + Send + Sync + 'static,
94+
Provider: Prov + Send + Sync + 'static,
9595
Subscriber: Sub + Send + Sync + 'static,
9696
Event: s2n_quic::provider::event::Subscriber,
9797
>(

dc/s2n-quic-dc/src/psk/client/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<Event: s2n_quic::provider::event::Subscriber> Builder<Event> {
9393
///
9494
/// Typically the address provided can use an ephemeral port.
9595
pub fn start<
96-
TlsProvider: Prov + Clone + Send + Sync + 'static,
96+
TlsProvider: Prov + Send + Sync + 'static,
9797
Subscriber: Sub + Send + Sync + 'static,
9898
>(
9999
self,

dc/s2n-quic-dc/src/psk/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct Server {
4444

4545
impl Server {
4646
pub fn bind<
47-
Provider: Prov + Clone + Send + Sync + 'static,
47+
Provider: Prov + Send + Sync + 'static,
4848
Subscriber: Sub + Send + Sync + 'static,
4949
Event: s2n_quic::provider::event::Subscriber,
5050
>(
@@ -89,7 +89,7 @@ impl Server {
8989
}
9090

9191
pub(super) async fn server<
92-
Provider: Prov + Clone + Send + Sync + 'static,
92+
Provider: Prov + Send + Sync + 'static,
9393
Subscriber: Sub + Send + Sync + 'static,
9494
Event: s2n_quic::provider::event::Subscriber,
9595
>(
@@ -164,7 +164,7 @@ impl Client {
164164
}
165165

166166
pub fn bind<
167-
Provider: Prov + Clone + Send + Sync + 'static,
167+
Provider: Prov + Send + Sync + 'static,
168168
Subscriber: Sub + Send + Sync + 'static,
169169
Event: s2n_quic::provider::event::Subscriber,
170170
>(

dc/s2n-quic-dc/src/psk/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct Provider {
1919

2020
impl Provider {
2121
pub fn setup<
22-
Provider: Prov + Clone + Send + Sync + 'static,
22+
Provider: Prov + Send + Sync + 'static,
2323
Subscriber: Sub + Send + Sync + 'static,
2424
Event: s2n_quic::provider::event::Subscriber,
2525
>(

dc/s2n-quic-dc/src/psk/server/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ impl<Event: s2n_quic::provider::event::Subscriber> Builder<Event> {
8888

8989
/// Starts the server listening to the given address.
9090
pub async fn start<
91-
TlsProvider: Prov + Clone + Send + Sync + 'static,
92-
Subscriber: Sub + Default + Clone + Send + Sync + 'static,
91+
TlsProvider: Prov + Send + Sync + 'static,
92+
Subscriber: Sub + Send + Sync + 'static,
9393
>(
9494
self,
9595
bind: SocketAddr,
@@ -110,8 +110,8 @@ impl<Event: s2n_quic::provider::event::Subscriber> Builder<Event> {
110110

111111
/// Starts the server listening to the given address, blocking until the server has been bound to the address.
112112
pub fn start_blocking<
113-
TlsProvider: Prov + Clone + Send + Sync + 'static,
114-
Subscriber: Sub + Default + Clone + Send + Sync + 'static,
113+
TlsProvider: Prov + Send + Sync + 'static,
114+
Subscriber: Sub + Send + Sync + 'static,
115115
>(
116116
self,
117117
bind: SocketAddr,

dc/s2n-quic-dc/src/stream/client/tokio.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ pub trait Handshake: Clone {
4040
fn map(&self) -> &secret::Map;
4141
}
4242

43+
impl Handshake for crate::psk::client::Provider {
44+
async fn handshake_with_entry(
45+
&self,
46+
remote_handshake_addr: SocketAddr,
47+
) -> std::io::Result<(secret::map::Peer, secret::HandshakeKind)> {
48+
self.handshake_with_entry(remote_handshake_addr, |_conn, _duration| {})
49+
.await
50+
}
51+
52+
fn local_addr(&self) -> std::io::Result<SocketAddr> {
53+
self.local_addr()
54+
}
55+
56+
fn map(&self) -> &secret::Map {
57+
self.map()
58+
}
59+
}
60+
4361
#[derive(Clone)]
4462
pub struct Client<H: Handshake + Clone, S: event::Subscriber + Clone> {
4563
env: Environment<S>,

dc/s2n-quic-dc/src/stream/server/tokio.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ pub trait Handshake: Clone {
3232
fn map(&self) -> &secret::Map;
3333
}
3434

35+
impl Handshake for crate::psk::server::Provider {
36+
fn local_addr(&self) -> SocketAddr {
37+
self.local_addr()
38+
}
39+
40+
fn map(&self) -> &secret::Map {
41+
self.map()
42+
}
43+
}
44+
3545
#[derive(Clone)]
3646
pub struct Server<H: Handshake + Clone, S: event::Subscriber + Clone> {
3747
streams: accept::Receiver<S>,

dc/s2n-quic-dc/src/stream/server/tokio/tcp.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
};
1212
use core::{future::poll_fn, task::Poll};
1313
use s2n_quic_core::{inet::SocketAddress, time::Clock};
14-
use std::{net::TcpListener, os::fd::AsRawFd, time::Duration};
14+
use std::{net::TcpListener, time::Duration};
1515
use tokio::io::unix::AsyncFd;
1616
use tracing::debug;
1717

@@ -62,6 +62,8 @@ where
6262

6363
#[cfg(target_os = "linux")]
6464
{
65+
use std::os::fd::AsRawFd;
66+
6567
let res = unsafe {
6668
libc::setsockopt(
6769
acceptor.socket.get_ref().as_raw_fd(),

0 commit comments

Comments
 (0)