fidl_fuchsia_component_config_ext/
lib.rs
1#[macro_export]
7macro_rules! config_ty {
8 (bool) => {
9 cm_rust::ConfigValueType::Bool
10 };
11 (uint8) => {
12 cm_rust::ConfigValueType::Uint8
13 };
14 (uint16) => {
15 cm_rust::ConfigValueType::Uint16
16 };
17 (uint32) => {
18 cm_rust::ConfigValueType::Uint32
19 };
20 (uint64) => {
21 cm_rust::ConfigValueType::Uint64
22 };
23 (int8) => {
24 cm_rust::ConfigValueType::Int8
25 };
26 (int16) => {
27 cm_rust::ConfigValueType::Int16
28 };
29 (int32) => {
30 cm_rust::ConfigValueType::Int32
31 };
32 (int64) => {
33 cm_rust::ConfigValueType::Int64
34 };
35 (string, max_size: $size:expr ) => {
36 cm_rust::ConfigValueType::String { max_size: $size }
37 };
38 (vector, element: bool, max_count: $count:expr ) => {
39 cm_rust::ConfigValueType::Vector {
40 max_count: $count,
41 nested_type: cm_rust::ConfigNestedValueType::Bool,
42 }
43 };
44 (vector, element: uint8, max_count: $count:expr ) => {
45 cm_rust::ConfigValueType::Vector {
46 max_count: $count,
47 nested_type: cm_rust::ConfigNestedValueType::Uint8,
48 }
49 };
50 (vector, element: uint16, max_count: $count:expr ) => {
51 cm_rust::ConfigValueType::Vector {
52 max_count: $count,
53 nested_type: cm_rust::ConfigNestedValueType::Uint16,
54 }
55 };
56 (vector, element: uint32, max_count: $count:expr ) => {
57 cm_rust::ConfigValueType::Vector {
58 max_count: $count,
59 nested_type: cm_rust::ConfigNestedValueType::Uint32,
60 }
61 };
62 (vector, element: uint64, max_count: $count:expr ) => {
63 cm_rust::ConfigValueType::Vector {
64 max_count: $count,
65 nested_type: cm_rust::ConfigNestedValueType::Uint64,
66 }
67 };
68 (vector, element: int8, max_count: $count:expr ) => {
69 cm_rust::ConfigValueType::Vector {
70 max_count: $count,
71 nested_type: cm_rust::ConfigNestedValueType::Int8,
72 }
73 };
74 (vector, element: int16, max_count: $count:expr ) => {
75 cm_rust::ConfigValueType::Vector {
76 max_count: $count,
77 nested_type: cm_rust::ConfigNestedValueType::Int16,
78 }
79 };
80 (vector, element: int32, max_count: $count:expr ) => {
81 cm_rust::ConfigValueType::Vector {
82 max_count: $count,
83 nested_type: cm_rust::ConfigNestedValueType::Int32,
84 }
85 };
86 (vector, element: int64, max_count: $count:expr ) => {
87 cm_rust::ConfigValueType::Vector {
88 max_count: $count,
89 nested_type: cm_rust::ConfigNestedValueType::Int64,
90 }
91 };
92 (vector, element: { string, max_size: $size:expr }, max_count: $count:expr ) => {
93 cm_rust::ConfigValueType::Vector {
94 max_count: $count,
95 nested_type: cm_rust::ConfigNestedValueType::String { max_size: $size },
96 }
97 };
98}
99
100#[macro_export]
102macro_rules! config_decl {
103 (ck@ $checksum:expr, $($key:ident: { $($type_toks:tt)+ },)*) => {{
104 let mut fields = vec![];
105 $(
106 fields.push(cm_rust::ConfigField {
107 key: stringify!($key).to_string(),
108 type_: $crate::config_ty!($($type_toks)+ ),
109 mutability: Default::default(),
110 });
111 )*
112 cm_rust::ConfigDecl {
113 fields,
114 checksum: $checksum,
115 value_source: cm_rust::ConfigValueSource::PackagePath("fake.cvf".to_string()),
116 }
117 }};
118}
119
120#[macro_export]
122macro_rules! values_data {
123 [ck@ $checksum:expr, $($value:expr,)*] => {{
124 let mut values = vec![];
125 $(
126 values.push(cm_rust::ConfigValueSpec {
127 value: $value,
128 });
129 )*
130 cm_rust::ConfigValuesData {
131 values,
132 checksum: $checksum
133 }
134 }};
135}