Skip to content

Commit d6dc01e

Browse files
author
Julian Orth
committed
Deprecate UdpStream
1 parent 8adfd02 commit d6dc01e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libstd/io/net/udp.rs

+12
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ impl UdpSocket {
100100
///
101101
/// Note that this call does not perform any actual network communication,
102102
/// because UDP is a datagram protocol.
103+
#[deprecated = "`UdpStream` has been deprecated"]
104+
#[allow(deprecated)]
103105
pub fn connect(self, other: SocketAddr) -> UdpStream {
104106
UdpStream {
105107
socket: self,
@@ -205,6 +207,14 @@ impl Clone for UdpSocket {
205207

206208
/// A type that allows convenient usage of a UDP stream connected to one
207209
/// address via the `Reader` and `Writer` traits.
210+
///
211+
/// # Note
212+
///
213+
/// This structure has been deprecated because `Reader` is a stream-oriented API but UDP
214+
/// is a packet-oriented protocol. Every `Reader` method will read a whole packet and
215+
/// throw all superfluous bytes away so that they are no longer available for further
216+
/// method calls.
217+
#[deprecated]
208218
pub struct UdpStream {
209219
socket: UdpSocket,
210220
connected_to: SocketAddr
@@ -336,6 +346,7 @@ mod test {
336346
}
337347

338348
#[test]
349+
#[allow(deprecated)]
339350
fn stream_smoke_test_ip4() {
340351
let server_ip = next_test_ip4();
341352
let client_ip = next_test_ip4();
@@ -380,6 +391,7 @@ mod test {
380391
}
381392

382393
#[test]
394+
#[allow(deprecated)]
383395
fn stream_smoke_test_ip6() {
384396
let server_ip = next_test_ip6();
385397
let client_ip = next_test_ip6();

0 commit comments

Comments
 (0)