Skip to content

Commit

Permalink
Introduce UdpSocketState::try_send API for fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger authored and Ralith committed Oct 25, 2024
1 parent e055980 commit bb68125
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions quinn-udp/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ impl UdpSocketState {
/// UDP transmission errors are considered non-fatal because higher-level protocols must
/// employ retransmits and timeouts anyway in order to deal with UDP's unreliable nature.
/// Thus, logging is most likely the only thing you can do with these errors.
///
/// If you would like to handle these errors yourself, use [`UdpSocketState::try_send`]
/// instead.
pub fn send(&self, socket: UdpSockRef<'_>, transmit: &Transmit<'_>) -> io::Result<()> {
match send(socket, transmit) {
Ok(()) => Ok(()),
Expand All @@ -44,6 +47,11 @@ impl UdpSocketState {
}
}

/// Sends a [`Transmit`] on the given socket without any additional error handling.
pub fn try_send(&self, socket: UdpSockRef<'_>, transmit: &Transmit<'_>) -> io::Result<()> {
send(socket, transmit)
}

pub fn recv(
&self,
socket: UdpSockRef<'_>,
Expand Down

0 comments on commit bb68125

Please sign in to comment.