pub struct JsonExtEntry {
pub number: u32,
pub full_name: &'static str,
pub extendee: &'static str,
pub to_json: fn(u32, &UnknownFields) -> Result<Value, String>,
pub from_json: fn(Value, u32) -> Result<Vec<UnknownField>, String>,
}json only.Expand description
JSON-specific registry entry for a single extension field.
The to_json / from_json function pointers are monomorphized per proto
type by codegen — they compose an ExtensionCodec
decode/encode with the proto3 JSON rules for that type (int64 stringify,
bytes base64, message-as-object, etc.).
Text-format conversion lives in a separate TextExtEntry — the two
entry types are per-feature split so json and text are independently
enableable.
Fields§
§number: u32Field number on the extendee.
full_name: &'static strFully-qualified proto name. The JSON key is "[<this>]".
extendee: &'static strFully-qualified extendee message name (no leading dot). Used both for
the serialize-side (extendee, number) lookup and for rejecting
wrong-extendee parses on the deserialize side.
to_json: fn(u32, &UnknownFields) -> Result<Value, String>Extract this extension’s value from the extendee’s unknown fields and serialize it to a JSON value.
from_json: fn(Value, u32) -> Result<Vec<UnknownField>, String>Parse a JSON value into unknown-field records at the given number. The
function owns the ProtoJSON null policy: returning an empty vector
means the recognized key is absent and no record is added. Hand-written
entries may choose a different policy.