fidl_next_codec/chunk.rs
1// Copyright 2024 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::WireU64;
6
7/// FIDL alignment, used for buffer alignment to ensure decoding in-place is
8/// possible.
9pub const CHUNK_SIZE: usize = 8;
10
11/// A group of eight bytes, aligned to an 8-byte boundary.
12pub type Chunk = WireU64;
13
14/// Returns a slice of chunks with the same bytewise value as the given bytes.
15#[macro_export]
16macro_rules! chunks {
17 ($(
18 $b0:literal, $b1:literal, $b2:literal, $b3:literal,
19 $b4:literal, $b5:literal, $b6:literal, $b7:literal
20 ),* $(,)?) => {
21 [
22 $($crate::WireU64(u64::from_le_bytes([
23 $b0, $b1, $b2, $b3, $b4, $b5, $b6, $b7,
24 ])),)*
25 ]
26 }
27}