byte_pool/lib.rs
1//! Pool of byte slices.
2//!
3//! # Example
4//! ```rust
5//! use byte_pool::BytePool;
6//!
7//! // Create a pool
8//! let pool = BytePool::<Vec<u8>>::new();
9//!
10//! // Allocate a buffer with capacity 1024.
11//! let mut buf = pool.alloc(1024);
12//!
13//! // write some data into it
14//! for i in 0..100 {
15//! buf[i] = 12;
16//! }
17//!
18//! // Check that we actually wrote sth.
19//! assert_eq!(buf[55], 12);
20//!
21//! // Returns the underlying memory to the pool.
22//! drop(buf);
23//!
24//! // Frees all memory in the pool.
25//! drop(pool);
26//! ```
27
28mod pool;
29mod poolable;
30
31pub use pool::{Block, BytePool};
32pub use poolable::{Poolable, Realloc};