Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
See UPGRADE.md for additional help when upgrading to newer versions.
[0.23.0] - 2021-12-22
Added
NifExceptionfor using Elixir exception structs- Hashing for term
- Hash and Equality for
BinaryandOwnedBinary
Changed
- Rustler changed its supported range of OTP and Elixir versions. We aim to support the three newest versions of OTP and Elixir.
- The decoder for
Rangerequires that:stepequals1. The:stepfield was introduced with Elixir v1.12 and cannot be represented with Rust'sRangeInclusive. - NIF API bindings are generated using Rust
Fixed
mix rustler.newwith Elixir v1.13- Template config for
macos - Crash if metadata cannot be retrieved while compiling (#398)
[0.22.2] - 2021-10-07
Fixed
- Fixed a regression introduced with #386:
Rustler.Compiler.Configcalled intocargowhenskip_compilation?was set, breaking setups where cargo is not installed. Fixed with #389, thanks @karolsluszniak
[0.22.1] - 2021-10-05
Fixed
- [Breaking change] codegen-generated decoders always raise an error instead of causing the calling NIF to return an atom in some cases
- Fix codegen problem for untagged enums (#370)
- Fix handling local dependencies with
@external_resources(#381)
[0.22.0] - 2021-06-22
Added
- Simple
Debugimpl forrustler::Error - Support newtype and tuple structs for
NifTupleandNifRecord rustler::Error::Termencoding an arbitrary boxed encoder, returning{:error, term}- Generic encoder/decoder for
HashMap<T, U>, whereT: DecoderandU: Decoder
Fixed
- Compilation time of generated decoders has been reduced significantly.
- Fixed a segfault caused by
OwnedEnv::send_and_clear
Changes
- Renamed
PidtoLocalPidto clarify that it can't point to a remote process - Dependencies have been updated.
- Derive macros have been refactored.
- Macros have been renamed and old ones have been deprecated:
rustler_export_nifs!is nowrustler::init!rustler_atoms!is nowrustler::atoms!resource_struct_init!is nowrustler::resource!
- New
rustler::atoms!macro removed theatomprefix from the name:
//
// Before
//
rustler::rustler_atoms! {
atom ok;
atom error;
atom renamed_atom = "Renamed";
}
//
// After
//
rustler::atoms! {
ok,
error,
renamed_atom = "Renamed",
}- NIF functions can be initialized with a simplified syntax:
//
// Before
//
rustler::rustler_export_nifs! {
"Elixir.Math",
[
("add", 2, add)
],
None
}
//
// After
//
rustler::init!("Elixir.Math", [add]);- NIFs can be derived from regular functions, if the arguments implement
Decoderand the return type implementsEncoder:
//
// Before
//
fn add<'a>(env: Env<'a>, args: &[Term<'a>]) -> Result<Term<'a>, Error> {
let num1: i64 = args[0].decode()?;
let num2: i64 = args[1].decode()?;
Ok((atoms::ok(), num1 + num2).encode(env))
}
//
// After
//
#[rustler::nif]
fn add(a: i64, b: i64) -> i64 {
a + b
}rustler::nifexposes more options to configure a NIF were the NIF is defined:
#[rustler::nif(schedule = "DirtyCpu")]
pub fn dirty_cpu() -> Atom {
let duration = Duration::from_millis(100);
std::thread::sleep(duration);
atoms::ok()
}
#[rustler::nif(name = "my_add")]
fn add(a: i64, b: i64) -> i64 {
a + b
}Deprecations
The rustler compiler has been deprecated and will be removed with v1.0. NIFs
are no longer defined in mix.exs, but are configured with use Rustler. See
the documentation for the Rustler module. To migrate to the new
configuration:
Drop
:rustlerfrom the:compilerskey in yourmix.exsproject/0functionDrop
:rustler_cratesfromproject/0and move the configurations into theuse Rustlerof your NIF module or application config:# config/dev.exs config :my_app, MyApp.Native, mode: :debug
For more information, see the documentation.
[0.21.0] - 2019-09-07
Added
- Support for OTP22.
- Rust linting with clippy.
- Support for decoding IOLists as binaries,
Term::decode_as_binary.
Changes
rustler_codegenis now reexported by therustlercrate. Depending on therustler_codegencrate is deprecated.erlang_nif-syshas been renamed torustler_sysand vendored into the rustler repo.- Replaced the hand-rolled TOML parser in
rustler_mixwith thetoml-elixirpackage. - Improve error messages for derived encoders/decoders.
- Rust
boolnow corresponds only to booleans (false,true) in Elixir. Previously,nilandfalsewere both decodable tobool. To use the previous behaviour, aTruthynewtype was introduced.