Struct httlib_protos::encoder::Encoder [−][src]
pub struct Encoder;Expand description
Provides the encoding engine for Protocol Buffers.
Implementations
Transforms a field into proto3 binary format and writes the result
into dst.
By default, the encoder uses mostly “standard” variant formats for
numbers. A developer can choose a specific format by passing the
EncoderLit.
use httlib_protos::{Encoder, EncoderLit};
let encoder = Encoder::default();
let mut dst = Vec::new();
encoder.encode((1, &150i32), &mut dst).unwrap();
encoder.encode((2, EncoderLit::SInt32(&-150i32)), &mut dst).unwrap();On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_bool<W>(
&self,
tag: u32,
val: &bool,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_bool<W>(
&self,
tag: u32,
val: &bool,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into bool field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into bool repeated field with a specific
tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_int32<W>(
&self,
tag: u32,
val: &i32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_int32<W>(
&self,
tag: u32,
val: &i32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into int32 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into int32 repeated field with a specific
tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_int64<W>(
&self,
tag: u32,
val: &i64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_int64<W>(
&self,
tag: u32,
val: &i64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into int64 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into int64 repeated field with a specific
tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_uint32<W>(
&self,
tag: u32,
val: &u32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_uint32<W>(
&self,
tag: u32,
val: &u32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into uint32 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into uint32 repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_uint64<W>(
&self,
tag: u32,
val: &u64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_uint64<W>(
&self,
tag: u32,
val: &u64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into uint64 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into uint64 repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_float<W>(
&self,
tag: u32,
val: &f32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_float<W>(
&self,
tag: u32,
val: &f32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into float field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into float repeated field with a specific
tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_double<W>(
&self,
tag: u32,
val: &f64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_double<W>(
&self,
tag: u32,
val: &f64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into double field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into double repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided val into bytes field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_sint32<W>(
&self,
tag: u32,
val: &i32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_sint32<W>(
&self,
tag: u32,
val: &i32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into sint32 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into sin32 repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_sint64<W>(
&self,
tag: u32,
val: &i64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_sint64<W>(
&self,
tag: u32,
val: &i64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into sint64 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into sin64 repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_fixed32<W>(
&self,
tag: u32,
val: &u32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_fixed32<W>(
&self,
tag: u32,
val: &u32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into fixed32 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into fixed32 repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_fixed64<W>(
&self,
tag: u32,
val: &u64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_fixed64<W>(
&self,
tag: u32,
val: &u64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into fixed64 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into fixed64 repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_sfixed32<W>(
&self,
tag: u32,
val: &i32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_sfixed32<W>(
&self,
tag: u32,
val: &i32,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into sfixed32 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into sfixed32 repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
pub fn encode_sfixed64<W>(
&self,
tag: u32,
val: &i64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
pub fn encode_sfixed64<W>(
&self,
tag: u32,
val: &i64,
dst: &mut W
) -> Result<usize, EncoderError> where
W: ?Sized + Write,
Encodes the provided val into sfixed64 field with a specific tag
number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.
Encodes the provided vals into sfixed64 repeated field with a
specific tag number and writes the resulting bytes into dst.
On success the number of written bytes is returned otherwise an error is thrown.