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) -> Result<(), ProtobufError>
pub fn flush(&mut self) -> Result<(), ProtobufError>
Flush the buffer to underlying write
Sourcepub fn write_raw_byte(&mut self, byte: u8) -> Result<(), ProtobufError>
pub fn write_raw_byte(&mut self, byte: u8) -> Result<(), ProtobufError>
Write a byte
Sourcepub fn write_raw_bytes(&mut self, bytes: &[u8]) -> Result<(), ProtobufError>
pub fn write_raw_bytes(&mut self, bytes: &[u8]) -> Result<(), ProtobufError>
Write bytes
Sourcepub fn write_tag(
&mut self,
field_number: u32,
wire_type: WireType,
) -> Result<(), ProtobufError>
pub fn write_tag( &mut self, field_number: u32, wire_type: WireType, ) -> Result<(), ProtobufError>
Write a tag
Sourcepub fn write_raw_varint32(&mut self, value: u32) -> Result<(), ProtobufError>
pub fn write_raw_varint32(&mut self, value: u32) -> Result<(), ProtobufError>
Write varint
Sourcepub fn write_raw_varint64(&mut self, value: u64) -> Result<(), ProtobufError>
pub fn write_raw_varint64(&mut self, value: u64) -> Result<(), ProtobufError>
Write varint
Sourcepub fn write_raw_little_endian32(
&mut self,
value: u32,
) -> Result<(), ProtobufError>
pub fn write_raw_little_endian32( &mut self, value: u32, ) -> Result<(), ProtobufError>
Write 32-bit integer little endian
Sourcepub fn write_raw_little_endian64(
&mut self,
value: u64,
) -> Result<(), ProtobufError>
pub fn write_raw_little_endian64( &mut self, value: u64, ) -> Result<(), ProtobufError>
Write 64-bit integer little endian
Sourcepub fn write_float_no_tag(&mut self, value: f32) -> Result<(), ProtobufError>
pub fn write_float_no_tag(&mut self, value: f32) -> Result<(), ProtobufError>
Write float
Sourcepub fn write_double_no_tag(&mut self, value: f64) -> Result<(), ProtobufError>
pub fn write_double_no_tag(&mut self, value: f64) -> Result<(), ProtobufError>
Write double
Sourcepub fn write_float(
&mut self,
field_number: u32,
value: f32,
) -> Result<(), ProtobufError>
pub fn write_float( &mut self, field_number: u32, value: f32, ) -> Result<(), ProtobufError>
Write float
field
Sourcepub fn write_double(
&mut self,
field_number: u32,
value: f64,
) -> Result<(), ProtobufError>
pub fn write_double( &mut self, field_number: u32, value: f64, ) -> Result<(), ProtobufError>
Write double
field
Sourcepub fn write_uint64_no_tag(&mut self, value: u64) -> Result<(), ProtobufError>
pub fn write_uint64_no_tag(&mut self, value: u64) -> Result<(), ProtobufError>
Write varint
Sourcepub fn write_uint32_no_tag(&mut self, value: u32) -> Result<(), ProtobufError>
pub fn write_uint32_no_tag(&mut self, value: u32) -> Result<(), ProtobufError>
Write varint
Sourcepub fn write_int64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>
pub fn write_int64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>
Write varint
Sourcepub fn write_int32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>
pub fn write_int32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>
Write varint
Sourcepub fn write_sint64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>
pub fn write_sint64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>
Write zigzag varint
Sourcepub fn write_sint32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>
pub fn write_sint32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>
Write zigzag varint
Sourcepub fn write_fixed64_no_tag(&mut self, value: u64) -> Result<(), ProtobufError>
pub fn write_fixed64_no_tag(&mut self, value: u64) -> Result<(), ProtobufError>
Write fixed64
Sourcepub fn write_fixed32_no_tag(&mut self, value: u32) -> Result<(), ProtobufError>
pub fn write_fixed32_no_tag(&mut self, value: u32) -> Result<(), ProtobufError>
Write fixed32
Sourcepub fn write_sfixed64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>
pub fn write_sfixed64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>
Write sfixed64
Sourcepub fn write_sfixed32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>
pub fn write_sfixed32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>
Write sfixed32
Sourcepub fn write_bool_no_tag(&mut self, value: bool) -> Result<(), ProtobufError>
pub fn write_bool_no_tag(&mut self, value: bool) -> Result<(), ProtobufError>
Write bool
Sourcepub fn write_enum_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>
pub fn write_enum_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>
Write enum
Sourcepub fn write_enum_obj_no_tag<E>(
&mut self,
value: E,
) -> Result<(), ProtobufError>where
E: ProtobufEnum,
pub fn write_enum_obj_no_tag<E>(
&mut self,
value: E,
) -> Result<(), ProtobufError>where
E: ProtobufEnum,
Write enum
Sourcepub fn write_unknown_no_tag(
&mut self,
unknown: UnknownValueRef<'_>,
) -> Result<(), ProtobufError>
pub fn write_unknown_no_tag( &mut self, unknown: UnknownValueRef<'_>, ) -> Result<(), ProtobufError>
Write unknown value
Sourcepub fn write_uint64(
&mut self,
field_number: u32,
value: u64,
) -> Result<(), ProtobufError>
pub fn write_uint64( &mut self, field_number: u32, value: u64, ) -> Result<(), ProtobufError>
Write uint64
field
Sourcepub fn write_uint32(
&mut self,
field_number: u32,
value: u32,
) -> Result<(), ProtobufError>
pub fn write_uint32( &mut self, field_number: u32, value: u32, ) -> Result<(), ProtobufError>
Write uint32
field
Sourcepub fn write_int64(
&mut self,
field_number: u32,
value: i64,
) -> Result<(), ProtobufError>
pub fn write_int64( &mut self, field_number: u32, value: i64, ) -> Result<(), ProtobufError>
Write int64
field
Sourcepub fn write_int32(
&mut self,
field_number: u32,
value: i32,
) -> Result<(), ProtobufError>
pub fn write_int32( &mut self, field_number: u32, value: i32, ) -> Result<(), ProtobufError>
Write int32
field
Sourcepub fn write_sint64(
&mut self,
field_number: u32,
value: i64,
) -> Result<(), ProtobufError>
pub fn write_sint64( &mut self, field_number: u32, value: i64, ) -> Result<(), ProtobufError>
Write sint64
field
Sourcepub fn write_sint32(
&mut self,
field_number: u32,
value: i32,
) -> Result<(), ProtobufError>
pub fn write_sint32( &mut self, field_number: u32, value: i32, ) -> Result<(), ProtobufError>
Write sint32
field
Sourcepub fn write_fixed64(
&mut self,
field_number: u32,
value: u64,
) -> Result<(), ProtobufError>
pub fn write_fixed64( &mut self, field_number: u32, value: u64, ) -> Result<(), ProtobufError>
Write fixed64
field
Sourcepub fn write_fixed32(
&mut self,
field_number: u32,
value: u32,
) -> Result<(), ProtobufError>
pub fn write_fixed32( &mut self, field_number: u32, value: u32, ) -> Result<(), ProtobufError>
Write fixed32
field
Sourcepub fn write_sfixed64(
&mut self,
field_number: u32,
value: i64,
) -> Result<(), ProtobufError>
pub fn write_sfixed64( &mut self, field_number: u32, value: i64, ) -> Result<(), ProtobufError>
Write sfixed64
field
Sourcepub fn write_sfixed32(
&mut self,
field_number: u32,
value: i32,
) -> Result<(), ProtobufError>
pub fn write_sfixed32( &mut self, field_number: u32, value: i32, ) -> Result<(), ProtobufError>
Write sfixed32
field
Sourcepub fn write_bool(
&mut self,
field_number: u32,
value: bool,
) -> Result<(), ProtobufError>
pub fn write_bool( &mut self, field_number: u32, value: bool, ) -> Result<(), ProtobufError>
Write bool
field
Sourcepub fn write_enum(
&mut self,
field_number: u32,
value: i32,
) -> Result<(), ProtobufError>
pub fn write_enum( &mut self, field_number: u32, value: i32, ) -> Result<(), ProtobufError>
Write enum
field
Sourcepub fn write_enum_obj<E>(
&mut self,
field_number: u32,
value: E,
) -> Result<(), ProtobufError>where
E: ProtobufEnum,
pub fn write_enum_obj<E>(
&mut self,
field_number: u32,
value: E,
) -> Result<(), ProtobufError>where
E: ProtobufEnum,
Write enum
field
Sourcepub fn write_unknown(
&mut self,
field_number: u32,
value: UnknownValueRef<'_>,
) -> Result<(), ProtobufError>
pub fn write_unknown( &mut self, field_number: u32, value: UnknownValueRef<'_>, ) -> Result<(), ProtobufError>
Write unknown field
Sourcepub fn write_unknown_fields(
&mut self,
fields: &UnknownFields,
) -> Result<(), ProtobufError>
pub fn write_unknown_fields( &mut self, fields: &UnknownFields, ) -> Result<(), ProtobufError>
Write unknown fields
Sourcepub fn write_bytes_no_tag(&mut self, bytes: &[u8]) -> Result<(), ProtobufError>
pub fn write_bytes_no_tag(&mut self, bytes: &[u8]) -> Result<(), ProtobufError>
Write bytes
Sourcepub fn write_string_no_tag(&mut self, s: &str) -> Result<(), ProtobufError>
pub fn write_string_no_tag(&mut self, s: &str) -> Result<(), ProtobufError>
Write string
Sourcepub fn write_message_no_tag<M>(&mut self, msg: &M) -> Result<(), ProtobufError>where
M: Message,
pub fn write_message_no_tag<M>(&mut self, msg: &M) -> Result<(), ProtobufError>where
M: Message,
Write message
Sourcepub fn write_bytes(
&mut self,
field_number: u32,
bytes: &[u8],
) -> Result<(), ProtobufError>
pub fn write_bytes( &mut self, field_number: u32, bytes: &[u8], ) -> Result<(), ProtobufError>
Write bytes
field
Sourcepub fn write_string(
&mut self,
field_number: u32,
s: &str,
) -> Result<(), ProtobufError>
pub fn write_string( &mut self, field_number: u32, s: &str, ) -> Result<(), ProtobufError>
Write string
field
Sourcepub fn write_message<M>(
&mut self,
field_number: u32,
msg: &M,
) -> Result<(), ProtobufError>where
M: Message,
pub fn write_message<M>(
&mut self,
field_number: u32,
msg: &M,
) -> Result<(), ProtobufError>where
M: Message,
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, Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Source§fn flush(&mut self) -> Result<(), Error>
fn flush(&mut self) -> Result<(), Error>
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
)Auto Trait Implementations§
impl<'a> Freeze for CodedOutputStream<'a>
impl<'a> !RefUnwindSafe for CodedOutputStream<'a>
impl<'a> !Send for CodedOutputStream<'a>
impl<'a> !Sync for CodedOutputStream<'a>
impl<'a> Unpin for CodedOutputStream<'a>
impl<'a> !UnwindSafe for CodedOutputStream<'a>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more