Skip to content

reem/rust-appendbuf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

appendbuf

A Sync append-only buffer with Send views.

Provides an atomically reference counted, append-only buffer. Each buffer consists of a unique AppendBuf handle which can write new data to the buffer and any number of atomically reference counted Slice handles, which contain read-only windows into data previously written to the buffer.

Example

extern crate appendbuf;

use appendbuf::AppendBuf;

fn main() {
    // Create an AppendBuf with capacity for 100 bytes.
    let mut buf = AppendBuf::new(100);

    // Write some data in pieces.
    assert_eq!(buf.fill(&[1, 2, 3, 4]), 4);
    assert_eq!(buf.fill(&[10, 12, 13, 14, 15]), 5);
    assert_eq!(buf.fill(&[34, 35]), 2);

    // Read all the data we just wrote.
    assert_eq!(&*buf.slice(), &[1, 2, 3, 4, 10, 12, 13, 14, 15, 34, 35]);
}

Usage

Use the crates.io repository; add this to your Cargo.toml along with the rest of your dependencies:

[dependencies]
appendbuf = "0.1"

Author

Jonathan Reem is the primary author and maintainer of appendbuf.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages