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

#160 in Memory management

Download history 14/week @ 2023-12-22 15/week @ 2023-12-29 20/week @ 2024-01-05 43/week @ 2024-01-12 54/week @ 2024-01-19 25/week @ 2024-01-26 26/week @ 2024-02-02 53/week @ 2024-02-09 138/week @ 2024-02-16 287/week @ 2024-02-23 805/week @ 2024-03-01 872/week @ 2024-03-08 1183/week @ 2024-03-15 737/week @ 2024-03-22 371/week @ 2024-03-29 646/week @ 2024-04-05

3,082 downloads per month
Used in 15 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