serde_rustler 0.0.1

Serializer and Deserializer traits for Rustler NIFs
Documentation

serde_rustler

Serde Serializer and Deserializer traits for Rustler NIFs.

Source

Crates.io Documentation

serde_rustler provides Serde Serializer and Deserializer traits for Rustler types, so you can easily serialize and deserialize native Rust types directly to and from native Elixir terms within your NIFs.

Installation

Install from Crates.io:

[dependencies]
serde_rustler = "0.0.1"

API Overview

Type Name Serde Data Model Default Elixir Term
bool true or false true or false
number i8, i16, i32, i64, u8, u16, u32, u64, f32, f64 number
char "" bitstring
string "" bitstring
byte array [u8] <<_::_*8>>
option Some(T) or None T or :nil
unit None :nil
unit struct struct Unit :nil
unit variant E::A in enum UnitVariant { A } *:A
newtype struct struct Millimeters(u8) 1{:Millimeters, u8}
newtype variant E::N in enum E { N(u8) } 1{:N, u8}
seq Vec<T> [T]
tuple (u8,) {u8,}
tuple struct struct Rgb(u8, u8, u8) 1{:Rgb, u8, u8, u8}
tuple variant E::T in enum E { T(u8, u8) } 1{:T, u8, u8}
map HashMap<K, V> %{}
struct struct Rgb { r: u8, g: u8, b: u8 } 1%Rgb{ r: byte, g: byte, b: byte }
struct variant E::S in enum E { Rgb { r: u8, g: u8, b: u8 } } 1%Rgb{ r: byte, g: byte, b: byte }

1: If transcoding, the atom may not exist and will instead be serialized/deserialized to/from an Elixir bitstring. This means that may only be maps with a __struct__ key and string value. These types are also lossy (newtype structs and variants are indistinguishable in Elixir terms), so deserialization hints may be required.

Changelog

Version Change Summary
v0.0.1 initial release

Contributing

  1. Fork it https://github.com/your_username/xdr/fork
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Maintainers

License

MIT