Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit b5ba683

Browse files
authored
v0.10.0 (#48)
Draft pull request for release v0.10.0 to receive status and coverage information through GH Actions. Closes #44 and #45 # Release v0.10 The tenth release of the polyproto crate is the biggest one yet. It touches almost all areas of the source code and brings numerous improvements, bug fixes and additions. Most notably, v0.10 has been updated to be almost fully compliant with Beta 1 of the polyproto specification! All the API routes, types and the most important behaviors are there and available for you to tinker and prototype with! Some more advanced features are missing, though. Notably, v0.10 lacks `zstd` WebSocket compression support and advanced migrations features, such as performing and verifying migrations out of the box. Developers and tinkerers can add this functionality themselves, as all the needed "parts" for it exist (API routes, verification behaviors, etc.)—there just isn't one, simple function you can call yet. Things like these are planned for the v0.11 and v0.12 releases. ## Gateway This version ships polyproto WebSocket gateway client functionality, gated behind the `gateway` crate feature. The implementation of this feature is super backend-agnostic—though, for now, we have sealed the needed traits, and are only shipping a `tokio-tungstenite` backend for testing. The gateway handles establishing a connection to the server, sending regular heartbeats at the specified interval and responding to Opcode 11—the manual heartbeat request. Apart from the `Hello` payload, library consumers can easily get access to all messages received from the gateway by calling `subscribe()` on the internal `tokio::sync::watch::Sender<GatewayMessage>`. This means that this crate handles only the bare necessities of connecting to the gateway, and that you are free to handle incoming messages however you would like to. Our `GatewayMessage` type is `.into()` and `From::<>`-compatible with `tokio_tungstenite::tungstenite::Message`, so that you are not locked into using our types, should you not want that.
2 parents 8473b12 + 5c1a18d commit b5ba683

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+6409
-1333
lines changed

.github/license-check/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"include": ["**/*.rs"],
4+
"license": "./.github/license-check/header-mpl-2.0.txt",
5+
"exclude": ["target/**", "**/"]
6+
},
7+
{
8+
"include": ["target/**", "**/**"]
9+
}
10+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

.github/workflows/build_and_test.yml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,13 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v4
18+
- name: Install rust toolchain 1.85.1
19+
uses: dtolnay/rust-toolchain@1.85.1
1820
- uses: Swatinem/rust-cache@v2
1921
with:
2022
cache-all-crates: "true"
2123
prefix-key: "linux"
2224
- uses: taiki-e/install-action@nextest
2325
- name: nextest run
2426
run: |
25-
cargo nextest run --verbose --all-features --tests --examples
26-
27-
# wasm:
28-
# runs-on: ubuntu-latest
29-
# steps:
30-
# - uses: actions/checkout@v4
31-
# - uses: Swatinem/rust-cache@v2
32-
# with:
33-
# cache-all-crates: "true"
34-
# prefix-key: "macos"
35-
# - name: Run WASM tests with Safari, Firefox, Chrome
36-
# run: |
37-
# rustup target add wasm32-unknown-unknown
38-
# curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
39-
# cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.88" --force
40-
# cargo binstall --no-confirm wasm-pack --force
41-
# wasm-pack test --node -- --features wasm --examples
42-
# wasm-pack test --firefox -- --features wasm --examples
43-
# wasm-pack test --chrome -- --features wasm --examples
44-
# wasm-pack test --node -- --features wasm
45-
# wasm-pack test --firefox -- --features wasm
46-
# wasm-pack test --chrome -- --features wasm
27+
cargo nextest run --features="types,reqwest,gateway" --failure-output final --no-fail-fast

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
if [ -n "${{ secrets.COVERALLS_REPO_TOKEN }}" ]; then
2424
curl -L --proto '=https' --tlsv1.3 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
2525
cargo binstall --no-confirm cargo-tarpaulin --force
26-
cargo tarpaulin --all-features --tests --verbose --skip-clean --coveralls ${{ secrets.COVERALLS_REPO_TOKEN }} --timeout 120
26+
cargo tarpaulin --features="gateway, reqwest, serde, types" --tests --verbose --skip-clean --coveralls ${{ secrets.COVERALLS_REPO_TOKEN }} --timeout 120 --fail-immediately
2727
else
2828
echo "Code Coverage step is skipped on PRs from forks."
2929
fi
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: License Header Check
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
check-license-headers:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v4
11+
12+
- name: Check license headers
13+
uses: viperproject/check-license-header@v2
14+
with:
15+
path: .
16+
config: ./.github/license-check/config.json
17+
strict: true

.github/workflows/wasm.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build and Test (wasm32)
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["*"]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
wasm:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 15
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install rust toolchain 1.85.1
19+
uses: dtolnay/rust-toolchain@1.85.1
20+
- uses: Swatinem/rust-cache@v2
21+
with:
22+
cache-all-crates: "true"
23+
prefix-key: "wasm"
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: "lts/*"
27+
check-latest: true
28+
- name: Compile wasm
29+
run: |
30+
rustup target add wasm32-unknown-unknown
31+
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
32+
cargo binstall --no-confirm wasm-pack --force
33+
wasm-pack build --features=wasm,serde,types --no-default-features
34+
wasm-pack build --features=wasm,types --no-default-features
35+
wasm-pack build --features=wasm --no-default-features

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
cert.csr
88
cert.der
99
/firedbg
10-
.vscode/ltex.*
10+
.vscode/ltex.*
11+
pkg/
12+
wasm-pack.log

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
{
22
"markiscodecoverage.searchCriteria": ".coverage/lcov*.info",
3+
// --- Toggle the below setting using line comments to enable/disable working with wasm platforms ---
34
"rust-analyzer.cargo.features": ["types", "reqwest", "gateway", "serde"]
5+
// --- Toggle the below settings using line comments to enable/disable working with wasm platforms ---
6+
// "rust-analyzer.cargo.features": [
7+
// "_wasm_bindgen",
8+
// "wasm",
9+
// "types",
10+
// "reqwest",
11+
// "gateway",
12+
// "serde"
13+
// ],
14+
// "rust-analyzer.cargo.noDefaultFeatures": true,
15+
// "rust-analyzer.cargo.target": "wasm32-unknown-unknown"
416
}

Cargo.toml

Lines changed: 65 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,97 @@
11
[package]
22
name = "polyproto"
3-
version = "0.9.0"
4-
edition = "2021"
3+
version = "0.10.0"
4+
edition = "2024"
55
license = "MPL-2.0"
66
description = "(Generic) Rust types and traits to quickly get a polyproto implementation up and running"
77
repository = "https://github.com/polyphony-chat/polyproto"
8-
rust-version = "1.71.1"
8+
rust-version = "1.85.0"
99

1010
[lib]
11-
crate-type = ["rlib", "cdylib", "staticlib"]
11+
crate-type = ["cdylib", "rlib"]
1212

1313
[features]
14-
default = ["types"]
15-
wasm = ["getrandom", "getrandom/js"]
14+
default = ["types", "serde", "gateway", "tokio/net"]
15+
wasm = ["getrandom", "getrandom/js", "dep:ws_stream_wasm"]
1616
getrandom = ["dep:getrandom"]
1717
types = ["dep:http"]
18-
reqwest = ["dep:reqwest", "types", "serde", "dep:url"]
19-
serde = [
20-
"dep:serde",
21-
"dep:serde_json",
22-
"dep:url",
23-
"url/serde",
24-
"dep:serde_with",
25-
]
18+
reqwest = ["dep:reqwest", "types", "serde"]
19+
serde = ["dep:serde", "serde_json", "serde_with", "url/serde"]
20+
serde_with = ["dep:serde_with"]
21+
serde_json = ["dep:serde_json"]
2622
gateway = ["serde", "types"]
23+
_wasm_bindgen = ["wasm", "dep:wasm-bindgen", "dep:js-sys", "dep:wee_alloc"]
24+
__no_wee_alloc = []
2725

2826
[dependencies]
2927
der = { version = "0.7.9", features = ["pem"] }
3028
getrandom = { version = "0.2.15", optional = true }
3129
regex = "1.11.1"
32-
reqwest = { version = "0.12.12", features = ["json", "zstd"], optional = true }
33-
serde = { version = "1.0.217", optional = true, features = ["derive"] }
34-
serde_json = { version = "1.0.137", optional = true }
30+
reqwest = { version = "0.12.15", features = [
31+
"json",
32+
"zstd",
33+
"rustls-tls-webpki-roots",
34+
"charset",
35+
"http2",
36+
"macos-system-configuration",
37+
"multipart",
38+
], optional = true, default-features = false }
39+
serde = { version = "1.0.219", optional = true, features = ["derive"] }
40+
serde_json = { version = "1.0.140", optional = true }
3541
spki = { version = "0.7.3", features = ["pem"] }
36-
thiserror = "2.0.11"
42+
thiserror = "2.0.12"
3743
x509-cert = "0.2.5"
38-
log = "0.4.25"
39-
url = { version = "2.5.4", optional = true }
40-
http = { version = "1.2.0", optional = true }
44+
log = "0.4.27"
45+
url = { version = "2.5.4" }
46+
http = { version = "1.3.1", optional = true }
4147
serde_with = { version = "3.12.0", optional = true }
48+
hex = "0.4.3"
49+
tokio = { version = "1.44.1", features = ["macros", "sync", "time", "rt"] }
50+
webpki-roots = "0.26.8"
51+
futures-util = "0.3.31"
52+
urlencoding = "2.1.3"
53+
ws_stream_wasm = { version = "*", optional = true }
54+
55+
[target.'cfg(target_arch = "wasm32")'.dependencies]
56+
wasm-bindgen = { version = "0.2.100", optional = true }
57+
js-sys = { version = "0.3.77", optional = true }
58+
wee_alloc = { version = "0.4.5", optional = true }
59+
60+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
61+
rustls = "0.23.25"
62+
tokio-tungstenite = { version = "0.26.2", features = [
63+
"rustls-tls-webpki-roots",
64+
"url",
65+
] }
4266

4367
[dev-dependencies]
4468
ed25519-dalek = { version = "2.1.1", features = ["rand_core", "signature"] }
45-
env_logger = "0.11.6"
46-
httptest = "0.16.1"
4769
rand = "0.8.5"
48-
tokio = { version = "1.43.0", features = ["full"] }
49-
serde = { version = "1.0.217", features = ["derive"] }
50-
serde_json = { version = "1.0.137" }
70+
serde = { version = "1.0.219", features = ["derive"] }
71+
serde_json = { version = "1.0.140" }
5172
serde_test = "1.0.177"
5273
polyproto = { path = "./", features = ["types", "reqwest", "serde"] }
74+
env_logger = "0.11.7"
75+
76+
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
77+
ws-mock = "0.3.0"
78+
httptest = "0.16.3"
79+
5380

5481
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
5582
wasm-bindgen-test = "0.3.50"
56-
wasm-bindgen = "0.2.100"
83+
# The `console_error_panic_hook` crate provides better debugging of panics by
84+
# logging them with `console.error`. This is great for development, but requires
85+
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
86+
# code size when deploying.
87+
console_error_panic_hook = { version = "0.1.7" }
88+
89+
[target.'cfg(target_arch = "wasm32")'.release]
90+
# Tell `rustc` to optimize for small code size.
91+
opt-level = "s"
92+
lto = true
93+
codegen-units = 1
94+
panic = "abort"
5795

5896
[lints.rust]
5997
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }

README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ crate.
2626

2727
## Implementing polyproto
2828

29-
Start by implementing the trait [crate::signature::Signature] for a signature algorithm of your
29+
Start by implementing the trait `[crate::signature::Signature]` for a signature algorithm of your
3030
choice. Popular crates for cryptography and signature algorithms supply their own `PublicKey` and
3131
`PrivateKey` types. You should extend upon these types with your own structs and implement the
32-
[crate::key] traits for these new structs.
32+
`[crate::key]` traits for these new structs.
3333

34-
You can then use the [crate::certs] types to build certificates using your implementations of the
34+
You can then use the `[crate::certs]` types to build certificates using your implementations of the
3535
aforementioned traits.
3636

3737
**View the [examples](./examples/)** directory for a simple example on how to implement and use this
@@ -63,6 +63,10 @@ will have to use the `wasm` feature:
6363
polyproto = { version = "0", features = ["wasm"] }
6464
```
6565

66+
Additionally, you will have to compile the project using the `--no-default-features` flag, to ensure
67+
that `tokio/net` is not pulled in as a feature dependency. The `types`, `serde`, `reqwest` and `gateway`
68+
features all work with WASM.
69+
6670
## HTTP API client through `reqwest`
6771

6872
If the `reqwest` feature is activated, this crate offers a polyproto HTTP API client, using the
@@ -75,6 +79,28 @@ the `types` and `serde` features. Using these features, you can implement your o
7579
the polyproto crate acting as a single source of truth for request and response types, as well as
7680
request routes and methods through the exported `static` `Route`s.
7781

82+
## WebSocket Gateway client
83+
84+
Since `v0.10`, this crate ships polyproto WebSocket Gateway client functionality, gated behind the `gateway` feature.
85+
The implementation of this feature is super backend-agnostic—though, for now, we have sealed the needed traits, and are only shipping a `tokio-tungstenite` backend for testing.
86+
87+
The gateway handles establishing a connection to the server, sending regular heartbeats at the specified interval and responding to Opcode 11—the manual heartbeat request.
88+
89+
Apart from the Hello payload, library consumers can easily get access to all messages received from the gateway by calling `subscribe()` on the internal `tokio::sync::watch::Sender<GatewayMessage>`. This means that this crate handles only the bare necessities of connecting to the gateway, and that you are free to handle incoming messages however you would like to. Our `GatewayMessage` type is `.into()` and `From::<>`-compatible with `tokio_tungstenite::tungstenite::Message`, so that you are not locked into using our message types, should you not want that.
90+
91+
## Versioning and MSRV
92+
93+
Semver v2.0 is used for the versioning scheme for this crate.
94+
95+
The default feature set of this crate is used to determine, verify and update the MSRV and semver version
96+
of this crate.
97+
98+
## Logo
99+
100+
The polyproto logo was designed by the wonderful [antidoxi](https://antidoxi.carrd.co/).
101+
The polyproto logos provided in this document are not covered by the MPL-2.0 license covering the rest
102+
of this project.
103+
78104
[dev-status]: https://img.shields.io/static/v1?label=Status&message=Alpha&color=blue
79105
[build-shield]: https://img.shields.io/github/actions/workflow/status/polyphony-chat/polyproto-rs/build_and_test.yml?style=flat
80106
[build-url]: https://github.com/polyphony-chat/polyproto-rs/blob/main/.github/workflows/build_and_test.yml
@@ -85,7 +111,3 @@ request routes and methods through the exported `static` `Route`s.
85111
[crates-link]: https://crates.io/crates/polyproto
86112
[docs]: https://docs.polyphony.chat/Protocol%20Specifications/core/
87113
[overview]: https://docs.polyphony.chat/Overviews/core/
88-
89-
## Logo
90-
91-
The polyproto logo was designed by the wonderful [antidoxi](https://antidoxi.carrd.co/).

0 commit comments

Comments
 (0)