pub trait ProtobufType {
    type Value: ProtobufValue + Clone + 'static;

    // Required methods
    fn wire_type() -> WireType;
    fn read(is: &mut CodedInputStream<'_>) -> ProtobufResult<Self::Value>;
    fn compute_size(value: &Self::Value) -> u32;
    fn get_from_unknown(unknown_values: &UnknownValues) -> Option<Self::Value>;
    fn write_with_cached_size(
        field_number: u32,
        value: &Self::Value,
        os: &mut CodedOutputStream<'_>
    ) -> ProtobufResult<()>;

    // Provided methods
    fn compute_size_with_length_delimiter(value: &Self::Value) -> u32 { ... }
    fn get_cached_size(value: &Self::Value) -> u32 { ... }
    fn get_cached_size_with_length_delimiter(value: &Self::Value) -> u32 { ... }
}
Expand description

Protobuf elementary type as generic trait

Required Associated Types§

source

type Value: ProtobufValue + Clone + 'static

Rust type of value

Required Methods§

source

fn wire_type() -> WireType

Wire type when writing to stream

source

fn read(is: &mut CodedInputStream<'_>) -> ProtobufResult<Self::Value>

Read value from CodedInputStream

source

fn compute_size(value: &Self::Value) -> u32

Compute wire size

source

fn get_from_unknown(unknown_values: &UnknownValues) -> Option<Self::Value>

Get value from UnknownValues

source

fn write_with_cached_size( field_number: u32, value: &Self::Value, os: &mut CodedOutputStream<'_> ) -> ProtobufResult<()>

Write a value with previously cached size

Provided Methods§

source

fn compute_size_with_length_delimiter(value: &Self::Value) -> u32

Compute size adding length prefix if wire type is length delimited (i. e. string, bytes, message)

source

fn get_cached_size(value: &Self::Value) -> u32

Get previously computed size

source

fn get_cached_size_with_length_delimiter(value: &Self::Value) -> u32

Get previously cached size with length prefix

Implementors§