Struct protobuf::CodedInputStream
source · [−]pub struct CodedInputStream<'a> { /* private fields */ }
Expand description
Buffered read with handy utilities.
Implementations
sourceimpl<'a> CodedInputStream<'a>
impl<'a> CodedInputStream<'a>
sourcepub fn new(read: &'a mut dyn Read) -> CodedInputStream<'a>ⓘNotable traits for CodedInputStream<'a>impl<'a> Read for CodedInputStream<'a>
pub fn new(read: &'a mut dyn Read) -> CodedInputStream<'a>ⓘNotable traits for CodedInputStream<'a>impl<'a> Read for CodedInputStream<'a>
Wrap a Read
.
Note resulting CodedInputStream
is buffered.
If Read
is buffered, the resulting stream will be double buffered,
consider using from_buf_read
instead.
sourcepub fn from_buf_read(buf_read: &'a mut dyn BufRead) -> CodedInputStream<'a>ⓘNotable traits for CodedInputStream<'a>impl<'a> Read for CodedInputStream<'a>
pub fn from_buf_read(buf_read: &'a mut dyn BufRead) -> CodedInputStream<'a>ⓘNotable traits for CodedInputStream<'a>impl<'a> Read for CodedInputStream<'a>
Create from BufRead
.
CodedInputStream
will utilize BufRead
buffer.
sourcepub fn from_bytes(bytes: &'a [u8]) -> CodedInputStream<'a>ⓘNotable traits for CodedInputStream<'a>impl<'a> Read for CodedInputStream<'a>
pub fn from_bytes(bytes: &'a [u8]) -> CodedInputStream<'a>ⓘNotable traits for CodedInputStream<'a>impl<'a> Read for CodedInputStream<'a>
Read from byte slice
sourcepub fn from_tokio_bytes(bytes: &'a Bytes) -> CodedInputStream<'a>ⓘNotable traits for CodedInputStream<'a>impl<'a> Read for CodedInputStream<'a>
pub fn from_tokio_bytes(bytes: &'a Bytes) -> CodedInputStream<'a>ⓘNotable traits for CodedInputStream<'a>impl<'a> Read for CodedInputStream<'a>
Read from Bytes
.
CodedInputStream
operations like
read_tokio_bytes
will return a shared copy of this bytes object.
sourcepub fn set_recursion_limit(&mut self, limit: u32)
pub fn set_recursion_limit(&mut self, limit: u32)
Set the recursion limit.
sourcepub fn bytes_until_limit(&self) -> u64
pub fn bytes_until_limit(&self) -> u64
How many bytes until current limit
sourcepub fn read_exact(&mut self, buf: &mut [MaybeUninit<u8>]) -> Result<()>
pub fn read_exact(&mut self, buf: &mut [MaybeUninit<u8>]) -> Result<()>
Read bytes into given buf
.
sourcepub fn read_raw_byte(&mut self) -> Result<u8>
pub fn read_raw_byte(&mut self) -> Result<u8>
Read one byte
sourcepub fn push_limit(&mut self, limit: u64) -> Result<u64>
pub fn push_limit(&mut self, limit: u64) -> Result<u64>
Push new limit, return previous limit.
sourcepub fn check_eof(&mut self) -> Result<()>
pub fn check_eof(&mut self) -> Result<()>
Check we are at EOF.
Return error if we are not at EOF.
sourcepub fn read_raw_varint64(&mut self) -> Result<u64>
pub fn read_raw_varint64(&mut self) -> Result<u64>
Read varint
sourcepub fn read_raw_varint32(&mut self) -> Result<u32>
pub fn read_raw_varint32(&mut self) -> Result<u32>
Read varint
sourcepub fn read_raw_little_endian32(&mut self) -> Result<u32>
pub fn read_raw_little_endian32(&mut self) -> Result<u32>
Read little-endian 32-bit integer
sourcepub fn read_raw_little_endian64(&mut self) -> Result<u64>
pub fn read_raw_little_endian64(&mut self) -> Result<u64>
Read little-endian 64-bit integer
sourcepub fn read_raw_tag_or_eof(&mut self) -> Result<Option<u32>>
pub fn read_raw_tag_or_eof(&mut self) -> Result<Option<u32>>
Read tag number as u32
or None if EOF is reached.
sourcepub fn read_double(&mut self) -> Result<f64>
pub fn read_double(&mut self) -> Result<f64>
Read double
sourcepub fn read_float(&mut self) -> Result<f32>
pub fn read_float(&mut self) -> Result<f32>
Read float
sourcepub fn read_int64(&mut self) -> Result<i64>
pub fn read_int64(&mut self) -> Result<i64>
Read int64
sourcepub fn read_int32(&mut self) -> Result<i32>
pub fn read_int32(&mut self) -> Result<i32>
Read int32
sourcepub fn read_uint64(&mut self) -> Result<u64>
pub fn read_uint64(&mut self) -> Result<u64>
Read uint64
sourcepub fn read_uint32(&mut self) -> Result<u32>
pub fn read_uint32(&mut self) -> Result<u32>
Read uint32
sourcepub fn read_sint64(&mut self) -> Result<i64>
pub fn read_sint64(&mut self) -> Result<i64>
Read sint64
sourcepub fn read_sint32(&mut self) -> Result<i32>
pub fn read_sint32(&mut self) -> Result<i32>
Read sint32
sourcepub fn read_fixed64(&mut self) -> Result<u64>
pub fn read_fixed64(&mut self) -> Result<u64>
Read fixed64
sourcepub fn read_fixed32(&mut self) -> Result<u32>
pub fn read_fixed32(&mut self) -> Result<u32>
Read fixed32
sourcepub fn read_sfixed64(&mut self) -> Result<i64>
pub fn read_sfixed64(&mut self) -> Result<i64>
Read sfixed64
sourcepub fn read_sfixed32(&mut self) -> Result<i32>
pub fn read_sfixed32(&mut self) -> Result<i32>
Read sfixed32
sourcepub fn read_enum_or_unknown<E: Enum>(&mut self) -> Result<EnumOrUnknown<E>>
pub fn read_enum_or_unknown<E: Enum>(&mut self) -> Result<EnumOrUnknown<E>>
Read enum
as ProtobufEnumOrUnknown
sourcepub fn read_repeated_packed_double_into(
&mut self,
target: &mut Vec<f64>
) -> Result<()>
pub fn read_repeated_packed_double_into(
&mut self,
target: &mut Vec<f64>
) -> Result<()>
Read repeated packed double
sourcepub fn read_repeated_packed_float_into(
&mut self,
target: &mut Vec<f32>
) -> Result<()>
pub fn read_repeated_packed_float_into(
&mut self,
target: &mut Vec<f32>
) -> Result<()>
Read repeated packed float
sourcepub fn read_repeated_packed_int64_into(
&mut self,
target: &mut Vec<i64>
) -> Result<()>
pub fn read_repeated_packed_int64_into(
&mut self,
target: &mut Vec<i64>
) -> Result<()>
Read repeated packed int64
sourcepub fn read_repeated_packed_int32_into(
&mut self,
target: &mut Vec<i32>
) -> Result<()>
pub fn read_repeated_packed_int32_into(
&mut self,
target: &mut Vec<i32>
) -> Result<()>
Read repeated packed int32
sourcepub fn read_repeated_packed_uint64_into(
&mut self,
target: &mut Vec<u64>
) -> Result<()>
pub fn read_repeated_packed_uint64_into(
&mut self,
target: &mut Vec<u64>
) -> Result<()>
Read repeated packed uint64
sourcepub fn read_repeated_packed_uint32_into(
&mut self,
target: &mut Vec<u32>
) -> Result<()>
pub fn read_repeated_packed_uint32_into(
&mut self,
target: &mut Vec<u32>
) -> Result<()>
Read repeated packed uint32
sourcepub fn read_repeated_packed_sint64_into(
&mut self,
target: &mut Vec<i64>
) -> Result<()>
pub fn read_repeated_packed_sint64_into(
&mut self,
target: &mut Vec<i64>
) -> Result<()>
Read repeated packed sint64
sourcepub fn read_repeated_packed_sint32_into(
&mut self,
target: &mut Vec<i32>
) -> Result<()>
pub fn read_repeated_packed_sint32_into(
&mut self,
target: &mut Vec<i32>
) -> Result<()>
Read repeated packed sint32
sourcepub fn read_repeated_packed_fixed64_into(
&mut self,
target: &mut Vec<u64>
) -> Result<()>
pub fn read_repeated_packed_fixed64_into(
&mut self,
target: &mut Vec<u64>
) -> Result<()>
Read repeated packed fixed64
sourcepub fn read_repeated_packed_fixed32_into(
&mut self,
target: &mut Vec<u32>
) -> Result<()>
pub fn read_repeated_packed_fixed32_into(
&mut self,
target: &mut Vec<u32>
) -> Result<()>
Read repeated packed fixed32
sourcepub fn read_repeated_packed_sfixed64_into(
&mut self,
target: &mut Vec<i64>
) -> Result<()>
pub fn read_repeated_packed_sfixed64_into(
&mut self,
target: &mut Vec<i64>
) -> Result<()>
Read repeated packed sfixed64
sourcepub fn read_repeated_packed_sfixed32_into(
&mut self,
target: &mut Vec<i32>
) -> Result<()>
pub fn read_repeated_packed_sfixed32_into(
&mut self,
target: &mut Vec<i32>
) -> Result<()>
Read repeated packed sfixed32
sourcepub fn read_repeated_packed_bool_into(
&mut self,
target: &mut Vec<bool>
) -> Result<()>
pub fn read_repeated_packed_bool_into(
&mut self,
target: &mut Vec<bool>
) -> Result<()>
Read repeated packed bool
sourcepub fn read_unknown(&mut self, wire_type: WireType) -> Result<UnknownValue>
pub fn read_unknown(&mut self, wire_type: WireType) -> Result<UnknownValue>
Read UnknownValue
sourcepub fn skip_field(&mut self, wire_type: WireType) -> Result<()>
pub fn skip_field(&mut self, wire_type: WireType) -> Result<()>
Skip field.
sourcepub fn read_raw_bytes_into(
&mut self,
count: u32,
target: &mut Vec<u8>
) -> Result<()>
pub fn read_raw_bytes_into(
&mut self,
count: u32,
target: &mut Vec<u8>
) -> Result<()>
Read raw bytes into the supplied vector. The vector will be resized as needed and overwritten.
sourcepub fn skip_raw_bytes(&mut self, count: u32) -> Result<()>
pub fn skip_raw_bytes(&mut self, count: u32) -> Result<()>
Skip exact number of bytes
sourcepub fn read_bytes(&mut self) -> Result<Vec<u8>>
pub fn read_bytes(&mut self) -> Result<Vec<u8>>
Read bytes
field, length delimited
sourcepub fn read_tokio_bytes(&mut self) -> Result<Bytes>
pub fn read_tokio_bytes(&mut self) -> Result<Bytes>
Read bytes
field, length delimited
sourcepub fn read_tokio_chars(&mut self) -> Result<Chars>
pub fn read_tokio_chars(&mut self) -> Result<Chars>
Read string
field, length delimited
sourcepub fn read_bytes_into(&mut self, target: &mut Vec<u8>) -> Result<()>
pub fn read_bytes_into(&mut self, target: &mut Vec<u8>) -> Result<()>
Read bytes
field, length delimited
sourcepub fn read_string(&mut self) -> Result<String>
pub fn read_string(&mut self) -> Result<String>
Read string
field, length delimited
sourcepub fn read_string_into(&mut self, target: &mut String) -> Result<()>
pub fn read_string_into(&mut self, target: &mut String) -> Result<()>
Read string
field, length delimited
sourcepub fn merge_message<M: Message>(&mut self, message: &mut M) -> Result<()>
pub fn merge_message<M: Message>(&mut self, message: &mut M) -> Result<()>
Read message, do not check if message is initialized
sourcepub fn merge_message_dyn(&mut self, message: &mut dyn MessageDyn) -> Result<()>
pub fn merge_message_dyn(&mut self, message: &mut dyn MessageDyn) -> Result<()>
Like merge_message
, but for dynamic messages.
sourcepub fn read_message<M: Message>(&mut self) -> Result<M>
pub fn read_message<M: Message>(&mut self) -> Result<M>
Read message
sourcepub fn read_message_dyn(
&mut self,
descriptor: &MessageDescriptor
) -> Result<Box<dyn MessageDyn>>
pub fn read_message_dyn(
&mut self,
descriptor: &MessageDescriptor
) -> Result<Box<dyn MessageDyn>>
Read message.
Trait Implementations
sourceimpl<'a> BufRead for CodedInputStream<'a>
impl<'a> BufRead for CodedInputStream<'a>
sourcefn fill_buf(&mut self) -> Result<&[u8]>
fn fill_buf(&mut self) -> Result<&[u8]>
Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
sourcefn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
Tells this buffer that amt
bytes have been consumed from the buffer,
so they should no longer be returned in calls to read
. Read more
sourcefn has_data_left(&mut self) -> Result<bool, Error>
fn has_data_left(&mut self) -> Result<bool, Error>
buf_read_has_data_left
)Check if the underlying Read
has any data left to be read. Read more
1.0.0 · sourcefn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
fn read_until(
&mut self,
byte: u8,
buf: &mut Vec<u8, Global>
) -> Result<usize, Error>
Read all bytes into buf
until the delimiter byte
or EOF is reached. Read more
1.0.0 · sourcefn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until a newline (the 0xA
byte) is reached, and append
them to the provided buffer. You do not need to clear the buffer before
appending. Read more
sourceimpl<'a> Debug for CodedInputStream<'a>
impl<'a> Debug for CodedInputStream<'a>
sourceimpl<'a> Read for CodedInputStream<'a>
impl<'a> Read for CodedInputStream<'a>
sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
1.36.0 · sourcefn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like read
, except that it reads into a slice of buffers. Read more
sourcefn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
1.0.0 · sourcefn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into buf
. Read more
1.0.0 · sourcefn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to buf
. Read more
1.6.0 · sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill buf
. Read more
sourcefn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Pull some bytes from this source into the specified buffer. Read more
sourcefn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Read the exact number of bytes required to fill buf
. Read more
1.0.0 · sourcefn by_ref(&mut self) -> &mut Self
fn by_ref(&mut self) -> &mut Self
Creates a “by reference” adaptor for this instance of Read
. Read more
Auto Trait Implementations
impl<'a> !RefUnwindSafe for CodedInputStream<'a>
impl<'a> !Send for CodedInputStream<'a>
impl<'a> !Sync for CodedInputStream<'a>
impl<'a> Unpin for CodedInputStream<'a>
impl<'a> !UnwindSafe for CodedInputStream<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more