From 44db49f7d0ebd13acd3e961474aafbcacad33c66 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 12 Mar 2024 23:05:01 +0100 Subject: [PATCH] Update readme and upgrade docs --- CHANGELOG.md | 1 + README.md | 44 ++++++++++++++++++++++++++++---------------- UPGRADE.md | 4 ++++ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77ad7252..1272c9b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ versions. - `Env::is_process_alive` and `LocalPid::is_alive` (#599) - Encoding and decoding of 128 bit integers (#600) - Optional codec for `num_bigint::BigInt` using the `big_integer` feature (#601) +- Add experimental `serde` support derived from `serde_rustler` ### Fixed diff --git a/README.md b/README.md index dcbe6a82..93e94ea9 100644 --- a/README.md +++ b/README.md @@ -16,22 +16,34 @@ they unwind into C. The library provides functionality for both Erlang and Elixir, however Elixir is favored as of now. -#### Features: +#### Features -- 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. -- 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. +Safety +: The code you write in a Rust NIF should never be able to crash the BEAM. -#### Getting started +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. -The easiest way of getting started is the [rustler elixir library](https://hex.pm/packages/rustler). +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 -- Add the [rustler elixir library](https://hex.pm/packages/rustler) as a dependency of your project. -- Run `mix rustler.new` to generate a new NIF in your project. Follow the instructions. -- If you're already using [`serde`](https://serde.rs), consider using [`serde_rustler`](https://github.com/sunny-g/serde_rustler/tree/master/serde_rustler) to easily encode and decode your data types into and from Elixir terms. +The easiest way of getting started is the [rustler Elixir library](https://hex.pm/packages/rustler). -NOTE: If you have previously used Rustler, you need to run `mix archive.uninstall rustler_installer.ez` to remove it before generating the NIF. +- Add the [rustler Elixir library](https://hex.pm/packages/rustler) as a + dependency of your project. +- Run `mix rustler.new` to generate a new NIF in your project. Follow the + instructions. +- If you are already using [`serde`](https://serde.rs) and/or have been using + `serde_rustler` before, please enable the `serde` feature in your NIF crate's + `Cargo.toml` on the `rustler` dependency. #### What it looks like @@ -58,9 +70,9 @@ Rustler aims to support the newest three major OTP versions as well as newest th #### Supported NIF version The minimal supported NIF version for a library should be defined via Cargo -features. The default is currently `2.14` (Erlang/OTP 21). To use features from -NIF version `2.16` (Erlang/OTP 24), the respective feature flag has to be -enabled on the dependency: +features. The default is currently `2.15` (Erlang/OTP 21). To use features from +NIF version `2.16` (Erlang/OTP 24) or `2.17` (Erlang/OTP 26), the respective +feature flag has to be enabled on the dependency: ```toml [dependencies] @@ -84,5 +96,5 @@ at your option. ##### Contribution Unless you explicitly state otherwise, any contribution intentionally submitted -for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any -additional terms or conditions. +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/UPGRADE.md b/UPGRADE.md index a10f6586..c3e8fd36 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -11,6 +11,10 @@ This document is intended to simplify upgrading to newer versions by extending t wrapper. For most codebases, it will be enough to activate the feature and replace all `rustler_bigint::BigInt` usages by `rustler::BigInt` (or `num_bigint::BigInt`). +2. `serde_rustler` has been integrated into `rustler` behind the feature flag + `serde`. Arbitrary, `serde`-compatible objects (i.e. with `Deserialize` or + `Serialize` `impl`s) can be wrapped in `SerdeTerm` to use them in place of + `Encoder` or `Decoder`. ## 0.29 -> 0.30