From e4748e8815228f601dba8bd0cab721fdd5575cec Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 20 Aug 2026 15:22:21 -0700 Subject: [PATCH 1/3] Enforce a minimal supported Rust version of 1.89.0 --- .github/workflows/build.yaml | 15 +++++++++++++++ Cargo.toml | 1 + 2 files changed, 16 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 84fb902..8adf02d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -18,6 +18,21 @@ env: RUSTFLAGS: --deny warnings jobs: + msrv: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.89.0 + + - uses: Swatinem/rust-cache@v2 + + - name: Check + run: cargo check + all: name: All diff --git a/Cargo.toml b/Cargo.toml index b68d7a0..d8335ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ keywords = ["p2p", "sharing", "bittorrent", "torrent"] license.workspace = true readme = "README.md" repository = "https://github.com/casey/intermodal" +rust-version = "1.89.0" [workspace.package] edition = "2021" From c26a734152160c6cbb39db8f9fa7c4b83eb0b74f Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 20 Aug 2026 15:26:23 -0700 Subject: [PATCH 2/3] Placate clippy --- build.rs | 3 +-- src/piece_list.rs | 18 +++++++----------- src/table.rs | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/build.rs b/build.rs index db14a8b..efc333f 100644 --- a/build.rs +++ b/build.rs @@ -8,8 +8,7 @@ fn is_inside_git_work_tree() -> bool { .arg("rev-parse") .arg("--is-inside-work-tree") .output() - .map(|output| String::from_utf8_lossy(&output.stdout).trim() == "true") - .unwrap_or(false) + .is_ok_and(|output| String::from_utf8_lossy(&output.stdout).trim() == "true") } fn error(message: String) -> io::Error { diff --git a/src/piece_list.rs b/src/piece_list.rs index 2662b02..10c77f9 100644 --- a/src/piece_list.rs +++ b/src/piece_list.rs @@ -57,23 +57,19 @@ impl<'de> Deserialize<'de> for PieceList { { let bytes = serde_bytes::ByteBuf::deserialize(deserializer)?.into_vec(); - if bytes.len() % Sha1Digest::LENGTH != 0 { + let (chunks, remainder) = bytes.as_chunks::<{ Sha1Digest::LENGTH }>(); + + if !remainder.is_empty() { return Err(D::Error::custom(format!( "buffer length {} is not a multiple of {}", bytes.len(), - sha1_smol::DIGEST_LENGTH + Sha1Digest::LENGTH, ))); } - let piece_hashes = bytes - .chunks_exact(Sha1Digest::LENGTH) - .map(|chunk| { - Sha1Digest::from_bytes( - chunk - .try_into() - .invariant_unwrap("chunks are all Sha1Digest::LENGTH"), - ) - }) + let piece_hashes = chunks + .iter() + .map(|chunk| Sha1Digest::from_bytes(*chunk)) .collect(); Ok(Self { piece_hashes }) diff --git a/src/table.rs b/src/table.rs index fe379dd..13696b6 100644 --- a/src/table.rs +++ b/src/table.rs @@ -273,14 +273,14 @@ mod tests { .write_human_readable(&mut cursor, Style::inactive()) .unwrap(); let have = String::from_utf8(cursor.into_inner()).unwrap(); - assert_eq!(have, want, "have != want:\nHAVE:\n{have}\nWANT:\n{want}",); + assert_eq!(have, want, "have != want:\nHAVE:\n{have}\nWANT:\n{want}"); } fn tab_delimited(table: &Table, want: &str) { let mut cursor = Cursor::new(Vec::new()); table.write_tab_delimited(&mut cursor).unwrap(); let have = String::from_utf8(cursor.into_inner()).unwrap(); - assert_eq!(have, want, "have != want:\nHAVE:\n{have}\nWANT:\n{want}",); + assert_eq!(have, want, "have != want:\nHAVE:\n{have}\nWANT:\n{want}"); } #[test] From ab069c8f135afec94ecf05befa1f66cf78f06232 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 20 Aug 2026 15:29:52 -0700 Subject: [PATCH 3/3] Make rust version workspace-wide --- .github/workflows/build.yaml | 2 +- Cargo.toml | 3 ++- bin/demo/Cargo.toml | 1 + bin/gen/Cargo.toml | 1 + bin/update-contributors/Cargo.toml | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8adf02d..f9efbd3 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -31,7 +31,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Check - run: cargo check + run: cargo check --workspace all: name: All diff --git a/Cargo.toml b/Cargo.toml index d8335ea..bc5de0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,12 +12,13 @@ keywords = ["p2p", "sharing", "bittorrent", "torrent"] license.workspace = true readme = "README.md" repository = "https://github.com/casey/intermodal" -rust-version = "1.89.0" +rust-version.workspace = true [workspace.package] edition = "2021" license = "CC0-1.0" authors = ["Casey Rodarmor "] +rust-version = "1.89.0" [features] default = [] diff --git a/bin/demo/Cargo.toml b/bin/demo/Cargo.toml index 380142d..3bb4162 100644 --- a/bin/demo/Cargo.toml +++ b/bin/demo/Cargo.toml @@ -3,4 +3,5 @@ name = "demo" version = "0.0.0" authors.workspace = true edition.workspace = true +rust-version.workspace = true publish = false diff --git a/bin/gen/Cargo.toml b/bin/gen/Cargo.toml index ac8f9de..20f4268 100644 --- a/bin/gen/Cargo.toml +++ b/bin/gen/Cargo.toml @@ -3,6 +3,7 @@ name = "gen" version = "0.0.0" authors.workspace = true edition.workspace = true +rust-version.workspace = true publish = false [dependencies] diff --git a/bin/update-contributors/Cargo.toml b/bin/update-contributors/Cargo.toml index 5ad9165..587481c 100644 --- a/bin/update-contributors/Cargo.toml +++ b/bin/update-contributors/Cargo.toml @@ -3,6 +3,7 @@ name = "update-contributors" version = "0.0.0" authors.workspace = true edition.workspace = true +rust-version.workspace = true publish = false [dependencies]