buffer 0.1.6

Safe, write-only, generics-free buffer abstraction

Crate buffer [] [src]

buffer provides safe, write-only and generics-free byte buffers that can be used without initializing them first.

The main trait of this library is Buffer that represents a type that can contain uninitialized bytes (such as Vec, ArrayVec, etc.) and can safely be read into (e.g. using ReadBuffer).

In order to keep code sizes down, such a type implementing Buffer is quickly converted into the struct BufferRef, so this is the type receivers of types implementing Buffers should work with.

An example for the usage of this trait can be found with ReadBuffer which implements reading into a buffer without initializing it first.

Structs

ArrayVecBuffer

The intermediate step from a ArrayVec to a BufferRef.

BufferRef

A reference to an uninitialized or partially initialized byte buffer.

BufferRefBuffer

The intermediate step from a BufferRef to another BufferRef.

CapacityError

An error occuring when too many bytes are being pushed into a buffer.

SliceBuffer

The intermediate step from a byte slice to a BufferRef.

SliceRefBuffer

The intermediate step from a byte slice reference to a BufferRef.

VecBuffer

The intermediate step from a Vec to a BufferRef.

Traits

Buffer

Trait for types that can act as buffer for bytes.

ReadBuffer

Trait to read to T: Buffer.

ReadBufferRef

An internal trait to be implemented by T: Read which do not access the read buffer in Read::read. Prefer implementing ReadBufferMarker over this.

ToBufferRef

Internal trait for the intermediate result of converting a T: Buffer into a BufferRef.

Functions

read_buffer_ref

A utility function for unsafely implementing ReadBufferRef for readers that don't read the buffer passed to Read::read.

with_buffer

Convenience function that converts a T: Buffer into a BufferRef.