Trait protobuf::types::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§
sourcetype Value: ProtobufValue + Clone + 'static
type Value: ProtobufValue + Clone + 'static
Rust type of value
Required Methods§
sourcefn read(is: &mut CodedInputStream<'_>) -> ProtobufResult<Self::Value>
fn read(is: &mut CodedInputStream<'_>) -> ProtobufResult<Self::Value>
Read value from CodedInputStream
sourcefn compute_size(value: &Self::Value) -> u32
fn compute_size(value: &Self::Value) -> u32
Compute wire size
sourcefn get_from_unknown(unknown_values: &UnknownValues) -> Option<Self::Value>
fn get_from_unknown(unknown_values: &UnknownValues) -> Option<Self::Value>
Get value from UnknownValues
sourcefn write_with_cached_size(
field_number: u32,
value: &Self::Value,
os: &mut CodedOutputStream<'_>
) -> ProtobufResult<()>
fn write_with_cached_size( field_number: u32, value: &Self::Value, os: &mut CodedOutputStream<'_> ) -> ProtobufResult<()>
Write a value with previously cached size
Provided Methods§
sourcefn compute_size_with_length_delimiter(value: &Self::Value) -> u32
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)
sourcefn get_cached_size(value: &Self::Value) -> u32
fn get_cached_size(value: &Self::Value) -> u32
Get previously computed size
sourcefn get_cached_size_with_length_delimiter(value: &Self::Value) -> u32
fn get_cached_size_with_length_delimiter(value: &Self::Value) -> u32
Get previously cached size with length prefix