Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push, pull_request]
on: [push]

jobs:
check:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/sile/eetf"
readme = "README.md"
keywords = ["erlang"]
license = "MIT"
edition = "2021"
edition = "2024"

[dependencies]
byteorder = "1"
Expand Down
8 changes: 2 additions & 6 deletions src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ mod aux {
Err(io::Error::new(io::ErrorKind::InvalidData, message))
}
pub fn other_error<T>(message: String) -> io::Result<T> {
Err(io::Error::new(io::ErrorKind::Other, message))
Err(io::Error::other(message))
}
pub fn latin1_bytes_to_string(buf: &[u8]) -> io::Result<String> {
// FIXME: Supports Latin1 characters
Expand All @@ -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 }
}
}
6 changes: 1 addition & 5 deletions src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@ impl From<HashMap<String, Term>> for Map {
#[cfg(test)]
mod tests {
use super::*;
use crate::pattern::any;
use crate::pattern::U8;
use crate::pattern::any;

#[test]
fn it_works() {
Expand Down
26 changes: 20 additions & 6 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
);
}
Expand All @@ -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))))
);
}
Expand Down Expand Up @@ -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
Expand Down