Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

byte-pool

A flexible byte pool.


Example

use byte_pool::BytePool;

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

// Allocate and copy from existing bytes.
let payload = pool.alloc_from_slice(b"hello");
assert_eq!(&payload[..], b"hello");

// Allocate a writable frame and shrink it after recv/write.
let mut frame = pool.alloc_and_fill(1024);
let received = 128;
frame.set_filled_len(received);
assert_eq!(frame.len(), received);

// Returns the underlying memory to the pool.
drop(payload);
drop(frame);

// 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.

About

A flexible byte pool.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages