|
1 |
| -//! TCP/UDP bindings for `tokio`. |
| 1 | +//! TCP/UDP/Unix bindings for `tokio`. |
2 | 2 | //!
|
3 |
| -//! This module contains the TCP/UDP networking types, similar to the standard |
| 3 | +//! This module contains the TCP/UDP/Unix networking types, similar to the standard |
4 | 4 | //! library, which can be used to implement networking protocols.
|
5 | 5 | //!
|
6 |
| -//! # TCP |
| 6 | +//! # Organization |
7 | 7 | //!
|
8 |
| -//! Connecting to an address, via TCP, can be done using [`TcpStream`]'s |
9 |
| -//! [`connect`] method, which returns [`ConnectFuture`]. `ConnectFuture` |
10 |
| -//! implements a future which returns a `TcpStream`. |
| 8 | +//! * [`TcpListener`] and [`TcpStream`] provide functionality for communication over TCP |
| 9 | +//! * [`UdpSocket`] and [`UdpFramed`] provide functionality for communication over UDP |
| 10 | +//! * [`UnixListener`] and [`UnixStream`] provide functionality for communication over a |
| 11 | +//! Unix Domain Socket **(available on Unix only)** |
11 | 12 | //!
|
12 |
| -//! To listen on an address [`TcpListener`] can be used. `TcpListener`'s |
13 |
| -//! [`incoming`][incoming_method] method can be used to accept new connections. |
14 |
| -//! It return the [`Incoming`] struct, which implements a stream which returns |
15 |
| -//! `TcpStream`s. |
16 |
| -//! |
17 |
| -//! [`TcpStream`]: struct.TcpStream.html |
18 |
| -//! [`connect`]: struct.TcpStream.html#method.connect |
19 |
| -//! [`ConnectFuture`]: struct.ConnectFuture.html |
20 | 13 | //! [`TcpListener`]: struct.TcpListener.html
|
21 |
| -//! [incoming_method]: struct.TcpListener.html#method.incoming |
22 |
| -//! [`Incoming`]: struct.Incoming.html |
23 |
| -//! |
24 |
| -//! # UDP |
25 |
| -//! |
26 |
| -//! The main struct for UDP is the [`UdpSocket`], which represents a UDP socket. |
27 |
| -//! Reading and writing to it can be done using futures, which return the |
28 |
| -//! [`RecvDgram`] and [`SendDgram`] structs respectively. |
29 |
| -//! |
30 |
| -//! For convenience it's also possible to convert raw datagrams into higher-level |
31 |
| -//! frames. |
32 |
| -//! |
| 14 | +//! [`TcpStream`]: struct.TcpStream.html |
33 | 15 | //! [`UdpSocket`]: struct.UdpSocket.html
|
34 |
| -//! [`RecvDgram`]: struct.RecvDgram.html |
35 |
| -//! [`SendDgram`]: struct.SendDgram.html |
36 | 16 | //! [`UdpFramed`]: struct.UdpFramed.html
|
37 |
| -//! [`framed`]: struct.UdpSocket.html#method.framed |
| 17 | +//! [`UnixListener`]: struct.UnixListener.html |
| 18 | +//! [`UnixStream`]: struct.UnixStream.html |
38 | 19 |
|
39 |
| -pub use tokio_tcp::{TcpStream, ConnectFuture}; |
40 |
| -pub use tokio_tcp::{TcpListener, Incoming}; |
41 |
| -pub use tokio_udp::{UdpSocket, UdpFramed, SendDgram, RecvDgram}; |
| 20 | +pub mod tcp { |
| 21 | + //! TCP bindings for `tokio`. |
| 22 | + //! |
| 23 | + //! Connecting to an address, via TCP, can be done using [`TcpStream`]'s |
| 24 | + //! [`connect`] method, which returns [`ConnectFuture`]. `ConnectFuture` |
| 25 | + //! implements a future which returns a `TcpStream`. |
| 26 | + //! |
| 27 | + //! To listen on an address [`TcpListener`] can be used. `TcpListener`'s |
| 28 | + //! [`incoming`][incoming_method] method can be used to accept new connections. |
| 29 | + //! It return the [`Incoming`] struct, which implements a stream which returns |
| 30 | + //! `TcpStream`s. |
| 31 | + //! |
| 32 | + //! [`TcpStream`]: struct.TcpStream.html |
| 33 | + //! [`connect`]: struct.TcpStream.html#method.connect |
| 34 | + //! [`ConnectFuture`]: struct.ConnectFuture.html |
| 35 | + //! [`TcpListener`]: struct.TcpListener.html |
| 36 | + //! [incoming_method]: struct.TcpListener.html#method.incoming |
| 37 | + //! [`Incoming`]: struct.Incoming.html |
| 38 | + pub use tokio_tcp::{ConnectFuture, Incoming, TcpListener, TcpStream}; |
| 39 | +} |
| 40 | +pub use self::tcp::{TcpListener, TcpStream}; |
| 41 | + |
| 42 | +#[deprecated(note = "use `tokio::net::tcp::ConnectFuture` instead")] |
| 43 | +#[doc(hidden)] |
| 44 | +pub type ConnectFuture = self::tcp::ConnectFuture; |
| 45 | +#[deprecated(note = "use `tokio::net::tcp::Incoming` instead")] |
| 46 | +#[doc(hidden)] |
| 47 | +pub type Incoming = self::tcp::Incoming; |
| 48 | + |
| 49 | +pub mod udp { |
| 50 | + //! UDP bindings for `tokio`. |
| 51 | + //! |
| 52 | + //! The main struct for UDP is the [`UdpSocket`], which represents a UDP socket. |
| 53 | + //! Reading and writing to it can be done using futures, which return the |
| 54 | + //! [`RecvDgram`] and [`SendDgram`] structs respectively. |
| 55 | + //! |
| 56 | + //! For convenience it's also possible to convert raw datagrams into higher-level |
| 57 | + //! frames. |
| 58 | + //! |
| 59 | + //! [`UdpSocket`]: struct.UdpSocket.html |
| 60 | + //! [`RecvDgram`]: struct.RecvDgram.html |
| 61 | + //! [`SendDgram`]: struct.SendDgram.html |
| 62 | + //! [`UdpFramed`]: struct.UdpFramed.html |
| 63 | + //! [`framed`]: struct.UdpSocket.html#method.framed |
| 64 | + pub use tokio_udp::{RecvDgram, SendDgram, UdpFramed, UdpSocket}; |
| 65 | +} |
| 66 | +pub use self::udp::{UdpFramed, UdpSocket}; |
| 67 | + |
| 68 | +#[deprecated(note = "use `tokio::net::udp::RecvDgram` instead")] |
| 69 | +#[doc(hidden)] |
| 70 | +pub type RecvDgram<T> = self::udp::RecvDgram<T>; |
| 71 | +#[deprecated(note = "use `tokio::net::udp::SendDgram` instead")] |
| 72 | +#[doc(hidden)] |
| 73 | +pub type SendDgram<T> = self::udp::SendDgram<T>; |
42 | 74 |
|
43 | 75 | #[cfg(unix)]
|
44 | 76 | pub mod unix {
|
45 |
| - //! Unix domain socket bindings for `tokio`. |
| 77 | + //! Unix domain socket bindings for `tokio` (only available on unix systems). |
46 | 78 |
|
47 | 79 | pub use tokio_uds::{
|
48 | 80 | ConnectFuture, Incoming, RecvDgram, SendDgram, UCred, UnixDatagram, UnixListener,
|
49 | 81 | UnixStream,
|
50 | 82 | };
|
51 | 83 | }
|
52 |
| - |
53 | 84 | #[cfg(unix)]
|
54 | 85 | pub use self::unix::{UnixListener, UnixStream};
|
0 commit comments