serde-rs / serde-rs/bytes

How to handle Vec<Vec<u8>>

Open
#29 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
384
Forks
40
PR merge metrics
No merged PRs in 30d

Description

Hi,
i have a message to send in the form of:

type PubKey = Vec<u8>;

#[derive(Serialize, Deserialize, Debug)]
#[serde(tag="kind")]
pub enum Envelope<T> {
    Greeting {
        #[serde(with="serde_bytes")]
        id: PubKey,
        #[serde(with="serde_bytes")]
        shared: PubKey,
        thin: bool
    },
    AllKnown { 
        all_known: Vec<PubKey>
    },
}

As you can see, PubKey is only a Vec<u8>, what is the most idiomatic way to pack this. I do not want to put the Vec<u8> in a struct to use serde_bytes.
Is there something i am missing?
It would be really neat to annotated all_known just with #[serde(with="serde_bytes")].
It seems a pretty common problem to be to have an array of byte arrays.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the serde_bytes annotations and the Vec field shown in the issue. Review the repository’s existing handling and tests for byte vectors, then determine the intended API for collections of byte arrays. Done means the requested representation is supported or the limitation is documented with coverage for the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.