1use super::StructMetadata;
7use super::TableEncoder;
8use super::decode::ErasedDecoderEntry;
9use super::decode::StructDecodeMetadata;
10use super::encode::ErasedEncoderEntry;
11use super::encode::StructEncodeMetadata;
12use crate::DefaultEncoding;
13use crate::FieldDecode;
14use crate::FieldEncode;
15use crate::protofile::DescribeField;
16use crate::protofile::DescribeMessage;
17use crate::protofile::FieldType;
18use crate::protofile::MessageDescription;
19
20impl DescribeMessage<()> for TableEncoder {
21 const DESCRIPTION: MessageDescription<'static> = MessageDescription::External {
22 name: "google.protobuf.Empty",
23 import_path: "google/protobuf/empty.proto",
24 };
25}
26
27macro_rules! tuplegen {
28 { $(
29 ($count:expr, $( ($t:ident, $e:ident, $u:ident, $n:tt) ),* $(,)?)
30 ),* $(,)?
31 } => {
32 $(
33 unsafe impl<'a, $($t,)*> StructMetadata for ($($t,)*) {
35 const NUMBERS: &'static [u32] = &[$($n + 1,)*];
36 const OFFSETS: &'static [usize] = &[$(core::mem::offset_of!(Self, $n),)*];
37 }
38
39 unsafe impl<R, $($t,)*> StructEncodeMetadata<R> for ($($t,)*)
41 where
42 $($t: DefaultEncoding,)*
43 $($t::Encoding: FieldEncode<$t, R>,)*
44 {
45 const ENCODERS: &'static [ErasedEncoderEntry] = &[$(<$t::Encoding>::ENTRY.erase(),)*];
46 }
47
48 unsafe impl<'de, R, $($t,)*> StructDecodeMetadata<'de, R> for ($($t,)*)
50 where
51 $($t: DefaultEncoding,)*
52 $($t::Encoding: FieldDecode<'de, $t, R>,)*
53 {
54 const DECODERS: &'static [ErasedDecoderEntry] = &[$(<$t::Encoding>::ENTRY.erase(),)*];
55 }
56
57 impl<$($t: DefaultEncoding,)*> DefaultEncoding for ($($t,)*) {
58 type Encoding = TableEncoder;
59 }
60
61 impl<$($t,)*> DescribeField<($($t,)*)> for TableEncoder
62 where
63 $($t: DefaultEncoding,)*
64 $($t::Encoding: DescribeField<$t>,)*
65 {
66 const FIELD_TYPE: FieldType<'static> = FieldType::tuple(&[$(<$t::Encoding as DescribeField<$t>>::FIELD_TYPE,)*]);
67 }
68 )*
69 };
70}
71
72tuplegen! {
73 (0, ),
74 (1, (E0, T0, U0, 0)),
75 (2, (E0, T0, U0, 0), (E1, T1, U1, 1)),
76 (3, (E0, T0, U0, 0), (E1, T1, U1, 1), (E2, T2, U2, 2)),
77 (4, (E0, T0, U0, 0), (E1, T1, U1, 1), (E2, T2, U2, 2), (E3, T3, U3, 3)),
78 (5, (E0, T0, U0, 0), (E1, T1, U1, 1), (E2, T2, U2, 2), (E3, T3, U3, 3), (E4, T4, U4, 4)),
79 (6, (E0, T0, U0, 0), (E1, T1, U1, 1), (E2, T2, U2, 2), (E3, T3, U3, 3), (E4, T4, U4, 4), (E5, T5, U5, 5)),
80 (7, (E0, T0, U0, 0), (E1, T1, U1, 1), (E2, T2, U2, 2), (E3, T3, U3, 3), (E4, T4, U4, 4), (E5, T5, U5, 5), (E6, T6, U6, 6)),
81}