4 releases

0.2.0 Dec 13, 2023
0.1.3 Dec 12, 2023
0.1.2 Dec 12, 2023
0.1.1 Dec 7, 2023
0.1.0 Dec 6, 2023

#435 in Memory management

Download history 400/week @ 2024-06-22 343/week @ 2024-06-29 410/week @ 2024-07-06 412/week @ 2024-07-13 463/week @ 2024-07-20 549/week @ 2024-07-27 519/week @ 2024-08-03 592/week @ 2024-08-10 506/week @ 2024-08-17 547/week @ 2024-08-24 653/week @ 2024-08-31 211/week @ 2024-09-07 244/week @ 2024-09-14 362/week @ 2024-09-21 639/week @ 2024-09-28 550/week @ 2024-10-05

1,825 downloads per month
Used in 17 crates (via serde_bolt)

Apache-2.0

17KB
393 lines

Chunked Buffer

A deque style buffer backed by non-contiguous chunks of memory.

The buffer grows incrementally without re-allocations and can also be consumed incrementally, releasing memory as it is consumed.

This structure is useful for memory constrained environments. It limits the size of contiguous allocations and incrementally releases memory as the buffer is consumed.

Supports no_std environments with alloc.

Usage

use chunked_buffer::ChunkedBuffer;

fn doit() { 
    let mut buf = ChunkedBuffer::new();
    buf.write(&[1, 2, 3]);
    let mut dest = [0; 10];
    let n = buf.read(&mut dest);
    
    assert_eq!(n, 3);
    assert_eq!(dest, [1, 2, 3, 0, 0, 0, 0, 0, 0, 0]);
}

No runtime deps