Struct structbuf::Packer

source ·
pub struct Packer<'a> { /* private fields */ }
Expand description

Packer of POD values into a StructBuf.

The packer maintains an index (0 <= i <= lim()) where new values are written, which is incremented after each write. Write operations panic if the buffer capacity limit is exceeded.

The packer intentionally does not expose the underlying StructBuf to guarantee append-only operation.

Little-endian encoding is assumed.

Implementations§

Returns the current index.

Returns the number of additional bytes that can be written.

Advances the current index by n bytes.

Writes a bool as a u8 at the current index.

Writes a u8 at the current index.

Writes a u16 at the current index.

Writes a u32 as a u24 at the current index.

Panics

Panics if v cannot be represented in 24 bits.

Writes a u32 at the current index.

Writes a u64 at the current index.

Writes a u128 at the current index.

Writes an i8 at the current index.

Writes an i16 at the current index.

Writes an i32 at the current index.

Writes an i64 at the current index.

Writes an i128 at the current index.

Returns whether n bytes can be written at the current index.

Writes v at the current index.

Trait Implementations§

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Formats the value using the given formatter. Read more

Allows terminating packer method calls with .into().

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Returns an unpacker for reading values from the start of the buffer.