@@ -387,10 +387,11 @@ impl UnixStream {
387387 /// Sets the read timeout for the socket.
388388 ///
389389 /// If the provided value is [`None`], then [`read`] calls will block
390- /// indefinitely. It is an error to pass the zero [`Duration`] to this
390+ /// indefinitely. An [`Err`] is returned if the zero [`Duration`] is passed to this
391391 /// method.
392392 ///
393393 /// [`None`]: ../../../../std/option/enum.Option.html#variant.None
394+ /// [`Err`]: ../../../../std/result/enum.Result.html#variant.Err
394395 /// [`read`]: ../../../../std/io/trait.Read.html#tymethod.read
395396 /// [`Duration`]: ../../../../std/time/struct.Duration.html
396397 ///
@@ -403,6 +404,20 @@ impl UnixStream {
403404 /// let socket = UnixStream::connect("/tmp/sock").unwrap();
404405 /// socket.set_read_timeout(Some(Duration::new(1, 0))).expect("Couldn't set read timeout");
405406 /// ```
407+ ///
408+ /// An [`Err`] is returned if the zero [`Duration`] is passed to this
409+ /// method:
410+ ///
411+ /// ```no_run
412+ /// use std::io;
413+ /// use std::os::unix::net::UnixStream;
414+ /// use std::time::Duration;
415+ ///
416+ /// let socket = UnixStream::connect("/tmp/sock").unwrap();
417+ /// let result = socket.set_read_timeout(Some(Duration::new(0, 0)));
418+ /// let err = result.unwrap_err();
419+ /// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
420+ /// ```
406421 #[ stable( feature = "unix_socket" , since = "1.10.0" ) ]
407422 pub fn set_read_timeout ( & self , timeout : Option < Duration > ) -> io:: Result < ( ) > {
408423 self . 0 . set_timeout ( timeout, libc:: SO_RCVTIMEO )
@@ -411,10 +426,11 @@ impl UnixStream {
411426 /// Sets the write timeout for the socket.
412427 ///
413428 /// If the provided value is [`None`], then [`write`] calls will block
414- /// indefinitely. It is an error to pass the zero [`Duration`] to this
415- /// method.
429+ /// indefinitely. An [`Err`] is returned if the zero [`Duration`] is
430+ /// passed to this method.
416431 ///
417432 /// [`None`]: ../../../../std/option/enum.Option.html#variant.None
433+ /// [`Err`]: ../../../../std/result/enum.Result.html#variant.Err
418434 /// [`write`]: ../../../../std/io/trait.Write.html#tymethod.write
419435 /// [`Duration`]: ../../../../std/time/struct.Duration.html
420436 ///
@@ -427,6 +443,20 @@ impl UnixStream {
427443 /// let socket = UnixStream::connect("/tmp/sock").unwrap();
428444 /// socket.set_write_timeout(Some(Duration::new(1, 0))).expect("Couldn't set write timeout");
429445 /// ```
446+ ///
447+ /// An [`Err`] is returned if the zero [`Duration`] is passed to this
448+ /// method:
449+ ///
450+ /// ```no_run
451+ /// use std::io;
452+ /// use std::net::UdpSocket;
453+ /// use std::time::Duration;
454+ ///
455+ /// let socket = UdpSocket::bind("127.0.0.1:34254").unwrap();
456+ /// let result = socket.set_write_timeout(Some(Duration::new(0, 0)));
457+ /// let err = result.unwrap_err();
458+ /// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
459+ /// ```
430460 #[ stable( feature = "unix_socket" , since = "1.10.0" ) ]
431461 pub fn set_write_timeout ( & self , timeout : Option < Duration > ) -> io:: Result < ( ) > {
432462 self . 0 . set_timeout ( timeout, libc:: SO_SNDTIMEO )
@@ -1250,10 +1280,11 @@ impl UnixDatagram {
12501280 /// Sets the read timeout for the socket.
12511281 ///
12521282 /// If the provided value is [`None`], then [`recv`] and [`recv_from`] calls will
1253- /// block indefinitely. It is an error to pass the zero [`Duration`] to this
1254- /// method.
1283+ /// block indefinitely. An [`Err`] is returned if the zero [`Duration`]
1284+ /// is passed to this method.
12551285 ///
12561286 /// [`None`]: ../../../../std/option/enum.Option.html#variant.None
1287+ /// [`Err`]: ../../../../std/result/enum.Result.html#variant.Err
12571288 /// [`recv`]: #method.recv
12581289 /// [`recv_from`]: #method.recv_from
12591290 /// [`Duration`]: ../../../../std/time/struct.Duration.html
@@ -1267,6 +1298,20 @@ impl UnixDatagram {
12671298 /// let sock = UnixDatagram::unbound().unwrap();
12681299 /// sock.set_read_timeout(Some(Duration::new(1, 0))).expect("set_read_timeout function failed");
12691300 /// ```
1301+ ///
1302+ /// An [`Err`] is returned if the zero [`Duration`] is passed to this
1303+ /// method:
1304+ ///
1305+ /// ```no_run
1306+ /// use std::io;
1307+ /// use std::os::unix::net::UnixDatagram;
1308+ /// use std::time::Duration;
1309+ ///
1310+ /// let socket = UnixDatagram::unbound().unwrap();
1311+ /// let result = socket.set_read_timeout(Some(Duration::new(0, 0)));
1312+ /// let err = result.unwrap_err();
1313+ /// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
1314+ /// ```
12701315 #[ stable( feature = "unix_socket" , since = "1.10.0" ) ]
12711316 pub fn set_read_timeout ( & self , timeout : Option < Duration > ) -> io:: Result < ( ) > {
12721317 self . 0 . set_timeout ( timeout, libc:: SO_RCVTIMEO )
@@ -1275,7 +1320,7 @@ impl UnixDatagram {
12751320 /// Sets the write timeout for the socket.
12761321 ///
12771322 /// If the provided value is [`None`], then [`send`] and [`send_to`] calls will
1278- /// block indefinitely. It is an error to pass the zero [`Duration`] to this
1323+ /// block indefinitely. An [`Err`] is returned if the zero [`Duration`] is passed to this
12791324 /// method.
12801325 ///
12811326 /// [`None`]: ../../../../std/option/enum.Option.html#variant.None
@@ -1293,6 +1338,20 @@ impl UnixDatagram {
12931338 /// sock.set_write_timeout(Some(Duration::new(1, 0)))
12941339 /// .expect("set_write_timeout function failed");
12951340 /// ```
1341+ ///
1342+ /// An [`Err`] is returned if the zero [`Duration`] is passed to this
1343+ /// method:
1344+ ///
1345+ /// ```no_run
1346+ /// use std::io;
1347+ /// use std::os::unix::net::UnixDatagram;
1348+ /// use std::time::Duration;
1349+ ///
1350+ /// let socket = UnixDatagram::unbound().unwrap();
1351+ /// let result = socket.set_write_timeout(Some(Duration::new(0, 0)));
1352+ /// let err = result.unwrap_err();
1353+ /// assert_eq!(err.kind(), io::ErrorKind::InvalidInput)
1354+ /// ```
12961355 #[ stable( feature = "unix_socket" , since = "1.10.0" ) ]
12971356 pub fn set_write_timeout ( & self , timeout : Option < Duration > ) -> io:: Result < ( ) > {
12981357 self . 0 . set_timeout ( timeout, libc:: SO_SNDTIMEO )
0 commit comments