Crates.io | linebuffer |
lib.rs | linebuffer |
version | 0.1.2 |
source | src |
created_at | 2019-10-08 22:27:37.232282 |
updated_at | 2019-10-16 14:16:34.767829 |
description | ringbuffer for dynamic sized u8-elements |
homepage | |
repository | https://github.com/0xpr03/LineBuffer |
max_upload_size | |
id | 170922 |
size | 18,645 |
This crate is specifically for the following use case:
You can use it for example to buffer the stdout of a process per line.
It allows setting the amount of last lines to store and the size of bytes before wrapping.
use linebuffer::{typenum, LineBuffer};
// create a buffer of max 2048 entries/lines and 512KB data cache
// with the additional flag type ()
let mut buffer: LineBuffer<(), typenum::U2048> = LineBuffer::new(512_000);
let data = String::from("Some data stuff");
buffer.insert(data.as_bytes(),());
assert_eq!(buffer.get(0),Some((data.as_bytes(), &())));