Skip to content

Commit bbd9433

Browse files
authored
Merge pull request #31 from swimos/docs
Cancellation safety documentation
2 parents 7c3a23c + eec2d62 commit bbd9433

File tree

10 files changed

+216
-116
lines changed

10 files changed

+216
-116
lines changed

.github/workflows/ci.yml

+52-72
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ on:
66
name: Continuous integration
77

88
jobs:
9-
check:
10-
name: Check
9+
docs:
10+
name: Documentation
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14-
- uses: actions-rs/toolchain@v1
14+
- name: Install Rust
15+
uses: dtolnay/rust-toolchain@stable
1516
with:
16-
profile: minimal
1717
toolchain: 1.65
18-
override: true
19-
- uses: actions-rs/cargo@v1
20-
with:
21-
command: check
18+
- uses: Swatinem/rust-cache@v2
19+
- name: Build Documentation
20+
run: cargo doc --lib --no-deps --all-features --workspace
21+
env:
22+
RUSTDOCFLAGS: --cfg docsrs -Dwarnings
2223

2324
testmsrv:
2425
name: Test Suite Latest
@@ -31,15 +32,13 @@ jobs:
3132
- macos-latest
3233
steps:
3334
- uses: actions/checkout@v2
34-
- uses: actions-rs/toolchain@v1
35+
- name: Install Rust
36+
uses: dtolnay/rust-toolchain@stable
3537
with:
36-
profile: minimal
3738
toolchain: 1.78.0
38-
override: true
39-
- uses: actions-rs/cargo@v1
40-
with:
41-
command: test
42-
args: --all-features --all-targets --workspace
39+
- uses: Swatinem/rust-cache@v2
40+
- name: Test
41+
run: cargo test --all-features --all-targets --workspace
4342

4443
testlatest:
4544
name: Test Suite MSRV
@@ -52,104 +51,85 @@ jobs:
5251
- macos-latest
5352
steps:
5453
- uses: actions/checkout@v2
55-
- uses: actions-rs/toolchain@v1
54+
- name: Install Rust
55+
uses: dtolnay/rust-toolchain@stable
5656
with:
57-
profile: minimal
5857
toolchain: 1.65
59-
override: true
60-
- uses: actions-rs/cargo@v1
61-
with:
62-
command: test
63-
args: --all-features --all-targets --workspace
58+
- uses: Swatinem/rust-cache@v2
59+
- name: Test
60+
run: cargo test --all-features --all-targets --workspace
6461

6562
fmt:
6663
name: Rustfmt
6764
runs-on: ubuntu-latest
6865
steps:
6966
- uses: actions/checkout@v2
70-
- uses: actions-rs/toolchain@v1
67+
- name: Install Rust
68+
uses: dtolnay/rust-toolchain@stable
7169
with:
72-
profile: minimal
7370
toolchain: 1.65
74-
override: true
75-
- run: rustup component add rustfmt
76-
- uses: actions-rs/cargo@v1
77-
with:
78-
command: fmt
79-
args: --all -- --check
71+
components: rustfmt
72+
- uses: Swatinem/rust-cache@v2
73+
- run: cargo fmt --all -- --check
8074

8175
clippy:
8276
name: Clippy
8377
runs-on: ubuntu-latest
8478
steps:
8579
- uses: actions/checkout@v2
86-
- uses: actions-rs/toolchain@v1
87-
with:
88-
profile: minimal
89-
toolchain: 1.65
90-
override: true
91-
- run: rustup component add clippy
92-
- uses: actions-rs/cargo@v1
93-
with:
94-
command: clippy
95-
args: --all-features --workspace -- -D warnings
80+
- name: Install Rust
81+
uses: dtolnay/rust-toolchain@stable
82+
with:
83+
# Not the same as the MSRV as an ICE is thrown
84+
toolchain: 1.66.0
85+
components: clippy
86+
- uses: Swatinem/rust-cache@v2
87+
- run: cargo clippy --all-features --all-targets --workspace -- -D warnings
9688

9789
autobahnclient:
9890
name: Autobahn Client
9991
runs-on: ubuntu-latest
10092
steps:
10193
- uses: actions/checkout@v2
102-
- uses: actions-rs/toolchain@v1
94+
- name: Install Rust
95+
uses: dtolnay/rust-toolchain@stable
10396
with:
104-
profile: minimal
105-
toolchain: 1.65
106-
override: true
107-
- uses: actions-rs/cargo@v1
108-
with:
109-
command: run
110-
args: --bin client --release
97+
toolchain: 1.65.0
98+
- uses: Swatinem/rust-cache@v2
99+
- run: cargo run --bin client --release
111100

112101
autobahnserver:
113102
name: Autobahn Server
114103
runs-on: ubuntu-latest
115104
steps:
116105
- uses: actions/checkout@v2
117-
- uses: actions-rs/toolchain@v1
118-
with:
119-
profile: minimal
120-
toolchain: 1.65
121-
override: true
122-
- uses: actions-rs/cargo@v1
106+
- name: Install Rust
107+
uses: dtolnay/rust-toolchain@stable
123108
with:
124-
command: run
125-
args: --bin server --release
109+
toolchain: 1.65.0
110+
- uses: Swatinem/rust-cache@v2
111+
- run: cargo run --bin server --release
126112

127113
autobahnclientsplit:
128114
name: Autobahn Client Split Socket
129115
runs-on: ubuntu-latest
130116
steps:
131117
- uses: actions/checkout@v2
132-
- uses: actions-rs/toolchain@v1
118+
- name: Install Rust
119+
uses: dtolnay/rust-toolchain@stable
133120
with:
134-
profile: minimal
135-
toolchain: 1.65
136-
override: true
137-
- uses: actions-rs/cargo@v1
138-
with:
139-
command: run
140-
args: --bin split_client --release
121+
toolchain: 1.65.0
122+
- uses: Swatinem/rust-cache@v2
123+
- run: cargo run --bin split_client --release
141124

142125
autobahnserversplit:
143126
name: Autobahn Server Split Socket
144127
runs-on: ubuntu-latest
145128
steps:
146129
- uses: actions/checkout@v2
147-
- uses: actions-rs/toolchain@v1
148-
with:
149-
profile: minimal
150-
toolchain: 1.65
151-
override: true
152-
- uses: actions-rs/cargo@v1
130+
- name: Install Rust
131+
uses: dtolnay/rust-toolchain@stable
153132
with:
154-
command: run
155-
args: --bin split_server --release
133+
toolchain: 1.65.0
134+
- uses: Swatinem/rust-cache@v2
135+
- run: cargo run --bin split_server --release

ratchet_core/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ratchet_core"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
authors = ["Swim Inc. developers [email protected]"]
55
edition = "2021"
66
description = "Async WebSocket implementation"
@@ -16,7 +16,7 @@ split = ["futures"]
1616
fixture = []
1717

1818
[dependencies]
19-
ratchet_ext = { version = "1.0.0", path = "../ratchet_ext" }
19+
ratchet_ext = { version = "1.0.1", path = "../ratchet_ext" }
2020
url = { workspace = true }
2121
http = { workspace = true }
2222
tokio = { workspace = true, features = ["rt", "net", "io-util"] }

ratchet_core/src/framed/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ where
200200

201201
#[tokio::test]
202202
async fn ping() {
203-
let buffer = BytesMut::from_iter(&[137, 4, 1, 2, 3, 4]);
203+
let buffer = BytesMut::from_iter([137, 4, 1, 2, 3, 4]);
204204
let mut framed = FramedIo::new(EmptyIo, buffer, Role::Client, usize::MAX, 0);
205205

206206
ok_eq(
@@ -211,7 +211,7 @@ async fn ping() {
211211

212212
#[tokio::test]
213213
async fn pong() {
214-
let buffer = BytesMut::from_iter(&[138, 4, 1, 2, 3, 4]);
214+
let buffer = BytesMut::from_iter([138, 4, 1, 2, 3, 4]);
215215
let mut framed = FramedIo::new(EmptyIo, buffer, Role::Client, usize::MAX, 0);
216216

217217
ok_eq(

ratchet_core/src/protocol/tests.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ mod decode {
163163

164164
#[test]
165165
fn header() {
166-
let bytes = BytesMut::from_iter(&[129, 4, 1, 2, 3, 4]);
166+
let bytes = BytesMut::from_iter([129, 4, 1, 2, 3, 4]);
167167
let (header, _header_len, _payload_len) =
168168
FrameHeader::read_from(&bytes, false, 0, usize::MAX)
169169
.unwrap()
@@ -181,15 +181,15 @@ mod decode {
181181

182182
#[test]
183183
fn rsv() {
184-
let bytes = BytesMut::from_iter(&[161, 4, 1, 2, 3, 4]);
184+
let bytes = BytesMut::from_iter([161, 4, 1, 2, 3, 4]);
185185
let r = FrameHeader::read_from(&bytes, false, 0, usize::MAX);
186186
expect_protocol_error(r, ProtocolError::UnknownExtension);
187187

188-
let bytes = BytesMut::from_iter(&[161, 4, 1, 2, 3, 4]);
188+
let bytes = BytesMut::from_iter([161, 4, 1, 2, 3, 4]);
189189
let r = FrameHeader::read_from(&bytes, false, 1 << 6 & 1 << 4, usize::MAX);
190190
expect_protocol_error(r, ProtocolError::UnknownExtension);
191191

192-
let bytes = BytesMut::from_iter(&[193, 4, 1, 2, 3, 4]);
192+
let bytes = BytesMut::from_iter([193, 4, 1, 2, 3, 4]);
193193
let result = FrameHeader::read_from(&bytes, false, 1 << 6, usize::MAX);
194194

195195
let _expected = FrameHeader {
@@ -202,28 +202,28 @@ mod decode {
202202

203203
#[test]
204204
fn overflow() {
205-
let bytes = BytesMut::from_iter(&[129, 4, 1, 2, 3, 4]);
205+
let bytes = BytesMut::from_iter([129, 4, 1, 2, 3, 4]);
206206
let r = FrameHeader::read_from(&bytes, false, 0, 1);
207207
expect_protocol_error(r, ProtocolError::FrameOverflow);
208208
}
209209

210210
#[test]
211211
fn fragmented_control() {
212-
let bytes = BytesMut::from_iter(&[8, 4, 1, 2, 3, 4]);
212+
let bytes = BytesMut::from_iter([8, 4, 1, 2, 3, 4]);
213213
let r = FrameHeader::read_from(&bytes, false, 0, usize::MAX);
214214
expect_protocol_error(r, ProtocolError::FragmentedControl);
215215
}
216216

217217
#[test]
218218
fn unmasked() {
219-
let bytes = BytesMut::from_iter(&[1, 132, 0, 0, 0, 0, 1, 2, 3, 4]);
219+
let bytes = BytesMut::from_iter([1, 132, 0, 0, 0, 0, 1, 2, 3, 4]);
220220
let r = FrameHeader::read_from(&bytes, false, 0, usize::MAX);
221221
expect_protocol_error(r, ProtocolError::MaskedFrame);
222222
}
223223

224224
#[test]
225225
fn masked_err() {
226-
let bytes = BytesMut::from_iter(&[129, 4, 1, 2, 3, 4]);
226+
let bytes = BytesMut::from_iter([129, 4, 1, 2, 3, 4]);
227227
let r = FrameHeader::read_from(&bytes, true, 0, usize::MAX);
228228
expect_protocol_error(r, ProtocolError::UnmaskedFrame);
229229
}

0 commit comments

Comments
 (0)