Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rusterlium/rustler
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: rustler-0.35.1
Choose a base ref
...
head repository: rusterlium/rustler
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jan 6, 2025

  1. Fix Nif* macros requiring an encoder (#676)

    * Fix Nif* macros requiring an encoder
    * Add note and changelog entry
    filmor authored Jan 6, 2025
    Copy the full SHA
    47ce1af View commit details

Commits on Jan 8, 2025

  1. Add workspace and remove linkage override from 'mix rustler.new' temp…

    …lates (#672)
    
    * Update 'mix.rustler.new' templates
    
    - Add a workspace `Cargo.toml`` at the root of the project to be able
      to `cargo build` directly
    - Remove now obsolete linkage override that was necessary on macOS
      before merging #650 (Dynamic Symbols on Unix)
    
    * Use template for the root Cargo.toml as well
    filmor authored Jan 8, 2025
    Copy the full SHA
    7edf2ac View commit details

Commits on Jan 13, 2025

  1. (release) 0.36.0

    filmor committed Jan 13, 2025
    Copy the full SHA
    0a44899 View commit details
  2. Back to dev

    filmor committed Jan 13, 2025
    Copy the full SHA
    c14befb View commit details
  3. Copy the full SHA
    a6e2a15 View commit details

Commits on Jan 16, 2025

  1. Fix build status badge

    The URL format changed.
    filmor authored Jan 16, 2025
    Copy the full SHA
    bc33bc4 View commit details
  2. Copy the full SHA
    cae083d View commit details

Commits on Jan 26, 2025

  1. Use non-rc Elixir 1.18 in CI

    filmor committed Jan 26, 2025
    Copy the full SHA
    e8876e9 View commit details

Commits on Feb 1, 2025

  1. Fixes for rustler_mix (#682)

    - Support Erlang-style NIF module names (:module_name)
    - Retrieve newest Rustler version without additional dependencies
      (fixes #680)
    - Update dependencies
    - Adjust .gitignore handling to match the new workspace style
    - Detect an existing workspace configuration and advise to add a newly
      generated project
    filmor authored Feb 1, 2025
    Copy the full SHA
    ef75277 View commit details

Commits on Feb 3, 2025

  1. (release) 0.36.1

    filmor committed Feb 3, 2025
    Copy the full SHA
    c97e45a View commit details
  2. Update changelog

    filmor committed Feb 3, 2025
    Copy the full SHA
    f1e5381 View commit details
  3. Copy the full SHA
    adc9847 View commit details

Commits on Apr 12, 2025

  1. Replace unsupported definition list syntax in README.md (#689)

    * Replace unsupported definition list syntax in README.md
    
    problem: GitHub Flavored Markdown (GFM) does not support Markdown's definition lists natively.
    
    fix: simulate a definition list using bold terms and line breaks
    
    * Update README.md
    
    * Add line breaks in README.md
    emig authored Apr 12, 2025
    Copy the full SHA
    f5e2b09 View commit details

Commits on Apr 27, 2025

  1. Implement Hash for atoms (#695)

    ---------
    
    Co-authored-by: Sonny Scroggin <sonny@scrogg.in>
    filmor and scrogson authored Apr 27, 2025
    Copy the full SHA
    7535e94 View commit details

Commits on Jun 9, 2025

  1. Copy the full SHA
    a466948 View commit details
  2. (release) 0.36.2

    filmor committed Jun 9, 2025
    Copy the full SHA
    c9849a7 View commit details
  3. Back to dev

    filmor committed Jun 9, 2025
    Copy the full SHA
    eec7ba4 View commit details

Commits on Jun 11, 2025

  1. Copy the full SHA
    b54de69 View commit details
  2. Copy the full SHA
    23efcd8 View commit details
  3. Drop OTP24

    filmor committed Jun 11, 2025
    Copy the full SHA
    a8e6a5f View commit details
  4. Merge pull request #697 from rusterlium/elixir-1.19-ci

    CI Updates
    filmor authored Jun 11, 2025
    Copy the full SHA
    390ce02 View commit details
  5. Copy the full SHA
    b4d2988 View commit details
  6. Merge pull request #691 from filmor/build-refactor

    Build refactor
    filmor authored Jun 11, 2025
    Copy the full SHA
    2a67590 View commit details
23 changes: 9 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -23,8 +23,8 @@ jobs:
- name: Install Erlang/Elixir
uses: erlef/setup-beam@v1
with:
otp-version: "26"
elixir-version: "1.15"
otp-version: "27"
elixir-version: "1.18"

- name: Check cargo fmt
run: cargo fmt --all -- --check
@@ -85,14 +85,15 @@ jobs:
strategy:
matrix:
pair:
- { erlang: "27", elixir: "1.18.0-rc.0" }
- { erlang: "26", elixir: "1.18.0-rc.0" }
- { erlang: "27", elixir: "1.17", latest: true }
- { erlang: "28.0", elixir: "1.19.0-rc.0", strict: true }
- { erlang: "27.3.4", elixir: "1.19.0-rc.0", strict: true }
- { erlang: "27", elixir: "1.18", latest: true }
- { erlang: "26", elixir: "1.18" }
- { erlang: "27", elixir: "1.17" }
- { erlang: "26", elixir: "1.17" }
- { erlang: "26", elixir: "1.16" }
- { erlang: "26", elixir: "1.15" }
- { erlang: "25", elixir: "1.15" }
- { erlang: "24", elixir: "1.14" }
rust:
- stable
- nightly
@@ -107,17 +108,11 @@ jobs:
uses: actions/checkout@v4

- name: Install Erlang/Elixir
uses: erlef/setup-beam@v1
uses: erlef/setup-beam@main
with:
otp-version: ${{matrix.pair.erlang}}
elixir-version: ${{matrix.pair.elixir}}
if: "!startsWith(matrix.os, 'macos')"

- name: Install Erlang/Elixir with Brew
run: |
brew install elixir
mix local.hex --force
if: "startsWith(matrix.os, 'macos')"
version-type: ${{ matrix.pair.strict && 'strict' || 'loose' }}

- name: Install Rust ${{matrix.rust}} toolchain
uses: dtolnay/rust-toolchain@master
59 changes: 58 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -8,6 +8,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
See [`UPGRADE.md`](./UPGRADE.md) for additional help when upgrading to newer
versions.

## unreleased

### Added

### Fixed

### Changed

### Removed

## 0.36.2 - 2025-06-09

### Added

- `std::hash::Hash` implementation for atoms (#695)

### Fixed

- Fix typing error in `rustler_mix` (#696, thanks @dkuku)

## 0.36.1 - 2025-02-03

No changes in the Rust code, only `rustler_mix` adjustments and dependency
updates.

### Added

- Support for Erlang-style NIF module names (`:module_name`) (#682)

### Fixed

- Retrieve the newest Rustler version without additional dependencies
(#682, fixes #680)
- Adjust `.gitignore` handling to match the new workspace style

### Changed

- Only depend on `libloading` on non-Windows systems (#677)

## 0.36.0 - 2025-01-13

### Added

- Create a workplace `Cargo.toml` file with `mix rustler.new` (#672)

### Fixed

- Some derive macros failed when only `decode` was requested (#676)

### Removed

- The linkage override for macOS is not needed anymore and has been removed from
the template (#672)

## [0.35.1] - 2024-12-18

### Fixed
@@ -311,7 +365,6 @@ The `Untagged` variant is represented as the atom `:untagged` in Elixir.
- `rustler_mix`: Bumped required toml dependency to 0.6
- Bumped `rustler_sys` dependency to `~2.2`


## [0.23.0] - 2021-12-22

### Added
@@ -377,6 +430,7 @@ The `Untagged` variant is represented as the atom `:untagged` in Elixir.
- `rustler_atoms!` is now `rustler::atoms!`
- `resource_struct_init!` is now `rustler::resource!`
- New `rustler::atoms!` macro removed the `atom` prefix from the name:

```rust
//
// Before
@@ -398,6 +452,7 @@ The `Untagged` variant is represented as the atom `:untagged` in Elixir.
```

- NIF functions can be initialized with a simplified syntax:

```rust
//
// Before
@@ -418,6 +473,7 @@ The `Untagged` variant is represented as the atom `:untagged` in Elixir.

- NIFs can be derived from regular functions, if the arguments implement
`Decoder` and the return type implements `Encoder`:

```rust
//
// Before
@@ -440,6 +496,7 @@ The `Untagged` variant is represented as the atom `:untagged` in Elixir.

- `rustler::nif` exposes more options to configure a NIF were the NIF is
defined:

```rust

#[rustler::nif(schedule = "DirtyCpu")]
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

[Documentation](https://docs.rs/rustler/latest/rustler) | [Getting Started](https://github.com/rusterlium/rustler/blob/master/README.md#getting-started) | [Example](https://github.com/rusterlium/NifIo)

[![Build Status](https://github.com/rusterlium/rustler/workflows/CI/badge.svg?branch=master)](https://github.com/rusterlium/rustler/actions/workflows/main.yml)
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/rusterlium/rustler/main.yml)](https://github.com/rusterlium/rustler/actions/workflows/main.yml)
[![Hex.pm package version](https://img.shields.io/hexpm/v/rustler.svg)](https://hex.pm/packages/rustler)
[![Crates.io package version](https://img.shields.io/crates/v/rustler.svg)](https://crates.io/crates/rustler)
[![Last Updated](https://img.shields.io/github/last-commit/rusterlium/rustler.svg)](https://github.com/rusterlium/rustler/commits/master)
@@ -18,20 +18,17 @@ is favored as of now.

#### Features

Safety
: The code you write in a Rust NIF should never be able to crash the BEAM.
**Safety**
The code you write in a Rust NIF should never be able to crash the BEAM.

Interop
: Decoding and encoding rust values into Erlang terms is as easy as a function
: call.
**Interop**
Decoding and encoding rust values into Erlang terms is as easy as a function call.

Type composition
: Making a Rust struct encodable and decodable to Erlang or Elixir can be done
: with a single attribute.
**Type composition**
Making a Rust struct encodable and decodable to Erlang or Elixir can be done with a single attribute.

Resource objects
: Enables you to safely pass a reference to a Rust struct into Erlang code. The
: struct will be automatically dropped when it's no longer referenced.
**Resource objects**
Enables you to safely pass a reference to a Rust struct into Erlang code. The struct will be automatically dropped when it's no longer referenced.

#### Getting started

8 changes: 5 additions & 3 deletions rustler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
name = "rustler"
description = "Safe Rust wrappers for creating Erlang NIF functions"
repository = "https://github.com/rusterlium/rustler"
version = "0.35.1" # rustler version
version = "0.36.2" # rustler version
authors = ["Hansihe <me@hansihe.com>"]
license = "MIT/Apache-2.0"
readme = "../README.md"
@@ -22,12 +22,14 @@ nif_version_2_17 = ["nif_version_2_16"]
serde = ["dep:serde"]

[dependencies]
libloading = "0.8"
inventory = "0.3"
rustler_codegen = { path = "../rustler_codegen", version = "0.35.1"}
rustler_codegen = { path = "../rustler_codegen", version = "0.36.2"}
num-bigint = { version = "0.4", optional = true }
serde = { version = "1", optional = true }

[target.'cfg(not(windows))'.dependencies]
libloading = "0.8"

[build-dependencies]
regex-lite = "0.1"

12 changes: 11 additions & 1 deletion rustler/src/types/atom.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::wrapper::atom;
use crate::wrapper::NIF_TERM;
use crate::{Decoder, Encoder, Env, Error, NifResult, Term};
use std::fmt;
use std::hash::{Hash, Hasher};

// Atoms are a special case of a term. They can be stored and used on all envs regardless of where
// it lives and when it is created.
@@ -81,7 +83,6 @@ impl Atom {
}
}

use std::fmt;
impl fmt::Debug for Atom {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
crate::wrapper::term::fmt(self.as_c_arg(), f)
@@ -137,6 +138,15 @@ pub(in crate::types) fn decode_bool(term: Term) -> NifResult<bool> {
Err(Error::BadArg)
}

impl Hash for Atom {
fn hash<H: Hasher>(&self, state: &mut H) {
use crate::sys::{enif_hash, ErlNifHash};
let hash =
unsafe { enif_hash(ErlNifHash::ERL_NIF_INTERNAL_HASH, self.as_c_arg(), 0) as u32 };
state.write_u32(hash);
}
}

// This is safe because atoms are never removed/changed once they are created.
unsafe impl Sync for Atom {}
unsafe impl Send for Atom {}
2 changes: 1 addition & 1 deletion rustler_codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
name = "rustler_codegen"
description = "Compiler plugin for Rustler"
repository = "https://github.com/rusterlium/rustler/tree/master/rustler_codegen"
version = "0.35.1" # rustler_codegen version
version = "0.36.2" # rustler_codegen version
authors = ["Hansihe <hansihe@hansihe.com>"]
license = "MIT/Apache-2.0"
readme = "../README.md"
1 change: 0 additions & 1 deletion rustler_codegen/src/ex_struct.rs
Original file line number Diff line number Diff line change
@@ -59,7 +59,6 @@ pub fn transcoder_decorator(ast: &syn::DeriveInput, add_exception: bool) -> Toke

#decoder

#[allow(clippy::needless_borrow)]
#encoder
};

1 change: 0 additions & 1 deletion rustler_codegen/src/map.rs
Original file line number Diff line number Diff line change
@@ -44,7 +44,6 @@ pub fn transcoder_decorator(ast: &syn::DeriveInput) -> TokenStream {

#decoder

#[allow(clippy::needless_borrow)]
#encoder
};

2 changes: 1 addition & 1 deletion rustler_mix/README.md
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ This package is available on [Hex.pm](https://hex.pm/packages/rustler). To insta
```elixir
def deps do
[
{:rustler, "~> 0.35.1", runtime: false}
{:rustler, "~> 0.36.2", runtime: false}
]
end
```
Loading