-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(quic): use Provider::send_to for UDP datagram #28
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ use async_std::task::spawn; | |
use futures::{future::BoxFuture, Future, FutureExt}; | ||
use std::{ | ||
io, | ||
net::UdpSocket, | ||
task::{Context, Poll}, | ||
time::Duration, | ||
}; | ||
|
@@ -59,4 +60,16 @@ impl super::Provider for Provider { | |
fn sleep(duration: Duration) -> BoxFuture<'static, ()> { | ||
async_std::task::sleep(duration).boxed() | ||
} | ||
|
||
fn send_to<'a>( | ||
udp_socket: &'a UdpSocket, | ||
buf: &'a [u8], | ||
target: std::net::SocketAddr, | ||
) -> BoxFuture<'a, io::Result<usize>> { | ||
Box::pin(async move { | ||
async_std::net::UdpSocket::from(udp_socket.try_clone()?) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding:
I am assuming that you wonder whether we can do without propagating the error. Given that we already need a way to propagate the error from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good to me! I was just wondering whether there are any specific error cases :) Happy to keep as is! |
||
.send_to(buf, target) | ||
.await | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just what
?
would do?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered the same. Note the function signature:
The function never returns, unless there is an
Error
. In words, the function returnsError
and notResult<_, Error>
. Thus one can not use?
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should change it to
Result<Infallible, Error>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this in libp2p#3964 as well, can't find the concrete conversation right now. I suggest we keep as is unless you feel strongly about it @thomaseizinger.