Skip to content

Commit d884931

Browse files
feat(netwatch)!: switch from iroh-quinn-udp to noq-udp (#114)
## Breaking Changes - netwatch - renames the relevant functions from `_quinn` to `_noq
1 parent 2ceaa23 commit d884931

3 files changed

Lines changed: 37 additions & 43 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netwatch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tracing = "0.1"
3434

3535
# non-browser dependencies
3636
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
37-
quinn-udp = { package = "iroh-quinn-udp", version = "0.8" }
37+
noq-udp = "0.9"
3838
libc = "0.2.139"
3939
netdev = "0.40.1"
4040
socket2 = { version = "0.6", features = ["all"] }

netwatch/src/udp.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
};
1010

1111
use atomic_waker::AtomicWaker;
12-
use quinn_udp::Transmit;
12+
use noq_udp::Transmit;
1313
use tokio::io::Interest;
1414
use tracing::{debug, trace, warn};
1515

@@ -325,8 +325,8 @@ impl UdpSocket {
325325
}
326326
}
327327

328-
/// Send a quinn based `Transmit`.
329-
pub fn try_send_quinn(&self, transmit: &Transmit<'_>) -> io::Result<()> {
328+
/// Send a noq based `Transmit`.
329+
pub fn try_send_noq(&self, transmit: &Transmit<'_>) -> io::Result<()> {
330330
loop {
331331
self.maybe_rebind()?;
332332

@@ -355,12 +355,8 @@ impl UdpSocket {
355355
}
356356
}
357357

358-
/// poll send a quinn based `Transmit`.
359-
pub fn poll_send_quinn(
360-
&self,
361-
cx: &mut Context,
362-
transmit: &Transmit<'_>,
363-
) -> Poll<io::Result<()>> {
358+
/// poll send a noq based `Transmit`.
359+
pub fn poll_send_noq(&self, cx: &mut Context, transmit: &Transmit<'_>) -> Poll<io::Result<()>> {
364360
loop {
365361
if let Err(err) = self.maybe_rebind() {
366362
return Poll::Ready(Err(err));
@@ -399,12 +395,12 @@ impl UdpSocket {
399395
}
400396
}
401397

402-
/// quinn based `poll_recv`
403-
pub fn poll_recv_quinn(
398+
/// noq based `poll_recv`
399+
pub fn poll_recv_noq(
404400
&self,
405401
cx: &mut Context,
406402
bufs: &mut [io::IoSliceMut<'_>],
407-
meta: &mut [quinn_udp::RecvMeta],
403+
meta: &mut [noq_udp::RecvMeta],
408404
) -> Poll<io::Result<usize>> {
409405
loop {
410406
if let Err(err) = self.maybe_rebind() {
@@ -697,7 +693,7 @@ impl Future for SendToFut<'_, '_> {
697693
enum SocketState {
698694
Connected {
699695
socket: tokio::net::UdpSocket,
700-
state: quinn_udp::UdpSocketState,
696+
state: noq_udp::UdpSocketState,
701697
/// The addr we are binding to.
702698
addr: SocketAddr,
703699
},
@@ -711,9 +707,7 @@ enum SocketState {
711707
}
712708

713709
impl SocketState {
714-
fn try_get_connected(
715-
&self,
716-
) -> io::Result<(&tokio::net::UdpSocket, &quinn_udp::UdpSocketState)> {
710+
fn try_get_connected(&self) -> io::Result<(&tokio::net::UdpSocket, &noq_udp::UdpSocketState)> {
717711
match self {
718712
Self::Connected {
719713
socket,
@@ -752,7 +746,7 @@ impl SocketState {
752746
socket.set_only_v6(true)?;
753747
}
754748

755-
// Binding must happen before calling quinn, otherwise `local_addr`
749+
// Binding must happen before calling noq, otherwise `local_addr`
756750
// is not yet available on all OSes.
757751
socket.bind(&addr.into())?;
758752

@@ -763,8 +757,8 @@ impl SocketState {
763757

764758
// Convert into tokio UdpSocket
765759
let socket = tokio::net::UdpSocket::from_std(socket)?;
766-
let socket_ref = quinn_udp::UdpSockRef::from(&socket);
767-
let socket_state = quinn_udp::UdpSocketState::new(socket_ref)?;
760+
let socket_ref = noq_udp::UdpSockRef::from(&socket);
761+
let socket_state = noq_udp::UdpSocketState::new(socket_ref)?;
768762

769763
let local_addr = socket.local_addr()?;
770764
if addr.port() != 0 && local_addr.port() != addr.port() {
@@ -818,7 +812,7 @@ impl SocketState {
818812
matches!(self, Self::Closed { .. })
819813
}
820814

821-
fn close(&mut self) -> Option<(tokio::net::UdpSocket, quinn_udp::UdpSocketState)> {
815+
fn close(&mut self) -> Option<(tokio::net::UdpSocket, noq_udp::UdpSocketState)> {
822816
match self {
823817
Self::Connected { state, addr, .. } => {
824818
let s = SocketState::Closed {
@@ -907,8 +901,8 @@ impl UdpSender {
907901
}
908902

909903
/// Async sending
910-
pub fn send<'a, 'b>(&self, transmit: &'a quinn_udp::Transmit<'b>) -> SendFutQuinn<'a, 'b> {
911-
SendFutQuinn {
904+
pub fn send<'a, 'b>(&self, transmit: &'a noq_udp::Transmit<'b>) -> SendFutNoq<'a, 'b> {
905+
SendFutNoq {
912906
socket: self.socket.clone(),
913907
transmit,
914908
}
@@ -917,7 +911,7 @@ impl UdpSender {
917911
/// Poll send
918912
pub fn poll_send(
919913
self: Pin<&mut Self>,
920-
transmit: &quinn_udp::Transmit,
914+
transmit: &noq_udp::Transmit,
921915
cx: &mut Context,
922916
) -> Poll<io::Result<()>> {
923917
let mut this = self.project();
@@ -964,7 +958,7 @@ impl UdpSender {
964958
}
965959

966960
/// Best effort sending
967-
pub fn try_send(&self, transmit: &quinn_udp::Transmit) -> io::Result<()> {
961+
pub fn try_send(&self, transmit: &noq_udp::Transmit) -> io::Result<()> {
968962
self.socket.maybe_rebind()?;
969963

970964
match self.socket.socket.try_read() {
@@ -980,14 +974,14 @@ impl UdpSender {
980974
}
981975
}
982976

983-
/// Send future quinn
977+
/// Send future noq
984978
#[derive(Debug)]
985-
pub struct SendFutQuinn<'a, 'b> {
979+
pub struct SendFutNoq<'a, 'b> {
986980
socket: Arc<UdpSocket>,
987-
transmit: &'a quinn_udp::Transmit<'b>,
981+
transmit: &'a noq_udp::Transmit<'b>,
988982
}
989983

990-
impl Future for SendFutQuinn<'_, '_> {
984+
impl Future for SendFutNoq<'_, '_> {
991985
type Output = io::Result<()>;
992986

993987
fn poll(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> Poll<Self::Output> {

0 commit comments

Comments
 (0)