1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub const MAX_QUERY_LENGTH: u16 = 64;
13
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16#[repr(u32)]
17pub enum LogMethod {
18 LogOccurrence = 1,
19 LogInteger = 2,
20 LogIntegerHistogram = 3,
21 LogString = 4,
22 LogMetricEvents = 5,
23}
24
25impl LogMethod {
26 #[inline]
27 pub fn from_primitive(prim: u32) -> Option<Self> {
28 match prim {
29 1 => Some(Self::LogOccurrence),
30 2 => Some(Self::LogInteger),
31 3 => Some(Self::LogIntegerHistogram),
32 4 => Some(Self::LogString),
33 5 => Some(Self::LogMetricEvents),
34 _ => None,
35 }
36 }
37
38 #[inline]
39 pub const fn into_primitive(self) -> u32 {
40 self as u32
41 }
42
43 #[deprecated = "Strict enums should not use `is_unknown`"]
44 #[inline]
45 pub fn is_unknown(&self) -> bool {
46 false
47 }
48}
49
50#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
51pub struct MetricEventLoggerQuerierResetLoggerRequest {
52 pub project_id: u32,
53 pub method: LogMethod,
54}
55
56impl fidl::Persistable for MetricEventLoggerQuerierResetLoggerRequest {}
57
58#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
59pub struct MetricEventLoggerQuerierWatchLogsRequest {
60 pub project_id: u32,
61 pub method: LogMethod,
62}
63
64impl fidl::Persistable for MetricEventLoggerQuerierWatchLogsRequest {}
65
66#[derive(Clone, Debug, PartialEq)]
67pub struct MetricEventLoggerQuerierWatchLogsResponse {
68 pub events: Vec<fidl_fuchsia_metrics::MetricEvent>,
69 pub more: bool,
70}
71
72impl fidl::Persistable for MetricEventLoggerQuerierWatchLogsResponse {}
73
74mod internal {
75 use super::*;
76 unsafe impl fidl::encoding::TypeMarker for LogMethod {
77 type Owned = Self;
78
79 #[inline(always)]
80 fn inline_align(_context: fidl::encoding::Context) -> usize {
81 std::mem::align_of::<u32>()
82 }
83
84 #[inline(always)]
85 fn inline_size(_context: fidl::encoding::Context) -> usize {
86 std::mem::size_of::<u32>()
87 }
88
89 #[inline(always)]
90 fn encode_is_copy() -> bool {
91 true
92 }
93
94 #[inline(always)]
95 fn decode_is_copy() -> bool {
96 false
97 }
98 }
99
100 impl fidl::encoding::ValueTypeMarker for LogMethod {
101 type Borrowed<'a> = Self;
102 #[inline(always)]
103 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
104 *value
105 }
106 }
107
108 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LogMethod {
109 #[inline]
110 unsafe fn encode(
111 self,
112 encoder: &mut fidl::encoding::Encoder<'_, D>,
113 offset: usize,
114 _depth: fidl::encoding::Depth,
115 ) -> fidl::Result<()> {
116 encoder.debug_check_bounds::<Self>(offset);
117 encoder.write_num(self.into_primitive(), offset);
118 Ok(())
119 }
120 }
121
122 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LogMethod {
123 #[inline(always)]
124 fn new_empty() -> Self {
125 Self::LogOccurrence
126 }
127
128 #[inline]
129 unsafe fn decode(
130 &mut self,
131 decoder: &mut fidl::encoding::Decoder<'_, D>,
132 offset: usize,
133 _depth: fidl::encoding::Depth,
134 ) -> fidl::Result<()> {
135 decoder.debug_check_bounds::<Self>(offset);
136 let prim = decoder.read_num::<u32>(offset);
137
138 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
139 Ok(())
140 }
141 }
142
143 impl fidl::encoding::ValueTypeMarker for MetricEventLoggerQuerierResetLoggerRequest {
144 type Borrowed<'a> = &'a Self;
145 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
146 value
147 }
148 }
149
150 unsafe impl fidl::encoding::TypeMarker for MetricEventLoggerQuerierResetLoggerRequest {
151 type Owned = Self;
152
153 #[inline(always)]
154 fn inline_align(_context: fidl::encoding::Context) -> usize {
155 4
156 }
157
158 #[inline(always)]
159 fn inline_size(_context: fidl::encoding::Context) -> usize {
160 8
161 }
162 }
163
164 unsafe impl<D: fidl::encoding::ResourceDialect>
165 fidl::encoding::Encode<MetricEventLoggerQuerierResetLoggerRequest, D>
166 for &MetricEventLoggerQuerierResetLoggerRequest
167 {
168 #[inline]
169 unsafe fn encode(
170 self,
171 encoder: &mut fidl::encoding::Encoder<'_, D>,
172 offset: usize,
173 _depth: fidl::encoding::Depth,
174 ) -> fidl::Result<()> {
175 encoder.debug_check_bounds::<MetricEventLoggerQuerierResetLoggerRequest>(offset);
176 fidl::encoding::Encode::<MetricEventLoggerQuerierResetLoggerRequest, D>::encode(
178 (
179 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.project_id),
180 <LogMethod as fidl::encoding::ValueTypeMarker>::borrow(&self.method),
181 ),
182 encoder,
183 offset,
184 _depth,
185 )
186 }
187 }
188 unsafe impl<
189 D: fidl::encoding::ResourceDialect,
190 T0: fidl::encoding::Encode<u32, D>,
191 T1: fidl::encoding::Encode<LogMethod, D>,
192 > fidl::encoding::Encode<MetricEventLoggerQuerierResetLoggerRequest, D> for (T0, T1)
193 {
194 #[inline]
195 unsafe fn encode(
196 self,
197 encoder: &mut fidl::encoding::Encoder<'_, D>,
198 offset: usize,
199 depth: fidl::encoding::Depth,
200 ) -> fidl::Result<()> {
201 encoder.debug_check_bounds::<MetricEventLoggerQuerierResetLoggerRequest>(offset);
202 self.0.encode(encoder, offset + 0, depth)?;
206 self.1.encode(encoder, offset + 4, depth)?;
207 Ok(())
208 }
209 }
210
211 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
212 for MetricEventLoggerQuerierResetLoggerRequest
213 {
214 #[inline(always)]
215 fn new_empty() -> Self {
216 Self { project_id: fidl::new_empty!(u32, D), method: fidl::new_empty!(LogMethod, D) }
217 }
218
219 #[inline]
220 unsafe fn decode(
221 &mut self,
222 decoder: &mut fidl::encoding::Decoder<'_, D>,
223 offset: usize,
224 _depth: fidl::encoding::Depth,
225 ) -> fidl::Result<()> {
226 decoder.debug_check_bounds::<Self>(offset);
227 fidl::decode!(u32, D, &mut self.project_id, decoder, offset + 0, _depth)?;
229 fidl::decode!(LogMethod, D, &mut self.method, decoder, offset + 4, _depth)?;
230 Ok(())
231 }
232 }
233
234 impl fidl::encoding::ValueTypeMarker for MetricEventLoggerQuerierWatchLogsRequest {
235 type Borrowed<'a> = &'a Self;
236 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
237 value
238 }
239 }
240
241 unsafe impl fidl::encoding::TypeMarker for MetricEventLoggerQuerierWatchLogsRequest {
242 type Owned = Self;
243
244 #[inline(always)]
245 fn inline_align(_context: fidl::encoding::Context) -> usize {
246 4
247 }
248
249 #[inline(always)]
250 fn inline_size(_context: fidl::encoding::Context) -> usize {
251 8
252 }
253 }
254
255 unsafe impl<D: fidl::encoding::ResourceDialect>
256 fidl::encoding::Encode<MetricEventLoggerQuerierWatchLogsRequest, D>
257 for &MetricEventLoggerQuerierWatchLogsRequest
258 {
259 #[inline]
260 unsafe fn encode(
261 self,
262 encoder: &mut fidl::encoding::Encoder<'_, D>,
263 offset: usize,
264 _depth: fidl::encoding::Depth,
265 ) -> fidl::Result<()> {
266 encoder.debug_check_bounds::<MetricEventLoggerQuerierWatchLogsRequest>(offset);
267 fidl::encoding::Encode::<MetricEventLoggerQuerierWatchLogsRequest, D>::encode(
269 (
270 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.project_id),
271 <LogMethod as fidl::encoding::ValueTypeMarker>::borrow(&self.method),
272 ),
273 encoder,
274 offset,
275 _depth,
276 )
277 }
278 }
279 unsafe impl<
280 D: fidl::encoding::ResourceDialect,
281 T0: fidl::encoding::Encode<u32, D>,
282 T1: fidl::encoding::Encode<LogMethod, D>,
283 > fidl::encoding::Encode<MetricEventLoggerQuerierWatchLogsRequest, D> for (T0, T1)
284 {
285 #[inline]
286 unsafe fn encode(
287 self,
288 encoder: &mut fidl::encoding::Encoder<'_, D>,
289 offset: usize,
290 depth: fidl::encoding::Depth,
291 ) -> fidl::Result<()> {
292 encoder.debug_check_bounds::<MetricEventLoggerQuerierWatchLogsRequest>(offset);
293 self.0.encode(encoder, offset + 0, depth)?;
297 self.1.encode(encoder, offset + 4, depth)?;
298 Ok(())
299 }
300 }
301
302 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
303 for MetricEventLoggerQuerierWatchLogsRequest
304 {
305 #[inline(always)]
306 fn new_empty() -> Self {
307 Self { project_id: fidl::new_empty!(u32, D), method: fidl::new_empty!(LogMethod, D) }
308 }
309
310 #[inline]
311 unsafe fn decode(
312 &mut self,
313 decoder: &mut fidl::encoding::Decoder<'_, D>,
314 offset: usize,
315 _depth: fidl::encoding::Depth,
316 ) -> fidl::Result<()> {
317 decoder.debug_check_bounds::<Self>(offset);
318 fidl::decode!(u32, D, &mut self.project_id, decoder, offset + 0, _depth)?;
320 fidl::decode!(LogMethod, D, &mut self.method, decoder, offset + 4, _depth)?;
321 Ok(())
322 }
323 }
324
325 impl fidl::encoding::ValueTypeMarker for MetricEventLoggerQuerierWatchLogsResponse {
326 type Borrowed<'a> = &'a Self;
327 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
328 value
329 }
330 }
331
332 unsafe impl fidl::encoding::TypeMarker for MetricEventLoggerQuerierWatchLogsResponse {
333 type Owned = Self;
334
335 #[inline(always)]
336 fn inline_align(_context: fidl::encoding::Context) -> usize {
337 8
338 }
339
340 #[inline(always)]
341 fn inline_size(_context: fidl::encoding::Context) -> usize {
342 24
343 }
344 }
345
346 unsafe impl<D: fidl::encoding::ResourceDialect>
347 fidl::encoding::Encode<MetricEventLoggerQuerierWatchLogsResponse, D>
348 for &MetricEventLoggerQuerierWatchLogsResponse
349 {
350 #[inline]
351 unsafe fn encode(
352 self,
353 encoder: &mut fidl::encoding::Encoder<'_, D>,
354 offset: usize,
355 _depth: fidl::encoding::Depth,
356 ) -> fidl::Result<()> {
357 encoder.debug_check_bounds::<MetricEventLoggerQuerierWatchLogsResponse>(offset);
358 fidl::encoding::Encode::<MetricEventLoggerQuerierWatchLogsResponse, D>::encode(
360 (
361 <fidl::encoding::Vector<fidl_fuchsia_metrics::MetricEvent, 64> as fidl::encoding::ValueTypeMarker>::borrow(&self.events),
362 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.more),
363 ),
364 encoder, offset, _depth
365 )
366 }
367 }
368 unsafe impl<
369 D: fidl::encoding::ResourceDialect,
370 T0: fidl::encoding::Encode<
371 fidl::encoding::Vector<fidl_fuchsia_metrics::MetricEvent, 64>,
372 D,
373 >,
374 T1: fidl::encoding::Encode<bool, D>,
375 > fidl::encoding::Encode<MetricEventLoggerQuerierWatchLogsResponse, D> for (T0, T1)
376 {
377 #[inline]
378 unsafe fn encode(
379 self,
380 encoder: &mut fidl::encoding::Encoder<'_, D>,
381 offset: usize,
382 depth: fidl::encoding::Depth,
383 ) -> fidl::Result<()> {
384 encoder.debug_check_bounds::<MetricEventLoggerQuerierWatchLogsResponse>(offset);
385 unsafe {
388 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
389 (ptr as *mut u64).write_unaligned(0);
390 }
391 self.0.encode(encoder, offset + 0, depth)?;
393 self.1.encode(encoder, offset + 16, depth)?;
394 Ok(())
395 }
396 }
397
398 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
399 for MetricEventLoggerQuerierWatchLogsResponse
400 {
401 #[inline(always)]
402 fn new_empty() -> Self {
403 Self {
404 events: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_metrics::MetricEvent, 64>, D),
405 more: fidl::new_empty!(bool, D),
406 }
407 }
408
409 #[inline]
410 unsafe fn decode(
411 &mut self,
412 decoder: &mut fidl::encoding::Decoder<'_, D>,
413 offset: usize,
414 _depth: fidl::encoding::Depth,
415 ) -> fidl::Result<()> {
416 decoder.debug_check_bounds::<Self>(offset);
417 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
419 let padval = unsafe { (ptr as *const u64).read_unaligned() };
420 let mask = 0xffffffffffffff00u64;
421 let maskedval = padval & mask;
422 if maskedval != 0 {
423 return Err(fidl::Error::NonZeroPadding {
424 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
425 });
426 }
427 fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_metrics::MetricEvent, 64>, D, &mut self.events, decoder, offset + 0, _depth)?;
428 fidl::decode!(bool, D, &mut self.more, decoder, offset + 16, _depth)?;
429 Ok(())
430 }
431 }
432}