rust-italia / dgc

A parser and validator for the EU Digital Green Certificate (dgc) a.k.a. greenpass

Home Page:https://github.com/rust-italia/dgc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rename all "cryptic" fields into more descriptive names

lmammino opened this issue · comments

We are currently taking a mixed approach to field naming:

  • All the numeric fields are converted to more descriptive equivalents (e.g. 1 is converted to issuer in DgcCertContainer)
  • Every other fields is not renamed and we end up with things like: fn rather than something more descriptive like family_name.

I'd like to go for a descriptive approach, leaving to serde the responsability to rename the fields back to their original format in case we want to re-serialise the structs (for instance to JSON).

As an example (suggested by @dodomorandi in #27):

struct x {
    #[serde(skip_serializing_if = "Option::is_none", rename = "fn")]
    pub family_name: Option<String>,
}

In the example above we are deserialising the field fn to family_name (better api for the user) but we tell serde to serialise it back to fn if we have to serialise the struct again (e.g. to JSON).

Since this will be a significant breaking change, I'd like to mark this for 0.1.0. But I suggest it's tackled as part of #6!