pub struct BytesBuilder(_);
Expand description

Fast Byte Buffer

Puff’s BytesBuilder type uses std::vec::Vec under the hood. Vecs are not sharable structures and so need to be wrapped in an Arc to be shared between threads and cheaply copied. You should use a BytesBuilder and convert it into Bytes when you are done writing to it.

Examples

use puff_rs::types::BytesBuilder;

let mut builder = BytesBuilder::new();
builder.put("hello_world");
let bytes = builder.into_bytes();

Implementations

Creates an empty BytesBuilder.

The hash map is initially created with a capacity of 0, so it will not allocate until it is first inserted into.

Examples
use puff_rs::types::{Text, BytesBuilder};
let mut builder = BytesBuilder::new();

Creates an empty BytesBuilder with the specified capacity.

The buffer will be able to hold at least capacity elements without reallocating. If capacity is 0, the hash map will not allocate.

Examples
use puff_rs::types::BytesBuilder;
let mut builder = BytesBuilder::with_capacity(10);

Puts some bytes into the builder.

Examples
use puff_rs::types::BytesBuilder;
let mut builder = BytesBuilder::new();
builder.put("Hi");

Puts a slice into the builder.

Examples
use puff_rs::types::BytesBuilder;
let mut builder = BytesBuilder::new();
builder.put_slice("Hi".as_bytes());

Converts BytesBuilder into Bytes.

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.

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

Calls U::from(self).

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

Should always be Self
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.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more