#buffer #network


A library primarily designed for network packet buffer operations

9 releases

0.4.2 Sep 24, 2019
0.4.1 Sep 23, 2019
0.3.4 Jun 25, 2019
0.3.2 May 3, 2019
0.1.0 Jul 22, 2018

#558 in Network programming

Download history 86/week @ 2019-10-11 197/week @ 2019-10-18 164/week @ 2019-10-25 145/week @ 2019-11-01 157/week @ 2019-11-08 132/week @ 2019-11-15 130/week @ 2019-11-22 83/week @ 2019-11-29 233/week @ 2019-12-06 88/week @ 2019-12-13 66/week @ 2019-12-20 98/week @ 2019-12-27 90/week @ 2020-01-03 270/week @ 2020-01-10 87/week @ 2020-01-17

587 downloads per month
Used in 4 crates (3 directly)


223 lines


A library for handling buffer operations


This library is primarily aimed at simple network serialization and deserialization for a variety of struct types. It provides a copy-based Cursor solution for more complicated network data structures or a macro to generate a union type that allows access to fields for inspection and the underlying buffer for network transfer.



This crate is meant to provide two methods for serializing and deserializing with buffer operations:

  • The copy module is a more flexible, high-level stream based approach for reading from and writing to buffers. This will introduce some overhead so do not use this if copies are a bottleneck.
  • The nocopy module is a more restrictive macro-based approach. It uses procedural macros and unions to provide some level of safety when writing to fields in a struct while allowing the underlying struct to be interpreted as a slice. This is a C-like workflow but does provide some helpful guarantees that come with Rust like protection against buffer overflows and bounds checking. One very important note is that structs that use the provided procedural macro must be completely stack allocated. Compilation will fail if certain constructs that prevent size computation at compile time are used. As a result this really should only be used as a Rust substitute with some additional safety for the common C workflow when doing things like parsing network packets.


Each module is feature-flagged so that either or both can be used. Available features are:

  • copy
  • nocopy