Skip to content

Commit 4d918e4

Browse files
dlrobertsonwhitequark
authored andcommitted
Fix documentation warnings.
- There are several warnings that are thrown when running `cargo doc`. Fix these warnings. - Convert all module documentation to use /*! for consistency.
1 parent 793227f commit 4d918e4

File tree

9 files changed

+102
-101
lines changed

9 files changed

+102
-101
lines changed

src/iface/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
//! Network interface logic.
2-
//!
3-
//! The `iface` module deals with the *network interfaces*. It filters incoming frames,
4-
//! provides lookup and caching of hardware addresses, and handles management packets.
1+
/*! Network interface logic.
2+
3+
The `iface` module deals with the *network interfaces*. It filters incoming frames,
4+
provides lookup and caching of hardware addresses, and handles management packets.
5+
*/
56

67
mod neighbor;
78
mod ethernet;

src/iface/neighbor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ pub(crate) enum Answer {
3232
/// # Examples
3333
///
3434
/// On systems with heap, this cache can be created with:
35+
///
3536
/// ```rust
3637
/// use std::collections::BTreeMap;
3738
/// use smoltcp::iface::NeighborCache;
3839
/// let mut neighbor_cache = NeighborCache::new(BTreeMap::new());
3940
/// ```
4041
///
4142
/// On systems without heap, use:
43+
///
4244
/// ```rust
4345
/// use smoltcp::iface::NeighborCache;
4446
/// let mut neighbor_cache_storage = [None; 8];

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@
1212
//!
1313
//! When discussing networking stacks and layering, often the [OSI model][osi] is invoked.
1414
//! _smoltcp_ makes no effort to conform to the OSI model as it is not applicable to TCP/IP.
15-
//! [osi]: https://en.wikipedia.org/wiki/OSI_model
1615
//!
1716
//! # The socket layer
1817
//! The socket layer APIs are provided in the module [socket](socket/index.html); currently,
1918
//! raw, ICMP, TCP, and UDP sockets are provided. The socket API provides the usual primitives,
2019
//! but necessarily differs in many from the [Berkeley socket API][berk], as the latter was
2120
//! not designed to be used without heap allocation.
22-
//! [berk]: https://en.wikipedia.org/wiki/Berkeley_sockets
2321
//!
2422
//! The socket layer provides the buffering, packet construction and validation, and (for
2523
//! stateful sockets) the state machines, but it is interface-agnostic. An application must
@@ -69,6 +67,9 @@
6967
//! except where necessary to provide safe access to fields, and strives to implement every
7068
//! feature ever defined, to ensure that, when the representation layer is unable to make sense
7169
//! of a packet, it is still logged correctly and in full.
70+
//!
71+
//! [osi]: https://en.wikipedia.org/wiki/OSI_model
72+
//! [berk]: https://en.wikipedia.org/wiki/Berkeley_sockets
7273
7374
/* XXX compiler bug
7475
#![cfg(not(any(feature = "socket-raw",

src/phy/mod.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
//! Access to networking hardware.
2-
//!
3-
//! The `phy` module deals with the *network devices*. It provides a trait
4-
//! for transmitting and receiving frames, [Device](trait.Device.html)
5-
//! and implementations of it:
6-
//!
7-
//! * the [_loopback_](struct.Loopback.html), for zero dependency testing;
8-
//! * _middleware_ [Tracer](struct.Tracer.html) and
9-
//! [FaultInjector](struct.FaultInjector.html), to facilitate debugging;
10-
//! * _adapters_ [RawSocket](struct.RawSocket.html) and
11-
//! [TapInterface](struct.TapInterface.html), to transmit and receive frames
12-
//! on the host OS.
13-
//!
14-
// https://github.com/rust-lang/rust/issues/38740
15-
//! <h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
16-
//!
17-
//! An implementation of the [Device](trait.Device.html) trait for a simple hardware
18-
//! Ethernet controller could look as follows:
19-
//!
20-
/*!
1+
/*! Access to networking hardware.
2+
3+
The `phy` module deals with the *network devices*. It provides a trait
4+
for transmitting and receiving frames, [Device](trait.Device.html)
5+
and implementations of it:
6+
7+
* the [_loopback_](struct.Loopback.html), for zero dependency testing;
8+
* _middleware_ [Tracer](struct.Tracer.html) and
9+
[FaultInjector](struct.FaultInjector.html), to facilitate debugging;
10+
* _adapters_ [RawSocket](struct.RawSocket.html) and
11+
[TapInterface](struct.TapInterface.html), to transmit and receive frames
12+
on the host OS.
13+
14+
# Examples
15+
16+
An implementation of the [Device](trait.Device.html) trait for a simple hardware
17+
Ethernet controller could look as follows:
18+
2119
```rust
2220
use smoltcp::Result;
2321
use smoltcp::phy::{self, DeviceCapabilities, Device};

src/socket/mod.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
//! Communication between endpoints.
2-
//!
3-
//! The `socket` module deals with *network endpoints* and *buffering*.
4-
//! It provides interfaces for accessing buffers of data, and protocol state machines
5-
//! for filling and emptying these buffers.
6-
//!
7-
//! The programming interface implemented here differs greatly from the common Berkeley socket
8-
//! interface. Specifically, in the Berkeley interface the buffering is implicit:
9-
//! the operating system decides on the good size for a buffer and manages it.
10-
//! The interface implemented by this module uses explicit buffering: you decide on the good
11-
//! size for a buffer, allocate it, and let the networking stack use it.
1+
/*! Communication between endpoints.
2+
3+
The `socket` module deals with *network endpoints* and *buffering*.
4+
It provides interfaces for accessing buffers of data, and protocol state machines
5+
for filling and emptying these buffers.
6+
7+
The programming interface implemented here differs greatly from the common Berkeley socket
8+
interface. Specifically, in the Berkeley interface the buffering is implicit:
9+
the operating system decides on the good size for a buffer and manages it.
10+
The interface implemented by this module uses explicit buffering: you decide on the good
11+
size for a buffer, allocate it, and let the networking stack use it.
12+
*/
1213

1314
use core::marker::PhantomData;
1415

src/socket/tcp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ use storage::{Assembler, RingBuffer};
1313
/// A TCP socket ring buffer.
1414
pub type SocketBuffer<'a> = RingBuffer<'a, u8>;
1515

16-
/// The state of a TCP socket, according to [RFC 793][rfc793].
17-
/// [rfc793]: https://tools.ietf.org/html/rfc793
16+
/// The state of a TCP socket, according to [RFC 793].
17+
///
18+
/// [RFC 793]: https://tools.ietf.org/html/rfc793
1819
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
1920
pub enum State {
2021
Closed,

src/storage/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
//! Specialized containers.
2-
//!
3-
//! The `storage` module provides containers for use in other modules.
4-
//! The containers support both pre-allocated memory, without the `std`
5-
//! or `alloc` crates being available, and heap-allocated memory.
1+
/*! Specialized containers.
2+
3+
The `storage` module provides containers for use in other modules.
4+
The containers support both pre-allocated memory, without the `std`
5+
or `alloc` crates being available, and heap-allocated memory.
6+
*/
67

78
mod assembler;
89
mod ring_buffer;

src/wire/mod.rs

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,47 @@
1-
//! Low-level packet access and construction.
2-
//!
3-
//! The `wire` module deals with the packet *representation*. It provides two levels
4-
//! of functionality.
5-
//!
6-
//! * First, it provides functions to extract fields from sequences of octets,
7-
//! and to insert fields into sequences of octets. This happens `Packet` family of
8-
//! structures, e.g. [EthernetFrame] or [Ipv4Packet].
9-
//! * Second, in cases where the space of valid field values is much smaller than the space
10-
//! of possible field values, it provides a compact, high-level representation
11-
//! of packet data that can be parsed from and emitted into a sequence of octets.
12-
//! This happens through the `Repr` family of structs and enums, e.g. [ArpRepr] or [Ipv4Repr].
13-
// https://github.com/rust-lang/rust/issues/38739
14-
//! </ul>
15-
//!
16-
//! [EthernetFrame]: struct.EthernetFrame.html
17-
//! [Ipv4Packet]: struct.Ipv4Packet.html
18-
//! [ArpRepr]: enum.ArpRepr.html
19-
//! [Ipv4Repr]: struct.Ipv4Repr.html
20-
//!
21-
//! The functions in the `wire` module are designed for use together with `-Cpanic=abort`.
22-
//!
23-
//! The `Packet` family of data structures guarantees that, if the `Packet::check_len()` method
24-
//! returned `Ok(())`, then no accessor or setter method will panic; however, the guarantee
25-
//! provided by `Packet::check_len()` may no longer hold after changing certain fields,
26-
//! which are listed in the documentation for the specific packet.
27-
//!
28-
//! The `Packet::new_checked` method is a shorthand for a combination of `Packet::new` and
29-
//! `Packet::check_len`.
30-
//! When parsing untrusted input, it is *necessary* to use `Packet::new_checked()`;
31-
//! so long as the buffer is not modified, no accessor will fail.
32-
//! When emitting output, though, it is *incorrect* to use `Packet::new_checked()`;
33-
//! the length check is likely to succeed on a zeroed buffer, but fail on a buffer
34-
//! filled with data from a previous packet, such as when reusing buffers, resulting
35-
//! in nondeterministic panics with some network devices but not others.
36-
//! The buffer length for emission is not calculated by the `Packet` layer.
37-
//!
38-
//! In the `Repr` family of data structures, the `Repr::parse()` method never panics
39-
//! as long as `Packet::new_checked()` (or `Packet::check_len()`) has succeeded, and
40-
//! the `Repr::emit()` method never panics as long as the underlying buffer is exactly
41-
//! `Repr::buffer_len()` octets long.
42-
//!
43-
//! # Examples
44-
//!
45-
//! To emit an IP packet header into an octet buffer, and then parse it back:
46-
//!
47-
/*!
1+
/*! Low-level packet access and construction.
2+
3+
The `wire` module deals with the packet *representation*. It provides two levels
4+
of functionality.
5+
6+
* First, it provides functions to extract fields from sequences of octets,
7+
and to insert fields into sequences of octets. This happens `Packet` family of
8+
structures, e.g. [EthernetFrame] or [Ipv4Packet].
9+
* Second, in cases where the space of valid field values is much smaller than the space
10+
of possible field values, it provides a compact, high-level representation
11+
of packet data that can be parsed from and emitted into a sequence of octets.
12+
This happens through the `Repr` family of structs and enums, e.g. [ArpRepr] or [Ipv4Repr].
13+
14+
[EthernetFrame]: struct.EthernetFrame.html
15+
[Ipv4Packet]: struct.Ipv4Packet.html
16+
[ArpRepr]: enum.ArpRepr.html
17+
[Ipv4Repr]: struct.Ipv4Repr.html
18+
19+
The functions in the `wire` module are designed for use together with `-Cpanic=abort`.
20+
21+
The `Packet` family of data structures guarantees that, if the `Packet::check_len()` method
22+
returned `Ok(())`, then no accessor or setter method will panic; however, the guarantee
23+
provided by `Packet::check_len()` may no longer hold after changing certain fields,
24+
which are listed in the documentation for the specific packet.
25+
26+
The `Packet::new_checked` method is a shorthand for a combination of `Packet::new` and
27+
`Packet::check_len`.
28+
When parsing untrusted input, it is *necessary* to use `Packet::new_checked()`;
29+
so long as the buffer is not modified, no accessor will fail.
30+
When emitting output, though, it is *incorrect* to use `Packet::new_checked()`;
31+
the length check is likely to succeed on a zeroed buffer, but fail on a buffer
32+
filled with data from a previous packet, such as when reusing buffers, resulting
33+
in nondeterministic panics with some network devices but not others.
34+
The buffer length for emission is not calculated by the `Packet` layer.
35+
36+
In the `Repr` family of data structures, the `Repr::parse()` method never panics
37+
as long as `Packet::new_checked()` (or `Packet::check_len()`) has succeeded, and
38+
the `Repr::emit()` method never panics as long as the underlying buffer is exactly
39+
`Repr::buffer_len()` octets long.
40+
41+
# Examples
42+
43+
To emit an IP packet header into an octet buffer, and then parse it back:
44+
4845
```rust
4946
# #[cfg(feature = "proto-ipv4")]
5047
# {

src/wire/pretty_print.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
//! Pretty-printing of packet representation.
2-
//!
3-
//! The `pretty_print` module provides bits and pieces for printing concise,
4-
//! easily human readable packet listings.
5-
//!
6-
//! # Example
7-
//!
8-
//! A packet can be formatted using the `PrettyPrinter` wrapper:
9-
//!
10-
/*!
1+
/*! Pretty-printing of packet representation.
2+
3+
The `pretty_print` module provides bits and pieces for printing concise,
4+
easily human readable packet listings.
5+
6+
# Example
7+
8+
A packet can be formatted using the `PrettyPrinter` wrapper:
9+
1110
```rust
1211
use smoltcp::wire::*;
1312
let buffer = vec![

0 commit comments

Comments
 (0)