Struct CodedInputStream

Source
pub struct CodedInputStream<'a> { /* private fields */ }
Expand description

Buffered read with handy utilities.

Implementations§

Source§

impl<'a> CodedInputStream<'a>

Source

pub fn new(read: &'a mut dyn Read) -> 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.

Source

pub fn from_buf_read(buf_read: &'a mut dyn BufRead) -> CodedInputStream<'a>

Create from BufRead.

CodedInputStream will utilize BufRead buffer.

Source

pub fn from_bytes(bytes: &'a [u8]) -> CodedInputStream<'a>

Read from byte slice

Source

pub fn from_tokio_bytes(bytes: &'a Bytes) -> CodedInputStream<'a>

Read from Bytes.

CodedInputStream operations like read_tokio_bytes will return a shared copy of this bytes object.

Source

pub fn set_recursion_limit(&mut self, limit: u32)

Set the recursion limit.

Source

pub fn pos(&self) -> u64

How many bytes processed

Source

pub fn bytes_until_limit(&self) -> u64

How many bytes until current limit

Source

pub fn read_exact(&mut self, buf: &mut [MaybeUninit<u8>]) -> Result<()>

Read bytes into given buf.

Source

pub fn read_raw_byte(&mut self) -> Result<u8>

Read one byte

Source

pub fn push_limit(&mut self, limit: u64) -> Result<u64>

Push new limit, return previous limit.

Source

pub fn pop_limit(&mut self, old_limit: u64)

Restore previous limit.

Source

pub fn eof(&mut self) -> Result<bool>

Are we at EOF?

Source

pub fn check_eof(&mut self) -> Result<()>

Check we are at EOF.

Return error if we are not at EOF.

Source

pub fn read_raw_varint64(&mut self) -> Result<u64>

Read varint

Source

pub fn read_raw_varint32(&mut self) -> Result<u32>

Read varint

Source

pub fn read_raw_little_endian32(&mut self) -> Result<u32>

Read little-endian 32-bit integer

Source

pub fn read_raw_little_endian64(&mut self) -> Result<u64>

Read little-endian 64-bit integer

Source

pub fn read_raw_tag_or_eof(&mut self) -> Result<Option<u32>>

Read tag number as u32 or None if EOF is reached.

Source

pub fn read_double(&mut self) -> Result<f64>

Read double

Source

pub fn read_float(&mut self) -> Result<f32>

Read float

Source

pub fn read_int64(&mut self) -> Result<i64>

Read int64

Source

pub fn read_int32(&mut self) -> Result<i32>

Read int32

Source

pub fn read_uint64(&mut self) -> Result<u64>

Read uint64

Source

pub fn read_uint32(&mut self) -> Result<u32>

Read uint32

Source

pub fn read_sint64(&mut self) -> Result<i64>

Read sint64

Source

pub fn read_sint32(&mut self) -> Result<i32>

Read sint32

Source

pub fn read_fixed64(&mut self) -> Result<u64>

Read fixed64

Source

pub fn read_fixed32(&mut self) -> Result<u32>

Read fixed32

Source

pub fn read_sfixed64(&mut self) -> Result<i64>

Read sfixed64

Source

pub fn read_sfixed32(&mut self) -> Result<i32>

Read sfixed32

Source

pub fn read_bool(&mut self) -> Result<bool>

Read bool

Source

pub fn read_enum<E: Enum>(&mut self) -> Result<E>

Read enum as ProtobufEnum

Source

pub fn read_enum_or_unknown<E: Enum>(&mut self) -> Result<EnumOrUnknown<E>>

Read enum as ProtobufEnumOrUnknown

Source

pub fn read_repeated_packed_double_into( &mut self, target: &mut Vec<f64>, ) -> Result<()>

Read repeated packed double

Source

pub fn read_repeated_packed_float_into( &mut self, target: &mut Vec<f32>, ) -> Result<()>

Read repeated packed float

Source

pub fn read_repeated_packed_int64_into( &mut self, target: &mut Vec<i64>, ) -> Result<()>

Read repeated packed int64

Source

pub fn read_repeated_packed_int32_into( &mut self, target: &mut Vec<i32>, ) -> Result<()>

Read repeated packed int32

Source

pub fn read_repeated_packed_uint64_into( &mut self, target: &mut Vec<u64>, ) -> Result<()>

Read repeated packed uint64

Source

pub fn read_repeated_packed_uint32_into( &mut self, target: &mut Vec<u32>, ) -> Result<()>

Read repeated packed uint32

Source

pub fn read_repeated_packed_sint64_into( &mut self, target: &mut Vec<i64>, ) -> Result<()>

Read repeated packed sint64

Source

pub fn read_repeated_packed_sint32_into( &mut self, target: &mut Vec<i32>, ) -> Result<()>

Read repeated packed sint32

Source

pub fn read_repeated_packed_fixed64_into( &mut self, target: &mut Vec<u64>, ) -> Result<()>

Read repeated packed fixed64

Source

pub fn read_repeated_packed_fixed32_into( &mut self, target: &mut Vec<u32>, ) -> Result<()>

Read repeated packed fixed32

Source

pub fn read_repeated_packed_sfixed64_into( &mut self, target: &mut Vec<i64>, ) -> Result<()>

Read repeated packed sfixed64

Source

pub fn read_repeated_packed_sfixed32_into( &mut self, target: &mut Vec<i32>, ) -> Result<()>

Read repeated packed sfixed32

Source

pub fn read_repeated_packed_bool_into( &mut self, target: &mut Vec<bool>, ) -> Result<()>

Read repeated packed bool

Source

pub fn read_unknown(&mut self, wire_type: WireType) -> Result<UnknownValue>

Read UnknownValue

Source

pub fn skip_field(&mut self, wire_type: WireType) -> Result<()>

Skip field.

Source

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.

Source

pub fn read_raw_bytes(&mut self, count: u32) -> Result<Vec<u8>>

Read exact number of bytes

Source

pub fn skip_raw_bytes(&mut self, count: u32) -> Result<()>

Skip exact number of bytes

Source

pub fn read_bytes(&mut self) -> Result<Vec<u8>>

Read bytes field, length delimited

Source

pub fn read_tokio_bytes(&mut self) -> Result<Bytes>

Read bytes field, length delimited

Source

pub fn read_tokio_chars(&mut self) -> Result<Chars>

Read string field, length delimited

Source

pub fn read_bytes_into(&mut self, target: &mut Vec<u8>) -> Result<()>

Read bytes field, length delimited

Source

pub fn read_string(&mut self) -> Result<String>

Read string field, length delimited

Source

pub fn read_string_into(&mut self, target: &mut String) -> Result<()>

Read string field, length delimited

Source

pub fn merge_message<M: Message>(&mut self, message: &mut M) -> Result<()>

Read message, do not check if message is initialized

Source

pub fn merge_message_dyn(&mut self, message: &mut dyn MessageDyn) -> Result<()>

Like merge_message, but for dynamic messages.

Source

pub fn read_message<M: Message>(&mut self) -> Result<M>

Read message

Source

pub fn read_message_dyn( &mut self, descriptor: &MessageDescriptor, ) -> Result<Box<dyn MessageDyn>>

Read message.

Trait Implementations§

Source§

impl<'a> BufRead for CodedInputStream<'a>

Source§

fn fill_buf(&mut self) -> Result<&[u8]>

Returns the contents of the internal buffer, filling it with more data, via Read methods, if empty. Read more
Source§

fn consume(&mut self, amt: usize)

Marks the given amount of additional bytes from the internal buffer as having been read. Subsequent calls to read only return bytes that have not been marked as read. Read more
Source§

fn has_data_left(&mut self) -> Result<bool, Error>

🔬This is a nightly-only experimental API. (buf_read_has_data_left)
Checks if there is any data left to be read. Read more
1.0.0 · Source§

fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes into buf until the delimiter byte or EOF is reached. Read more
1.83.0 · Source§

fn skip_until(&mut self, byte: u8) -> Result<usize, Error>

Skips all bytes until the delimiter byte or EOF is reached. Read more
1.0.0 · Source§

fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until a newline (the 0xA byte) is reached, and append them to the provided String buffer. Read more
1.0.0 · Source§

fn split(self, byte: u8) -> Split<Self>
where Self: Sized,

Returns an iterator over the contents of this reader split on the byte byte. Read more
1.0.0 · Source§

fn lines(self) -> Lines<Self>
where Self: Sized,

Returns an iterator over the lines of this reader. Read more
Source§

impl<'a> Debug for CodedInputStream<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Read for CodedInputStream<'a>

Source§

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 · Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes until EOF in this source, placing them into buf. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
1.6.0 · Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CodedInputStream<'a>

§

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§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.