Skip to content

How to conveniently work with binaries as vectors of bytes? #551

@radrow

Description

@radrow

In my project I extensively use various byte arrays (Vec<u8>, [u8]). I have quite a number of types which comprise those as fields.

My problem is, ruslter converts those to Erlang lists, and I don't like for obvious reasons. This leaves me to these workarounds:

  1. Implement almost all decoders/encoders by hand
  2. Wrap all byte arrays with a newtype
  3. Cry

The problem with 1 is that it's quite a tedious work. It also adds maintenance burden. Normally I would use a derive macro, but it automatically picks lists. I know the current way to go is 2, but I don't want to pollute entire code with a custom wrapper for a byte array for this one sole purpose. My project is not Erlang-first oriented. Regarding 3, I am out of tears already.

Is there any better way around it? If not, could this be a feature request?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions