Skip to content

Commit d4205e5

Browse files
authored
Merge pull request #1135 from dotnet/mxstream-2
Add Rust MultiplexingStream crate
2 parents 53a9b34 + 86b465f commit d4205e5

15 files changed

Lines changed: 4505 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,27 @@ jobs:
8383
run: corepack pnpm lint
8484
working-directory: src/nerdbank-streams
8585

86+
- name: 🦀 Install Rust 1.85.0
87+
uses: dtolnay/rust-toolchain@1.85.0
88+
with:
89+
components: rustfmt, clippy
90+
- name: 🦀 cargo build
91+
run: cargo build --locked
92+
working-directory: src/nerdbank-streams-rs
93+
- name: 🦀 cargo test
94+
run: cargo test --locked
95+
working-directory: src/nerdbank-streams-rs
96+
- name: 🦀 Verify Rust formatting
97+
run: cargo fmt --check
98+
working-directory: src/nerdbank-streams-rs
99+
- name: 🦀 cargo clippy
100+
run: cargo clippy --locked --all-targets -- -D warnings
101+
working-directory: src/nerdbank-streams-rs
102+
- name: 🦀 Package crate
103+
run: tools/Pack-Cargo.ps1
104+
shell: pwsh
105+
if: runner.os == 'Linux'
106+
86107
- name: 💅🏻 Verify formatted code
87108
run: dotnet format --verify-no-changes --no-restore
88109
shell: pwsh

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
description: Skip publishing NuGet packages
1717
type: boolean
1818
default: false
19+
skip_cargo:
20+
description: Skip publishing Cargo packages
21+
type: boolean
22+
default: false
1923

2024
run-name: ${{ github.ref_name }}
2125

@@ -127,6 +131,29 @@ jobs:
127131
registry-url: https://registry.npmjs.org
128132
package-manager-cache: false # never use caching in release builds
129133

134+
- name: 🦀 Install Rust 1.85.0
135+
uses: dtolnay/rust-toolchain@1.85.0
136+
137+
# The crate must first be manually published and configured for Trusted
138+
# Publishing at crates.io before this OIDC exchange can succeed.
139+
- name: 🪪 Authorize crates.io publishing
140+
if: ${{ !inputs.skip_cargo }}
141+
id: crates-io-auth
142+
uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5
143+
144+
- name: 🚀 Push Cargo package
145+
if: ${{ !inputs.skip_cargo }}
146+
shell: pwsh
147+
env:
148+
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
149+
run: |
150+
$crate = (Get-ChildItem ./deployables -Filter 'nerdbank-streams-*.crate' -Recurse)[0].FullName
151+
$packageDirectory = Join-Path $PWD 'cargo-package'
152+
tar -xzf $crate -C $packageDirectory
153+
$manifest = (Get-ChildItem $packageDirectory -Filter Cargo.toml -Recurse)[0].FullName
154+
cargo publish --manifest-path $manifest --no-verify --token $env:CARGO_REGISTRY_TOKEN
155+
working-directory: ${{ runner.temp }}
156+
130157
- name: 🚀 Push NPM packages
131158
if: ${{ !inputs.skip_npm }}
132159
shell: pwsh

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ MigrationBackup/
356356
# mac-created file to track user view preferences for a directory
357357
.DS_Store
358358

359+
# Rust build and editor artifacts
360+
**/target/
361+
*.rs.bk
362+
.rust-analyzer/
363+
359364
# Analysis results
360365
*.sarif
361366

src/nerdbank-streams-rs/Cargo.lock

Lines changed: 275 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nerdbank-streams-rs/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "nerdbank-streams"
3+
# This placeholder is replaced in the staging copy by tools/Pack-Cargo.ps1
4+
# using Nerdbank.GitVersioning, before invoking `cargo package`.
5+
version = "0.0.0-placeholder"
6+
edition = "2021"
7+
rust-version = "1.85"
8+
description = "Tokio implementation of the Nerdbank.Streams multiplexing protocol"
9+
license = "MIT"
10+
repository = "https://github.com/AArnott/Nerdbank.Streams"
11+
homepage = "https://github.com/AArnott/Nerdbank.Streams"
12+
documentation = "https://docs.rs/nerdbank-streams"
13+
readme = "README.md"
14+
keywords = ["tokio", "multiplexing", "streams", "async"]
15+
categories = ["asynchronous", "network-programming"]
16+
authors = ["Andrew Arnott"]
17+
include = ["Cargo.toml", "Cargo.lock", "README.md", "LICENSE", "src/**"]
18+
19+
[dependencies]
20+
rand = "0.9"
21+
rmp = "0.8"
22+
tokio = { version = "1.48", features = ["io-util", "macros", "rt", "sync"] }
23+
24+
[dev-dependencies]
25+
tokio = { version = "1.48", features = ["io-util", "macros", "rt-multi-thread", "process", "time"] }
26+
27+
[lints.rust]
28+
unsafe_code = "forbid"
29+
missing_docs = "warn"
30+
31+
[lints.clippy]
32+
all = "warn"

0 commit comments

Comments
 (0)