Skip to main content

JsonExtEntry

Struct JsonExtEntry 

Source
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>,
}
Available on crate feature 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: u32

Field number on the extendee.

§full_name: &'static str

Fully-qualified proto name. The JSON key is "[<this>]".

§extendee: &'static str

Fully-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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.