linebuffer

Crates.iolinebuffer
lib.rslinebuffer
version0.1.2
sourcesrc
created_at2019-10-08 22:27:37.232282
updated_at2019-10-16 14:16:34.767829
descriptionringbuffer for dynamic sized u8-elements
homepage
repositoryhttps://github.com/0xpr03/LineBuffer
max_upload_size
id170922
size18,645
Aron (0xpr03)

documentation

README

LineBuffer - ringbuffer but for elements of different sizes

crates.io docs.rs Build Status

This crate is specifically for the following use case:

  • high throughput of data
  • infrequent read of entries or the whole buffer
  • entries are distinguishable arrays of bytes
  • data has dynamic size
  • numbering is infinite

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.

Example

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(), &())));
Commit count: 25

cargo fmt