#buffer #network

buffering

A library primarily designed for network packet buffer operations

8 releases

0.3.4 Jun 25, 2019
0.3.3 Jun 10, 2019
0.3.2 May 3, 2019
0.3.1 Apr 20, 2019
0.1.0 Jul 22, 2018

#17 in #buffer

Download history 12/week @ 2019-04-11 25/week @ 2019-04-18 26/week @ 2019-04-25 43/week @ 2019-05-02 31/week @ 2019-05-09 19/week @ 2019-05-16 23/week @ 2019-05-23 10/week @ 2019-05-30 46/week @ 2019-06-06 19/week @ 2019-06-13 59/week @ 2019-06-20 113/week @ 2019-06-27 125/week @ 2019-07-04 52/week @ 2019-07-11 31/week @ 2019-07-18

106 downloads per month
Used in 2 crates

BSD-3-Clause

11KB
207 lines

buffering

A library for handling buffer operations

Purpose

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.


lib.rs:

Approach

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 the notion that structs that use the provided procedural macro must be completely allocatable on the stack. 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 an optimization for a more type safe common C workflow in very low level scenarios.

Features

Each module is feature-flagged at build time to avoid pulling in unnecessary code if only one is necessary. Available features are:

  • copy
  • nocopy

Dependencies

~185KB