https://github.com/0xpr03/linebuffer
(circular) ringbuffer for lines of bytes (IO buffer over [u8] with line count)
https://github.com/0xpr03/linebuffer
circular linebuffer performance ringbuffer rust
Last synced: 4 months ago
JSON representation
(circular) ringbuffer for lines of bytes (IO buffer over [u8] with line count)
- Host: GitHub
- URL: https://github.com/0xpr03/linebuffer
- Owner: 0xpr03
- License: mit
- Created: 2019-09-26T19:01:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-17T18:31:47.000Z (over 6 years ago)
- Last Synced: 2025-08-04T07:07:15.960Z (6 months ago)
- Topics: circular, linebuffer, performance, ringbuffer, rust
- Language: Rust
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
#### LineBuffer - ringbuffer but for elements of different sizes
[](https://crates.io/crates/linebuffer)
[](https://docs.rs/linebuffer)
[](https://travis-ci.com/0xpr03/linebuffer)
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
```rust
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(), &())));
```