pub unsafe trait Value: Default + Eq {
const WIRE_TYPE: WireType;
// Required methods
fn proto_len(&self) -> u64;
fn encode<W: Write>(&self, writer: &mut W) -> Result<()>;
}Expand description
Required Associated Constants§
Required Methods§
Sourcefn proto_len(&self) -> u64
fn proto_len(&self) -> u64
The number of bytes it takes to encode this value. Do not include the number of bytes it takes to encode the length-prefix as a varint. For example, using this snippet of the reference:
len-prefix := size (message | string | packed);
size encoded as int32 varintCalculate the number of bytes for (message | string | packed) only.
For a varint, returns between 1 and 10 bytes for the number of bytes used to encode the varint.
Returns u64 rather than u31 to avoid a lot of overflow checking.
Sourcefn encode<W: Write>(&self, writer: &mut W) -> Result<()>
fn encode<W: Write>(&self, writer: &mut W) -> Result<()>
Encode the value to the in-wire protobuf format. For length-delimited
types, do not include the length-prefix; see Value::proto_len for
more details.
Encoding often happens one byte at a time, so a buffered writer should probably be used.
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.
Implementations on Foreign Types§
Source§impl<T: Value> Value for &[T]
§Safety
The Default implementation will return all zero-representations.
impl<T: Value> Value for &[T]
§Safety
The Default implementation will return all zero-representations.
Implementors§
Source§impl Value for Function
§Safety
The Default implementation will return all zero-representations.
impl Value for Function
§Safety
The Default implementation will return all zero-representations.
Source§impl Value for Location
§Safety
The Default implementation will return all zero-representations.
impl Value for Location
§Safety
The Default implementation will return all zero-representations.
Source§impl Value for Mapping
§Safety
The Default implementation will return all zero-representations.
impl Value for Mapping
§Safety
The Default implementation will return all zero-representations.
Source§impl Value for Sample<'_>
§Safety
The Default implementation will return all zero-representations.
impl Value for Sample<'_>
§Safety
The Default implementation will return all zero-representations.
Source§impl Value for StringOffset
§Safety
The Default implementation will return all zero-representations.
impl Value for StringOffset
§Safety
The Default implementation will return all zero-representations.