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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12pub enum AutoFocusError {
13 #[doc(hidden)]
14 __SourceBreaking { unknown_ordinal: u32 },
15}
16
17#[macro_export]
19macro_rules! AutoFocusErrorUnknown {
20 () => {
21 _
22 };
23}
24
25impl AutoFocusError {
26 #[inline]
27 pub fn from_primitive(prim: u32) -> Option<Self> {
28 match prim {
29 _ => None,
30 }
31 }
32
33 #[inline]
34 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
35 match prim {
36 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
37 }
38 }
39
40 #[inline]
41 pub fn unknown() -> Self {
42 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
43 }
44
45 #[inline]
46 pub const fn into_primitive(self) -> u32 {
47 match self {
48 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
49 }
50 }
51
52 #[inline]
53 pub fn is_unknown(&self) -> bool {
54 match self {
55 Self::__SourceBreaking { unknown_ordinal: _ } => true,
56 }
57 }
58}
59
60#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
62#[repr(u32)]
63pub enum Error {
64 Denied = 1,
66}
67
68impl Error {
69 #[inline]
70 pub fn from_primitive(prim: u32) -> Option<Self> {
71 match prim {
72 1 => Some(Self::Denied),
73 _ => None,
74 }
75 }
76
77 #[inline]
78 pub const fn into_primitive(self) -> u32 {
79 self as u32
80 }
81
82 #[deprecated = "Strict enums should not use `is_unknown`"]
83 #[inline]
84 pub fn is_unknown(&self) -> bool {
85 false
86 }
87}
88
89#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
91#[repr(u32)]
92pub enum ViewRefInstalledError {
93 InvalidViewRef = 1,
95}
96
97impl ViewRefInstalledError {
98 #[inline]
99 pub fn from_primitive(prim: u32) -> Option<Self> {
100 match prim {
101 1 => Some(Self::InvalidViewRef),
102 _ => None,
103 }
104 }
105
106 #[inline]
107 pub const fn into_primitive(self) -> u32 {
108 self as u32
109 }
110
111 #[deprecated = "Strict enums should not use `is_unknown`"]
112 #[inline]
113 pub fn is_unknown(&self) -> bool {
114 false
115 }
116}
117
118#[derive(Clone, Debug, PartialEq)]
119pub struct ViewRefFocusedWatchResponse {
120 pub state: FocusState,
121}
122
123impl fidl::Persistable for ViewRefFocusedWatchResponse {}
124
125#[derive(Clone, Debug, Default, PartialEq)]
127pub struct FocusState {
128 pub focused: Option<bool>,
132 #[doc(hidden)]
133 pub __source_breaking: fidl::marker::SourceBreaking,
134}
135
136impl fidl::Persistable for FocusState {}
137
138#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
140pub enum Command {
141 Empty(i32),
142}
143
144impl Command {
145 #[inline]
146 pub fn ordinal(&self) -> u64 {
147 match *self {
148 Self::Empty(_) => 1,
149 }
150 }
151
152 #[deprecated = "Strict unions should not use `is_unknown`"]
153 #[inline]
154 pub fn is_unknown(&self) -> bool {
155 false
156 }
157}
158
159impl fidl::Persistable for Command {}
160
161mod internal {
162 use super::*;
163 unsafe impl fidl::encoding::TypeMarker for AutoFocusError {
164 type Owned = Self;
165
166 #[inline(always)]
167 fn inline_align(_context: fidl::encoding::Context) -> usize {
168 std::mem::align_of::<u32>()
169 }
170
171 #[inline(always)]
172 fn inline_size(_context: fidl::encoding::Context) -> usize {
173 std::mem::size_of::<u32>()
174 }
175
176 #[inline(always)]
177 fn encode_is_copy() -> bool {
178 false
179 }
180
181 #[inline(always)]
182 fn decode_is_copy() -> bool {
183 false
184 }
185 }
186
187 impl fidl::encoding::ValueTypeMarker for AutoFocusError {
188 type Borrowed<'a> = Self;
189 #[inline(always)]
190 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
191 *value
192 }
193 }
194
195 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for AutoFocusError {
196 #[inline]
197 unsafe fn encode(
198 self,
199 encoder: &mut fidl::encoding::Encoder<'_, D>,
200 offset: usize,
201 _depth: fidl::encoding::Depth,
202 ) -> fidl::Result<()> {
203 encoder.debug_check_bounds::<Self>(offset);
204 encoder.write_num(self.into_primitive(), offset);
205 Ok(())
206 }
207 }
208
209 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AutoFocusError {
210 #[inline(always)]
211 fn new_empty() -> Self {
212 Self::unknown()
213 }
214
215 #[inline]
216 unsafe fn decode(
217 &mut self,
218 decoder: &mut fidl::encoding::Decoder<'_, D>,
219 offset: usize,
220 _depth: fidl::encoding::Depth,
221 ) -> fidl::Result<()> {
222 decoder.debug_check_bounds::<Self>(offset);
223 let prim = decoder.read_num::<u32>(offset);
224
225 *self = Self::from_primitive_allow_unknown(prim);
226 Ok(())
227 }
228 }
229 unsafe impl fidl::encoding::TypeMarker for Error {
230 type Owned = Self;
231
232 #[inline(always)]
233 fn inline_align(_context: fidl::encoding::Context) -> usize {
234 std::mem::align_of::<u32>()
235 }
236
237 #[inline(always)]
238 fn inline_size(_context: fidl::encoding::Context) -> usize {
239 std::mem::size_of::<u32>()
240 }
241
242 #[inline(always)]
243 fn encode_is_copy() -> bool {
244 true
245 }
246
247 #[inline(always)]
248 fn decode_is_copy() -> bool {
249 false
250 }
251 }
252
253 impl fidl::encoding::ValueTypeMarker for Error {
254 type Borrowed<'a> = Self;
255 #[inline(always)]
256 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
257 *value
258 }
259 }
260
261 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
262 #[inline]
263 unsafe fn encode(
264 self,
265 encoder: &mut fidl::encoding::Encoder<'_, D>,
266 offset: usize,
267 _depth: fidl::encoding::Depth,
268 ) -> fidl::Result<()> {
269 encoder.debug_check_bounds::<Self>(offset);
270 encoder.write_num(self.into_primitive(), offset);
271 Ok(())
272 }
273 }
274
275 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
276 #[inline(always)]
277 fn new_empty() -> Self {
278 Self::Denied
279 }
280
281 #[inline]
282 unsafe fn decode(
283 &mut self,
284 decoder: &mut fidl::encoding::Decoder<'_, D>,
285 offset: usize,
286 _depth: fidl::encoding::Depth,
287 ) -> fidl::Result<()> {
288 decoder.debug_check_bounds::<Self>(offset);
289 let prim = decoder.read_num::<u32>(offset);
290
291 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
292 Ok(())
293 }
294 }
295 unsafe impl fidl::encoding::TypeMarker for ViewRefInstalledError {
296 type Owned = Self;
297
298 #[inline(always)]
299 fn inline_align(_context: fidl::encoding::Context) -> usize {
300 std::mem::align_of::<u32>()
301 }
302
303 #[inline(always)]
304 fn inline_size(_context: fidl::encoding::Context) -> usize {
305 std::mem::size_of::<u32>()
306 }
307
308 #[inline(always)]
309 fn encode_is_copy() -> bool {
310 true
311 }
312
313 #[inline(always)]
314 fn decode_is_copy() -> bool {
315 false
316 }
317 }
318
319 impl fidl::encoding::ValueTypeMarker for ViewRefInstalledError {
320 type Borrowed<'a> = Self;
321 #[inline(always)]
322 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
323 *value
324 }
325 }
326
327 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
328 for ViewRefInstalledError
329 {
330 #[inline]
331 unsafe fn encode(
332 self,
333 encoder: &mut fidl::encoding::Encoder<'_, D>,
334 offset: usize,
335 _depth: fidl::encoding::Depth,
336 ) -> fidl::Result<()> {
337 encoder.debug_check_bounds::<Self>(offset);
338 encoder.write_num(self.into_primitive(), offset);
339 Ok(())
340 }
341 }
342
343 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ViewRefInstalledError {
344 #[inline(always)]
345 fn new_empty() -> Self {
346 Self::InvalidViewRef
347 }
348
349 #[inline]
350 unsafe fn decode(
351 &mut self,
352 decoder: &mut fidl::encoding::Decoder<'_, D>,
353 offset: usize,
354 _depth: fidl::encoding::Depth,
355 ) -> fidl::Result<()> {
356 decoder.debug_check_bounds::<Self>(offset);
357 let prim = decoder.read_num::<u32>(offset);
358
359 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
360 Ok(())
361 }
362 }
363
364 impl fidl::encoding::ValueTypeMarker for ViewRefFocusedWatchResponse {
365 type Borrowed<'a> = &'a Self;
366 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
367 value
368 }
369 }
370
371 unsafe impl fidl::encoding::TypeMarker for ViewRefFocusedWatchResponse {
372 type Owned = Self;
373
374 #[inline(always)]
375 fn inline_align(_context: fidl::encoding::Context) -> usize {
376 8
377 }
378
379 #[inline(always)]
380 fn inline_size(_context: fidl::encoding::Context) -> usize {
381 16
382 }
383 }
384
385 unsafe impl<D: fidl::encoding::ResourceDialect>
386 fidl::encoding::Encode<ViewRefFocusedWatchResponse, D> for &ViewRefFocusedWatchResponse
387 {
388 #[inline]
389 unsafe fn encode(
390 self,
391 encoder: &mut fidl::encoding::Encoder<'_, D>,
392 offset: usize,
393 _depth: fidl::encoding::Depth,
394 ) -> fidl::Result<()> {
395 encoder.debug_check_bounds::<ViewRefFocusedWatchResponse>(offset);
396 fidl::encoding::Encode::<ViewRefFocusedWatchResponse, D>::encode(
398 (<FocusState as fidl::encoding::ValueTypeMarker>::borrow(&self.state),),
399 encoder,
400 offset,
401 _depth,
402 )
403 }
404 }
405 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<FocusState, D>>
406 fidl::encoding::Encode<ViewRefFocusedWatchResponse, D> for (T0,)
407 {
408 #[inline]
409 unsafe fn encode(
410 self,
411 encoder: &mut fidl::encoding::Encoder<'_, D>,
412 offset: usize,
413 depth: fidl::encoding::Depth,
414 ) -> fidl::Result<()> {
415 encoder.debug_check_bounds::<ViewRefFocusedWatchResponse>(offset);
416 self.0.encode(encoder, offset + 0, depth)?;
420 Ok(())
421 }
422 }
423
424 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
425 for ViewRefFocusedWatchResponse
426 {
427 #[inline(always)]
428 fn new_empty() -> Self {
429 Self { state: fidl::new_empty!(FocusState, D) }
430 }
431
432 #[inline]
433 unsafe fn decode(
434 &mut self,
435 decoder: &mut fidl::encoding::Decoder<'_, D>,
436 offset: usize,
437 _depth: fidl::encoding::Depth,
438 ) -> fidl::Result<()> {
439 decoder.debug_check_bounds::<Self>(offset);
440 fidl::decode!(FocusState, D, &mut self.state, decoder, offset + 0, _depth)?;
442 Ok(())
443 }
444 }
445
446 impl FocusState {
447 #[inline(always)]
448 fn max_ordinal_present(&self) -> u64 {
449 if let Some(_) = self.focused {
450 return 1;
451 }
452 0
453 }
454 }
455
456 impl fidl::encoding::ValueTypeMarker for FocusState {
457 type Borrowed<'a> = &'a Self;
458 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
459 value
460 }
461 }
462
463 unsafe impl fidl::encoding::TypeMarker for FocusState {
464 type Owned = Self;
465
466 #[inline(always)]
467 fn inline_align(_context: fidl::encoding::Context) -> usize {
468 8
469 }
470
471 #[inline(always)]
472 fn inline_size(_context: fidl::encoding::Context) -> usize {
473 16
474 }
475 }
476
477 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<FocusState, D>
478 for &FocusState
479 {
480 unsafe fn encode(
481 self,
482 encoder: &mut fidl::encoding::Encoder<'_, D>,
483 offset: usize,
484 mut depth: fidl::encoding::Depth,
485 ) -> fidl::Result<()> {
486 encoder.debug_check_bounds::<FocusState>(offset);
487 let max_ordinal: u64 = self.max_ordinal_present();
489 encoder.write_num(max_ordinal, offset);
490 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
491 if max_ordinal == 0 {
493 return Ok(());
494 }
495 depth.increment()?;
496 let envelope_size = 8;
497 let bytes_len = max_ordinal as usize * envelope_size;
498 #[allow(unused_variables)]
499 let offset = encoder.out_of_line_offset(bytes_len);
500 let mut _prev_end_offset: usize = 0;
501 if 1 > max_ordinal {
502 return Ok(());
503 }
504
505 let cur_offset: usize = (1 - 1) * envelope_size;
508
509 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
511
512 fidl::encoding::encode_in_envelope_optional::<bool, D>(
517 self.focused.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
518 encoder,
519 offset + cur_offset,
520 depth,
521 )?;
522
523 _prev_end_offset = cur_offset + envelope_size;
524
525 Ok(())
526 }
527 }
528
529 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FocusState {
530 #[inline(always)]
531 fn new_empty() -> Self {
532 Self::default()
533 }
534
535 unsafe fn decode(
536 &mut self,
537 decoder: &mut fidl::encoding::Decoder<'_, D>,
538 offset: usize,
539 mut depth: fidl::encoding::Depth,
540 ) -> fidl::Result<()> {
541 decoder.debug_check_bounds::<Self>(offset);
542 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
543 None => return Err(fidl::Error::NotNullable),
544 Some(len) => len,
545 };
546 if len == 0 {
548 return Ok(());
549 };
550 depth.increment()?;
551 let envelope_size = 8;
552 let bytes_len = len * envelope_size;
553 let offset = decoder.out_of_line_offset(bytes_len)?;
554 let mut _next_ordinal_to_read = 0;
556 let mut next_offset = offset;
557 let end_offset = offset + bytes_len;
558 _next_ordinal_to_read += 1;
559 if next_offset >= end_offset {
560 return Ok(());
561 }
562
563 while _next_ordinal_to_read < 1 {
565 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
566 _next_ordinal_to_read += 1;
567 next_offset += envelope_size;
568 }
569
570 let next_out_of_line = decoder.next_out_of_line();
571 let handles_before = decoder.remaining_handles();
572 if let Some((inlined, num_bytes, num_handles)) =
573 fidl::encoding::decode_envelope_header(decoder, next_offset)?
574 {
575 let member_inline_size =
576 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
577 if inlined != (member_inline_size <= 4) {
578 return Err(fidl::Error::InvalidInlineBitInEnvelope);
579 }
580 let inner_offset;
581 let mut inner_depth = depth.clone();
582 if inlined {
583 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
584 inner_offset = next_offset;
585 } else {
586 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
587 inner_depth.increment()?;
588 }
589 let val_ref = self.focused.get_or_insert_with(|| fidl::new_empty!(bool, D));
590 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
591 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
592 {
593 return Err(fidl::Error::InvalidNumBytesInEnvelope);
594 }
595 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
596 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
597 }
598 }
599
600 next_offset += envelope_size;
601
602 while next_offset < end_offset {
604 _next_ordinal_to_read += 1;
605 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
606 next_offset += envelope_size;
607 }
608
609 Ok(())
610 }
611 }
612
613 impl fidl::encoding::ValueTypeMarker for Command {
614 type Borrowed<'a> = &'a Self;
615 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
616 value
617 }
618 }
619
620 unsafe impl fidl::encoding::TypeMarker for Command {
621 type Owned = Self;
622
623 #[inline(always)]
624 fn inline_align(_context: fidl::encoding::Context) -> usize {
625 8
626 }
627
628 #[inline(always)]
629 fn inline_size(_context: fidl::encoding::Context) -> usize {
630 16
631 }
632 }
633
634 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Command, D> for &Command {
635 #[inline]
636 unsafe fn encode(
637 self,
638 encoder: &mut fidl::encoding::Encoder<'_, D>,
639 offset: usize,
640 _depth: fidl::encoding::Depth,
641 ) -> fidl::Result<()> {
642 encoder.debug_check_bounds::<Command>(offset);
643 encoder.write_num::<u64>(self.ordinal(), offset);
644 match self {
645 Command::Empty(ref val) => fidl::encoding::encode_in_envelope::<i32, D>(
646 <i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
647 encoder,
648 offset + 8,
649 _depth,
650 ),
651 }
652 }
653 }
654
655 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Command {
656 #[inline(always)]
657 fn new_empty() -> Self {
658 Self::Empty(fidl::new_empty!(i32, D))
659 }
660
661 #[inline]
662 unsafe fn decode(
663 &mut self,
664 decoder: &mut fidl::encoding::Decoder<'_, D>,
665 offset: usize,
666 mut depth: fidl::encoding::Depth,
667 ) -> fidl::Result<()> {
668 decoder.debug_check_bounds::<Self>(offset);
669 #[allow(unused_variables)]
670 let next_out_of_line = decoder.next_out_of_line();
671 let handles_before = decoder.remaining_handles();
672 let (ordinal, inlined, num_bytes, num_handles) =
673 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
674
675 let member_inline_size = match ordinal {
676 1 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
677 _ => return Err(fidl::Error::UnknownUnionTag),
678 };
679
680 if inlined != (member_inline_size <= 4) {
681 return Err(fidl::Error::InvalidInlineBitInEnvelope);
682 }
683 let _inner_offset;
684 if inlined {
685 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
686 _inner_offset = offset + 8;
687 } else {
688 depth.increment()?;
689 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
690 }
691 match ordinal {
692 1 => {
693 #[allow(irrefutable_let_patterns)]
694 if let Command::Empty(_) = self {
695 } else {
697 *self = Command::Empty(fidl::new_empty!(i32, D));
699 }
700 #[allow(irrefutable_let_patterns)]
701 if let Command::Empty(ref mut val) = self {
702 fidl::decode!(i32, D, val, decoder, _inner_offset, depth)?;
703 } else {
704 unreachable!()
705 }
706 }
707 ordinal => panic!("unexpected ordinal {:?}", ordinal),
708 }
709 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
710 return Err(fidl::Error::InvalidNumBytesInEnvelope);
711 }
712 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
713 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
714 }
715 Ok(())
716 }
717 }
718}