Skip to content

Commit 359d024

Browse files
Change crate docs to reflect new crate goals (#74)
* Add a comment about the code structure * Change crate docs to reflect new crate goals * Address feedback
1 parent 110f7fc commit 359d024

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/lib.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,30 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Utilities for handling sockets
11+
// # Source code structure.
12+
//
13+
// All types and methods that are available on tier 1 all platforms are defined
14+
// in the first level of the source, i.e. `src/*.rs` files. Additional API that
15+
// is platform specific, e.g. `Domain::UNIX`, is defined in `src/sys/*.rs` and
16+
// only for the platforms that support it.
17+
18+
//! Utilities for creating and using sockets.
19+
//!
20+
//! The goal of this crate is to create and use a socket using advanced
21+
//! configuration options (those that are not available in the types in the
22+
//! standard library) without using any unsafe code.
23+
//!
24+
//! This crate provides as direct as possible access to the system's
25+
//! functionality for sockets, this means **no** effort to provide
26+
//! cross-platform utilities, no extra goodies, no creature comforts. It is up
27+
//! to the user to know how to use sockets when using this crate. *If you don't
28+
//! know how to create a socket using libc/system calls then this crate is not
29+
//! for you*. Most, if not all, functions directly relate to the equivalent
30+
//! system call with no error handling applied, so no handling errors such as
31+
//! [`EINTR`]. As a result using this crate can be a little wordy, but it should
32+
//! give you maximal flexibility over configuration of sockets.
1233
//!
13-
//! This crate is sort of an evolution of the `net2` crate after seeing the
14-
//! issues on it over time. The intention of this crate is to provide as direct
15-
//! as possible access to the system's functionality for sockets as possible. No
16-
//! extra fluff (e.g. multiple syscalls or builders) provided in this crate.
17-
//! This also means it doesn't handle errors such as `EINTR`. As a result using
18-
//! this crate can be a little wordy, but it should give you maximal flexibility
19-
//! over configuration of sockets.
34+
//! [`EINTR`]: std::io::ErrorKind::Interrupted
2035
//!
2136
//! # Examples
2237
//!
@@ -25,7 +40,7 @@
2540
//! use std::net::SocketAddr;
2641
//! use socket2::{Socket, Domain, Type};
2742
//!
28-
//! // create a TCP listener bound to two addresses
43+
//! // Create a TCP listener bound to two addresses.
2944
//! let socket = Socket::new(Domain::IPV6, Type::STREAM, None)?;
3045
//!
3146
//! let address: SocketAddr = "[::1]:12345".parse().unwrap();

0 commit comments

Comments
 (0)