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
Prior to this change, the `exit_codes` fields for the resource and
extension manifests defined the map of exit codes to their semantic
meanings as `Option<HashMap<String, String>>`.
As part of schema canonicalization, we need to provide a canonical
JSON Schema for that object. Unfortunately, because we don't own either
the `JsonSchema` trait or `HashMap<T>` type, we need to use a newtype
wrapper.
This change defines two new types:
- `ExitCode` as a lightweight wrapper around `i32` where we can control
serialization and deserialization with strings as the serialized
format instead of an integer.
- `ExitCodeMap` as a lightweight wrapper for `HashMap<ExitCode, String>`.
It implements a helper function for determining whether the map is
empty or default and defines the default map for exit `0` (success)
and `1` (error).
The `ExitCodeMap` includes a hand-implementation of `JsonSchema` to
match the canonical JSON Schema, which `schemars` won't generate from
the struct definition.
This change not only enables us to provide the canonical JSON Schema
for exit code fields in a reusable way, it also removes the need to
maintain a converter function for transforming the exit codes map from
`HashMap<String, String>` to `HashMap<i32, String>`.
0 commit comments