fidl_next_protocol/
wire.rs1use core::mem::MaybeUninit;
6
7use fidl_next_codec::{
8 Decode, DecodeError, Encodable, Encode, EncodeError, Slot, WireU32, WireU64, ZeroPadding,
9};
10
11use zerocopy::IntoBytes;
12
13#[derive(Clone, Copy, Debug, IntoBytes)]
15#[repr(C)]
16pub struct WireMessageHeader {
17 pub txid: WireU32,
19 pub flags: [u8; 3],
21 pub magic_number: u8,
23 pub ordinal: WireU64,
25}
26
27unsafe impl ZeroPadding for WireMessageHeader {
28 #[inline]
29 fn zero_padding(_: &mut MaybeUninit<Self>) {
30 }
32}
33
34pub const FLAG_0_WIRE_FORMAT_V2_BIT: u8 = 0b0000_0010;
36
37pub const MAGIC_NUMBER: u8 = 0x01;
39
40impl Encodable for WireMessageHeader {
41 type Encoded = WireMessageHeader;
42}
43
44unsafe impl<E: ?Sized> Encode<E> for WireMessageHeader {
45 #[inline]
46 fn encode(
47 &mut self,
48 _: &mut E,
49 out: &mut MaybeUninit<Self::Encoded>,
50 ) -> Result<(), EncodeError> {
51 out.write(*self);
52 Ok(())
53 }
54}
55
56unsafe impl<D: ?Sized> Decode<D> for WireMessageHeader {
57 #[inline]
58 fn decode(_: Slot<'_, Self>, _: &mut D) -> Result<(), DecodeError> {
59 Ok(())
60 }
61}