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
11bitflags! {
12 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
24 pub struct LockState: u64 {
25 const CAPS_LOCK = 1;
38 const NUM_LOCK = 2;
40 const SCROLL_LOCK = 4;
42 const FUNCTION_LOCK = 8;
44 const SYMBOL_LOCK = 16;
46 }
47}
48
49impl LockState {
50 #[inline(always)]
51 pub fn from_bits_allow_unknown(bits: u64) -> Self {
52 Self::from_bits_retain(bits)
53 }
54
55 #[inline(always)]
56 pub fn has_unknown_bits(&self) -> bool {
57 self.get_unknown_bits() != 0
58 }
59
60 #[inline(always)]
61 pub fn get_unknown_bits(&self) -> u64 {
62 self.bits() & !Self::all().bits()
63 }
64}
65
66bitflags! {
67 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
82 pub struct Modifiers: u64 {
83 const CAPS_LOCK = 1;
85 const NUM_LOCK = 2;
87 const SCROLL_LOCK = 4;
89 const FUNCTION = 8;
91 const SYMBOL = 16;
93 const LEFT_SHIFT = 32;
95 const RIGHT_SHIFT = 64;
97 const SHIFT = 128;
102 const LEFT_ALT = 256;
104 const RIGHT_ALT = 512;
106 const ALT = 1024;
109 const ALT_GRAPH = 2048;
111 const LEFT_META = 4096;
113 const RIGHT_META = 8192;
115 const META = 16384;
117 const LEFT_CTRL = 32768;
119 const RIGHT_CTRL = 65536;
121 const CTRL = 131072;
123 }
124}
125
126impl Modifiers {
127 #[inline(always)]
128 pub fn from_bits_allow_unknown(bits: u64) -> Self {
129 Self::from_bits_retain(bits)
130 }
131
132 #[inline(always)]
133 pub fn has_unknown_bits(&self) -> bool {
134 self.get_unknown_bits() != 0
135 }
136
137 #[inline(always)]
138 pub fn get_unknown_bits(&self) -> u64 {
139 self.bits() & !Self::all().bits()
140 }
141}
142
143#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
147#[repr(u32)]
148pub enum KeyEventStatus {
149 Handled = 1,
151 NotHandled = 2,
153}
154
155impl KeyEventStatus {
156 #[inline]
157 pub fn from_primitive(prim: u32) -> Option<Self> {
158 match prim {
159 1 => Some(Self::Handled),
160 2 => Some(Self::NotHandled),
161 _ => None,
162 }
163 }
164
165 #[inline]
166 pub const fn into_primitive(self) -> u32 {
167 self as u32
168 }
169
170 #[deprecated = "Strict enums should not use `is_unknown`"]
171 #[inline]
172 pub fn is_unknown(&self) -> bool {
173 false
174 }
175}
176
177#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
181#[repr(u32)]
182pub enum KeyEventType {
183 Pressed = 1,
192 Released = 2,
201 Sync = 3,
222 Cancel = 4,
243}
244
245impl KeyEventType {
246 #[inline]
247 pub fn from_primitive(prim: u32) -> Option<Self> {
248 match prim {
249 1 => Some(Self::Pressed),
250 2 => Some(Self::Released),
251 3 => Some(Self::Sync),
252 4 => Some(Self::Cancel),
253 _ => None,
254 }
255 }
256
257 #[inline]
258 pub const fn into_primitive(self) -> u32 {
259 self as u32
260 }
261
262 #[deprecated = "Strict enums should not use `is_unknown`"]
263 #[inline]
264 pub fn is_unknown(&self) -> bool {
265 false
266 }
267}
268
269#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
311pub enum NonPrintableKey {
312 Unidentified,
316 Alt,
322 AltGraph,
329 CapsLock,
333 Control,
336 Fn,
342 FnLock,
348 Meta,
353 NumLock,
356 ScrollLock,
358 Shift,
361 Symbol,
363 SymbolLock,
365 Hyper,
367 Super,
369 Enter,
372 Tab,
374 Backspace,
377 Down,
379 Left,
381 Right,
383 Up,
385 End,
387 Home,
389 PageDown,
391 PageUp,
393 Escape,
395 Select,
397 BrightnessDown,
399 BrightnessUp,
401 F1,
403 F2,
405 F3,
407 F4,
409 F5,
411 F6,
413 F7,
415 F8,
417 F9,
419 F10,
421 F11,
423 F12,
425 Soft1,
427 Soft2,
429 Soft3,
431 Soft4,
433 MediaPlayPause,
438 AudioVolumeDown,
440 AudioVolumeUp,
442 AudioVolumeMute,
444 BrowserBack,
446 BrowserFavorites,
448 BrowserForward,
450 BrowserHome,
452 BrowserRefresh,
454 BrowserSearch,
456 BrowserStop,
457 ZoomToggle,
459 #[doc(hidden)]
460 __SourceBreaking {
461 unknown_ordinal: u32,
462 },
463}
464
465#[macro_export]
467macro_rules! NonPrintableKeyUnknown {
468 () => {
469 _
470 };
471}
472
473impl NonPrintableKey {
474 #[inline]
475 pub fn from_primitive(prim: u32) -> Option<Self> {
476 match prim {
477 0 => Some(Self::Unidentified),
478 17 => Some(Self::Alt),
479 18 => Some(Self::AltGraph),
480 19 => Some(Self::CapsLock),
481 20 => Some(Self::Control),
482 21 => Some(Self::Fn),
483 22 => Some(Self::FnLock),
484 23 => Some(Self::Meta),
485 24 => Some(Self::NumLock),
486 25 => Some(Self::ScrollLock),
487 26 => Some(Self::Shift),
488 27 => Some(Self::Symbol),
489 28 => Some(Self::SymbolLock),
490 29 => Some(Self::Hyper),
491 30 => Some(Self::Super),
492 49 => Some(Self::Enter),
493 50 => Some(Self::Tab),
494 65 => Some(Self::Backspace),
495 97 => Some(Self::Down),
496 98 => Some(Self::Left),
497 99 => Some(Self::Right),
498 100 => Some(Self::Up),
499 101 => Some(Self::End),
500 102 => Some(Self::Home),
501 103 => Some(Self::PageDown),
502 104 => Some(Self::PageUp),
503 24581 => Some(Self::Escape),
504 24588 => Some(Self::Select),
505 28672 => Some(Self::BrightnessDown),
506 28673 => Some(Self::BrightnessUp),
507 36865 => Some(Self::F1),
508 36866 => Some(Self::F2),
509 36867 => Some(Self::F3),
510 36868 => Some(Self::F4),
511 36869 => Some(Self::F5),
512 36870 => Some(Self::F6),
513 36871 => Some(Self::F7),
514 36872 => Some(Self::F8),
515 36873 => Some(Self::F9),
516 36874 => Some(Self::F10),
517 36875 => Some(Self::F11),
518 36876 => Some(Self::F12),
519 36881 => Some(Self::Soft1),
520 36882 => Some(Self::Soft2),
521 36883 => Some(Self::Soft3),
522 36884 => Some(Self::Soft4),
523 40968 => Some(Self::MediaPlayPause),
524 49162 => Some(Self::AudioVolumeDown),
525 49163 => Some(Self::AudioVolumeUp),
526 49164 => Some(Self::AudioVolumeMute),
527 61440 => Some(Self::BrowserBack),
528 61441 => Some(Self::BrowserFavorites),
529 61442 => Some(Self::BrowserForward),
530 61443 => Some(Self::BrowserHome),
531 61444 => Some(Self::BrowserRefresh),
532 61445 => Some(Self::BrowserSearch),
533 61446 => Some(Self::BrowserStop),
534 73799 => Some(Self::ZoomToggle),
535 _ => None,
536 }
537 }
538
539 #[inline]
540 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
541 match prim {
542 0 => Self::Unidentified,
543 17 => Self::Alt,
544 18 => Self::AltGraph,
545 19 => Self::CapsLock,
546 20 => Self::Control,
547 21 => Self::Fn,
548 22 => Self::FnLock,
549 23 => Self::Meta,
550 24 => Self::NumLock,
551 25 => Self::ScrollLock,
552 26 => Self::Shift,
553 27 => Self::Symbol,
554 28 => Self::SymbolLock,
555 29 => Self::Hyper,
556 30 => Self::Super,
557 49 => Self::Enter,
558 50 => Self::Tab,
559 65 => Self::Backspace,
560 97 => Self::Down,
561 98 => Self::Left,
562 99 => Self::Right,
563 100 => Self::Up,
564 101 => Self::End,
565 102 => Self::Home,
566 103 => Self::PageDown,
567 104 => Self::PageUp,
568 24581 => Self::Escape,
569 24588 => Self::Select,
570 28672 => Self::BrightnessDown,
571 28673 => Self::BrightnessUp,
572 36865 => Self::F1,
573 36866 => Self::F2,
574 36867 => Self::F3,
575 36868 => Self::F4,
576 36869 => Self::F5,
577 36870 => Self::F6,
578 36871 => Self::F7,
579 36872 => Self::F8,
580 36873 => Self::F9,
581 36874 => Self::F10,
582 36875 => Self::F11,
583 36876 => Self::F12,
584 36881 => Self::Soft1,
585 36882 => Self::Soft2,
586 36883 => Self::Soft3,
587 36884 => Self::Soft4,
588 40968 => Self::MediaPlayPause,
589 49162 => Self::AudioVolumeDown,
590 49163 => Self::AudioVolumeUp,
591 49164 => Self::AudioVolumeMute,
592 61440 => Self::BrowserBack,
593 61441 => Self::BrowserFavorites,
594 61442 => Self::BrowserForward,
595 61443 => Self::BrowserHome,
596 61444 => Self::BrowserRefresh,
597 61445 => Self::BrowserSearch,
598 61446 => Self::BrowserStop,
599 73799 => Self::ZoomToggle,
600 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
601 }
602 }
603
604 #[inline]
605 pub fn unknown() -> Self {
606 Self::__SourceBreaking { unknown_ordinal: 0x0 }
607 }
608
609 #[inline]
610 pub const fn into_primitive(self) -> u32 {
611 match self {
612 Self::Unidentified => 0,
613 Self::Alt => 17,
614 Self::AltGraph => 18,
615 Self::CapsLock => 19,
616 Self::Control => 20,
617 Self::Fn => 21,
618 Self::FnLock => 22,
619 Self::Meta => 23,
620 Self::NumLock => 24,
621 Self::ScrollLock => 25,
622 Self::Shift => 26,
623 Self::Symbol => 27,
624 Self::SymbolLock => 28,
625 Self::Hyper => 29,
626 Self::Super => 30,
627 Self::Enter => 49,
628 Self::Tab => 50,
629 Self::Backspace => 65,
630 Self::Down => 97,
631 Self::Left => 98,
632 Self::Right => 99,
633 Self::Up => 100,
634 Self::End => 101,
635 Self::Home => 102,
636 Self::PageDown => 103,
637 Self::PageUp => 104,
638 Self::Escape => 24581,
639 Self::Select => 24588,
640 Self::BrightnessDown => 28672,
641 Self::BrightnessUp => 28673,
642 Self::F1 => 36865,
643 Self::F2 => 36866,
644 Self::F3 => 36867,
645 Self::F4 => 36868,
646 Self::F5 => 36869,
647 Self::F6 => 36870,
648 Self::F7 => 36871,
649 Self::F8 => 36872,
650 Self::F9 => 36873,
651 Self::F10 => 36874,
652 Self::F11 => 36875,
653 Self::F12 => 36876,
654 Self::Soft1 => 36881,
655 Self::Soft2 => 36882,
656 Self::Soft3 => 36883,
657 Self::Soft4 => 36884,
658 Self::MediaPlayPause => 40968,
659 Self::AudioVolumeDown => 49162,
660 Self::AudioVolumeUp => 49163,
661 Self::AudioVolumeMute => 49164,
662 Self::BrowserBack => 61440,
663 Self::BrowserFavorites => 61441,
664 Self::BrowserForward => 61442,
665 Self::BrowserHome => 61443,
666 Self::BrowserRefresh => 61444,
667 Self::BrowserSearch => 61445,
668 Self::BrowserStop => 61446,
669 Self::ZoomToggle => 73799,
670 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
671 }
672 }
673
674 #[inline]
675 pub fn is_unknown(&self) -> bool {
676 match self {
677 Self::__SourceBreaking { unknown_ordinal: _ } => true,
678 _ => false,
679 }
680 }
681}
682
683#[derive(Clone, Debug, PartialEq)]
684pub struct KeyEventInjectorInjectRequest {
685 pub key_event: KeyEvent,
686}
687
688impl fidl::Persistable for KeyEventInjectorInjectRequest {}
689
690#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
691pub struct KeyEventInjectorInjectResponse {
692 pub status: KeyEventStatus,
693}
694
695impl fidl::Persistable for KeyEventInjectorInjectResponse {}
696
697#[derive(Clone, Debug, PartialEq)]
698pub struct KeyboardListenerOnKeyEventRequest {
699 pub event: KeyEvent,
700}
701
702impl fidl::Persistable for KeyboardListenerOnKeyEventRequest {}
703
704#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
705pub struct KeyboardListenerOnKeyEventResponse {
706 pub status: KeyEventStatus,
707}
708
709impl fidl::Persistable for KeyboardListenerOnKeyEventResponse {}
710
711#[derive(Clone, Debug, Default, PartialEq)]
714pub struct KeyEvent {
715 pub timestamp: Option<i64>,
719 pub type_: Option<KeyEventType>,
721 pub key: Option<fidl_fuchsia_input::Key>,
725 pub modifiers: Option<Modifiers>,
740 pub key_meaning: Option<KeyMeaning>,
742 pub repeat_sequence: Option<u32>,
750 pub lock_state: Option<LockState>,
759 pub device_id: Option<u32>,
761 #[doc(hidden)]
762 pub __source_breaking: fidl::marker::SourceBreaking,
763}
764
765impl fidl::Persistable for KeyEvent {}
766
767#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
771pub enum KeyMeaning {
772 Codepoint(u32),
777 NonPrintableKey(NonPrintableKey),
779}
780
781impl KeyMeaning {
782 #[inline]
783 pub fn ordinal(&self) -> u64 {
784 match *self {
785 Self::Codepoint(_) => 1,
786 Self::NonPrintableKey(_) => 2,
787 }
788 }
789
790 #[deprecated = "Strict unions should not use `is_unknown`"]
791 #[inline]
792 pub fn is_unknown(&self) -> bool {
793 false
794 }
795}
796
797impl fidl::Persistable for KeyMeaning {}
798
799mod internal {
800 use super::*;
801 unsafe impl fidl::encoding::TypeMarker for LockState {
802 type Owned = Self;
803
804 #[inline(always)]
805 fn inline_align(_context: fidl::encoding::Context) -> usize {
806 8
807 }
808
809 #[inline(always)]
810 fn inline_size(_context: fidl::encoding::Context) -> usize {
811 8
812 }
813 }
814
815 impl fidl::encoding::ValueTypeMarker for LockState {
816 type Borrowed<'a> = Self;
817 #[inline(always)]
818 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
819 *value
820 }
821 }
822
823 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LockState {
824 #[inline]
825 unsafe fn encode(
826 self,
827 encoder: &mut fidl::encoding::Encoder<'_, D>,
828 offset: usize,
829 _depth: fidl::encoding::Depth,
830 ) -> fidl::Result<()> {
831 encoder.debug_check_bounds::<Self>(offset);
832 encoder.write_num(self.bits(), offset);
833 Ok(())
834 }
835 }
836
837 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LockState {
838 #[inline(always)]
839 fn new_empty() -> Self {
840 Self::empty()
841 }
842
843 #[inline]
844 unsafe fn decode(
845 &mut self,
846 decoder: &mut fidl::encoding::Decoder<'_, D>,
847 offset: usize,
848 _depth: fidl::encoding::Depth,
849 ) -> fidl::Result<()> {
850 decoder.debug_check_bounds::<Self>(offset);
851 let prim = decoder.read_num::<u64>(offset);
852 *self = Self::from_bits_allow_unknown(prim);
853 Ok(())
854 }
855 }
856 unsafe impl fidl::encoding::TypeMarker for Modifiers {
857 type Owned = Self;
858
859 #[inline(always)]
860 fn inline_align(_context: fidl::encoding::Context) -> usize {
861 8
862 }
863
864 #[inline(always)]
865 fn inline_size(_context: fidl::encoding::Context) -> usize {
866 8
867 }
868 }
869
870 impl fidl::encoding::ValueTypeMarker for Modifiers {
871 type Borrowed<'a> = Self;
872 #[inline(always)]
873 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
874 *value
875 }
876 }
877
878 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Modifiers {
879 #[inline]
880 unsafe fn encode(
881 self,
882 encoder: &mut fidl::encoding::Encoder<'_, D>,
883 offset: usize,
884 _depth: fidl::encoding::Depth,
885 ) -> fidl::Result<()> {
886 encoder.debug_check_bounds::<Self>(offset);
887 encoder.write_num(self.bits(), offset);
888 Ok(())
889 }
890 }
891
892 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Modifiers {
893 #[inline(always)]
894 fn new_empty() -> Self {
895 Self::empty()
896 }
897
898 #[inline]
899 unsafe fn decode(
900 &mut self,
901 decoder: &mut fidl::encoding::Decoder<'_, D>,
902 offset: usize,
903 _depth: fidl::encoding::Depth,
904 ) -> fidl::Result<()> {
905 decoder.debug_check_bounds::<Self>(offset);
906 let prim = decoder.read_num::<u64>(offset);
907 *self = Self::from_bits_allow_unknown(prim);
908 Ok(())
909 }
910 }
911 unsafe impl fidl::encoding::TypeMarker for KeyEventStatus {
912 type Owned = Self;
913
914 #[inline(always)]
915 fn inline_align(_context: fidl::encoding::Context) -> usize {
916 std::mem::align_of::<u32>()
917 }
918
919 #[inline(always)]
920 fn inline_size(_context: fidl::encoding::Context) -> usize {
921 std::mem::size_of::<u32>()
922 }
923
924 #[inline(always)]
925 fn encode_is_copy() -> bool {
926 true
927 }
928
929 #[inline(always)]
930 fn decode_is_copy() -> bool {
931 false
932 }
933 }
934
935 impl fidl::encoding::ValueTypeMarker for KeyEventStatus {
936 type Borrowed<'a> = Self;
937 #[inline(always)]
938 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
939 *value
940 }
941 }
942
943 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for KeyEventStatus {
944 #[inline]
945 unsafe fn encode(
946 self,
947 encoder: &mut fidl::encoding::Encoder<'_, D>,
948 offset: usize,
949 _depth: fidl::encoding::Depth,
950 ) -> fidl::Result<()> {
951 encoder.debug_check_bounds::<Self>(offset);
952 encoder.write_num(self.into_primitive(), offset);
953 Ok(())
954 }
955 }
956
957 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEventStatus {
958 #[inline(always)]
959 fn new_empty() -> Self {
960 Self::Handled
961 }
962
963 #[inline]
964 unsafe fn decode(
965 &mut self,
966 decoder: &mut fidl::encoding::Decoder<'_, D>,
967 offset: usize,
968 _depth: fidl::encoding::Depth,
969 ) -> fidl::Result<()> {
970 decoder.debug_check_bounds::<Self>(offset);
971 let prim = decoder.read_num::<u32>(offset);
972
973 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
974 Ok(())
975 }
976 }
977 unsafe impl fidl::encoding::TypeMarker for KeyEventType {
978 type Owned = Self;
979
980 #[inline(always)]
981 fn inline_align(_context: fidl::encoding::Context) -> usize {
982 std::mem::align_of::<u32>()
983 }
984
985 #[inline(always)]
986 fn inline_size(_context: fidl::encoding::Context) -> usize {
987 std::mem::size_of::<u32>()
988 }
989
990 #[inline(always)]
991 fn encode_is_copy() -> bool {
992 true
993 }
994
995 #[inline(always)]
996 fn decode_is_copy() -> bool {
997 false
998 }
999 }
1000
1001 impl fidl::encoding::ValueTypeMarker for KeyEventType {
1002 type Borrowed<'a> = Self;
1003 #[inline(always)]
1004 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1005 *value
1006 }
1007 }
1008
1009 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for KeyEventType {
1010 #[inline]
1011 unsafe fn encode(
1012 self,
1013 encoder: &mut fidl::encoding::Encoder<'_, D>,
1014 offset: usize,
1015 _depth: fidl::encoding::Depth,
1016 ) -> fidl::Result<()> {
1017 encoder.debug_check_bounds::<Self>(offset);
1018 encoder.write_num(self.into_primitive(), offset);
1019 Ok(())
1020 }
1021 }
1022
1023 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEventType {
1024 #[inline(always)]
1025 fn new_empty() -> Self {
1026 Self::Pressed
1027 }
1028
1029 #[inline]
1030 unsafe fn decode(
1031 &mut self,
1032 decoder: &mut fidl::encoding::Decoder<'_, D>,
1033 offset: usize,
1034 _depth: fidl::encoding::Depth,
1035 ) -> fidl::Result<()> {
1036 decoder.debug_check_bounds::<Self>(offset);
1037 let prim = decoder.read_num::<u32>(offset);
1038
1039 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1040 Ok(())
1041 }
1042 }
1043 unsafe impl fidl::encoding::TypeMarker for NonPrintableKey {
1044 type Owned = Self;
1045
1046 #[inline(always)]
1047 fn inline_align(_context: fidl::encoding::Context) -> usize {
1048 std::mem::align_of::<u32>()
1049 }
1050
1051 #[inline(always)]
1052 fn inline_size(_context: fidl::encoding::Context) -> usize {
1053 std::mem::size_of::<u32>()
1054 }
1055
1056 #[inline(always)]
1057 fn encode_is_copy() -> bool {
1058 false
1059 }
1060
1061 #[inline(always)]
1062 fn decode_is_copy() -> bool {
1063 false
1064 }
1065 }
1066
1067 impl fidl::encoding::ValueTypeMarker for NonPrintableKey {
1068 type Borrowed<'a> = Self;
1069 #[inline(always)]
1070 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1071 *value
1072 }
1073 }
1074
1075 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1076 for NonPrintableKey
1077 {
1078 #[inline]
1079 unsafe fn encode(
1080 self,
1081 encoder: &mut fidl::encoding::Encoder<'_, D>,
1082 offset: usize,
1083 _depth: fidl::encoding::Depth,
1084 ) -> fidl::Result<()> {
1085 encoder.debug_check_bounds::<Self>(offset);
1086 encoder.write_num(self.into_primitive(), offset);
1087 Ok(())
1088 }
1089 }
1090
1091 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NonPrintableKey {
1092 #[inline(always)]
1093 fn new_empty() -> Self {
1094 Self::unknown()
1095 }
1096
1097 #[inline]
1098 unsafe fn decode(
1099 &mut self,
1100 decoder: &mut fidl::encoding::Decoder<'_, D>,
1101 offset: usize,
1102 _depth: fidl::encoding::Depth,
1103 ) -> fidl::Result<()> {
1104 decoder.debug_check_bounds::<Self>(offset);
1105 let prim = decoder.read_num::<u32>(offset);
1106
1107 *self = Self::from_primitive_allow_unknown(prim);
1108 Ok(())
1109 }
1110 }
1111
1112 impl fidl::encoding::ValueTypeMarker for KeyEventInjectorInjectRequest {
1113 type Borrowed<'a> = &'a Self;
1114 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1115 value
1116 }
1117 }
1118
1119 unsafe impl fidl::encoding::TypeMarker for KeyEventInjectorInjectRequest {
1120 type Owned = Self;
1121
1122 #[inline(always)]
1123 fn inline_align(_context: fidl::encoding::Context) -> usize {
1124 8
1125 }
1126
1127 #[inline(always)]
1128 fn inline_size(_context: fidl::encoding::Context) -> usize {
1129 16
1130 }
1131 }
1132
1133 unsafe impl<D: fidl::encoding::ResourceDialect>
1134 fidl::encoding::Encode<KeyEventInjectorInjectRequest, D>
1135 for &KeyEventInjectorInjectRequest
1136 {
1137 #[inline]
1138 unsafe fn encode(
1139 self,
1140 encoder: &mut fidl::encoding::Encoder<'_, D>,
1141 offset: usize,
1142 _depth: fidl::encoding::Depth,
1143 ) -> fidl::Result<()> {
1144 encoder.debug_check_bounds::<KeyEventInjectorInjectRequest>(offset);
1145 fidl::encoding::Encode::<KeyEventInjectorInjectRequest, D>::encode(
1147 (<KeyEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.key_event),),
1148 encoder,
1149 offset,
1150 _depth,
1151 )
1152 }
1153 }
1154 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEvent, D>>
1155 fidl::encoding::Encode<KeyEventInjectorInjectRequest, D> for (T0,)
1156 {
1157 #[inline]
1158 unsafe fn encode(
1159 self,
1160 encoder: &mut fidl::encoding::Encoder<'_, D>,
1161 offset: usize,
1162 depth: fidl::encoding::Depth,
1163 ) -> fidl::Result<()> {
1164 encoder.debug_check_bounds::<KeyEventInjectorInjectRequest>(offset);
1165 self.0.encode(encoder, offset + 0, depth)?;
1169 Ok(())
1170 }
1171 }
1172
1173 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1174 for KeyEventInjectorInjectRequest
1175 {
1176 #[inline(always)]
1177 fn new_empty() -> Self {
1178 Self { key_event: fidl::new_empty!(KeyEvent, D) }
1179 }
1180
1181 #[inline]
1182 unsafe fn decode(
1183 &mut self,
1184 decoder: &mut fidl::encoding::Decoder<'_, D>,
1185 offset: usize,
1186 _depth: fidl::encoding::Depth,
1187 ) -> fidl::Result<()> {
1188 decoder.debug_check_bounds::<Self>(offset);
1189 fidl::decode!(KeyEvent, D, &mut self.key_event, decoder, offset + 0, _depth)?;
1191 Ok(())
1192 }
1193 }
1194
1195 impl fidl::encoding::ValueTypeMarker for KeyEventInjectorInjectResponse {
1196 type Borrowed<'a> = &'a Self;
1197 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1198 value
1199 }
1200 }
1201
1202 unsafe impl fidl::encoding::TypeMarker for KeyEventInjectorInjectResponse {
1203 type Owned = Self;
1204
1205 #[inline(always)]
1206 fn inline_align(_context: fidl::encoding::Context) -> usize {
1207 4
1208 }
1209
1210 #[inline(always)]
1211 fn inline_size(_context: fidl::encoding::Context) -> usize {
1212 4
1213 }
1214 }
1215
1216 unsafe impl<D: fidl::encoding::ResourceDialect>
1217 fidl::encoding::Encode<KeyEventInjectorInjectResponse, D>
1218 for &KeyEventInjectorInjectResponse
1219 {
1220 #[inline]
1221 unsafe fn encode(
1222 self,
1223 encoder: &mut fidl::encoding::Encoder<'_, D>,
1224 offset: usize,
1225 _depth: fidl::encoding::Depth,
1226 ) -> fidl::Result<()> {
1227 encoder.debug_check_bounds::<KeyEventInjectorInjectResponse>(offset);
1228 fidl::encoding::Encode::<KeyEventInjectorInjectResponse, D>::encode(
1230 (<KeyEventStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
1231 encoder,
1232 offset,
1233 _depth,
1234 )
1235 }
1236 }
1237 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEventStatus, D>>
1238 fidl::encoding::Encode<KeyEventInjectorInjectResponse, D> for (T0,)
1239 {
1240 #[inline]
1241 unsafe fn encode(
1242 self,
1243 encoder: &mut fidl::encoding::Encoder<'_, D>,
1244 offset: usize,
1245 depth: fidl::encoding::Depth,
1246 ) -> fidl::Result<()> {
1247 encoder.debug_check_bounds::<KeyEventInjectorInjectResponse>(offset);
1248 self.0.encode(encoder, offset + 0, depth)?;
1252 Ok(())
1253 }
1254 }
1255
1256 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1257 for KeyEventInjectorInjectResponse
1258 {
1259 #[inline(always)]
1260 fn new_empty() -> Self {
1261 Self { status: fidl::new_empty!(KeyEventStatus, D) }
1262 }
1263
1264 #[inline]
1265 unsafe fn decode(
1266 &mut self,
1267 decoder: &mut fidl::encoding::Decoder<'_, D>,
1268 offset: usize,
1269 _depth: fidl::encoding::Depth,
1270 ) -> fidl::Result<()> {
1271 decoder.debug_check_bounds::<Self>(offset);
1272 fidl::decode!(KeyEventStatus, D, &mut self.status, decoder, offset + 0, _depth)?;
1274 Ok(())
1275 }
1276 }
1277
1278 impl fidl::encoding::ValueTypeMarker for KeyboardListenerOnKeyEventRequest {
1279 type Borrowed<'a> = &'a Self;
1280 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1281 value
1282 }
1283 }
1284
1285 unsafe impl fidl::encoding::TypeMarker for KeyboardListenerOnKeyEventRequest {
1286 type Owned = Self;
1287
1288 #[inline(always)]
1289 fn inline_align(_context: fidl::encoding::Context) -> usize {
1290 8
1291 }
1292
1293 #[inline(always)]
1294 fn inline_size(_context: fidl::encoding::Context) -> usize {
1295 16
1296 }
1297 }
1298
1299 unsafe impl<D: fidl::encoding::ResourceDialect>
1300 fidl::encoding::Encode<KeyboardListenerOnKeyEventRequest, D>
1301 for &KeyboardListenerOnKeyEventRequest
1302 {
1303 #[inline]
1304 unsafe fn encode(
1305 self,
1306 encoder: &mut fidl::encoding::Encoder<'_, D>,
1307 offset: usize,
1308 _depth: fidl::encoding::Depth,
1309 ) -> fidl::Result<()> {
1310 encoder.debug_check_bounds::<KeyboardListenerOnKeyEventRequest>(offset);
1311 fidl::encoding::Encode::<KeyboardListenerOnKeyEventRequest, D>::encode(
1313 (<KeyEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.event),),
1314 encoder,
1315 offset,
1316 _depth,
1317 )
1318 }
1319 }
1320 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEvent, D>>
1321 fidl::encoding::Encode<KeyboardListenerOnKeyEventRequest, D> for (T0,)
1322 {
1323 #[inline]
1324 unsafe fn encode(
1325 self,
1326 encoder: &mut fidl::encoding::Encoder<'_, D>,
1327 offset: usize,
1328 depth: fidl::encoding::Depth,
1329 ) -> fidl::Result<()> {
1330 encoder.debug_check_bounds::<KeyboardListenerOnKeyEventRequest>(offset);
1331 self.0.encode(encoder, offset + 0, depth)?;
1335 Ok(())
1336 }
1337 }
1338
1339 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1340 for KeyboardListenerOnKeyEventRequest
1341 {
1342 #[inline(always)]
1343 fn new_empty() -> Self {
1344 Self { event: fidl::new_empty!(KeyEvent, D) }
1345 }
1346
1347 #[inline]
1348 unsafe fn decode(
1349 &mut self,
1350 decoder: &mut fidl::encoding::Decoder<'_, D>,
1351 offset: usize,
1352 _depth: fidl::encoding::Depth,
1353 ) -> fidl::Result<()> {
1354 decoder.debug_check_bounds::<Self>(offset);
1355 fidl::decode!(KeyEvent, D, &mut self.event, decoder, offset + 0, _depth)?;
1357 Ok(())
1358 }
1359 }
1360
1361 impl fidl::encoding::ValueTypeMarker for KeyboardListenerOnKeyEventResponse {
1362 type Borrowed<'a> = &'a Self;
1363 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1364 value
1365 }
1366 }
1367
1368 unsafe impl fidl::encoding::TypeMarker for KeyboardListenerOnKeyEventResponse {
1369 type Owned = Self;
1370
1371 #[inline(always)]
1372 fn inline_align(_context: fidl::encoding::Context) -> usize {
1373 4
1374 }
1375
1376 #[inline(always)]
1377 fn inline_size(_context: fidl::encoding::Context) -> usize {
1378 4
1379 }
1380 }
1381
1382 unsafe impl<D: fidl::encoding::ResourceDialect>
1383 fidl::encoding::Encode<KeyboardListenerOnKeyEventResponse, D>
1384 for &KeyboardListenerOnKeyEventResponse
1385 {
1386 #[inline]
1387 unsafe fn encode(
1388 self,
1389 encoder: &mut fidl::encoding::Encoder<'_, D>,
1390 offset: usize,
1391 _depth: fidl::encoding::Depth,
1392 ) -> fidl::Result<()> {
1393 encoder.debug_check_bounds::<KeyboardListenerOnKeyEventResponse>(offset);
1394 fidl::encoding::Encode::<KeyboardListenerOnKeyEventResponse, D>::encode(
1396 (<KeyEventStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
1397 encoder,
1398 offset,
1399 _depth,
1400 )
1401 }
1402 }
1403 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEventStatus, D>>
1404 fidl::encoding::Encode<KeyboardListenerOnKeyEventResponse, D> for (T0,)
1405 {
1406 #[inline]
1407 unsafe fn encode(
1408 self,
1409 encoder: &mut fidl::encoding::Encoder<'_, D>,
1410 offset: usize,
1411 depth: fidl::encoding::Depth,
1412 ) -> fidl::Result<()> {
1413 encoder.debug_check_bounds::<KeyboardListenerOnKeyEventResponse>(offset);
1414 self.0.encode(encoder, offset + 0, depth)?;
1418 Ok(())
1419 }
1420 }
1421
1422 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1423 for KeyboardListenerOnKeyEventResponse
1424 {
1425 #[inline(always)]
1426 fn new_empty() -> Self {
1427 Self { status: fidl::new_empty!(KeyEventStatus, D) }
1428 }
1429
1430 #[inline]
1431 unsafe fn decode(
1432 &mut self,
1433 decoder: &mut fidl::encoding::Decoder<'_, D>,
1434 offset: usize,
1435 _depth: fidl::encoding::Depth,
1436 ) -> fidl::Result<()> {
1437 decoder.debug_check_bounds::<Self>(offset);
1438 fidl::decode!(KeyEventStatus, D, &mut self.status, decoder, offset + 0, _depth)?;
1440 Ok(())
1441 }
1442 }
1443
1444 impl KeyEvent {
1445 #[inline(always)]
1446 fn max_ordinal_present(&self) -> u64 {
1447 if let Some(_) = self.device_id {
1448 return 8;
1449 }
1450 if let Some(_) = self.lock_state {
1451 return 7;
1452 }
1453 if let Some(_) = self.repeat_sequence {
1454 return 6;
1455 }
1456 if let Some(_) = self.key_meaning {
1457 return 5;
1458 }
1459 if let Some(_) = self.modifiers {
1460 return 4;
1461 }
1462 if let Some(_) = self.key {
1463 return 3;
1464 }
1465 if let Some(_) = self.type_ {
1466 return 2;
1467 }
1468 if let Some(_) = self.timestamp {
1469 return 1;
1470 }
1471 0
1472 }
1473 }
1474
1475 impl fidl::encoding::ValueTypeMarker for KeyEvent {
1476 type Borrowed<'a> = &'a Self;
1477 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1478 value
1479 }
1480 }
1481
1482 unsafe impl fidl::encoding::TypeMarker for KeyEvent {
1483 type Owned = Self;
1484
1485 #[inline(always)]
1486 fn inline_align(_context: fidl::encoding::Context) -> usize {
1487 8
1488 }
1489
1490 #[inline(always)]
1491 fn inline_size(_context: fidl::encoding::Context) -> usize {
1492 16
1493 }
1494 }
1495
1496 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<KeyEvent, D> for &KeyEvent {
1497 unsafe fn encode(
1498 self,
1499 encoder: &mut fidl::encoding::Encoder<'_, D>,
1500 offset: usize,
1501 mut depth: fidl::encoding::Depth,
1502 ) -> fidl::Result<()> {
1503 encoder.debug_check_bounds::<KeyEvent>(offset);
1504 let max_ordinal: u64 = self.max_ordinal_present();
1506 encoder.write_num(max_ordinal, offset);
1507 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1508 if max_ordinal == 0 {
1510 return Ok(());
1511 }
1512 depth.increment()?;
1513 let envelope_size = 8;
1514 let bytes_len = max_ordinal as usize * envelope_size;
1515 #[allow(unused_variables)]
1516 let offset = encoder.out_of_line_offset(bytes_len);
1517 let mut _prev_end_offset: usize = 0;
1518 if 1 > max_ordinal {
1519 return Ok(());
1520 }
1521
1522 let cur_offset: usize = (1 - 1) * envelope_size;
1525
1526 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1528
1529 fidl::encoding::encode_in_envelope_optional::<i64, D>(
1534 self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1535 encoder,
1536 offset + cur_offset,
1537 depth,
1538 )?;
1539
1540 _prev_end_offset = cur_offset + envelope_size;
1541 if 2 > max_ordinal {
1542 return Ok(());
1543 }
1544
1545 let cur_offset: usize = (2 - 1) * envelope_size;
1548
1549 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1551
1552 fidl::encoding::encode_in_envelope_optional::<KeyEventType, D>(
1557 self.type_.as_ref().map(<KeyEventType as fidl::encoding::ValueTypeMarker>::borrow),
1558 encoder,
1559 offset + cur_offset,
1560 depth,
1561 )?;
1562
1563 _prev_end_offset = cur_offset + envelope_size;
1564 if 3 > max_ordinal {
1565 return Ok(());
1566 }
1567
1568 let cur_offset: usize = (3 - 1) * envelope_size;
1571
1572 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1574
1575 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_input::Key, D>(
1580 self.key
1581 .as_ref()
1582 .map(<fidl_fuchsia_input::Key as fidl::encoding::ValueTypeMarker>::borrow),
1583 encoder,
1584 offset + cur_offset,
1585 depth,
1586 )?;
1587
1588 _prev_end_offset = cur_offset + envelope_size;
1589 if 4 > max_ordinal {
1590 return Ok(());
1591 }
1592
1593 let cur_offset: usize = (4 - 1) * envelope_size;
1596
1597 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1599
1600 fidl::encoding::encode_in_envelope_optional::<Modifiers, D>(
1605 self.modifiers.as_ref().map(<Modifiers as fidl::encoding::ValueTypeMarker>::borrow),
1606 encoder,
1607 offset + cur_offset,
1608 depth,
1609 )?;
1610
1611 _prev_end_offset = cur_offset + envelope_size;
1612 if 5 > max_ordinal {
1613 return Ok(());
1614 }
1615
1616 let cur_offset: usize = (5 - 1) * envelope_size;
1619
1620 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1622
1623 fidl::encoding::encode_in_envelope_optional::<KeyMeaning, D>(
1628 self.key_meaning
1629 .as_ref()
1630 .map(<KeyMeaning as fidl::encoding::ValueTypeMarker>::borrow),
1631 encoder,
1632 offset + cur_offset,
1633 depth,
1634 )?;
1635
1636 _prev_end_offset = cur_offset + envelope_size;
1637 if 6 > max_ordinal {
1638 return Ok(());
1639 }
1640
1641 let cur_offset: usize = (6 - 1) * envelope_size;
1644
1645 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1647
1648 fidl::encoding::encode_in_envelope_optional::<u32, D>(
1653 self.repeat_sequence.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1654 encoder,
1655 offset + cur_offset,
1656 depth,
1657 )?;
1658
1659 _prev_end_offset = cur_offset + envelope_size;
1660 if 7 > max_ordinal {
1661 return Ok(());
1662 }
1663
1664 let cur_offset: usize = (7 - 1) * envelope_size;
1667
1668 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1670
1671 fidl::encoding::encode_in_envelope_optional::<LockState, D>(
1676 self.lock_state
1677 .as_ref()
1678 .map(<LockState as fidl::encoding::ValueTypeMarker>::borrow),
1679 encoder,
1680 offset + cur_offset,
1681 depth,
1682 )?;
1683
1684 _prev_end_offset = cur_offset + envelope_size;
1685 if 8 > max_ordinal {
1686 return Ok(());
1687 }
1688
1689 let cur_offset: usize = (8 - 1) * envelope_size;
1692
1693 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1695
1696 fidl::encoding::encode_in_envelope_optional::<u32, D>(
1701 self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1702 encoder,
1703 offset + cur_offset,
1704 depth,
1705 )?;
1706
1707 _prev_end_offset = cur_offset + envelope_size;
1708
1709 Ok(())
1710 }
1711 }
1712
1713 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEvent {
1714 #[inline(always)]
1715 fn new_empty() -> Self {
1716 Self::default()
1717 }
1718
1719 unsafe fn decode(
1720 &mut self,
1721 decoder: &mut fidl::encoding::Decoder<'_, D>,
1722 offset: usize,
1723 mut depth: fidl::encoding::Depth,
1724 ) -> fidl::Result<()> {
1725 decoder.debug_check_bounds::<Self>(offset);
1726 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1727 None => return Err(fidl::Error::NotNullable),
1728 Some(len) => len,
1729 };
1730 if len == 0 {
1732 return Ok(());
1733 };
1734 depth.increment()?;
1735 let envelope_size = 8;
1736 let bytes_len = len * envelope_size;
1737 let offset = decoder.out_of_line_offset(bytes_len)?;
1738 let mut _next_ordinal_to_read = 0;
1740 let mut next_offset = offset;
1741 let end_offset = offset + bytes_len;
1742 _next_ordinal_to_read += 1;
1743 if next_offset >= end_offset {
1744 return Ok(());
1745 }
1746
1747 while _next_ordinal_to_read < 1 {
1749 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1750 _next_ordinal_to_read += 1;
1751 next_offset += envelope_size;
1752 }
1753
1754 let next_out_of_line = decoder.next_out_of_line();
1755 let handles_before = decoder.remaining_handles();
1756 if let Some((inlined, num_bytes, num_handles)) =
1757 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1758 {
1759 let member_inline_size =
1760 <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1761 if inlined != (member_inline_size <= 4) {
1762 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1763 }
1764 let inner_offset;
1765 let mut inner_depth = depth.clone();
1766 if inlined {
1767 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1768 inner_offset = next_offset;
1769 } else {
1770 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1771 inner_depth.increment()?;
1772 }
1773 let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
1774 fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1775 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1776 {
1777 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1778 }
1779 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1780 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1781 }
1782 }
1783
1784 next_offset += envelope_size;
1785 _next_ordinal_to_read += 1;
1786 if next_offset >= end_offset {
1787 return Ok(());
1788 }
1789
1790 while _next_ordinal_to_read < 2 {
1792 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1793 _next_ordinal_to_read += 1;
1794 next_offset += envelope_size;
1795 }
1796
1797 let next_out_of_line = decoder.next_out_of_line();
1798 let handles_before = decoder.remaining_handles();
1799 if let Some((inlined, num_bytes, num_handles)) =
1800 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1801 {
1802 let member_inline_size =
1803 <KeyEventType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1804 if inlined != (member_inline_size <= 4) {
1805 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1806 }
1807 let inner_offset;
1808 let mut inner_depth = depth.clone();
1809 if inlined {
1810 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1811 inner_offset = next_offset;
1812 } else {
1813 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1814 inner_depth.increment()?;
1815 }
1816 let val_ref = self.type_.get_or_insert_with(|| fidl::new_empty!(KeyEventType, D));
1817 fidl::decode!(KeyEventType, D, val_ref, decoder, inner_offset, inner_depth)?;
1818 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1819 {
1820 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1821 }
1822 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1823 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1824 }
1825 }
1826
1827 next_offset += envelope_size;
1828 _next_ordinal_to_read += 1;
1829 if next_offset >= end_offset {
1830 return Ok(());
1831 }
1832
1833 while _next_ordinal_to_read < 3 {
1835 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1836 _next_ordinal_to_read += 1;
1837 next_offset += envelope_size;
1838 }
1839
1840 let next_out_of_line = decoder.next_out_of_line();
1841 let handles_before = decoder.remaining_handles();
1842 if let Some((inlined, num_bytes, num_handles)) =
1843 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1844 {
1845 let member_inline_size =
1846 <fidl_fuchsia_input::Key as fidl::encoding::TypeMarker>::inline_size(
1847 decoder.context,
1848 );
1849 if inlined != (member_inline_size <= 4) {
1850 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1851 }
1852 let inner_offset;
1853 let mut inner_depth = depth.clone();
1854 if inlined {
1855 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1856 inner_offset = next_offset;
1857 } else {
1858 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1859 inner_depth.increment()?;
1860 }
1861 let val_ref =
1862 self.key.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_input::Key, D));
1863 fidl::decode!(
1864 fidl_fuchsia_input::Key,
1865 D,
1866 val_ref,
1867 decoder,
1868 inner_offset,
1869 inner_depth
1870 )?;
1871 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1872 {
1873 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1874 }
1875 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1876 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1877 }
1878 }
1879
1880 next_offset += envelope_size;
1881 _next_ordinal_to_read += 1;
1882 if next_offset >= end_offset {
1883 return Ok(());
1884 }
1885
1886 while _next_ordinal_to_read < 4 {
1888 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1889 _next_ordinal_to_read += 1;
1890 next_offset += envelope_size;
1891 }
1892
1893 let next_out_of_line = decoder.next_out_of_line();
1894 let handles_before = decoder.remaining_handles();
1895 if let Some((inlined, num_bytes, num_handles)) =
1896 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1897 {
1898 let member_inline_size =
1899 <Modifiers as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1900 if inlined != (member_inline_size <= 4) {
1901 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1902 }
1903 let inner_offset;
1904 let mut inner_depth = depth.clone();
1905 if inlined {
1906 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1907 inner_offset = next_offset;
1908 } else {
1909 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1910 inner_depth.increment()?;
1911 }
1912 let val_ref = self.modifiers.get_or_insert_with(|| fidl::new_empty!(Modifiers, D));
1913 fidl::decode!(Modifiers, D, val_ref, decoder, inner_offset, inner_depth)?;
1914 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1915 {
1916 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1917 }
1918 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1919 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1920 }
1921 }
1922
1923 next_offset += envelope_size;
1924 _next_ordinal_to_read += 1;
1925 if next_offset >= end_offset {
1926 return Ok(());
1927 }
1928
1929 while _next_ordinal_to_read < 5 {
1931 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1932 _next_ordinal_to_read += 1;
1933 next_offset += envelope_size;
1934 }
1935
1936 let next_out_of_line = decoder.next_out_of_line();
1937 let handles_before = decoder.remaining_handles();
1938 if let Some((inlined, num_bytes, num_handles)) =
1939 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1940 {
1941 let member_inline_size =
1942 <KeyMeaning as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1943 if inlined != (member_inline_size <= 4) {
1944 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1945 }
1946 let inner_offset;
1947 let mut inner_depth = depth.clone();
1948 if inlined {
1949 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1950 inner_offset = next_offset;
1951 } else {
1952 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1953 inner_depth.increment()?;
1954 }
1955 let val_ref =
1956 self.key_meaning.get_or_insert_with(|| fidl::new_empty!(KeyMeaning, D));
1957 fidl::decode!(KeyMeaning, D, val_ref, decoder, inner_offset, inner_depth)?;
1958 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1959 {
1960 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1961 }
1962 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1963 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1964 }
1965 }
1966
1967 next_offset += envelope_size;
1968 _next_ordinal_to_read += 1;
1969 if next_offset >= end_offset {
1970 return Ok(());
1971 }
1972
1973 while _next_ordinal_to_read < 6 {
1975 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1976 _next_ordinal_to_read += 1;
1977 next_offset += envelope_size;
1978 }
1979
1980 let next_out_of_line = decoder.next_out_of_line();
1981 let handles_before = decoder.remaining_handles();
1982 if let Some((inlined, num_bytes, num_handles)) =
1983 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1984 {
1985 let member_inline_size =
1986 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1987 if inlined != (member_inline_size <= 4) {
1988 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1989 }
1990 let inner_offset;
1991 let mut inner_depth = depth.clone();
1992 if inlined {
1993 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1994 inner_offset = next_offset;
1995 } else {
1996 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1997 inner_depth.increment()?;
1998 }
1999 let val_ref = self.repeat_sequence.get_or_insert_with(|| fidl::new_empty!(u32, D));
2000 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2001 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2002 {
2003 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2004 }
2005 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2006 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2007 }
2008 }
2009
2010 next_offset += envelope_size;
2011 _next_ordinal_to_read += 1;
2012 if next_offset >= end_offset {
2013 return Ok(());
2014 }
2015
2016 while _next_ordinal_to_read < 7 {
2018 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2019 _next_ordinal_to_read += 1;
2020 next_offset += envelope_size;
2021 }
2022
2023 let next_out_of_line = decoder.next_out_of_line();
2024 let handles_before = decoder.remaining_handles();
2025 if let Some((inlined, num_bytes, num_handles)) =
2026 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2027 {
2028 let member_inline_size =
2029 <LockState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2030 if inlined != (member_inline_size <= 4) {
2031 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2032 }
2033 let inner_offset;
2034 let mut inner_depth = depth.clone();
2035 if inlined {
2036 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2037 inner_offset = next_offset;
2038 } else {
2039 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2040 inner_depth.increment()?;
2041 }
2042 let val_ref = self.lock_state.get_or_insert_with(|| fidl::new_empty!(LockState, D));
2043 fidl::decode!(LockState, D, val_ref, decoder, inner_offset, inner_depth)?;
2044 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2045 {
2046 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2047 }
2048 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2049 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2050 }
2051 }
2052
2053 next_offset += envelope_size;
2054 _next_ordinal_to_read += 1;
2055 if next_offset >= end_offset {
2056 return Ok(());
2057 }
2058
2059 while _next_ordinal_to_read < 8 {
2061 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2062 _next_ordinal_to_read += 1;
2063 next_offset += envelope_size;
2064 }
2065
2066 let next_out_of_line = decoder.next_out_of_line();
2067 let handles_before = decoder.remaining_handles();
2068 if let Some((inlined, num_bytes, num_handles)) =
2069 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2070 {
2071 let member_inline_size =
2072 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2073 if inlined != (member_inline_size <= 4) {
2074 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2075 }
2076 let inner_offset;
2077 let mut inner_depth = depth.clone();
2078 if inlined {
2079 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2080 inner_offset = next_offset;
2081 } else {
2082 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2083 inner_depth.increment()?;
2084 }
2085 let val_ref = self.device_id.get_or_insert_with(|| fidl::new_empty!(u32, D));
2086 fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2087 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2088 {
2089 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2090 }
2091 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2092 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2093 }
2094 }
2095
2096 next_offset += envelope_size;
2097
2098 while next_offset < end_offset {
2100 _next_ordinal_to_read += 1;
2101 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2102 next_offset += envelope_size;
2103 }
2104
2105 Ok(())
2106 }
2107 }
2108
2109 impl fidl::encoding::ValueTypeMarker for KeyMeaning {
2110 type Borrowed<'a> = &'a Self;
2111 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2112 value
2113 }
2114 }
2115
2116 unsafe impl fidl::encoding::TypeMarker for KeyMeaning {
2117 type Owned = Self;
2118
2119 #[inline(always)]
2120 fn inline_align(_context: fidl::encoding::Context) -> usize {
2121 8
2122 }
2123
2124 #[inline(always)]
2125 fn inline_size(_context: fidl::encoding::Context) -> usize {
2126 16
2127 }
2128 }
2129
2130 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<KeyMeaning, D>
2131 for &KeyMeaning
2132 {
2133 #[inline]
2134 unsafe fn encode(
2135 self,
2136 encoder: &mut fidl::encoding::Encoder<'_, D>,
2137 offset: usize,
2138 _depth: fidl::encoding::Depth,
2139 ) -> fidl::Result<()> {
2140 encoder.debug_check_bounds::<KeyMeaning>(offset);
2141 encoder.write_num::<u64>(self.ordinal(), offset);
2142 match self {
2143 KeyMeaning::Codepoint(ref val) => fidl::encoding::encode_in_envelope::<u32, D>(
2144 <u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
2145 encoder,
2146 offset + 8,
2147 _depth,
2148 ),
2149 KeyMeaning::NonPrintableKey(ref val) => {
2150 fidl::encoding::encode_in_envelope::<NonPrintableKey, D>(
2151 <NonPrintableKey as fidl::encoding::ValueTypeMarker>::borrow(val),
2152 encoder,
2153 offset + 8,
2154 _depth,
2155 )
2156 }
2157 }
2158 }
2159 }
2160
2161 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyMeaning {
2162 #[inline(always)]
2163 fn new_empty() -> Self {
2164 Self::Codepoint(fidl::new_empty!(u32, D))
2165 }
2166
2167 #[inline]
2168 unsafe fn decode(
2169 &mut self,
2170 decoder: &mut fidl::encoding::Decoder<'_, D>,
2171 offset: usize,
2172 mut depth: fidl::encoding::Depth,
2173 ) -> fidl::Result<()> {
2174 decoder.debug_check_bounds::<Self>(offset);
2175 #[allow(unused_variables)]
2176 let next_out_of_line = decoder.next_out_of_line();
2177 let handles_before = decoder.remaining_handles();
2178 let (ordinal, inlined, num_bytes, num_handles) =
2179 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2180
2181 let member_inline_size = match ordinal {
2182 1 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2183 2 => <NonPrintableKey as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2184 _ => return Err(fidl::Error::UnknownUnionTag),
2185 };
2186
2187 if inlined != (member_inline_size <= 4) {
2188 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2189 }
2190 let _inner_offset;
2191 if inlined {
2192 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2193 _inner_offset = offset + 8;
2194 } else {
2195 depth.increment()?;
2196 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2197 }
2198 match ordinal {
2199 1 => {
2200 #[allow(irrefutable_let_patterns)]
2201 if let KeyMeaning::Codepoint(_) = self {
2202 } else {
2204 *self = KeyMeaning::Codepoint(fidl::new_empty!(u32, D));
2206 }
2207 #[allow(irrefutable_let_patterns)]
2208 if let KeyMeaning::Codepoint(ref mut val) = self {
2209 fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
2210 } else {
2211 unreachable!()
2212 }
2213 }
2214 2 => {
2215 #[allow(irrefutable_let_patterns)]
2216 if let KeyMeaning::NonPrintableKey(_) = self {
2217 } else {
2219 *self = KeyMeaning::NonPrintableKey(fidl::new_empty!(NonPrintableKey, D));
2221 }
2222 #[allow(irrefutable_let_patterns)]
2223 if let KeyMeaning::NonPrintableKey(ref mut val) = self {
2224 fidl::decode!(NonPrintableKey, D, val, decoder, _inner_offset, depth)?;
2225 } else {
2226 unreachable!()
2227 }
2228 }
2229 ordinal => panic!("unexpected ordinal {:?}", ordinal),
2230 }
2231 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2232 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2233 }
2234 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2235 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2236 }
2237 Ok(())
2238 }
2239 }
2240}