From b90b47399e7d4a1bd2282707c37ba288dfc29376 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Sat, 6 Sep 2025 11:44:27 +0900 Subject: [PATCH 1/5] refactor: use io::Error::other instead of io::Error::new with Other kind --- src/codec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codec.rs b/src/codec.rs index 77dfa99..ccade3a 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -810,7 +810,7 @@ mod aux { Err(io::Error::new(io::ErrorKind::InvalidData, message)) } pub fn other_error(message: String) -> io::Result { - Err(io::Error::new(io::ErrorKind::Other, message)) + Err(io::Error::other(message)) } pub fn latin1_bytes_to_string(buf: &[u8]) -> io::Result { // FIXME: Supports Latin1 characters From 7faab784233502842c4e9415753a83cb0f84d317 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Sat, 6 Sep 2025 11:45:13 +0900 Subject: [PATCH 2/5] chore: update Rust edition to 2024 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 74225d9..6ebd6e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/sile/eetf" readme = "README.md" keywords = ["erlang"] license = "MIT" -edition = "2021" +edition = "2024" [dependencies] byteorder = "1" From 78787fb96cb4208867e4a80c3e5d6fe364bc8142 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Sat, 6 Sep 2025 11:46:06 +0900 Subject: [PATCH 3/5] chore: update CI workflow configuration and dependencies --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79ae5a6..f2d50da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: CI -on: [push, pull_request] +on: [push] jobs: check: @@ -11,9 +11,9 @@ jobs: toolchain: [stable, beta, nightly] steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 - run: rustup update ${{ matrix.toolchain }} - - run: cargo check --all-features + - run: cargo check --all test: name: Test Suite @@ -23,9 +23,9 @@ jobs: toolchain: [stable, beta, nightly] steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 - run: rustup update ${{ matrix.toolchain }} - - run: cargo test --all-features + - run: cargo test --all lints: name: Lints @@ -35,7 +35,7 @@ jobs: toolchain: [stable, beta, nightly] steps: - name: Checkout sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 - run: rustup update ${{ matrix.toolchain }} - - run: cargo fmt -- --check - - run: cargo clippy --all-features -- -D warnings + - run: cargo fmt --all -- --check + - run: cargo clippy --all -- -D warnings From ec3287151e83cf8bbc7e36d982b23d2dee5286f4 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Sat, 6 Sep 2025 11:47:31 +0900 Subject: [PATCH 4/5] chore: add GitHub release and crates.io publish workflow --- .github/workflows/release.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bd19920 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Create GitHub Release and Publish to crates.io + +on: + push: + tags: ['v*'] + +jobs: + github-release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v5 + + - id: create-release + run: gh release create ${{ github.ref_name }} --title "${{ github.ref_name }}" --generate-notes + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish: + runs-on: ubuntu-latest + # environment: release # Optional: for enhanced security + permissions: + id-token: write + steps: + - uses: actions/checkout@v5 + - uses: rust-lang/crates-io-auth-action@v1 + id: auth + - run: cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} From 1de63cfd0cc96709718374853d73aae8468e3abc Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Sat, 6 Sep 2025 11:50:55 +0900 Subject: [PATCH 5/5] style: format code with consistent single-line conditionals and array formatting --- src/codec.rs | 6 +----- src/convert.rs | 6 +----- src/lib.rs | 2 +- tests/lib.rs | 26 ++++++++++++++++++++------ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/codec.rs b/src/codec.rs index ccade3a..db589b1 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -826,10 +826,6 @@ mod aux { } } pub fn sign_to_byte(sign: Sign) -> u8 { - if sign == Sign::Minus { - 1 - } else { - 0 - } + if sign == Sign::Minus { 1 } else { 0 } } } diff --git a/src/convert.rs b/src/convert.rs index cd94d69..c58e06f 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -96,11 +96,7 @@ pub trait AsOption { } impl AsOption for bool { fn as_option(&self) -> Option<&Self> { - if *self { - Some(self) - } else { - None - } + if *self { Some(self) } else { None } } } diff --git a/src/lib.rs b/src/lib.rs index 0285856..f7b6052 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -852,8 +852,8 @@ impl From> for Map { #[cfg(test)] mod tests { use super::*; - use crate::pattern::any; use crate::pattern::U8; + use crate::pattern::any; #[test] fn it_works() { diff --git a/tests/lib.rs b/tests/lib.rs index a4240bd..f31a4d1 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -230,7 +230,9 @@ fn reference_test() { // Encode assert_eq!( - vec![131, 90, 0, 1, 100, 0, 3, 102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 123], + vec![ + 131, 90, 0, 1, 100, 0, 3, 102, 111, 111, 0, 0, 0, 0, 0, 0, 0, 123 + ], encode(Term::from(Reference::from(("foo", 123)))) ); } @@ -246,12 +248,17 @@ fn external_fun_test() { // Decode assert_eq!( Ok(ExternalFun::from(("foo", "bar", 3))), - decode(&[131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3]).try_into() + decode(&[ + 131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3 + ]) + .try_into() ); // Encode assert_eq!( - vec![131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3], + vec![ + 131, 113, 100, 0, 3, 102, 111, 111, 100, 0, 3, 98, 97, 114, 97, 3 + ], encode(Term::from(ExternalFun::from(("foo", "bar", 3)))) ); } @@ -461,15 +468,22 @@ fn map_test() { // Decode assert_eq!( Ok(map.clone()), - decode(&[131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98]).try_into() + decode(&[ + 131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98 + ]) + .try_into() ); // Encode let buf = encode(Term::from(map.clone())); // Hashmap Iter is not deterministic, so we need to check both possible outputs assert!( - [131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98] == buf.as_slice() - || [131, 116, 0, 0, 0, 2, 100, 0, 1, 97, 100, 0, 1, 98, 97, 1, 97, 2] == buf.as_slice() + [ + 131, 116, 0, 0, 0, 2, 97, 1, 97, 2, 100, 0, 1, 97, 100, 0, 1, 98 + ] == buf.as_slice() + || [ + 131, 116, 0, 0, 0, 2, 100, 0, 1, 97, 100, 0, 1, 98, 97, 1, 97, 2 + ] == buf.as_slice() ); //Access