Skip to content

Commit 4644fa4

Browse files
authored
run doc test in parallel (#387)
1 parent 98c37fe commit 4644fa4

File tree

3 files changed

+68
-44
lines changed

3 files changed

+68
-44
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
[alias]
22
chk = "check --workspace --all-features --tests --examples --bins"
33
lint = "clippy --workspace --all-features --tests --examples --bins -- -Dclippy::todo"
4+
ci-test = "test --workspace --all-features --lib --tests --no-fail-fast -- --nocapture"
5+
ci-doctest = "test --workspace --all-features --doc --no-fail-fast -- --nocapture"

.github/workflows/ci.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ jobs:
104104
- name: tests
105105
if: matrix.target.triple != 'x86_64-pc-windows-gnu'
106106
uses: actions-rs/cargo@v1
107-
with:
108-
command: test
109-
args: --workspace --all-features --no-fail-fast -- --nocapture
107+
with: { command: ci-test }
110108

111109
- name: Generate coverage file
112110
if: >
@@ -129,3 +127,34 @@ jobs:
129127
run: |
130128
cargo install cargo-cache --version 0.6.2 --no-default-features --features ci-autoclean
131129
cargo-cache
130+
131+
rustdoc:
132+
name: rustdoc
133+
runs-on: ubuntu-latest
134+
135+
steps:
136+
- uses: actions/checkout@v2
137+
138+
- name: Install Rust (nightly)
139+
uses: actions-rs/toolchain@v1
140+
with:
141+
toolchain: nightly-x86_64-unknown-linux-gnu
142+
profile: minimal
143+
override: true
144+
145+
- name: Generate Cargo.lock
146+
uses: actions-rs/cargo@v1
147+
with: { command: generate-lockfile }
148+
- name: Cache Dependencies
149+
uses: Swatinem/[email protected]
150+
151+
- name: Install cargo-hack
152+
uses: actions-rs/cargo@v1
153+
with:
154+
command: install
155+
args: cargo-hack
156+
157+
- name: doc tests
158+
uses: actions-rs/cargo@v1
159+
timeout-minutes: 40
160+
with: { command: ci-doctest }

actix-codec/src/framed.rs

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ bitflags::bitflags! {
2121
}
2222

2323
pin_project_lite::pin_project! {
24-
/// A unified `Stream` and `Sink` interface to an underlying I/O object, using
25-
/// the `Encoder` and `Decoder` traits to encode and decode frames.
24+
/// A unified `Stream` and `Sink` interface to an underlying I/O object, using the `Encoder` and
25+
/// `Decoder` traits to encode and decode frames.
2626
///
27-
/// Raw I/O objects work with byte sequences, but higher-level code usually
28-
/// wants to batch these into meaningful chunks, called "frames". This
29-
/// method layers framing on top of an I/O object, by using the `Encoder`/`Decoder`
30-
/// traits to handle encoding and decoding of message frames. Note that
31-
/// the incoming and outgoing frame types may be distinct.
27+
/// Raw I/O objects work with byte sequences, but higher-level code usually wants to batch these
28+
/// into meaningful chunks, called "frames". This method layers framing on top of an I/O object,
29+
/// by using the `Encoder`/`Decoder` traits to handle encoding and decoding of message frames.
30+
/// Note that the incoming and outgoing frame types may be distinct.
3231
pub struct Framed<T, U> {
3332
#[pin]
3433
io: T,
@@ -44,10 +43,9 @@ where
4443
T: AsyncRead + AsyncWrite,
4544
U: Decoder,
4645
{
47-
/// This function returns a *single* object that is both `Stream` and
48-
/// `Sink`; grouping this into a single object is often useful for layering
49-
/// things like gzip or TLS, which require both read and write access to the
50-
/// underlying object.
46+
/// This function returns a *single* object that is both `Stream` and `Sink`; grouping this into
47+
/// a single object is often useful for layering things like gzip or TLS, which require both
48+
/// read and write access to the underlying object.
5149
pub fn new(io: T, codec: U) -> Framed<T, U> {
5250
Framed {
5351
io,
@@ -70,21 +68,18 @@ impl<T, U> Framed<T, U> {
7068
&mut self.codec
7169
}
7270

73-
/// Returns a reference to the underlying I/O stream wrapped by
74-
/// `Frame`.
71+
/// Returns a reference to the underlying I/O stream wrapped by `Frame`.
7572
///
76-
/// Note that care should be taken to not tamper with the underlying stream
77-
/// of data coming in as it may corrupt the stream of frames otherwise
78-
/// being worked with.
73+
/// Note that care should be taken to not tamper with the underlying stream of data coming in as
74+
/// it may corrupt the stream of frames otherwise being worked with.
7975
pub fn io_ref(&self) -> &T {
8076
&self.io
8177
}
8278

8379
/// Returns a mutable reference to the underlying I/O stream.
8480
///
85-
/// Note that care should be taken to not tamper with the underlying stream
86-
/// of data coming in as it may corrupt the stream of frames otherwise
87-
/// being worked with.
81+
/// Note that care should be taken to not tamper with the underlying stream of data coming in as
82+
/// it may corrupt the stream of frames otherwise being worked with.
8883
pub fn io_mut(&mut self) -> &mut T {
8984
&mut self.io
9085
}
@@ -184,10 +179,9 @@ impl<T, U> Framed<T, U> {
184179
{
185180
loop {
186181
let mut this = self.as_mut().project();
187-
// Repeatedly call `decode` or `decode_eof` as long as it is
188-
// "readable". Readable is defined as not having returned `None`. If
189-
// the upstream has returned EOF, and the decoder is no longer
190-
// readable, it can be assumed that the decoder will never become
182+
// Repeatedly call `decode` or `decode_eof` as long as it is "readable". Readable is
183+
// defined as not having returned `None`. If the upstream has returned EOF, and the
184+
// decoder is no longer readable, it can be assumed that the decoder will never become
191185
// readable again, at which point the stream is terminated.
192186

193187
if this.flags.contains(Flags::READABLE) {
@@ -215,7 +209,7 @@ impl<T, U> Framed<T, U> {
215209

216210
debug_assert!(!this.flags.contains(Flags::EOF));
217211

218-
// Otherwise, try to read more data and try again. Make sure we've got room
212+
// Otherwise, try to read more data and try again. Make sure we've got room.
219213
let remaining = this.read_buf.capacity() - this.read_buf.len();
220214
if remaining < LW {
221215
this.read_buf.reserve(HW - remaining)
@@ -341,13 +335,12 @@ where
341335
}
342336

343337
impl<T, U> Framed<T, U> {
344-
/// This function returns a *single* object that is both `Stream` and
345-
/// `Sink`; grouping this into a single object is often useful for layering
346-
/// things like gzip or TLS, which require both read and write access to the
347-
/// underlying object.
338+
/// This function returns a *single* object that is both `Stream` and `Sink`; grouping this into
339+
/// a single object is often useful for layering things like gzip or TLS, which require both
340+
/// read and write access to the underlying object.
348341
///
349-
/// These objects take a stream, a read buffer and a write buffer. These
350-
/// fields can be obtained from an existing `Framed` with the `into_parts` method.
342+
/// These objects take a stream, a read buffer and a write buffer. These fields can be obtained
343+
/// from an existing `Framed` with the `into_parts` method.
351344
pub fn from_parts(parts: FramedParts<T, U>) -> Framed<T, U> {
352345
Framed {
353346
io: parts.io,
@@ -358,12 +351,11 @@ impl<T, U> Framed<T, U> {
358351
}
359352
}
360353

361-
/// Consumes the `Frame`, returning its underlying I/O stream, the buffer
362-
/// with unprocessed data, and the codec.
354+
/// Consumes the `Frame`, returning its underlying I/O stream, the buffer with unprocessed data,
355+
/// and the codec.
363356
///
364-
/// Note that care should be taken to not tamper with the underlying stream
365-
/// of data coming in as it may corrupt the stream of frames otherwise
366-
/// being worked with.
357+
/// Note that care should be taken to not tamper with the underlying stream of data coming in as
358+
/// it may corrupt the stream of frames otherwise being worked with.
367359
pub fn into_parts(self) -> FramedParts<T, U> {
368360
FramedParts {
369361
io: self.io,
@@ -376,14 +368,15 @@ impl<T, U> Framed<T, U> {
376368
}
377369

378370
/// `FramedParts` contains an export of the data of a Framed transport.
379-
/// It can be used to construct a new `Framed` with a different codec.
380-
/// It contains all current buffers and the inner transport.
371+
///
372+
/// It can be used to construct a new `Framed` with a different codec. It contains all current
373+
/// buffers and the inner transport.
381374
#[derive(Debug)]
382375
pub struct FramedParts<T, U> {
383-
/// The inner transport used to read bytes to and write bytes to
376+
/// The inner transport used to read bytes to and write bytes to.
384377
pub io: T,
385378

386-
/// The codec
379+
/// The codec object.
387380
pub codec: U,
388381

389382
/// The buffer with read but unprocessed data.
@@ -396,7 +389,7 @@ pub struct FramedParts<T, U> {
396389
}
397390

398391
impl<T, U> FramedParts<T, U> {
399-
/// Create a new, default, `FramedParts`
392+
/// Creates a new default `FramedParts`.
400393
pub fn new(io: T, codec: U) -> FramedParts<T, U> {
401394
FramedParts {
402395
io,
@@ -407,7 +400,7 @@ impl<T, U> FramedParts<T, U> {
407400
}
408401
}
409402

410-
/// Create a new `FramedParts` with read buffer
403+
/// Creates a new `FramedParts` with read buffer.
411404
pub fn with_read_buf(io: T, codec: U, read_buf: BytesMut) -> FramedParts<T, U> {
412405
FramedParts {
413406
io,

0 commit comments

Comments
 (0)