Expand description
Pool of byte slices.
Example
use byte_pool::BytePool;
// Create a pool
let pool = BytePool::<Vec<u8>>::new();
// Allocate a buffer with capacity 1024.
let mut buf = pool.alloc(1024);
// write some data into it
for i in 0..100 {
buf[i] = 12;
}
// Check that we actually wrote sth.
assert_eq!(buf[55], 12);
// Returns the underlying memory to the pool.
drop(buf);
// Frees all memory in the pool.
drop(pool);
Structs
- The value returned by an allocation of the pool. When it is dropped the memory gets returned into the pool, and is not zeroed. If that is a concern, you must clear the data yourself.
- A pool of byte slices, that reuses memory.
Traits
- The trait required to be able to use a type in
BytePool
. - A trait allowing for efficient reallocation.