Skip to content

Commit 170a5ee

Browse files
committed
Merge branch 'docs_devguide_2.2' of https://github.com/swimos/swim-rust into docs_devguide_2.3
2 parents 3b264d6 + 18ac469 commit 170a5ee

File tree

662 files changed

+12670
-28151
lines changed

Some content is hidden

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

662 files changed

+12670
-28151
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "cargo"
4+
open-pull-requests-limit: 10
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
# ignore:
9+
# - dependency-name: ""

.github/workflows/ci.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
on:
2+
pull_request:
3+
push:
4+
branches: main
5+
6+
name: Continuous integration
7+
env:
8+
latest_version: "1.78.0"
9+
10+
jobs:
11+
test:
12+
name: Test
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os:
17+
- windows-latest
18+
- ubuntu-latest
19+
- macos-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Install Rust
23+
uses: dtolnay/rust-toolchain@stable
24+
with:
25+
toolchain: ${{ env.latest_version }}
26+
- uses: Swatinem/rust-cache@v2
27+
28+
- name: Install NASM for aws-lc-rs on Windows
29+
if: runner.os == 'Windows'
30+
uses: ilammy/setup-nasm@v1
31+
32+
- name: Install ninja-build tool for aws-lc-fips-sys on Windows
33+
if: runner.os == 'Windows'
34+
uses: seanmiddleditch/gha-setup-ninja@v5
35+
36+
- name: Install golang for aws-lc-fips-sys on macos
37+
if: runner.os == 'MacOS'
38+
uses: actions/setup-go@v5
39+
with:
40+
go-version: "1.22.2"
41+
42+
- run: cargo test --all-features --workspace --lib --tests --profile "ci"
43+
44+
# Check step to ensure that all targets are valid as the test step doesn't run them.
45+
check:
46+
name: Check
47+
runs-on: ${{ matrix.os }}
48+
strategy:
49+
matrix:
50+
os:
51+
- windows-latest
52+
- ubuntu-latest
53+
- macos-latest
54+
steps:
55+
- uses: actions/checkout@v2
56+
- name: Install Rust
57+
uses: dtolnay/rust-toolchain@stable
58+
with:
59+
toolchain: ${{ env.latest_version }}
60+
61+
- name: Install NASM for aws-lc-rs on Windows
62+
if: runner.os == 'Windows'
63+
uses: ilammy/setup-nasm@v1
64+
65+
- name: Install ninja-build tool for aws-lc-fips-sys on Windows
66+
if: runner.os == 'Windows'
67+
uses: seanmiddleditch/gha-setup-ninja@v5
68+
69+
- name: Install golang for aws-lc-fips-sys on macos
70+
if: runner.os == 'MacOS'
71+
uses: actions/setup-go@v5
72+
with:
73+
go-version: "1.22.2"
74+
75+
- uses: Swatinem/rust-cache@v2
76+
- run: cargo check --all-features --all-targets --workspace --lib --tests --profile "ci"
77+
78+
docs:
79+
name: Documentation
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v2
83+
- name: Install Rust
84+
uses: dtolnay/rust-toolchain@stable
85+
with:
86+
toolchain: ${{ env.latest_version }}
87+
- uses: Swatinem/rust-cache@v2
88+
- name: Build Documentation
89+
run: cargo doc --lib --no-deps --all-features --workspace
90+
env:
91+
RUSTDOCFLAGS: --cfg docsrs -Dwarnings
92+
93+
fmt:
94+
name: Rustfmt
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v2
98+
- name: Install Rust
99+
uses: dtolnay/rust-toolchain@stable
100+
with:
101+
toolchain: ${{ env.latest_version }}
102+
components: rustfmt
103+
- uses: Swatinem/rust-cache@v2
104+
- run: cargo fmt --all -- --check
105+
106+
clippy:
107+
name: Clippy
108+
runs-on: ubuntu-latest
109+
steps:
110+
- uses: actions/checkout@v2
111+
- name: Install Rust
112+
uses: dtolnay/rust-toolchain@stable
113+
with:
114+
toolchain: ${{ env.latest_version }}
115+
components: clippy
116+
- uses: Swatinem/rust-cache@v2
117+
- run: cargo clippy --all-features --all-targets --workspace -- -D warnings
118+
119+
code_coverage:
120+
name: Code Coverage
121+
runs-on: ubuntu-latest
122+
container:
123+
image: xd009642/tarpaulin:develop-nightly
124+
options: --security-opt seccomp=unconfined
125+
steps:
126+
- name: Checkout repository
127+
uses: actions/checkout@v2
128+
129+
- name: Install Clang
130+
# Required for rocksdb
131+
run: apt-get update && apt-get install -y llvm llvm-dev clang
132+
133+
- name: Set libclang path
134+
run: echo "LIBCLANG_PATH=$(llvm-config --libdir)" >> $GITHUB_ENV
135+
136+
- name: Generate code coverage
137+
run: |
138+
cargo tarpaulin
139+
140+
- name: Upload to codecov.io
141+
uses: codecov/codecov-action@v4
142+
with:
143+
token: ${{secrets.CODECOV_TOKEN}}
144+
fail_ci_if_error: true

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
!/demos/**/Cargo.lock
99

1010
**/.DS_Store
11-
*.iml
11+
*.iml
12+
13+
# Code coverage files
14+
*.profraw

.tarpaulin.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[coverage]
2+
exclude = [
3+
"example-util",
4+
"console",
5+
"console-views",
6+
"demand-lane",
7+
"demand-map-lane",
8+
"value-lane",
9+
"map-lane",
10+
"command-lane",
11+
"value-store",
12+
"map-store",
13+
"supply-lane",
14+
"value-lane-persistence",
15+
"map-lane-persistence",
16+
"value-store-persistence",
17+
"map-store-persistence",
18+
"event-downlink",
19+
"value-downlink",
20+
"map-downlink",
21+
"local-downlink",
22+
"http-lane",
23+
"transit",
24+
"transit-model",
25+
"tutorial-app",
26+
"tutorial-app-model",
27+
"tutorial-app-generator",
28+
"join_map",
29+
"join_value",
30+
"aggregations",
31+
"time_series",
32+
"swimos_form_derive",
33+
"swimos_agent_derive",
34+
"macro_utilities",
35+
"example_client_2_2",
36+
"example_server_2_2"
37+
]
38+
workspace = true
39+
avoid-cfg-tarpaulin = true
40+
profile = "ci"
41+
ignore-tests = true
42+
out = ["Xml"]
43+
timeout = "600s"
44+
all-features = true

Cargo.toml

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ members = [
77
"api/formats/swimos_*",
88
"macro_utilities",
99
"runtime/swimos_*",
10-
"swimos_store",
1110
"swimos_utilities",
1211
"swimos_utilities/swimos_*",
1312
"swimos_downlink",
@@ -37,6 +36,10 @@ members = [
3736
"example_apps/tutorial_app",
3837
"example_apps/tutorial_app/model",
3938
"example_apps/tutorial_app/generator",
39+
"example_apps/join_map",
40+
"example_apps/join_value",
41+
"example_apps/aggregations",
42+
"example_apps/time_series",
4043
"example_apps/devguide/2_2/*",
4144
"example_apps/devguide/2_3/*",
4245
]
@@ -65,7 +68,7 @@ futures-util = "0.3.25"
6568
parking_lot = "0.12"
6669
pin-project = "1.0.12"
6770
rand = "0.8"
68-
criterion = "0.4"
71+
criterion = "0.5.1"
6972
either = "1.8"
7073
tempdir = "0.3.7"
7174
slab = "0.4"
@@ -77,7 +80,7 @@ nom_locate = "4.0"
7780
tracing = "0.1"
7881
tracing-subscriber = "0.3"
7982
tracing-appender = "0.2"
80-
base64 = "0.13"
83+
base64 = "0.22"
8184
num-traits = "0.2"
8285
thiserror = "1.0"
8386
static_assertions = "1.1.0"
@@ -91,24 +94,40 @@ num-bigint = "0.4"
9194
ratchet = { package = "ratchet_rs", version = "0.4" }
9295
ratchet_fixture = "0.4"
9396
flate2 = "1.0.22"
94-
bitflags = "1.3"
95-
rocksdb = "0.19.0"
96-
integer-encoding = "3.0.4"
97-
rustls = "0.20"
97+
bitflags = "2.5"
98+
rocksdb = "0.22"
99+
integer-encoding = "4.0.0"
100+
rustls = "0.23.10"
98101
webpki = "0.22"
99-
webpki-roots = "0.22"
100-
tokio-rustls = "0.23"
101-
rustls-pemfile = "1.0.0"
102-
trust-dns-resolver = "0.22.0"
102+
webpki-roots = "0.26.3"
103+
tokio-rustls = "0.26"
104+
rustls-pemfile = "2.1.2"
105+
trust-dns-resolver = "0.23.2"
103106
clap = "4.1"
104107
crossbeam-queue = { version = "0.3" }
105108
crossbeam-channel = { version = "0.5" }
106109
hyper = "0.14"
107-
lazy_static = "1.4.0"
108110
percent-encoding = "2.1.0"
109111
mime = "0.3"
110112
serde_json = "1.0"
111113
serde = "1.0"
112-
reqwest = "0.11"
114+
reqwest = "0.12.4"
113115
convert_case = "0.6"
114116
frunk = "0.4"
117+
byteorder = "1.4"
118+
rmp = "0.8"
119+
ryu = "1.0"
120+
regex = "1.3.6"
121+
fnv = "1.0.7"
122+
cursive = { default-features = false, version = "0.20" }
123+
duration-str = "0.11.2"
124+
quick-xml = "0.33.0"
125+
csv = "1.2"
126+
serde-xml-rs = "0.6"
127+
axum = "0.6.20"
128+
hyper-staticfile = "0.9"
129+
httparse = "1.8"
130+
sha-1 = "0.10.1"
131+
waker-fn = "1.1.0"
132+
num = "0.4"
133+
smol_str = "0.2.0"

api/formats/swimos_msgpack/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ either = { workspace = true }
1010
swimos_form = { path = "../../swimos_form" }
1111
swimos_model = { path = "../../swimos_model" }
1212
bytes = { workspace = true }
13-
byteorder = "1.4"
14-
rmp = "0.8"
13+
byteorder = { workspace = true }
14+
rmp = { workspace = true }
15+
num-bigint = { workspace = true }
1516

1617
[dev-dependencies]
1718

api/formats/swimos_msgpack/src/lib.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,43 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
//! MessagePack support for Swim serialization.
16+
//!
17+
//! Provides a MessagesPack backend for the Swim serialization system. This consists of two parts:
18+
//!
19+
//! - A function [`read_from_msg_pack`] that will attempt to deserialize any type that implements
20+
//! [`swimos_form::read::StructuralReadable`] from a buffer containing MessagePack data.
21+
//! - The type [`MsgPackInterpreter`] that implements [`swimos_form::write::StructuralWriter`]
22+
//! allowing any type that implements [`swimos_form::write::StructuralWritable`] to be
23+
//! serialized as MessagePack.
24+
//!
25+
//! # Examples
26+
//!
27+
//! ```
28+
//! use bytes::{BufMut, BytesMut};
29+
//! use swimos_form::write::StructuralWritable;
30+
//! use swimos_msgpack::{read_from_msg_pack, MsgPackInterpreter};
31+
//!
32+
//! let mut buffer = BytesMut::with_capacity(128);
33+
//! let data = vec!["first".to_owned(), "second".to_owned(), "third".to_owned()];
34+
//! let mut writer = (&mut buffer).writer();
35+
//!
36+
//! let interpreter = MsgPackInterpreter::new(&mut writer);
37+
//! assert!(data.write_with(interpreter).is_ok());
38+
//!
39+
//! let mut bytes = buffer.split().freeze();
40+
//! let restored = read_from_msg_pack::<Vec<String>, _>(&mut bytes);
41+
//!
42+
//! assert_eq!(restored, Ok(data));
43+
//! ```
44+
1545
mod reader;
1646
#[cfg(test)]
1747
mod tests;
1848
mod writer;
1949

2050
pub use reader::{read_from_msg_pack, MsgPackReadError};
21-
pub use writer::{MsgPackBodyInterpreter, MsgPackInterpreter, MsgPackWriteError};
51+
pub use writer::{MsgPackInterpreter, MsgPackWriteError};
2252

2353
const BIG_INT_EXT: i8 = 0;
2454
const BIG_UINT_EXT: i8 = 1;

api/formats/swimos_msgpack/src/reader/mod.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ use std::str::Utf8Error;
1919

2020
use bytes::{Buf, BufMut, BytesMut};
2121
use either::Either;
22+
use num_bigint::Sign;
2223
use rmp::decode::{read_str_len, ValueReadError};
2324
use rmp::Marker;
2425

25-
use swimos_form::structural::read::event::ReadEvent;
26-
use swimos_form::structural::read::recognizer::Recognizer;
27-
use swimos_form::structural::read::{ReadError, StructuralReadable};
28-
use swimos_model::bigint::{BigInt, BigUint, Sign};
26+
use swimos_form::read::ReadEvent;
27+
use swimos_form::read::Recognizer;
28+
use swimos_form::read::{ReadError, StructuralReadable};
29+
use swimos_model::{BigInt, BigUint};
2930

3031
use crate::{BIG_INT_EXT, BIG_UINT_EXT};
3132

@@ -52,6 +53,9 @@ fn feed<T, E: Into<MsgPackReadError>>(maybe: Option<Result<T, E>>) -> Result<(),
5253
}
5354

5455
/// Attempt to read a [`StructuralReadable`] type from MessagePack data in a buffer.
56+
///
57+
/// # Arguments
58+
/// * `input` - The buffer containing the MessagePack data.
5559
pub fn read_from_msg_pack<T: StructuralReadable, R: Buf>(
5660
input: &mut R,
5761
) -> Result<T, MsgPackReadError> {
@@ -179,9 +183,11 @@ where
179183
})
180184
}
181185

186+
/// Reading MessagePack data can fail if the bytes do not constitute valid MessagePack or the buffer contains
187+
/// an incomplete record.
182188
#[derive(Debug, PartialEq)]
183189
pub enum MsgPackReadError {
184-
/// The parsed strucuture was not valid for the target type.
190+
/// The parsed structure was not valid for the target type.
185191
Structure(ReadError),
186192
/// The MessagePack data contained invalid UTF8 in a string.
187193
StringDecode(Utf8Error),

0 commit comments

Comments
 (0)