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
11#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct DisplayPowerSetDisplayPowerRequest {
13 pub power_on: bool,
14}
15
16impl fidl::Persistable for DisplayPowerSetDisplayPowerRequest {}
17
18#[derive(Clone, Debug, PartialEq)]
19pub struct InfoGetMetricsResponse {
20 pub info: Metrics,
21}
22
23impl fidl::Persistable for InfoGetMetricsResponse {}
24
25#[derive(Clone, Debug, Default, PartialEq)]
27pub struct Metrics {
28 pub extent_in_px: Option<fidl_fuchsia_math::SizeU>,
31 pub extent_in_mm: Option<fidl_fuchsia_math::SizeU>,
34 pub recommended_device_pixel_ratio: Option<fidl_fuchsia_math::VecF>,
40 pub maximum_refresh_rate_in_millihertz: Option<u32>,
43 #[doc(hidden)]
44 pub __source_breaking: fidl::marker::SourceBreaking,
45}
46
47impl fidl::Persistable for Metrics {}
48
49mod internal {
50 use super::*;
51
52 impl fidl::encoding::ValueTypeMarker for DisplayPowerSetDisplayPowerRequest {
53 type Borrowed<'a> = &'a Self;
54 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
55 value
56 }
57 }
58
59 unsafe impl fidl::encoding::TypeMarker for DisplayPowerSetDisplayPowerRequest {
60 type Owned = Self;
61
62 #[inline(always)]
63 fn inline_align(_context: fidl::encoding::Context) -> usize {
64 1
65 }
66
67 #[inline(always)]
68 fn inline_size(_context: fidl::encoding::Context) -> usize {
69 1
70 }
71 }
72
73 unsafe impl<D: fidl::encoding::ResourceDialect>
74 fidl::encoding::Encode<DisplayPowerSetDisplayPowerRequest, D>
75 for &DisplayPowerSetDisplayPowerRequest
76 {
77 #[inline]
78 unsafe fn encode(
79 self,
80 encoder: &mut fidl::encoding::Encoder<'_, D>,
81 offset: usize,
82 _depth: fidl::encoding::Depth,
83 ) -> fidl::Result<()> {
84 encoder.debug_check_bounds::<DisplayPowerSetDisplayPowerRequest>(offset);
85 fidl::encoding::Encode::<DisplayPowerSetDisplayPowerRequest, D>::encode(
87 (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.power_on),),
88 encoder,
89 offset,
90 _depth,
91 )
92 }
93 }
94 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
95 fidl::encoding::Encode<DisplayPowerSetDisplayPowerRequest, D> for (T0,)
96 {
97 #[inline]
98 unsafe fn encode(
99 self,
100 encoder: &mut fidl::encoding::Encoder<'_, D>,
101 offset: usize,
102 depth: fidl::encoding::Depth,
103 ) -> fidl::Result<()> {
104 encoder.debug_check_bounds::<DisplayPowerSetDisplayPowerRequest>(offset);
105 self.0.encode(encoder, offset + 0, depth)?;
109 Ok(())
110 }
111 }
112
113 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
114 for DisplayPowerSetDisplayPowerRequest
115 {
116 #[inline(always)]
117 fn new_empty() -> Self {
118 Self { power_on: fidl::new_empty!(bool, D) }
119 }
120
121 #[inline]
122 unsafe fn decode(
123 &mut self,
124 decoder: &mut fidl::encoding::Decoder<'_, D>,
125 offset: usize,
126 _depth: fidl::encoding::Depth,
127 ) -> fidl::Result<()> {
128 decoder.debug_check_bounds::<Self>(offset);
129 fidl::decode!(bool, D, &mut self.power_on, decoder, offset + 0, _depth)?;
131 Ok(())
132 }
133 }
134
135 impl fidl::encoding::ValueTypeMarker for InfoGetMetricsResponse {
136 type Borrowed<'a> = &'a Self;
137 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
138 value
139 }
140 }
141
142 unsafe impl fidl::encoding::TypeMarker for InfoGetMetricsResponse {
143 type Owned = Self;
144
145 #[inline(always)]
146 fn inline_align(_context: fidl::encoding::Context) -> usize {
147 8
148 }
149
150 #[inline(always)]
151 fn inline_size(_context: fidl::encoding::Context) -> usize {
152 16
153 }
154 }
155
156 unsafe impl<D: fidl::encoding::ResourceDialect>
157 fidl::encoding::Encode<InfoGetMetricsResponse, D> for &InfoGetMetricsResponse
158 {
159 #[inline]
160 unsafe fn encode(
161 self,
162 encoder: &mut fidl::encoding::Encoder<'_, D>,
163 offset: usize,
164 _depth: fidl::encoding::Depth,
165 ) -> fidl::Result<()> {
166 encoder.debug_check_bounds::<InfoGetMetricsResponse>(offset);
167 fidl::encoding::Encode::<InfoGetMetricsResponse, D>::encode(
169 (<Metrics as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
170 encoder,
171 offset,
172 _depth,
173 )
174 }
175 }
176 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Metrics, D>>
177 fidl::encoding::Encode<InfoGetMetricsResponse, D> for (T0,)
178 {
179 #[inline]
180 unsafe fn encode(
181 self,
182 encoder: &mut fidl::encoding::Encoder<'_, D>,
183 offset: usize,
184 depth: fidl::encoding::Depth,
185 ) -> fidl::Result<()> {
186 encoder.debug_check_bounds::<InfoGetMetricsResponse>(offset);
187 self.0.encode(encoder, offset + 0, depth)?;
191 Ok(())
192 }
193 }
194
195 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
196 for InfoGetMetricsResponse
197 {
198 #[inline(always)]
199 fn new_empty() -> Self {
200 Self { info: fidl::new_empty!(Metrics, D) }
201 }
202
203 #[inline]
204 unsafe fn decode(
205 &mut self,
206 decoder: &mut fidl::encoding::Decoder<'_, D>,
207 offset: usize,
208 _depth: fidl::encoding::Depth,
209 ) -> fidl::Result<()> {
210 decoder.debug_check_bounds::<Self>(offset);
211 fidl::decode!(Metrics, D, &mut self.info, decoder, offset + 0, _depth)?;
213 Ok(())
214 }
215 }
216
217 impl Metrics {
218 #[inline(always)]
219 fn max_ordinal_present(&self) -> u64 {
220 if let Some(_) = self.maximum_refresh_rate_in_millihertz {
221 return 4;
222 }
223 if let Some(_) = self.recommended_device_pixel_ratio {
224 return 3;
225 }
226 if let Some(_) = self.extent_in_mm {
227 return 2;
228 }
229 if let Some(_) = self.extent_in_px {
230 return 1;
231 }
232 0
233 }
234 }
235
236 impl fidl::encoding::ValueTypeMarker for Metrics {
237 type Borrowed<'a> = &'a Self;
238 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
239 value
240 }
241 }
242
243 unsafe impl fidl::encoding::TypeMarker for Metrics {
244 type Owned = Self;
245
246 #[inline(always)]
247 fn inline_align(_context: fidl::encoding::Context) -> usize {
248 8
249 }
250
251 #[inline(always)]
252 fn inline_size(_context: fidl::encoding::Context) -> usize {
253 16
254 }
255 }
256
257 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Metrics, D> for &Metrics {
258 unsafe fn encode(
259 self,
260 encoder: &mut fidl::encoding::Encoder<'_, D>,
261 offset: usize,
262 mut depth: fidl::encoding::Depth,
263 ) -> fidl::Result<()> {
264 encoder.debug_check_bounds::<Metrics>(offset);
265 let max_ordinal: u64 = self.max_ordinal_present();
267 encoder.write_num(max_ordinal, offset);
268 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
269 if max_ordinal == 0 {
271 return Ok(());
272 }
273 depth.increment()?;
274 let envelope_size = 8;
275 let bytes_len = max_ordinal as usize * envelope_size;
276 #[allow(unused_variables)]
277 let offset = encoder.out_of_line_offset(bytes_len);
278 let mut _prev_end_offset: usize = 0;
279 if 1 > max_ordinal {
280 return Ok(());
281 }
282
283 let cur_offset: usize = (1 - 1) * envelope_size;
286
287 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
289
290 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math::SizeU, D>(
295 self.extent_in_px
296 .as_ref()
297 .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
298 encoder,
299 offset + cur_offset,
300 depth,
301 )?;
302
303 _prev_end_offset = cur_offset + envelope_size;
304 if 2 > max_ordinal {
305 return Ok(());
306 }
307
308 let cur_offset: usize = (2 - 1) * envelope_size;
311
312 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
314
315 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math::SizeU, D>(
320 self.extent_in_mm
321 .as_ref()
322 .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
323 encoder,
324 offset + cur_offset,
325 depth,
326 )?;
327
328 _prev_end_offset = cur_offset + envelope_size;
329 if 3 > max_ordinal {
330 return Ok(());
331 }
332
333 let cur_offset: usize = (3 - 1) * envelope_size;
336
337 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
339
340 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_math::VecF, D>(
345 self.recommended_device_pixel_ratio
346 .as_ref()
347 .map(<fidl_fuchsia_math::VecF as fidl::encoding::ValueTypeMarker>::borrow),
348 encoder,
349 offset + cur_offset,
350 depth,
351 )?;
352
353 _prev_end_offset = cur_offset + envelope_size;
354 if 4 > max_ordinal {
355 return Ok(());
356 }
357
358 let cur_offset: usize = (4 - 1) * envelope_size;
361
362 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
364
365 fidl::encoding::encode_in_envelope_optional::<u32, D>(
370 self.maximum_refresh_rate_in_millihertz
371 .as_ref()
372 .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
373 encoder,
374 offset + cur_offset,
375 depth,
376 )?;
377
378 _prev_end_offset = cur_offset + envelope_size;
379
380 Ok(())
381 }
382 }
383
384 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Metrics {
385 #[inline(always)]
386 fn new_empty() -> Self {
387 Self::default()
388 }
389
390 unsafe fn decode(
391 &mut self,
392 decoder: &mut fidl::encoding::Decoder<'_, D>,
393 offset: usize,
394 mut depth: fidl::encoding::Depth,
395 ) -> fidl::Result<()> {
396 decoder.debug_check_bounds::<Self>(offset);
397 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
398 None => return Err(fidl::Error::NotNullable),
399 Some(len) => len,
400 };
401 if len == 0 {
403 return Ok(());
404 };
405 depth.increment()?;
406 let envelope_size = 8;
407 let bytes_len = len * envelope_size;
408 let offset = decoder.out_of_line_offset(bytes_len)?;
409 let mut _next_ordinal_to_read = 0;
411 let mut next_offset = offset;
412 let end_offset = offset + bytes_len;
413 _next_ordinal_to_read += 1;
414 if next_offset >= end_offset {
415 return Ok(());
416 }
417
418 while _next_ordinal_to_read < 1 {
420 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
421 _next_ordinal_to_read += 1;
422 next_offset += envelope_size;
423 }
424
425 let next_out_of_line = decoder.next_out_of_line();
426 let handles_before = decoder.remaining_handles();
427 if let Some((inlined, num_bytes, num_handles)) =
428 fidl::encoding::decode_envelope_header(decoder, next_offset)?
429 {
430 let member_inline_size =
431 <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
432 decoder.context,
433 );
434 if inlined != (member_inline_size <= 4) {
435 return Err(fidl::Error::InvalidInlineBitInEnvelope);
436 }
437 let inner_offset;
438 let mut inner_depth = depth.clone();
439 if inlined {
440 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
441 inner_offset = next_offset;
442 } else {
443 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
444 inner_depth.increment()?;
445 }
446 let val_ref = self
447 .extent_in_px
448 .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math::SizeU, D));
449 fidl::decode!(
450 fidl_fuchsia_math::SizeU,
451 D,
452 val_ref,
453 decoder,
454 inner_offset,
455 inner_depth
456 )?;
457 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
458 {
459 return Err(fidl::Error::InvalidNumBytesInEnvelope);
460 }
461 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
462 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
463 }
464 }
465
466 next_offset += envelope_size;
467 _next_ordinal_to_read += 1;
468 if next_offset >= end_offset {
469 return Ok(());
470 }
471
472 while _next_ordinal_to_read < 2 {
474 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
475 _next_ordinal_to_read += 1;
476 next_offset += envelope_size;
477 }
478
479 let next_out_of_line = decoder.next_out_of_line();
480 let handles_before = decoder.remaining_handles();
481 if let Some((inlined, num_bytes, num_handles)) =
482 fidl::encoding::decode_envelope_header(decoder, next_offset)?
483 {
484 let member_inline_size =
485 <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
486 decoder.context,
487 );
488 if inlined != (member_inline_size <= 4) {
489 return Err(fidl::Error::InvalidInlineBitInEnvelope);
490 }
491 let inner_offset;
492 let mut inner_depth = depth.clone();
493 if inlined {
494 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
495 inner_offset = next_offset;
496 } else {
497 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
498 inner_depth.increment()?;
499 }
500 let val_ref = self
501 .extent_in_mm
502 .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math::SizeU, D));
503 fidl::decode!(
504 fidl_fuchsia_math::SizeU,
505 D,
506 val_ref,
507 decoder,
508 inner_offset,
509 inner_depth
510 )?;
511 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
512 {
513 return Err(fidl::Error::InvalidNumBytesInEnvelope);
514 }
515 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
516 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
517 }
518 }
519
520 next_offset += envelope_size;
521 _next_ordinal_to_read += 1;
522 if next_offset >= end_offset {
523 return Ok(());
524 }
525
526 while _next_ordinal_to_read < 3 {
528 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
529 _next_ordinal_to_read += 1;
530 next_offset += envelope_size;
531 }
532
533 let next_out_of_line = decoder.next_out_of_line();
534 let handles_before = decoder.remaining_handles();
535 if let Some((inlined, num_bytes, num_handles)) =
536 fidl::encoding::decode_envelope_header(decoder, next_offset)?
537 {
538 let member_inline_size =
539 <fidl_fuchsia_math::VecF as fidl::encoding::TypeMarker>::inline_size(
540 decoder.context,
541 );
542 if inlined != (member_inline_size <= 4) {
543 return Err(fidl::Error::InvalidInlineBitInEnvelope);
544 }
545 let inner_offset;
546 let mut inner_depth = depth.clone();
547 if inlined {
548 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
549 inner_offset = next_offset;
550 } else {
551 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
552 inner_depth.increment()?;
553 }
554 let val_ref = self
555 .recommended_device_pixel_ratio
556 .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_math::VecF, D));
557 fidl::decode!(
558 fidl_fuchsia_math::VecF,
559 D,
560 val_ref,
561 decoder,
562 inner_offset,
563 inner_depth
564 )?;
565 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
566 {
567 return Err(fidl::Error::InvalidNumBytesInEnvelope);
568 }
569 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
570 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
571 }
572 }
573
574 next_offset += envelope_size;
575 _next_ordinal_to_read += 1;
576 if next_offset >= end_offset {
577 return Ok(());
578 }
579
580 while _next_ordinal_to_read < 4 {
582 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
583 _next_ordinal_to_read += 1;
584 next_offset += envelope_size;
585 }
586
587 let next_out_of_line = decoder.next_out_of_line();
588 let handles_before = decoder.remaining_handles();
589 if let Some((inlined, num_bytes, num_handles)) =
590 fidl::encoding::decode_envelope_header(decoder, next_offset)?
591 {
592 let member_inline_size =
593 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
594 if inlined != (member_inline_size <= 4) {
595 return Err(fidl::Error::InvalidInlineBitInEnvelope);
596 }
597 let inner_offset;
598 let mut inner_depth = depth.clone();
599 if inlined {
600 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
601 inner_offset = next_offset;
602 } else {
603 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
604 inner_depth.increment()?;
605 }
606 let val_ref = self
607 .maximum_refresh_rate_in_millihertz
608 .get_or_insert_with(|| fidl::new_empty!(u32, D));
609 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
610 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
611 {
612 return Err(fidl::Error::InvalidNumBytesInEnvelope);
613 }
614 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
615 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
616 }
617 }
618
619 next_offset += envelope_size;
620
621 while next_offset < end_offset {
623 _next_ordinal_to_read += 1;
624 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
625 next_offset += envelope_size;
626 }
627
628 Ok(())
629 }
630 }
631}