inspect_validator/
macros.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
// Copyright 2023 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#[macro_export]
macro_rules! create_node {
    (parent: $parent:expr, id: $id:expr, name: $name:expr) => {
        fidl_diagnostics_validate::Action::CreateNode(fidl_diagnostics_validate::CreateNode {
            parent: $parent,
            id: $id,
            name: $name.into(),
        })
    };
}

#[macro_export]
macro_rules! delete_node {
    (id: $id:expr) => {
        fidl_diagnostics_validate::Action::DeleteNode(fidl_diagnostics_validate::DeleteNode {
            id: $id,
        })
    };
}

#[macro_export]
macro_rules! create_numeric_property {
    (parent: $parent:expr, id: $id:expr, name: $name:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::CreateNumericProperty(
            fidl_diagnostics_validate::CreateNumericProperty {
                parent: $parent,
                id: $id,
                name: $name.into(),
                value: $value,
            },
        )
    };
}

#[macro_export]
macro_rules! create_bytes_property {
    (parent: $parent:expr, id: $id:expr, name: $name:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::CreateBytesProperty(
            fidl_diagnostics_validate::CreateBytesProperty {
                parent: $parent,
                id: $id,
                name: $name.into(),
                value: $value.into(),
            },
        )
    };
}

#[macro_export]
macro_rules! create_string_property {
    (parent: $parent:expr, id: $id:expr, name: $name:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::CreateStringProperty(
            fidl_diagnostics_validate::CreateStringProperty {
                parent: $parent,
                id: $id,
                name: $name.into(),
                value: $value.into(),
            },
        )
    };
}

#[macro_export]
macro_rules! create_bool_property {
    (parent: $parent:expr, id: $id:expr, name: $name:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::CreateBoolProperty(
            fidl_diagnostics_validate::CreateBoolProperty {
                parent: $parent,
                id: $id,
                name: $name.into(),
                value: $value.into(),
            },
        )
    };
}

#[macro_export]
macro_rules! set_string {
    (id: $id:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::SetString(fidl_diagnostics_validate::SetString {
            id: $id,
            value: $value.into(),
        })
    };
}

#[macro_export]
macro_rules! set_bytes {
    (id: $id:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::SetBytes(fidl_diagnostics_validate::SetBytes {
            id: $id,
            value: $value.into(),
        })
    };
}

#[macro_export]
macro_rules! set_number {
    (id: $id:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::SetNumber(fidl_diagnostics_validate::SetNumber {
            id: $id,
            value: $value,
        })
    };
}

#[macro_export]
macro_rules! set_bool {
    (id: $id:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::SetBool(fidl_diagnostics_validate::SetBool {
            id: $id,
            value: $value.into(),
        })
    };
}

#[macro_export]
macro_rules! add_number {
    (id: $id:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::AddNumber(fidl_diagnostics_validate::AddNumber {
            id: $id,
            value: $value,
        })
    };
}

#[macro_export]
macro_rules! subtract_number {
    (id: $id:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::SubtractNumber(
            fidl_diagnostics_validate::SubtractNumber { id: $id, value: $value },
        )
    };
}

#[macro_export]
macro_rules! delete_property {
    (id: $id:expr) => {
        fidl_diagnostics_validate::Action::DeleteProperty(
            fidl_diagnostics_validate::DeleteProperty { id: $id },
        )
    };
}

#[macro_export]
macro_rules! apply_no_op {
    () => {
        fidl_diagnostics_validate::Action::ApplyNoOp(fidl_diagnostics_validate::ApplyNoOp {})
    };
}

#[macro_export]
macro_rules! create_array_property {
    (parent: $parent:expr, id: $id:expr, name: $name:expr, slots: $slots:expr, type: $type:expr) => {
        fidl_diagnostics_validate::Action::CreateArrayProperty(
            fidl_diagnostics_validate::CreateArrayProperty {
                parent: $parent,
                id: $id,
                name: $name.into(),
                slots: $slots,
                value_type: $type,
            },
        )
    };
}

#[macro_export]
macro_rules! array_set {
    (id: $id:expr, index: $index:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::ArraySet(fidl_diagnostics_validate::ArraySet {
            id: $id,
            index: $index,
            value: $value,
        })
    };
}

#[macro_export]
macro_rules! array_add {
    (id: $id:expr, index: $index:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::ArrayAdd(fidl_diagnostics_validate::ArrayAdd {
            id: $id,
            index: $index,
            value: $value,
        })
    };
}

#[macro_export]
macro_rules! array_subtract {
    (id: $id:expr, index: $index:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::ArraySubtract(fidl_diagnostics_validate::ArraySubtract {
            id: $id,
            index: $index,
            value: $value,
        })
    };
}

#[macro_export]
macro_rules! create_linear_histogram {
    (parent: $parent:expr, id: $id:expr, name: $name:expr, floor: $floor:expr,
        step_size: $step_size:expr, buckets: $buckets:expr, type: $type:ident) => {
        fidl_diagnostics_validate::Action::CreateLinearHistogram(
            fidl_diagnostics_validate::CreateLinearHistogram {
                parent: $parent,
                id: $id,
                name: $name.into(),
                floor: Value::$type($floor),
                step_size: Value::$type($step_size),
                buckets: $buckets,
            },
        )
    };
}

#[macro_export]
macro_rules! create_exponential_histogram {
    (parent: $parent:expr, id: $id:expr, name: $name:expr, floor: $floor:expr,
        initial_step: $initial_step:expr, step_multiplier: $step_multiplier:expr,
        buckets: $buckets:expr, type: $type:ident) => {
        fidl_diagnostics_validate::Action::CreateExponentialHistogram(
            fidl_diagnostics_validate::CreateExponentialHistogram {
                parent: $parent,
                id: $id,
                name: $name.into(),
                floor: Value::$type($floor),
                initial_step: Value::$type($initial_step),
                step_multiplier: Value::$type($step_multiplier),
                buckets: $buckets,
            },
        )
    };
}

#[macro_export]
macro_rules! insert {
    (id: $id:expr, value: $value:expr) => {
        fidl_diagnostics_validate::Action::Insert(fidl_diagnostics_validate::Insert {
            id: $id,
            value: $value,
        })
    };
}

#[macro_export]
macro_rules! insert_multiple {
    (id: $id:expr, value: $value:expr, count: $count:expr) => {
        fidl_diagnostics_validate::Action::InsertMultiple(
            fidl_diagnostics_validate::InsertMultiple { id: $id, value: $value, count: $count },
        )
    };
}

#[macro_export]
macro_rules! create_lazy_node {
    (parent: $parent:expr, id: $id:expr, name: $name:expr, disposition: $disposition:expr, actions: $actions:expr) => {
        fidl_diagnostics_validate::LazyAction::CreateLazyNode(
            fidl_diagnostics_validate::CreateLazyNode {
                parent: $parent,
                id: $id,
                name: $name.into(),
                disposition: $disposition,
                actions: $actions,
            },
        )
    };
}

#[macro_export]
macro_rules! delete_lazy_node {
    (id: $id:expr) => {
        fidl_diagnostics_validate::LazyAction::DeleteLazyNode(
            fidl_diagnostics_validate::DeleteLazyNode { id: $id },
        )
    };
}