oxidecomputer / amd-apcb

AMD Generic Encapsulated Software Architecture Platform Security Processor Configuration Block manipulation library
Mozilla Public License 2.0
14 stars 2 forks source link

Cargo: Factor out serde_hex to optional "serde-hex" feature. #36

Closed daym closed 2 years ago

daym commented 2 years ago

This is so that users can use either Rust's json5 crate (and they would disable serde-hex in amd-apcb) or just Rust's serde_json crate (and they would enable the feature serde-hex in amd-apcb).

The new feature is the support of the json5 crate.

JSON5 is a superset of JSON. JSON5 still evaluate fine when interpreted as Javascript, but cannot be loaded by Javascript's JSON.parse.

The advantages of JSON5 useful to us are:

Note that this PR doesn't make it mandatory to use json5 in any way.

The intent is also to leave SerdeHex* structs private as an implementation detail, so whether or not the feature serde-hex is enabled should not affect the API in any way, except for Serde traits.

amd-host-image-builder, if unchanged except for the updated amd-apcb reference, would have to enable the feature serde-hex.

(A JSON5-aware amd-host-image-builder has been written and PR will be forthcoming)