You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to limitations of serde, Vec<u8> will serialize into "seq of u8", which is rendered into Elixir list instead of binary. There are libraries that force serde into treating Vec<u8> as bytes (e.g. serde_bytes, serde_with), but these libraries require users to annotate existing Rust code, which is not always possible or convenient.
Given that the goal of rustler is to make interop between Elixir and Rust as smooth as possible, I believe encoding Vec<u8> into binaries is a better default.
I propose the following breaking changes to rustler's serde conversion rules:
Allow Elixir binary to be deserialized into "seq of u8". This means SerdeTerm<Vec<u8>> can be decoded from binary.
Prefer to serialize "seq of u8" into binary when possible. This means SerdeTerm<Vec<u8>> will be encoded into binary, but SerdeTerm<Vec<i8>> will be encoded into list, as usual.
I'm currently working on an implementation. Any thoughts?