Skip to main content

decode_enum_field

Function decode_enum_field 

Source
pub(crate) fn decode_enum_field<'a, T>(
    raw: i32,
    message: &'static str,
    field: &'static str,
) -> Value<'a>
where T: TryFrom<i32> + ValueEnum,
Expand description

Decode a raw protobuf enum field (i32) into its shared Value rendering: convert to the enum type and then to its &Variant string, or produce a field-specific diagnostic when the raw value matches no variant.

Keeps the decode-or-diagnose shape in one place for callers that render an enum field straight from its i32 (currently SetRel’s op). message is the proto message tag used for the failure token, field the offending field name; both are named in the diagnostic so it identifies which field carried the unknown value.