protobuf::types

Trait ProtobufType

Source
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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§