Struct protobuf::CodedOutputStream
source · pub struct CodedOutputStream<'a> { /* private fields */ }
Expand description
Buffered write with handy utilities
Implementations§
source§impl<'a> CodedOutputStream<'a>
impl<'a> CodedOutputStream<'a>
sourcepub fn new(writer: &'a mut dyn Write) -> CodedOutputStream<'a> ⓘ
pub fn new(writer: &'a mut dyn Write) -> CodedOutputStream<'a> ⓘ
Construct from given Write
.
CodedOutputStream
is buffered even if Write
is not
sourcepub fn bytes(bytes: &'a mut [u8]) -> CodedOutputStream<'a> ⓘ
pub fn bytes(bytes: &'a mut [u8]) -> CodedOutputStream<'a> ⓘ
CodedOutputStream
which writes directly to bytes.
Attempt to write more than bytes capacity results in error.
sourcepub fn vec(vec: &'a mut Vec<u8>) -> CodedOutputStream<'a> ⓘ
pub fn vec(vec: &'a mut Vec<u8>) -> CodedOutputStream<'a> ⓘ
CodedOutputStream
which writes directly to Vec<u8>
.
Caller should call flush
at the end to guarantee vec contains
all written data.
sourcepub fn flush(&mut self) -> ProtobufResult<()>
pub fn flush(&mut self) -> ProtobufResult<()>
Flush the buffer to underlying write
sourcepub fn write_raw_byte(&mut self, byte: u8) -> ProtobufResult<()>
pub fn write_raw_byte(&mut self, byte: u8) -> ProtobufResult<()>
Write a byte
sourcepub fn write_raw_bytes(&mut self, bytes: &[u8]) -> ProtobufResult<()>
pub fn write_raw_bytes(&mut self, bytes: &[u8]) -> ProtobufResult<()>
Write bytes
sourcepub fn write_tag(
&mut self,
field_number: u32,
wire_type: WireType
) -> ProtobufResult<()>
pub fn write_tag( &mut self, field_number: u32, wire_type: WireType ) -> ProtobufResult<()>
Write a tag
sourcepub fn write_raw_varint32(&mut self, value: u32) -> ProtobufResult<()>
pub fn write_raw_varint32(&mut self, value: u32) -> ProtobufResult<()>
Write varint
sourcepub fn write_raw_varint64(&mut self, value: u64) -> ProtobufResult<()>
pub fn write_raw_varint64(&mut self, value: u64) -> ProtobufResult<()>
Write varint
sourcepub fn write_raw_little_endian32(&mut self, value: u32) -> ProtobufResult<()>
pub fn write_raw_little_endian32(&mut self, value: u32) -> ProtobufResult<()>
Write 32-bit integer little endian
sourcepub fn write_raw_little_endian64(&mut self, value: u64) -> ProtobufResult<()>
pub fn write_raw_little_endian64(&mut self, value: u64) -> ProtobufResult<()>
Write 64-bit integer little endian
sourcepub fn write_float_no_tag(&mut self, value: f32) -> ProtobufResult<()>
pub fn write_float_no_tag(&mut self, value: f32) -> ProtobufResult<()>
Write float
sourcepub fn write_double_no_tag(&mut self, value: f64) -> ProtobufResult<()>
pub fn write_double_no_tag(&mut self, value: f64) -> ProtobufResult<()>
Write double
sourcepub fn write_float(
&mut self,
field_number: u32,
value: f32
) -> ProtobufResult<()>
pub fn write_float( &mut self, field_number: u32, value: f32 ) -> ProtobufResult<()>
Write float
field
sourcepub fn write_double(
&mut self,
field_number: u32,
value: f64
) -> ProtobufResult<()>
pub fn write_double( &mut self, field_number: u32, value: f64 ) -> ProtobufResult<()>
Write double
field
sourcepub fn write_uint64_no_tag(&mut self, value: u64) -> ProtobufResult<()>
pub fn write_uint64_no_tag(&mut self, value: u64) -> ProtobufResult<()>
Write varint
sourcepub fn write_uint32_no_tag(&mut self, value: u32) -> ProtobufResult<()>
pub fn write_uint32_no_tag(&mut self, value: u32) -> ProtobufResult<()>
Write varint
sourcepub fn write_int64_no_tag(&mut self, value: i64) -> ProtobufResult<()>
pub fn write_int64_no_tag(&mut self, value: i64) -> ProtobufResult<()>
Write varint
sourcepub fn write_int32_no_tag(&mut self, value: i32) -> ProtobufResult<()>
pub fn write_int32_no_tag(&mut self, value: i32) -> ProtobufResult<()>
Write varint
sourcepub fn write_sint64_no_tag(&mut self, value: i64) -> ProtobufResult<()>
pub fn write_sint64_no_tag(&mut self, value: i64) -> ProtobufResult<()>
Write zigzag varint
sourcepub fn write_sint32_no_tag(&mut self, value: i32) -> ProtobufResult<()>
pub fn write_sint32_no_tag(&mut self, value: i32) -> ProtobufResult<()>
Write zigzag varint
sourcepub fn write_fixed64_no_tag(&mut self, value: u64) -> ProtobufResult<()>
pub fn write_fixed64_no_tag(&mut self, value: u64) -> ProtobufResult<()>
Write fixed64
sourcepub fn write_fixed32_no_tag(&mut self, value: u32) -> ProtobufResult<()>
pub fn write_fixed32_no_tag(&mut self, value: u32) -> ProtobufResult<()>
Write fixed32
sourcepub fn write_sfixed64_no_tag(&mut self, value: i64) -> ProtobufResult<()>
pub fn write_sfixed64_no_tag(&mut self, value: i64) -> ProtobufResult<()>
Write sfixed64
sourcepub fn write_sfixed32_no_tag(&mut self, value: i32) -> ProtobufResult<()>
pub fn write_sfixed32_no_tag(&mut self, value: i32) -> ProtobufResult<()>
Write sfixed32
sourcepub fn write_bool_no_tag(&mut self, value: bool) -> ProtobufResult<()>
pub fn write_bool_no_tag(&mut self, value: bool) -> ProtobufResult<()>
Write bool
sourcepub fn write_enum_no_tag(&mut self, value: i32) -> ProtobufResult<()>
pub fn write_enum_no_tag(&mut self, value: i32) -> ProtobufResult<()>
Write enum
sourcepub fn write_enum_obj_no_tag<E>(&mut self, value: E) -> ProtobufResult<()>where
E: ProtobufEnum,
pub fn write_enum_obj_no_tag<E>(&mut self, value: E) -> ProtobufResult<()>where E: ProtobufEnum,
Write enum
sourcepub fn write_unknown_no_tag(
&mut self,
unknown: UnknownValueRef<'_>
) -> ProtobufResult<()>
pub fn write_unknown_no_tag( &mut self, unknown: UnknownValueRef<'_> ) -> ProtobufResult<()>
Write unknown value
sourcepub fn write_uint64(
&mut self,
field_number: u32,
value: u64
) -> ProtobufResult<()>
pub fn write_uint64( &mut self, field_number: u32, value: u64 ) -> ProtobufResult<()>
Write uint64
field
sourcepub fn write_uint32(
&mut self,
field_number: u32,
value: u32
) -> ProtobufResult<()>
pub fn write_uint32( &mut self, field_number: u32, value: u32 ) -> ProtobufResult<()>
Write uint32
field
sourcepub fn write_int64(
&mut self,
field_number: u32,
value: i64
) -> ProtobufResult<()>
pub fn write_int64( &mut self, field_number: u32, value: i64 ) -> ProtobufResult<()>
Write int64
field
sourcepub fn write_int32(
&mut self,
field_number: u32,
value: i32
) -> ProtobufResult<()>
pub fn write_int32( &mut self, field_number: u32, value: i32 ) -> ProtobufResult<()>
Write int32
field
sourcepub fn write_sint64(
&mut self,
field_number: u32,
value: i64
) -> ProtobufResult<()>
pub fn write_sint64( &mut self, field_number: u32, value: i64 ) -> ProtobufResult<()>
Write sint64
field
sourcepub fn write_sint32(
&mut self,
field_number: u32,
value: i32
) -> ProtobufResult<()>
pub fn write_sint32( &mut self, field_number: u32, value: i32 ) -> ProtobufResult<()>
Write sint32
field
sourcepub fn write_fixed64(
&mut self,
field_number: u32,
value: u64
) -> ProtobufResult<()>
pub fn write_fixed64( &mut self, field_number: u32, value: u64 ) -> ProtobufResult<()>
Write fixed64
field
sourcepub fn write_fixed32(
&mut self,
field_number: u32,
value: u32
) -> ProtobufResult<()>
pub fn write_fixed32( &mut self, field_number: u32, value: u32 ) -> ProtobufResult<()>
Write fixed32
field
sourcepub fn write_sfixed64(
&mut self,
field_number: u32,
value: i64
) -> ProtobufResult<()>
pub fn write_sfixed64( &mut self, field_number: u32, value: i64 ) -> ProtobufResult<()>
Write sfixed64
field
sourcepub fn write_sfixed32(
&mut self,
field_number: u32,
value: i32
) -> ProtobufResult<()>
pub fn write_sfixed32( &mut self, field_number: u32, value: i32 ) -> ProtobufResult<()>
Write sfixed32
field
sourcepub fn write_bool(
&mut self,
field_number: u32,
value: bool
) -> ProtobufResult<()>
pub fn write_bool( &mut self, field_number: u32, value: bool ) -> ProtobufResult<()>
Write bool
field
sourcepub fn write_enum(
&mut self,
field_number: u32,
value: i32
) -> ProtobufResult<()>
pub fn write_enum( &mut self, field_number: u32, value: i32 ) -> ProtobufResult<()>
Write enum
field
sourcepub fn write_enum_obj<E>(
&mut self,
field_number: u32,
value: E
) -> ProtobufResult<()>where
E: ProtobufEnum,
pub fn write_enum_obj<E>( &mut self, field_number: u32, value: E ) -> ProtobufResult<()>where E: ProtobufEnum,
Write enum
field
sourcepub fn write_unknown(
&mut self,
field_number: u32,
value: UnknownValueRef<'_>
) -> ProtobufResult<()>
pub fn write_unknown( &mut self, field_number: u32, value: UnknownValueRef<'_> ) -> ProtobufResult<()>
Write unknown field
sourcepub fn write_unknown_fields(
&mut self,
fields: &UnknownFields
) -> ProtobufResult<()>
pub fn write_unknown_fields( &mut self, fields: &UnknownFields ) -> ProtobufResult<()>
Write unknown fields
sourcepub fn write_bytes_no_tag(&mut self, bytes: &[u8]) -> ProtobufResult<()>
pub fn write_bytes_no_tag(&mut self, bytes: &[u8]) -> ProtobufResult<()>
Write bytes
sourcepub fn write_string_no_tag(&mut self, s: &str) -> ProtobufResult<()>
pub fn write_string_no_tag(&mut self, s: &str) -> ProtobufResult<()>
Write string
sourcepub fn write_message_no_tag<M: Message>(
&mut self,
msg: &M
) -> ProtobufResult<()>
pub fn write_message_no_tag<M: Message>( &mut self, msg: &M ) -> ProtobufResult<()>
Write message
sourcepub fn write_bytes(
&mut self,
field_number: u32,
bytes: &[u8]
) -> ProtobufResult<()>
pub fn write_bytes( &mut self, field_number: u32, bytes: &[u8] ) -> ProtobufResult<()>
Write bytes
field
sourcepub fn write_string(&mut self, field_number: u32, s: &str) -> ProtobufResult<()>
pub fn write_string(&mut self, field_number: u32, s: &str) -> ProtobufResult<()>
Write string
field
sourcepub fn write_message<M: Message>(
&mut self,
field_number: u32,
msg: &M
) -> ProtobufResult<()>
pub fn write_message<M: Message>( &mut self, field_number: u32, msg: &M ) -> ProtobufResult<()>
Write message
field
Trait Implementations§
source§impl<'a> Write for CodedOutputStream<'a>
impl<'a> Write for CodedOutputStream<'a>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)