#abstraction #buffer #reader

buffer

Safe, write-only, generics-free buffer abstraction

10 releases

Uses old Rust 2015

0.1.9 Mar 6, 2021
0.1.8 Jul 12, 2017
0.1.7 Mar 26, 2017
0.1.6 Jul 21, 2016
0.1.4 Mar 20, 2016

#1158 in Rust patterns

Download history 118/week @ 2024-12-07 103/week @ 2024-12-14 40/week @ 2024-12-21 34/week @ 2024-12-28 51/week @ 2025-01-04 80/week @ 2025-01-11 108/week @ 2025-01-18 58/week @ 2025-01-25 105/week @ 2025-02-01 120/week @ 2025-02-08 79/week @ 2025-02-15 127/week @ 2025-02-22 93/week @ 2025-03-01 92/week @ 2025-03-08 175/week @ 2025-03-15 148/week @ 2025-03-22

527 downloads per month
Used in 20 crates (12 directly)

MIT/Apache

20KB
418 lines

buffer

buffer provides safe, write-only and generics-free byte buffers that can be used without initializing them first.

Example

let mut vec = Vec::with_capacity(1024);
if try!(reader.read_buffer(&mut vec)).len() != 0 {
    if vec[0] == 0 {
        // ...
    }
}

lib.rs:

buffer provides safe, write-only and generics-free byte buffers that can be used without initializing them first.

The main trait of this library is Buffer that represents a type that can contain uninitialized bytes (such as Vec, ArrayVec, etc.) and can safely be read into (e.g. using ReadBuffer).

In order to keep code sizes down, such a type implementing Buffer is quickly converted into the struct BufferRef, so this is the type receivers of types implementing Buffers should work with.

An example for the usage of this trait can be found with ReadBuffer which implements reading into a buffer without initializing it first.

Dependencies

~86KB