pub trait NativeType: PartialEq + Default + Sized + Debug {
    const TYPE: WireType;

    // Required methods
    fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>;
    fn encode_value(&self, dst: &mut BytesMut);

    // Provided methods
    fn value_len(&self) -> usize { ... }
    fn is_default(&self) -> bool { ... }
    fn encode_type(&self, tag: u32, dst: &mut BytesMut) { ... }
    fn encoded_len(&self, tag: u32) -> usize { ... }
    fn serialize(
        &self,
        tag: u32,
        default: DefaultValue<&Self>,
        dst: &mut BytesMut
    ) { ... }
    fn serialized_len(&self, tag: u32, default: DefaultValue<&Self>) -> usize { ... }
    fn deserialize(
        &mut self,
        _: u32,
        wtype: WireType,
        src: &mut Bytes
    ) -> Result<(), DecodeError> { ... }
    fn deserialize_default(
        tag: u32,
        wtype: WireType,
        src: &mut Bytes
    ) -> Result<Self, DecodeError> { ... }
}
Expand description

Protobuf type serializer

Required Associated Constants§

Required Methods§

source

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

Deserialize from the input

source

fn encode_value(&self, dst: &mut BytesMut)

Encode field value

Provided Methods§

source

fn value_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.

source

fn is_default(&self) -> bool

Check if value is default

source

fn encode_type(&self, tag: u32, dst: &mut BytesMut)

Encode field tag and length

source

fn encoded_len(&self, tag: u32) -> usize

Protobuf field length

source

fn serialize(&self, tag: u32, default: DefaultValue<&Self>, dst: &mut BytesMut)

Serialize protobuf field

source

fn serialized_len(&self, tag: u32, default: DefaultValue<&Self>) -> usize

Protobuf field length

source

fn deserialize( &mut self, _: u32, wtype: WireType, src: &mut Bytes ) -> Result<(), DecodeError>

Deserialize protobuf field

source

fn deserialize_default( tag: u32, wtype: WireType, src: &mut Bytes ) -> Result<Self, DecodeError>

Deserialize protobuf field to default value

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl NativeType for bool

source§

const TYPE: WireType = WireType::Varint

source§

fn is_default(&self) -> bool

source§

fn encode_value(&self, dst: &mut BytesMut)

source§

fn encoded_len(&self, tag: u32) -> usize

source§

fn value_len(&self) -> usize

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

source§

impl NativeType for i32

source§

const TYPE: WireType = WireType::Varint

source§

fn is_default(&self) -> bool

source§

fn encode_value(&self, dst: &mut BytesMut)

source§

fn encoded_len(&self, tag: u32) -> usize

source§

fn value_len(&self) -> usize

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

source§

impl NativeType for i64

source§

const TYPE: WireType = WireType::Varint

source§

fn is_default(&self) -> bool

source§

fn encode_value(&self, dst: &mut BytesMut)

source§

fn encoded_len(&self, tag: u32) -> usize

source§

fn value_len(&self) -> usize

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

source§

impl NativeType for u32

source§

const TYPE: WireType = WireType::Varint

source§

fn is_default(&self) -> bool

source§

fn encode_value(&self, dst: &mut BytesMut)

source§

fn encoded_len(&self, tag: u32) -> usize

source§

fn value_len(&self) -> usize

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

source§

impl NativeType for u64

source§

const TYPE: WireType = WireType::Varint

source§

fn is_default(&self) -> bool

source§

fn encode_value(&self, dst: &mut BytesMut)

source§

fn encoded_len(&self, tag: u32) -> usize

source§

fn value_len(&self) -> usize

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

source§

impl NativeType for String

source§

const TYPE: WireType = WireType::LengthDelimited

source§

fn value_len(&self) -> usize

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

source§

fn encode_value(&self, dst: &mut BytesMut)

source§

fn is_default(&self) -> bool

source§

impl NativeType for Vec<u8>

source§

fn encode_value(&self, dst: &mut BytesMut)

Serialize field value

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

Deserialize from the input

source§

const TYPE: WireType = WireType::LengthDelimited

source§

fn value_len(&self) -> usize

source§

fn is_default(&self) -> bool

source§

impl NativeType for Bytes

source§

fn encode_value(&self, dst: &mut BytesMut)

Serialize field value

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

Deserialize from the input

source§

const TYPE: WireType = WireType::LengthDelimited

source§

fn value_len(&self) -> usize

source§

fn is_default(&self) -> bool

source§

impl NativeType for ByteString

source§

const TYPE: WireType = WireType::LengthDelimited

source§

fn value_len(&self) -> usize

source§

fn merge(&mut self, src: &mut Bytes) -> Result<(), DecodeError>

source§

fn encode_value(&self, dst: &mut BytesMut)

source§

fn is_default(&self) -> bool

source§

impl<K: NativeType + Eq + Hash, V: NativeType, S: BuildHasher + Default> NativeType for HashMap<K, V, S>

source§

fn merge(&mut self, _: &mut Bytes) -> Result<(), DecodeError>

Deserialize from the input

source§

fn encode_value(&self, _: &mut BytesMut)

Serialize field value

source§

fn deserialize( &mut self, _: u32, wtype: WireType, src: &mut Bytes ) -> Result<(), DecodeError>

Deserialize protobuf field

source§

fn serialize(&self, tag: u32, _: DefaultValue<&Self>, dst: &mut BytesMut)

Serialize protobuf field

source§

fn encoded_len(&self, tag: u32) -> usize

Generic protobuf map encode function with an overridden value default.

source§

const TYPE: WireType = WireType::LengthDelimited

source§

fn is_default(&self) -> bool

source§

impl<T: NativeType> NativeType for Option<T>

source§

fn encode_value(&self, _: &mut BytesMut)

Serialize field value

source§

fn merge(&mut self, _: &mut Bytes) -> Result<(), DecodeError>

Deserialize from the input

source§

fn deserialize( &mut self, tag: u32, wtype: WireType, src: &mut Bytes ) -> Result<(), DecodeError>

Deserialize protobuf field

source§

fn serialize(&self, tag: u32, _: DefaultValue<&Self>, dst: &mut BytesMut)

Serialize protobuf field

source§

fn serialized_len(&self, tag: u32, _: DefaultValue<&Self>) -> usize

Protobuf field length

source§

fn encoded_len(&self, tag: u32) -> usize

Protobuf field length

source§

const TYPE: WireType = WireType::LengthDelimited

source§

fn is_default(&self) -> bool

source§

impl<T: NativeType> NativeType for Vec<T>

source§

fn encode_value(&self, _: &mut BytesMut)

Serialize field value

source§

fn merge(&mut self, _: &mut Bytes) -> Result<(), DecodeError>

Deserialize from the input

source§

fn deserialize( &mut self, tag: u32, wtype: WireType, src: &mut Bytes ) -> Result<(), DecodeError>

Deserialize protobuf field

source§

fn serialize(&self, tag: u32, _: DefaultValue<&Self>, dst: &mut BytesMut)

Serialize protobuf field

source§

fn encoded_len(&self, tag: u32) -> usize

Protobuf field length

source§

const TYPE: WireType = WireType::LengthDelimited

source§

fn is_default(&self) -> bool

Implementors§

source§

impl<T: Message + PartialEq> NativeType for T

source§

const TYPE: WireType = WireType::LengthDelimited