]> git.lizzy.rs Git - rust.git/commitdiff
Deprecate UdpStream
authorJulian Orth <ju.orth@gmail.com>
Fri, 17 Oct 2014 23:36:46 +0000 (01:36 +0200)
committerJulian Orth <ju.orth@gmail.com>
Sat, 25 Oct 2014 07:11:47 +0000 (09:11 +0200)
src/libstd/io/net/udp.rs

index 651cb9f596d010c6c998bc5e03dd73f128c95ebb..7d9eea3a73279bf535fdeb6cc8cb230fe6bf6718 100644 (file)
@@ -100,6 +100,8 @@ pub fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> {
     ///
     /// Note that this call does not perform any actual network communication,
     /// because UDP is a datagram protocol.
+    #[deprecated = "`UdpStream` has been deprecated"]
+    #[allow(deprecated)]
     pub fn connect(self, other: SocketAddr) -> UdpStream {
         UdpStream {
             socket: self,
@@ -205,6 +207,14 @@ fn clone(&self) -> UdpSocket {
 
 /// A type that allows convenient usage of a UDP stream connected to one
 /// address via the `Reader` and `Writer` traits.
+///
+/// # Note
+///
+/// This structure has been deprecated because `Reader` is a stream-oriented API but UDP
+/// is a packet-oriented protocol. Every `Reader` method will read a whole packet and
+/// throw all superfluous bytes away so that they are no longer available for further
+/// method calls.
+#[deprecated]
 pub struct UdpStream {
     socket: UdpSocket,
     connected_to: SocketAddr
@@ -336,6 +346,7 @@ fn socket_smoke_test_ip6() {
     }
 
     #[test]
+    #[allow(deprecated)]
     fn stream_smoke_test_ip4() {
         let server_ip = next_test_ip4();
         let client_ip = next_test_ip4();
@@ -380,6 +391,7 @@ fn stream_smoke_test_ip4() {
     }
 
     #[test]
+    #[allow(deprecated)]
     fn stream_smoke_test_ip6() {
         let server_ip = next_test_ip6();
         let client_ip = next_test_ip6();