#buffer #networking

buffering

A library primarily designed for network packet buffer operations

10 releases

0.5.0 Aug 5, 2020
0.4.2 Sep 24, 2019
0.3.4 Jun 25, 2019
0.3.2 May 3, 2019
0.1.0 Jul 22, 2018

#232 in #network

Download history 2759/week @ 2023-11-29 3942/week @ 2023-12-06 4000/week @ 2023-12-13 3491/week @ 2023-12-20 3192/week @ 2023-12-27 3487/week @ 2024-01-03 2987/week @ 2024-01-10 3498/week @ 2024-01-17 4554/week @ 2024-01-24 2788/week @ 2024-01-31 3414/week @ 2024-02-07 2964/week @ 2024-02-14 3527/week @ 2024-02-21 6260/week @ 2024-02-28 6824/week @ 2024-03-06 4111/week @ 2024-03-13

21,186 downloads per month
Used in 4 crates (2 directly)

BSD-3-Clause

5KB
55 lines

buffering

A library for handling buffer operations

Purpose

This library is primarily aimed at simple network serialization and deserialization for stack allocated struct types. It provides 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 a macro which behaves as follows:

  • The provided macro uses a more restrictive 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.

Dependencies

~1.5MB
~33K SLoC