Skip to content

Commit

Permalink
Add API parity stubs for UDP sockets/TCP streams (#174)
Browse files Browse the repository at this point in the history
These are no-ops in turmoil, but having these available
minimizes the amount of caller code that needs to change.
  • Loading branch information
progwriter authored Apr 24, 2024
1 parent 6728fbe commit 8b99772
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ impl TcpStream {
},
)
}

/// Has no effect in turmoil. API parity with
/// https://docs.rs/tokio/latest/tokio/net/struct.TcpStream.html#method.set_nodelay
pub fn set_nodelay(&self, _nodelay: bool) -> Result<()> {
Ok(())
}
}

pub(crate) struct ReadHalf {
Expand Down
14 changes: 13 additions & 1 deletion src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
use std::{
cmp,
io::{self, Error, ErrorKind, Result},
net::SocketAddr,
net::{Ipv6Addr, SocketAddr},
};

/// A simulated UDP socket.
Expand Down Expand Up @@ -299,6 +299,18 @@ impl UdpSocket {

Ok(())
}

/// Has no effect in turmoil. API parity with
/// https://docs.rs/tokio/latest/tokio/net/struct.UdpSocket.html#method.set_multicast_loop_v6
pub fn set_multicast_loop_v6(&self, _on: bool) -> Result<()> {
Ok(())
}

/// Has no effect in turmoil. API parity with
/// https://docs.rs/tokio/latest/tokio/net/struct.UdpSocket.html#method.join_multicast_v6
pub fn join_multicast_v6(&self, _multiaddr: &Ipv6Addr, _interface: u32) -> Result<()> {
Ok(())
}
}

fn send_loopback(src: SocketAddr, dst: SocketAddr, message: Protocol) {
Expand Down

0 comments on commit 8b99772

Please sign in to comment.