CodedOutputStream

Struct CodedOutputStream 

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

Buffered write with handy utilities

Implementations§

Source§

impl<'a> CodedOutputStream<'a>

Source

pub fn new(writer: &'a mut dyn Write) -> CodedOutputStream<'a>

Construct from given Write.

CodedOutputStream is buffered even if Write is not

Source

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.

Source

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.

Source

pub fn check_eof(&self)

Check if EOF is reached.

§Panics

If underlying write has no EOF

Source

pub fn flush(&mut self) -> Result<(), ProtobufError>

Flush the buffer to underlying write

Source

pub fn write_raw_byte(&mut self, byte: u8) -> Result<(), ProtobufError>

Write a byte

Source

pub fn write_raw_bytes(&mut self, bytes: &[u8]) -> Result<(), ProtobufError>

Write bytes

Source

pub fn write_tag( &mut self, field_number: u32, wire_type: WireType, ) -> Result<(), ProtobufError>

Write a tag

Source

pub fn write_raw_varint32(&mut self, value: u32) -> Result<(), ProtobufError>

Write varint

Source

pub fn write_raw_varint64(&mut self, value: u64) -> Result<(), ProtobufError>

Write varint

Source

pub fn write_raw_little_endian32( &mut self, value: u32, ) -> Result<(), ProtobufError>

Write 32-bit integer little endian

Source

pub fn write_raw_little_endian64( &mut self, value: u64, ) -> Result<(), ProtobufError>

Write 64-bit integer little endian

Source

pub fn write_float_no_tag(&mut self, value: f32) -> Result<(), ProtobufError>

Write float

Source

pub fn write_double_no_tag(&mut self, value: f64) -> Result<(), ProtobufError>

Write double

Source

pub fn write_float( &mut self, field_number: u32, value: f32, ) -> Result<(), ProtobufError>

Write float field

Source

pub fn write_double( &mut self, field_number: u32, value: f64, ) -> Result<(), ProtobufError>

Write double field

Source

pub fn write_uint64_no_tag(&mut self, value: u64) -> Result<(), ProtobufError>

Write varint

Source

pub fn write_uint32_no_tag(&mut self, value: u32) -> Result<(), ProtobufError>

Write varint

Source

pub fn write_int64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>

Write varint

Source

pub fn write_int32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>

Write varint

Source

pub fn write_sint64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>

Write zigzag varint

Source

pub fn write_sint32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>

Write zigzag varint

Source

pub fn write_fixed64_no_tag(&mut self, value: u64) -> Result<(), ProtobufError>

Write fixed64

Source

pub fn write_fixed32_no_tag(&mut self, value: u32) -> Result<(), ProtobufError>

Write fixed32

Source

pub fn write_sfixed64_no_tag(&mut self, value: i64) -> Result<(), ProtobufError>

Write sfixed64

Source

pub fn write_sfixed32_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>

Write sfixed32

Source

pub fn write_bool_no_tag(&mut self, value: bool) -> Result<(), ProtobufError>

Write bool

Source

pub fn write_enum_no_tag(&mut self, value: i32) -> Result<(), ProtobufError>

Write enum

Source

pub fn write_enum_obj_no_tag<E>( &mut self, value: E, ) -> Result<(), ProtobufError>
where E: ProtobufEnum,

Write enum

Source

pub fn write_unknown_no_tag( &mut self, unknown: UnknownValueRef<'_>, ) -> Result<(), ProtobufError>

Write unknown value

Source

pub fn write_uint64( &mut self, field_number: u32, value: u64, ) -> Result<(), ProtobufError>

Write uint64 field

Source

pub fn write_uint32( &mut self, field_number: u32, value: u32, ) -> Result<(), ProtobufError>

Write uint32 field

Source

pub fn write_int64( &mut self, field_number: u32, value: i64, ) -> Result<(), ProtobufError>

Write int64 field

Source

pub fn write_int32( &mut self, field_number: u32, value: i32, ) -> Result<(), ProtobufError>

Write int32 field

Source

pub fn write_sint64( &mut self, field_number: u32, value: i64, ) -> Result<(), ProtobufError>

Write sint64 field

Source

pub fn write_sint32( &mut self, field_number: u32, value: i32, ) -> Result<(), ProtobufError>

Write sint32 field

Source

pub fn write_fixed64( &mut self, field_number: u32, value: u64, ) -> Result<(), ProtobufError>

Write fixed64 field

Source

pub fn write_fixed32( &mut self, field_number: u32, value: u32, ) -> Result<(), ProtobufError>

Write fixed32 field

Source

pub fn write_sfixed64( &mut self, field_number: u32, value: i64, ) -> Result<(), ProtobufError>

Write sfixed64 field

Source

pub fn write_sfixed32( &mut self, field_number: u32, value: i32, ) -> Result<(), ProtobufError>

Write sfixed32 field

Source

pub fn write_bool( &mut self, field_number: u32, value: bool, ) -> Result<(), ProtobufError>

Write bool field

Source

pub fn write_enum( &mut self, field_number: u32, value: i32, ) -> Result<(), ProtobufError>

Write enum field

Source

pub fn write_enum_obj<E>( &mut self, field_number: u32, value: E, ) -> Result<(), ProtobufError>
where E: ProtobufEnum,

Write enum field

Source

pub fn write_unknown( &mut self, field_number: u32, value: UnknownValueRef<'_>, ) -> Result<(), ProtobufError>

Write unknown field

Source

pub fn write_unknown_fields( &mut self, fields: &UnknownFields, ) -> Result<(), ProtobufError>

Write unknown fields

Source

pub fn write_bytes_no_tag(&mut self, bytes: &[u8]) -> Result<(), ProtobufError>

Write bytes

Source

pub fn write_string_no_tag(&mut self, s: &str) -> Result<(), ProtobufError>

Write string

Source

pub fn write_message_no_tag<M>(&mut self, msg: &M) -> Result<(), ProtobufError>
where M: Message,

Write message

Source

pub fn write_bytes( &mut self, field_number: u32, bytes: &[u8], ) -> Result<(), ProtobufError>

Write bytes field

Source

pub fn write_string( &mut self, field_number: u32, s: &str, ) -> Result<(), ProtobufError>

Write string field

Source

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>

Source§

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

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

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

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

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

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

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

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

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

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

Creates a “by reference” adapter for this instance of Write. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more