binary_layout/
example.rs

1//! This module contains an example use case for defining a layout: ICMP packets.
2
3use crate::prelude::*;
4
5// See https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol for ICMP packet layout
6binary_layout!(icmp_packet, BigEndian, {
7  packet_type: u8,
8  code: u8,
9  checksum: u16,
10  rest_of_header: [u8; 4],
11  data_section: [u8], // open ended byte array, matches until the end of the packet
12});