#pool #byte

byte-pool

Pool of byte slices, for efficient memory usage

6 releases

0.2.4 Apr 12, 2023
0.2.3 Mar 28, 2021
0.2.2 Jul 29, 2020
0.2.1 Dec 14, 2019
0.1.0 Nov 13, 2019

#69 in Memory management

Download history 946/week @ 2023-06-11 1906/week @ 2023-06-18 2037/week @ 2023-06-25 2077/week @ 2023-07-02 1493/week @ 2023-07-09 1634/week @ 2023-07-16 2333/week @ 2023-07-23 1344/week @ 2023-07-30 1374/week @ 2023-08-06 1287/week @ 2023-08-13 1099/week @ 2023-08-20 929/week @ 2023-08-27 1278/week @ 2023-09-03 1101/week @ 2023-09-10 1083/week @ 2023-09-17 640/week @ 2023-09-24

4,144 downloads per month
Used in 4 crates (2 directly)

Apache-2.0/MIT

15KB
308 lines

byte-pool

A flexible byte pool.


Example

use byte_pool::BytePool;

// Create a pool
let pool = BytePool::<Vec<u8>>::new();

// Allocate a buffer
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);

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~180KB