fidl_fuchsia_ui_input3__common/
fidl_fuchsia_ui_input3__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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    /// A bit field of lock states which are currently active.
13    ///
14    /// Lock state reports whether the lock is active for the keys which have a lock
15    /// state (need to be pressed once to activate, and one more time to deactivate).
16    /// A set bit denotes active lock state.
17    ///
18    /// For example, when Caps Lock is active, i.e. pressing 'a' produces the effect
19    /// of 'A' appearing on the screen, the `CAPS_LOCK` bit will be active.
20    ///
21    /// The bit values in `LockState` are chosen to correspond to the values in
22    /// `Modifiers`, to the extent that this is doable in the long run.
23    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
24    pub struct LockState: u64 {
25        /// Applies when the `CAPS_LOCK` modifier is locked.
26        ///
27        /// Users should bear in mind that the effect of `CAPS_LOCK` is limited to
28        /// alphabetic keys (not even *alphanumerics*) mainly.
29        ///
30        /// For example, pressing `a` on a US QWERTY keyboard while `CAPS_LOCK`
31        /// state is locked results in the key meaning `A`, just as if the Shift modifier
32        /// was used.  However, pressing `[` when `CAPS_LOCK` is locked gives `[`,
33        /// even though Shift+`[` gives `{`.
34        ///
35        /// The position of alphabetic keys may vary depending on the keymap in
36        /// current use too.
37        const CAPS_LOCK = 1;
38        /// Applies when the `NUM_LOCK` modifier is locked.
39        const NUM_LOCK = 2;
40        /// Applies when the `SCROLL_LOCK` modifier is locked.
41        const SCROLL_LOCK = 4;
42        /// Applies when the `FUNCTION` modifier is locked.
43        const FUNCTION_LOCK = 8;
44        /// Applies when the `SYMBOL` modifier is locked.
45        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    /// Declares all the modifiers supported by Fuchsia's input subsystem.
68    ///
69    /// Modifiers are special keys that modify the purpose or the function
70    /// of other keys when used in combination with them.  In the Modifiers type,
71    /// a bit is set if the specific modifier key is actuated (held down),
72    /// irrespective of whether the modifier has an associated lock state or not.
73    ///
74    /// **NOTE:** If you want to examine the lock state (such as whether Caps
75    /// Lock needs to turn all letters into uppercase),you want [LockState]
76    /// instead.
77    ///
78    /// Somewhat specially, and as a convenience for the users, the modifiers that
79    /// have "left" and "right" flavors have special bit values which can be used
80    /// if the distinction between sides does not matter.
81    #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
82    pub struct Modifiers: u64 {
83        /// Applies when the `CAPS_LOCK` modifier is actuated.
84        const CAPS_LOCK = 1;
85        /// Applies when the `NUM_LOCK` modifier is actuated.
86        const NUM_LOCK = 2;
87        /// Applies when the `SCROLL_LOCK` modifier is actuated.
88        const SCROLL_LOCK = 4;
89        /// Applies when the `FUNCTION` modifier is actuated.
90        const FUNCTION = 8;
91        /// Applies when the `SYMBOL` modifier is actuated.
92        const SYMBOL = 16;
93        /// Applies when the left SHIFT modifier is actuated.
94        const LEFT_SHIFT = 32;
95        /// Applies when the right SHIFT modifier is actuated.
96        const RIGHT_SHIFT = 64;
97        /// Applies when either `LEFT_SHIFT` or `RIGHT_SHIFT` modifier is actuated.
98        ///
99        /// This bit mask a convenience to test for either `LEFT_SHIFT`
100        /// or `RIGHT_SHIFT`.
101        const SHIFT = 128;
102        /// Applies when the left `ALT` modifier is actuated.
103        const LEFT_ALT = 256;
104        /// Applies when the right `ALT` modifier is actuated.
105        const RIGHT_ALT = 512;
106        /// Applies when either the left `ALT` or the right `ALT` modifier
107        /// is actuated.
108        const ALT = 1024;
109        /// Applies when the `ALT_GRAPH` modifier is actuated.
110        const ALT_GRAPH = 2048;
111        /// Applies when the `LEFT_META` modifier is actuated.
112        const LEFT_META = 4096;
113        /// Applies when the `RIGHT_META` modifier is actuated.
114        const RIGHT_META = 8192;
115        /// Applies when either `LEFT_META` or `RIGHT_META` modifier is actuated.
116        const META = 16384;
117        /// Applies when the `LEFT_CTRL` modifier is actuated.
118        const LEFT_CTRL = 32768;
119        /// Applies when the `RIGHT_CTRL` modifier is actuated.
120        const RIGHT_CTRL = 65536;
121        /// Applies when either `LEFT_CTRL` or `RIGHT_CTRL` modifier is actuated.
122        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/// Return type for clients key events listener.
144///
145/// We do not expect new values to be added to this enum.
146#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
147#[repr(u32)]
148pub enum KeyEventStatus {
149    /// The key event was handled and its further propagation should be stopped.
150    Handled = 1,
151    /// The key event wasn't handled and should be delivered to other clients or listeners.
152    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
171/// Type of the keyboard key input event.
172///
173/// We do not expect new values to be added into this enum.
174#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
175#[repr(u32)]
176pub enum KeyEventType {
177    /// Key is actuated.
178    ///
179    /// Receiving this event type means that a key has been actuated
180    /// at the timestamp when the event is received, and while the event
181    /// recipient is focused.
182    ///
183    /// For example, if the key is a keyboard key, then it was just
184    /// pressed.
185    Pressed = 1,
186    /// Key is no longer actuated.
187    ///
188    /// Receiving this event type means that a key has been de-actuated
189    /// at the timestamp when the event is received, and while the event
190    /// recipient is focused.
191    ///
192    /// For example, if the key is a keyboard key, then it was just
193    /// released.
194    Released = 2,
195    /// Key was actuated while the client wasn't able to receive it,
196    /// and is still actuated now that the client is able to receive
197    /// key events.
198    ///
199    /// This may happen in a few ways:
200    ///
201    ///    - A new device was connected while its key was actuated.
202    ///    - The key was actuated while the event recipient did not
203    ///      have focus.
204    ///
205    /// Therefore, this is not a "regular" key actuation. It reports
206    /// now that the key has been actuated in the unknown past. Some
207    /// event recipients may therefore decide that this is not an
208    /// actionable key event, while some others may decide that it is.
209    ///
210    /// For example, recipients that trigger some user action may
211    /// decide to ignore `SYNC` events, to avoid spurious actions. In
212    /// contrast, recipients that keep track of the keyboard
213    /// state may want to consider a `SYNC` event as a signal
214    /// to update the key's state to actuated.
215    Sync = 3,
216    /// Key may have been actuated, but its actuation has
217    /// become invalid due to an event other than a key
218    /// de-actuation.
219    ///
220    /// This may happen in a few ways:
221    ///
222    ///    - A device was disconnected while its key was actuated.
223    ///    - The event recipient just lost focus.
224    ///
225    /// Therefore, this is not a "regular" key de-actuation. It reports
226    /// the key is no longer validly actuated due to an event other than
227    /// a key release. Some event recipients may therefore decide that
228    /// this is not an actionable key event, while some others may
229    /// decide that it is.
230    ///
231    /// For example, recipients which trigger some user action may
232    /// decide to ignore `CANCEL` events, to avoid spurious actions. In
233    /// contrast, recipients that keep track of the keyboard
234    /// state may want to consider a `CANCEL` event as a signal to update
235    /// the key's state to being de-actuated.
236    Cancel = 4,
237}
238
239impl KeyEventType {
240    #[inline]
241    pub fn from_primitive(prim: u32) -> Option<Self> {
242        match prim {
243            1 => Some(Self::Pressed),
244            2 => Some(Self::Released),
245            3 => Some(Self::Sync),
246            4 => Some(Self::Cancel),
247            _ => None,
248        }
249    }
250
251    #[inline]
252    pub const fn into_primitive(self) -> u32 {
253        self as u32
254    }
255}
256
257/// NonPrintableKey represents the meaning of a non-symbolic key on a keyboard.
258///
259/// The definition of each key is derived from [W3C named values of a key
260/// attribute][1].
261///
262/// ## API version 9 and onwards
263///
264/// Starting from API version 9, the enum value space is subdivided based on the
265/// subsection numbers of the section [Named Key Attribute Values][1], multiplied
266/// by 0x1000.
267///
268/// For example, the keys from section [3.10 Multimedia keys][2] will be located
269/// at `0xa000`-`0xafff`. The values and reservations that were present
270/// in this enum prior to the introduction of the convention have not been moved,
271/// and values that go logically into pre-existing sections have been inserted
272/// into their logical place using the prior convention (see below). This allows
273/// us to extract the section ranges if this is for some reason useful to the
274/// application.
275///
276/// ## Prior to API version 9
277///
278/// The space of the nonprintable keys is subdivided roughly to correspond to the
279/// subsections of Section 3 of the document Named Key Attribute Values.
280/// The choice for the section values is arbitrary, so long as blocks of
281/// values are allocated at once, and the keys with similar purpose are kept
282/// together.
283///
284/// ## Reserved ranges
285///
286/// The space of possible values for [NonPrintableKey] is subdivided into a
287/// number of ranges, with the intention that the enum values are placed in
288/// the appropriate range when added.
289///
290/// * Special keys: 0x00-0x10
291/// * Modifier keys: 0x11-0x30
292/// * Whitespace keys: 0x31-0x40
293/// * Navigation keys: 0x61-0x80
294/// * General-purpose function keys: 0x9000-0x9FFF
295///
296/// [1]: https://www.w3.org/TR/uievents-key/#named-key-attribute-values
297/// [2]: https://www.w3.org/TR/uievents-key/#keys-multimedia
298#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
299pub enum NonPrintableKey {
300    /// This key value is used when an implementation is unable to identify
301    /// another key value, due to either hardware, platform, or software
302    /// constraints.
303    Unidentified,
304    /// The Alt (Alternative) key.
305    ///
306    /// This key enables the alternate modifier function for interpreting concurrent
307    /// or subsequent keyboard input.
308    /// This key value is also used for the Apple Option key.
309    Alt,
310    /// The Alternate Graphics (AltGr or AltGraph).
311    ///
312    /// This key is used enable the ISO Level 3 shift modifier (the standard Shift key is the level
313    /// 2 modifier). See [ISO9995-1].
314    ///
315    /// [ISO9995-1]: http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=51645
316    AltGraph,
317    /// The Caps Lock (Capital) key.
318    ///
319    /// Toggle capital character lock function for interpreting subsequent keyboard input event.
320    CapsLock,
321    /// The Control or Ctrl key, to enable control modifier function for interpreting concurrent or
322    /// subsequent keyboard input.
323    Control,
324    /// The Function switch Fn key.
325    ///
326    /// Activating this key simultaneously with another key changes that key’s value to an alternate
327    /// character or function. This key is often handled directly in the keyboard hardware and does
328    /// not usually generate key events.
329    Fn,
330    /// The Function-Lock (FnLock or F-Lock) key.
331    ///
332    /// Activating this key switches the mode of the keyboard to changes some keys' values to an
333    /// alternate character or function. This key is often handled directly in the keyboard hardware
334    /// and does not usually generate key events.
335    FnLock,
336    /// The Meta key, to enable meta modifier function for interpreting concurrent or subsequent
337    /// keyboard input.
338    ///
339    /// This key value is used for the Windows Logo key and the Apple Command or ⌘ key.
340    Meta,
341    /// The NumLock or Number Lock key, to toggle numpad mode function for interpreting subsequent
342    /// keyboard input.
343    NumLock,
344    /// The Scroll Lock key, to toggle between scrolling and cursor movement modes.
345    ScrollLock,
346    /// The Shift key, to enable shift modifier function for interpreting concurrent or subsequent
347    /// keyboard input.
348    Shift,
349    /// The Symbol modifier key (used on some virtual keyboards).
350    Symbol,
351    /// The Symbol Lock key.
352    SymbolLock,
353    /// The Hyper key. A legacy modifier.
354    Hyper,
355    /// The Super key. A legacy modifier.
356    Super,
357    /// The Enter or ↵ key, to activate current selection or accept current input.
358    /// This key value is also used for the Return (Macintosh numpad) key.
359    Enter,
360    /// The Horizontal Tabulation Tab key.
361    Tab,
362    /// Delete the character immediately preceding the cursor (i.e. the
363    /// character to the left for LTR languages).
364    Backspace,
365    /// The down arrow navigation key.
366    Down,
367    /// The left arrow navigation key.
368    Left,
369    /// The right arrow navigation key.
370    Right,
371    /// The up arrow navigation key.
372    Up,
373    /// The "End" key.
374    End,
375    /// The "Home" key.
376    Home,
377    /// The "Page Down" key.
378    PageDown,
379    /// The "Page Up" key.
380    PageUp,
381    /// The `Escape` or `Esc` key.
382    Escape,
383    /// The Select key. Used to select the window of a task to focus on.
384    Select,
385    /// The Brightness Down key. Typically controls the display brightness.
386    BrightnessDown,
387    /// The Brightness Up key. Typically controls the display brightness.
388    BrightnessUp,
389    /// The F1 key, a general purpose function key, as index 1.
390    F1,
391    /// The F2 key, a general purpose function key, as index 2.
392    F2,
393    /// The F3 key, a general purpose function key, as index 3.
394    F3,
395    /// The F4 key, a general purpose function key, as index 4.
396    F4,
397    /// The F5 key, a general purpose function key, as index 5.
398    F5,
399    /// The F6 key, a general purpose function key, as index 6.
400    F6,
401    /// The F7 key, a general purpose function key, as index 7.
402    F7,
403    /// The F8 key, a general purpose function key, as index 8.
404    F8,
405    /// The F9 key, a general purpose function key, as index 9.
406    F9,
407    /// The F10 key, a general purpose function key, as index 10.
408    F10,
409    /// The F11 key, a general purpose function key, as index 11.
410    F11,
411    /// The F1 key, a general purpose function key, as index 12.
412    F12,
413    /// General purpose virtual function key, as index 1.
414    Soft1,
415    /// General purpose virtual function key, as index 2.
416    Soft2,
417    /// General purpose virtual function key, as index 3.
418    Soft3,
419    /// General purpose virtual function key, as index 4.
420    Soft4,
421    /// Pause the currently playing media.
422    ///
423    /// NOTE: Media controller devices should use this value rather than
424    /// `PAUSE` for their pause keys.
425    MediaPlayPause,
426    /// Decrease audio volume.
427    AudioVolumeDown,
428    /// Increase audio volume.
429    AudioVolumeUp,
430    /// Toggle between muted state and prior volume level.
431    AudioVolumeMute,
432    /// Navigate to previous content or page in current history.
433    BrowserBack,
434    /// Open the list of browser favorites.
435    BrowserFavorites,
436    /// Navigate to next content or page in current history.
437    BrowserForward,
438    /// Go to the user’s preferred home page.
439    BrowserHome,
440    /// Refresh the current page or content.
441    BrowserRefresh,
442    /// Call up the user’s preferred search page.
443    BrowserSearch,
444    BrowserStop,
445    /// Toggle between full-screen and scaled content, or alter magnification level.
446    ZoomToggle,
447    #[doc(hidden)]
448    __SourceBreaking {
449        unknown_ordinal: u32,
450    },
451}
452
453/// Pattern that matches an unknown `NonPrintableKey` member.
454#[macro_export]
455macro_rules! NonPrintableKeyUnknown {
456    () => {
457        _
458    };
459}
460
461impl NonPrintableKey {
462    #[inline]
463    pub fn from_primitive(prim: u32) -> Option<Self> {
464        match prim {
465            0 => Some(Self::Unidentified),
466            17 => Some(Self::Alt),
467            18 => Some(Self::AltGraph),
468            19 => Some(Self::CapsLock),
469            20 => Some(Self::Control),
470            21 => Some(Self::Fn),
471            22 => Some(Self::FnLock),
472            23 => Some(Self::Meta),
473            24 => Some(Self::NumLock),
474            25 => Some(Self::ScrollLock),
475            26 => Some(Self::Shift),
476            27 => Some(Self::Symbol),
477            28 => Some(Self::SymbolLock),
478            29 => Some(Self::Hyper),
479            30 => Some(Self::Super),
480            49 => Some(Self::Enter),
481            50 => Some(Self::Tab),
482            65 => Some(Self::Backspace),
483            97 => Some(Self::Down),
484            98 => Some(Self::Left),
485            99 => Some(Self::Right),
486            100 => Some(Self::Up),
487            101 => Some(Self::End),
488            102 => Some(Self::Home),
489            103 => Some(Self::PageDown),
490            104 => Some(Self::PageUp),
491            24581 => Some(Self::Escape),
492            24588 => Some(Self::Select),
493            28672 => Some(Self::BrightnessDown),
494            28673 => Some(Self::BrightnessUp),
495            36865 => Some(Self::F1),
496            36866 => Some(Self::F2),
497            36867 => Some(Self::F3),
498            36868 => Some(Self::F4),
499            36869 => Some(Self::F5),
500            36870 => Some(Self::F6),
501            36871 => Some(Self::F7),
502            36872 => Some(Self::F8),
503            36873 => Some(Self::F9),
504            36874 => Some(Self::F10),
505            36875 => Some(Self::F11),
506            36876 => Some(Self::F12),
507            36881 => Some(Self::Soft1),
508            36882 => Some(Self::Soft2),
509            36883 => Some(Self::Soft3),
510            36884 => Some(Self::Soft4),
511            40968 => Some(Self::MediaPlayPause),
512            49162 => Some(Self::AudioVolumeDown),
513            49163 => Some(Self::AudioVolumeUp),
514            49164 => Some(Self::AudioVolumeMute),
515            61440 => Some(Self::BrowserBack),
516            61441 => Some(Self::BrowserFavorites),
517            61442 => Some(Self::BrowserForward),
518            61443 => Some(Self::BrowserHome),
519            61444 => Some(Self::BrowserRefresh),
520            61445 => Some(Self::BrowserSearch),
521            61446 => Some(Self::BrowserStop),
522            73799 => Some(Self::ZoomToggle),
523            _ => None,
524        }
525    }
526
527    #[inline]
528    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
529        match prim {
530            0 => Self::Unidentified,
531            17 => Self::Alt,
532            18 => Self::AltGraph,
533            19 => Self::CapsLock,
534            20 => Self::Control,
535            21 => Self::Fn,
536            22 => Self::FnLock,
537            23 => Self::Meta,
538            24 => Self::NumLock,
539            25 => Self::ScrollLock,
540            26 => Self::Shift,
541            27 => Self::Symbol,
542            28 => Self::SymbolLock,
543            29 => Self::Hyper,
544            30 => Self::Super,
545            49 => Self::Enter,
546            50 => Self::Tab,
547            65 => Self::Backspace,
548            97 => Self::Down,
549            98 => Self::Left,
550            99 => Self::Right,
551            100 => Self::Up,
552            101 => Self::End,
553            102 => Self::Home,
554            103 => Self::PageDown,
555            104 => Self::PageUp,
556            24581 => Self::Escape,
557            24588 => Self::Select,
558            28672 => Self::BrightnessDown,
559            28673 => Self::BrightnessUp,
560            36865 => Self::F1,
561            36866 => Self::F2,
562            36867 => Self::F3,
563            36868 => Self::F4,
564            36869 => Self::F5,
565            36870 => Self::F6,
566            36871 => Self::F7,
567            36872 => Self::F8,
568            36873 => Self::F9,
569            36874 => Self::F10,
570            36875 => Self::F11,
571            36876 => Self::F12,
572            36881 => Self::Soft1,
573            36882 => Self::Soft2,
574            36883 => Self::Soft3,
575            36884 => Self::Soft4,
576            40968 => Self::MediaPlayPause,
577            49162 => Self::AudioVolumeDown,
578            49163 => Self::AudioVolumeUp,
579            49164 => Self::AudioVolumeMute,
580            61440 => Self::BrowserBack,
581            61441 => Self::BrowserFavorites,
582            61442 => Self::BrowserForward,
583            61443 => Self::BrowserHome,
584            61444 => Self::BrowserRefresh,
585            61445 => Self::BrowserSearch,
586            61446 => Self::BrowserStop,
587            73799 => Self::ZoomToggle,
588            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
589        }
590    }
591
592    #[inline]
593    pub fn unknown() -> Self {
594        Self::__SourceBreaking { unknown_ordinal: 0x0 }
595    }
596
597    #[inline]
598    pub const fn into_primitive(self) -> u32 {
599        match self {
600            Self::Unidentified => 0,
601            Self::Alt => 17,
602            Self::AltGraph => 18,
603            Self::CapsLock => 19,
604            Self::Control => 20,
605            Self::Fn => 21,
606            Self::FnLock => 22,
607            Self::Meta => 23,
608            Self::NumLock => 24,
609            Self::ScrollLock => 25,
610            Self::Shift => 26,
611            Self::Symbol => 27,
612            Self::SymbolLock => 28,
613            Self::Hyper => 29,
614            Self::Super => 30,
615            Self::Enter => 49,
616            Self::Tab => 50,
617            Self::Backspace => 65,
618            Self::Down => 97,
619            Self::Left => 98,
620            Self::Right => 99,
621            Self::Up => 100,
622            Self::End => 101,
623            Self::Home => 102,
624            Self::PageDown => 103,
625            Self::PageUp => 104,
626            Self::Escape => 24581,
627            Self::Select => 24588,
628            Self::BrightnessDown => 28672,
629            Self::BrightnessUp => 28673,
630            Self::F1 => 36865,
631            Self::F2 => 36866,
632            Self::F3 => 36867,
633            Self::F4 => 36868,
634            Self::F5 => 36869,
635            Self::F6 => 36870,
636            Self::F7 => 36871,
637            Self::F8 => 36872,
638            Self::F9 => 36873,
639            Self::F10 => 36874,
640            Self::F11 => 36875,
641            Self::F12 => 36876,
642            Self::Soft1 => 36881,
643            Self::Soft2 => 36882,
644            Self::Soft3 => 36883,
645            Self::Soft4 => 36884,
646            Self::MediaPlayPause => 40968,
647            Self::AudioVolumeDown => 49162,
648            Self::AudioVolumeUp => 49163,
649            Self::AudioVolumeMute => 49164,
650            Self::BrowserBack => 61440,
651            Self::BrowserFavorites => 61441,
652            Self::BrowserForward => 61442,
653            Self::BrowserHome => 61443,
654            Self::BrowserRefresh => 61444,
655            Self::BrowserSearch => 61445,
656            Self::BrowserStop => 61446,
657            Self::ZoomToggle => 73799,
658            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
659        }
660    }
661
662    #[inline]
663    pub fn is_unknown(&self) -> bool {
664        match self {
665            Self::__SourceBreaking { unknown_ordinal: _ } => true,
666            _ => false,
667        }
668    }
669}
670
671#[derive(Clone, Debug, PartialEq)]
672pub struct KeyEventInjectorInjectRequest {
673    pub key_event: KeyEvent,
674}
675
676impl fidl::Persistable for KeyEventInjectorInjectRequest {}
677
678#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
679pub struct KeyEventInjectorInjectResponse {
680    pub status: KeyEventStatus,
681}
682
683impl fidl::Persistable for KeyEventInjectorInjectResponse {}
684
685#[derive(Clone, Debug, PartialEq)]
686pub struct KeyboardListenerOnKeyEventRequest {
687    pub event: KeyEvent,
688}
689
690impl fidl::Persistable for KeyboardListenerOnKeyEventRequest {}
691
692#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
693pub struct KeyboardListenerOnKeyEventResponse {
694    pub status: KeyEventStatus,
695}
696
697impl fidl::Persistable for KeyboardListenerOnKeyEventResponse {}
698
699/// A Keyboard event generated to reflect key input. `timestamp` and `type` are required.
700/// At least one of `key` and `key_meaning`  must be set for a valid event.
701#[derive(Clone, Debug, Default, PartialEq)]
702pub struct KeyEvent {
703    /// Time in nanoseconds when the event was recorded, in the `CLOCK_MONOTONIC` time base.
704    /// The timestamp is **required** on every key event, and users can expect that it
705    /// will always be present.
706    pub timestamp: Option<i64>,
707    /// Type of event.
708    pub type_: Option<KeyEventType>,
709    /// Identifies the key ignoring modifiers, layout, prior key events, etc. This is called
710    /// the "physical key" on some platforms. In cases where the key event did not originate
711    /// from a physical keyboard (e.g. onscreen keyboard) this field may be empty.
712    pub key: Option<fidl_fuchsia_input__common::Key>,
713    /// Modifiers in effect at the time of the event.
714    /// Example:
715    ///  CapsLock is off, user presses CapsLock, then A, then releases both.
716    ///  Event sequence is as follows:
717    ///  1. type: Pressed, key: CapsLock, modifiers: None
718    ///  2. type: Pressed, key: A, modifiers: CapsLock
719    ///  3. type: Released, key: CapsLock, modifiers: CapsLock
720    ///  4. type: Released, key: A, modifiers: CapsLock
721    ///
722    ///  CapsLock is on, user presses CapsLock, then A, then releases both.
723    ///  1. type: Pressed, key: CapsLock, modifiers: CapsLock
724    ///  2. type: Pressed, key: A, modifiers: None
725    ///  3. type: Released, key: CapsLock, modifiers: None
726    ///  4. type: Released, key: A, modifiers: None
727    pub modifiers: Option<Modifiers>,
728    /// Meaning of the key.
729    pub key_meaning: Option<KeyMeaning>,
730    /// The sequence number of this `KeyEvent` in the sequence of autorepeated
731    /// keys.
732    ///
733    /// Unset if this event has been generated in the immediate response to an
734    /// input from the keyboard driver.  If the `KeyEvent` has been generated
735    /// through the autorepeat mechanism, this property is set and is
736    /// incremented by one for each successive generated key event.
737    pub repeat_sequence: Option<u32>,
738    /// The lock state in effect at the time of the event.
739    ///
740    /// For example, if CapsLock effect is turned on (pressing 'a' results in
741    /// the effect 'A'), the corresponding bit in the lock state is set.
742    ///
743    /// NOTE: `LockState` is different from whether the CapsLock modifier key
744    /// is actuated or not. `LockState.CAPS_LOCK` can be active even if the
745    /// Caps Lock key is not currently actuated.
746    pub lock_state: Option<LockState>,
747    /// Identifies the device originating this event.
748    pub device_id: Option<u32>,
749    #[doc(hidden)]
750    pub __source_breaking: fidl::marker::SourceBreaking,
751}
752
753impl fidl::Persistable for KeyEvent {}
754
755/// The meaning of the key press. This is typically the Unicode codepoint inserted
756/// by this event, or an enum representing a key that corresponds to whitespace or
757/// is otherwise unprintable.
758#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
759pub enum KeyMeaning {
760    /// The Unicode codepoint representing character typed, if any.
761    /// * In Dart and Go, this corresponds to a `rune`.
762    /// * In Rust, this corresponds to a `char`.
763    /// * In C and C++, this corresponds to ICU's UChar32.
764    Codepoint(u32),
765    /// The meaning of the key for key events with no corresponding symbol.
766    NonPrintableKey(NonPrintableKey),
767}
768
769impl KeyMeaning {
770    #[inline]
771    pub fn ordinal(&self) -> u64 {
772        match *self {
773            Self::Codepoint(_) => 1,
774            Self::NonPrintableKey(_) => 2,
775        }
776    }
777}
778
779impl fidl::Persistable for KeyMeaning {}
780
781pub mod key_event_injector_ordinals {
782    pub const INJECT: u64 = 0x1eb2c0d795c68949;
783}
784
785pub mod keyboard_ordinals {
786    pub const ADD_LISTENER: u64 = 0x3bc57587fc9b3d22;
787}
788
789pub mod keyboard_listener_ordinals {
790    pub const ON_KEY_EVENT: u64 = 0x2ef2ee16ac509093;
791}
792
793mod internal {
794    use super::*;
795    unsafe impl fidl::encoding::TypeMarker for LockState {
796        type Owned = Self;
797
798        #[inline(always)]
799        fn inline_align(_context: fidl::encoding::Context) -> usize {
800            8
801        }
802
803        #[inline(always)]
804        fn inline_size(_context: fidl::encoding::Context) -> usize {
805            8
806        }
807    }
808
809    impl fidl::encoding::ValueTypeMarker for LockState {
810        type Borrowed<'a> = Self;
811        #[inline(always)]
812        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
813            *value
814        }
815    }
816
817    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LockState {
818        #[inline]
819        unsafe fn encode(
820            self,
821            encoder: &mut fidl::encoding::Encoder<'_, D>,
822            offset: usize,
823            _depth: fidl::encoding::Depth,
824        ) -> fidl::Result<()> {
825            encoder.debug_check_bounds::<Self>(offset);
826            encoder.write_num(self.bits(), offset);
827            Ok(())
828        }
829    }
830
831    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LockState {
832        #[inline(always)]
833        fn new_empty() -> Self {
834            Self::empty()
835        }
836
837        #[inline]
838        unsafe fn decode(
839            &mut self,
840            decoder: &mut fidl::encoding::Decoder<'_, D>,
841            offset: usize,
842            _depth: fidl::encoding::Depth,
843        ) -> fidl::Result<()> {
844            decoder.debug_check_bounds::<Self>(offset);
845            let prim = decoder.read_num::<u64>(offset);
846            *self = Self::from_bits_allow_unknown(prim);
847            Ok(())
848        }
849    }
850    unsafe impl fidl::encoding::TypeMarker for Modifiers {
851        type Owned = Self;
852
853        #[inline(always)]
854        fn inline_align(_context: fidl::encoding::Context) -> usize {
855            8
856        }
857
858        #[inline(always)]
859        fn inline_size(_context: fidl::encoding::Context) -> usize {
860            8
861        }
862    }
863
864    impl fidl::encoding::ValueTypeMarker for Modifiers {
865        type Borrowed<'a> = Self;
866        #[inline(always)]
867        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
868            *value
869        }
870    }
871
872    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Modifiers {
873        #[inline]
874        unsafe fn encode(
875            self,
876            encoder: &mut fidl::encoding::Encoder<'_, D>,
877            offset: usize,
878            _depth: fidl::encoding::Depth,
879        ) -> fidl::Result<()> {
880            encoder.debug_check_bounds::<Self>(offset);
881            encoder.write_num(self.bits(), offset);
882            Ok(())
883        }
884    }
885
886    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Modifiers {
887        #[inline(always)]
888        fn new_empty() -> Self {
889            Self::empty()
890        }
891
892        #[inline]
893        unsafe fn decode(
894            &mut self,
895            decoder: &mut fidl::encoding::Decoder<'_, D>,
896            offset: usize,
897            _depth: fidl::encoding::Depth,
898        ) -> fidl::Result<()> {
899            decoder.debug_check_bounds::<Self>(offset);
900            let prim = decoder.read_num::<u64>(offset);
901            *self = Self::from_bits_allow_unknown(prim);
902            Ok(())
903        }
904    }
905    unsafe impl fidl::encoding::TypeMarker for KeyEventStatus {
906        type Owned = Self;
907
908        #[inline(always)]
909        fn inline_align(_context: fidl::encoding::Context) -> usize {
910            std::mem::align_of::<u32>()
911        }
912
913        #[inline(always)]
914        fn inline_size(_context: fidl::encoding::Context) -> usize {
915            std::mem::size_of::<u32>()
916        }
917
918        #[inline(always)]
919        fn encode_is_copy() -> bool {
920            true
921        }
922
923        #[inline(always)]
924        fn decode_is_copy() -> bool {
925            false
926        }
927    }
928
929    impl fidl::encoding::ValueTypeMarker for KeyEventStatus {
930        type Borrowed<'a> = Self;
931        #[inline(always)]
932        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
933            *value
934        }
935    }
936
937    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for KeyEventStatus {
938        #[inline]
939        unsafe fn encode(
940            self,
941            encoder: &mut fidl::encoding::Encoder<'_, D>,
942            offset: usize,
943            _depth: fidl::encoding::Depth,
944        ) -> fidl::Result<()> {
945            encoder.debug_check_bounds::<Self>(offset);
946            encoder.write_num(self.into_primitive(), offset);
947            Ok(())
948        }
949    }
950
951    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEventStatus {
952        #[inline(always)]
953        fn new_empty() -> Self {
954            Self::Handled
955        }
956
957        #[inline]
958        unsafe fn decode(
959            &mut self,
960            decoder: &mut fidl::encoding::Decoder<'_, D>,
961            offset: usize,
962            _depth: fidl::encoding::Depth,
963        ) -> fidl::Result<()> {
964            decoder.debug_check_bounds::<Self>(offset);
965            let prim = decoder.read_num::<u32>(offset);
966
967            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
968            Ok(())
969        }
970    }
971    unsafe impl fidl::encoding::TypeMarker for KeyEventType {
972        type Owned = Self;
973
974        #[inline(always)]
975        fn inline_align(_context: fidl::encoding::Context) -> usize {
976            std::mem::align_of::<u32>()
977        }
978
979        #[inline(always)]
980        fn inline_size(_context: fidl::encoding::Context) -> usize {
981            std::mem::size_of::<u32>()
982        }
983
984        #[inline(always)]
985        fn encode_is_copy() -> bool {
986            true
987        }
988
989        #[inline(always)]
990        fn decode_is_copy() -> bool {
991            false
992        }
993    }
994
995    impl fidl::encoding::ValueTypeMarker for KeyEventType {
996        type Borrowed<'a> = Self;
997        #[inline(always)]
998        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
999            *value
1000        }
1001    }
1002
1003    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for KeyEventType {
1004        #[inline]
1005        unsafe fn encode(
1006            self,
1007            encoder: &mut fidl::encoding::Encoder<'_, D>,
1008            offset: usize,
1009            _depth: fidl::encoding::Depth,
1010        ) -> fidl::Result<()> {
1011            encoder.debug_check_bounds::<Self>(offset);
1012            encoder.write_num(self.into_primitive(), offset);
1013            Ok(())
1014        }
1015    }
1016
1017    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEventType {
1018        #[inline(always)]
1019        fn new_empty() -> Self {
1020            Self::Pressed
1021        }
1022
1023        #[inline]
1024        unsafe fn decode(
1025            &mut self,
1026            decoder: &mut fidl::encoding::Decoder<'_, D>,
1027            offset: usize,
1028            _depth: fidl::encoding::Depth,
1029        ) -> fidl::Result<()> {
1030            decoder.debug_check_bounds::<Self>(offset);
1031            let prim = decoder.read_num::<u32>(offset);
1032
1033            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1034            Ok(())
1035        }
1036    }
1037    unsafe impl fidl::encoding::TypeMarker for NonPrintableKey {
1038        type Owned = Self;
1039
1040        #[inline(always)]
1041        fn inline_align(_context: fidl::encoding::Context) -> usize {
1042            std::mem::align_of::<u32>()
1043        }
1044
1045        #[inline(always)]
1046        fn inline_size(_context: fidl::encoding::Context) -> usize {
1047            std::mem::size_of::<u32>()
1048        }
1049
1050        #[inline(always)]
1051        fn encode_is_copy() -> bool {
1052            false
1053        }
1054
1055        #[inline(always)]
1056        fn decode_is_copy() -> bool {
1057            false
1058        }
1059    }
1060
1061    impl fidl::encoding::ValueTypeMarker for NonPrintableKey {
1062        type Borrowed<'a> = Self;
1063        #[inline(always)]
1064        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1065            *value
1066        }
1067    }
1068
1069    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1070        for NonPrintableKey
1071    {
1072        #[inline]
1073        unsafe fn encode(
1074            self,
1075            encoder: &mut fidl::encoding::Encoder<'_, D>,
1076            offset: usize,
1077            _depth: fidl::encoding::Depth,
1078        ) -> fidl::Result<()> {
1079            encoder.debug_check_bounds::<Self>(offset);
1080            encoder.write_num(self.into_primitive(), offset);
1081            Ok(())
1082        }
1083    }
1084
1085    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NonPrintableKey {
1086        #[inline(always)]
1087        fn new_empty() -> Self {
1088            Self::unknown()
1089        }
1090
1091        #[inline]
1092        unsafe fn decode(
1093            &mut self,
1094            decoder: &mut fidl::encoding::Decoder<'_, D>,
1095            offset: usize,
1096            _depth: fidl::encoding::Depth,
1097        ) -> fidl::Result<()> {
1098            decoder.debug_check_bounds::<Self>(offset);
1099            let prim = decoder.read_num::<u32>(offset);
1100
1101            *self = Self::from_primitive_allow_unknown(prim);
1102            Ok(())
1103        }
1104    }
1105
1106    impl fidl::encoding::ValueTypeMarker for KeyEventInjectorInjectRequest {
1107        type Borrowed<'a> = &'a Self;
1108        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1109            value
1110        }
1111    }
1112
1113    unsafe impl fidl::encoding::TypeMarker for KeyEventInjectorInjectRequest {
1114        type Owned = Self;
1115
1116        #[inline(always)]
1117        fn inline_align(_context: fidl::encoding::Context) -> usize {
1118            8
1119        }
1120
1121        #[inline(always)]
1122        fn inline_size(_context: fidl::encoding::Context) -> usize {
1123            16
1124        }
1125    }
1126
1127    unsafe impl<D: fidl::encoding::ResourceDialect>
1128        fidl::encoding::Encode<KeyEventInjectorInjectRequest, D>
1129        for &KeyEventInjectorInjectRequest
1130    {
1131        #[inline]
1132        unsafe fn encode(
1133            self,
1134            encoder: &mut fidl::encoding::Encoder<'_, D>,
1135            offset: usize,
1136            _depth: fidl::encoding::Depth,
1137        ) -> fidl::Result<()> {
1138            encoder.debug_check_bounds::<KeyEventInjectorInjectRequest>(offset);
1139            // Delegate to tuple encoding.
1140            fidl::encoding::Encode::<KeyEventInjectorInjectRequest, D>::encode(
1141                (<KeyEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.key_event),),
1142                encoder,
1143                offset,
1144                _depth,
1145            )
1146        }
1147    }
1148    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEvent, D>>
1149        fidl::encoding::Encode<KeyEventInjectorInjectRequest, D> for (T0,)
1150    {
1151        #[inline]
1152        unsafe fn encode(
1153            self,
1154            encoder: &mut fidl::encoding::Encoder<'_, D>,
1155            offset: usize,
1156            depth: fidl::encoding::Depth,
1157        ) -> fidl::Result<()> {
1158            encoder.debug_check_bounds::<KeyEventInjectorInjectRequest>(offset);
1159            // Zero out padding regions. There's no need to apply masks
1160            // because the unmasked parts will be overwritten by fields.
1161            // Write the fields.
1162            self.0.encode(encoder, offset + 0, depth)?;
1163            Ok(())
1164        }
1165    }
1166
1167    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1168        for KeyEventInjectorInjectRequest
1169    {
1170        #[inline(always)]
1171        fn new_empty() -> Self {
1172            Self { key_event: fidl::new_empty!(KeyEvent, D) }
1173        }
1174
1175        #[inline]
1176        unsafe fn decode(
1177            &mut self,
1178            decoder: &mut fidl::encoding::Decoder<'_, D>,
1179            offset: usize,
1180            _depth: fidl::encoding::Depth,
1181        ) -> fidl::Result<()> {
1182            decoder.debug_check_bounds::<Self>(offset);
1183            // Verify that padding bytes are zero.
1184            fidl::decode!(KeyEvent, D, &mut self.key_event, decoder, offset + 0, _depth)?;
1185            Ok(())
1186        }
1187    }
1188
1189    impl fidl::encoding::ValueTypeMarker for KeyEventInjectorInjectResponse {
1190        type Borrowed<'a> = &'a Self;
1191        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1192            value
1193        }
1194    }
1195
1196    unsafe impl fidl::encoding::TypeMarker for KeyEventInjectorInjectResponse {
1197        type Owned = Self;
1198
1199        #[inline(always)]
1200        fn inline_align(_context: fidl::encoding::Context) -> usize {
1201            4
1202        }
1203
1204        #[inline(always)]
1205        fn inline_size(_context: fidl::encoding::Context) -> usize {
1206            4
1207        }
1208    }
1209
1210    unsafe impl<D: fidl::encoding::ResourceDialect>
1211        fidl::encoding::Encode<KeyEventInjectorInjectResponse, D>
1212        for &KeyEventInjectorInjectResponse
1213    {
1214        #[inline]
1215        unsafe fn encode(
1216            self,
1217            encoder: &mut fidl::encoding::Encoder<'_, D>,
1218            offset: usize,
1219            _depth: fidl::encoding::Depth,
1220        ) -> fidl::Result<()> {
1221            encoder.debug_check_bounds::<KeyEventInjectorInjectResponse>(offset);
1222            // Delegate to tuple encoding.
1223            fidl::encoding::Encode::<KeyEventInjectorInjectResponse, D>::encode(
1224                (<KeyEventStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
1225                encoder,
1226                offset,
1227                _depth,
1228            )
1229        }
1230    }
1231    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEventStatus, D>>
1232        fidl::encoding::Encode<KeyEventInjectorInjectResponse, D> for (T0,)
1233    {
1234        #[inline]
1235        unsafe fn encode(
1236            self,
1237            encoder: &mut fidl::encoding::Encoder<'_, D>,
1238            offset: usize,
1239            depth: fidl::encoding::Depth,
1240        ) -> fidl::Result<()> {
1241            encoder.debug_check_bounds::<KeyEventInjectorInjectResponse>(offset);
1242            // Zero out padding regions. There's no need to apply masks
1243            // because the unmasked parts will be overwritten by fields.
1244            // Write the fields.
1245            self.0.encode(encoder, offset + 0, depth)?;
1246            Ok(())
1247        }
1248    }
1249
1250    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1251        for KeyEventInjectorInjectResponse
1252    {
1253        #[inline(always)]
1254        fn new_empty() -> Self {
1255            Self { status: fidl::new_empty!(KeyEventStatus, D) }
1256        }
1257
1258        #[inline]
1259        unsafe fn decode(
1260            &mut self,
1261            decoder: &mut fidl::encoding::Decoder<'_, D>,
1262            offset: usize,
1263            _depth: fidl::encoding::Depth,
1264        ) -> fidl::Result<()> {
1265            decoder.debug_check_bounds::<Self>(offset);
1266            // Verify that padding bytes are zero.
1267            fidl::decode!(KeyEventStatus, D, &mut self.status, decoder, offset + 0, _depth)?;
1268            Ok(())
1269        }
1270    }
1271
1272    impl fidl::encoding::ValueTypeMarker for KeyboardListenerOnKeyEventRequest {
1273        type Borrowed<'a> = &'a Self;
1274        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1275            value
1276        }
1277    }
1278
1279    unsafe impl fidl::encoding::TypeMarker for KeyboardListenerOnKeyEventRequest {
1280        type Owned = Self;
1281
1282        #[inline(always)]
1283        fn inline_align(_context: fidl::encoding::Context) -> usize {
1284            8
1285        }
1286
1287        #[inline(always)]
1288        fn inline_size(_context: fidl::encoding::Context) -> usize {
1289            16
1290        }
1291    }
1292
1293    unsafe impl<D: fidl::encoding::ResourceDialect>
1294        fidl::encoding::Encode<KeyboardListenerOnKeyEventRequest, D>
1295        for &KeyboardListenerOnKeyEventRequest
1296    {
1297        #[inline]
1298        unsafe fn encode(
1299            self,
1300            encoder: &mut fidl::encoding::Encoder<'_, D>,
1301            offset: usize,
1302            _depth: fidl::encoding::Depth,
1303        ) -> fidl::Result<()> {
1304            encoder.debug_check_bounds::<KeyboardListenerOnKeyEventRequest>(offset);
1305            // Delegate to tuple encoding.
1306            fidl::encoding::Encode::<KeyboardListenerOnKeyEventRequest, D>::encode(
1307                (<KeyEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.event),),
1308                encoder,
1309                offset,
1310                _depth,
1311            )
1312        }
1313    }
1314    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEvent, D>>
1315        fidl::encoding::Encode<KeyboardListenerOnKeyEventRequest, D> for (T0,)
1316    {
1317        #[inline]
1318        unsafe fn encode(
1319            self,
1320            encoder: &mut fidl::encoding::Encoder<'_, D>,
1321            offset: usize,
1322            depth: fidl::encoding::Depth,
1323        ) -> fidl::Result<()> {
1324            encoder.debug_check_bounds::<KeyboardListenerOnKeyEventRequest>(offset);
1325            // Zero out padding regions. There's no need to apply masks
1326            // because the unmasked parts will be overwritten by fields.
1327            // Write the fields.
1328            self.0.encode(encoder, offset + 0, depth)?;
1329            Ok(())
1330        }
1331    }
1332
1333    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1334        for KeyboardListenerOnKeyEventRequest
1335    {
1336        #[inline(always)]
1337        fn new_empty() -> Self {
1338            Self { event: fidl::new_empty!(KeyEvent, D) }
1339        }
1340
1341        #[inline]
1342        unsafe fn decode(
1343            &mut self,
1344            decoder: &mut fidl::encoding::Decoder<'_, D>,
1345            offset: usize,
1346            _depth: fidl::encoding::Depth,
1347        ) -> fidl::Result<()> {
1348            decoder.debug_check_bounds::<Self>(offset);
1349            // Verify that padding bytes are zero.
1350            fidl::decode!(KeyEvent, D, &mut self.event, decoder, offset + 0, _depth)?;
1351            Ok(())
1352        }
1353    }
1354
1355    impl fidl::encoding::ValueTypeMarker for KeyboardListenerOnKeyEventResponse {
1356        type Borrowed<'a> = &'a Self;
1357        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1358            value
1359        }
1360    }
1361
1362    unsafe impl fidl::encoding::TypeMarker for KeyboardListenerOnKeyEventResponse {
1363        type Owned = Self;
1364
1365        #[inline(always)]
1366        fn inline_align(_context: fidl::encoding::Context) -> usize {
1367            4
1368        }
1369
1370        #[inline(always)]
1371        fn inline_size(_context: fidl::encoding::Context) -> usize {
1372            4
1373        }
1374    }
1375
1376    unsafe impl<D: fidl::encoding::ResourceDialect>
1377        fidl::encoding::Encode<KeyboardListenerOnKeyEventResponse, D>
1378        for &KeyboardListenerOnKeyEventResponse
1379    {
1380        #[inline]
1381        unsafe fn encode(
1382            self,
1383            encoder: &mut fidl::encoding::Encoder<'_, D>,
1384            offset: usize,
1385            _depth: fidl::encoding::Depth,
1386        ) -> fidl::Result<()> {
1387            encoder.debug_check_bounds::<KeyboardListenerOnKeyEventResponse>(offset);
1388            // Delegate to tuple encoding.
1389            fidl::encoding::Encode::<KeyboardListenerOnKeyEventResponse, D>::encode(
1390                (<KeyEventStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
1391                encoder,
1392                offset,
1393                _depth,
1394            )
1395        }
1396    }
1397    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEventStatus, D>>
1398        fidl::encoding::Encode<KeyboardListenerOnKeyEventResponse, D> for (T0,)
1399    {
1400        #[inline]
1401        unsafe fn encode(
1402            self,
1403            encoder: &mut fidl::encoding::Encoder<'_, D>,
1404            offset: usize,
1405            depth: fidl::encoding::Depth,
1406        ) -> fidl::Result<()> {
1407            encoder.debug_check_bounds::<KeyboardListenerOnKeyEventResponse>(offset);
1408            // Zero out padding regions. There's no need to apply masks
1409            // because the unmasked parts will be overwritten by fields.
1410            // Write the fields.
1411            self.0.encode(encoder, offset + 0, depth)?;
1412            Ok(())
1413        }
1414    }
1415
1416    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1417        for KeyboardListenerOnKeyEventResponse
1418    {
1419        #[inline(always)]
1420        fn new_empty() -> Self {
1421            Self { status: fidl::new_empty!(KeyEventStatus, D) }
1422        }
1423
1424        #[inline]
1425        unsafe fn decode(
1426            &mut self,
1427            decoder: &mut fidl::encoding::Decoder<'_, D>,
1428            offset: usize,
1429            _depth: fidl::encoding::Depth,
1430        ) -> fidl::Result<()> {
1431            decoder.debug_check_bounds::<Self>(offset);
1432            // Verify that padding bytes are zero.
1433            fidl::decode!(KeyEventStatus, D, &mut self.status, decoder, offset + 0, _depth)?;
1434            Ok(())
1435        }
1436    }
1437
1438    impl KeyEvent {
1439        #[inline(always)]
1440        fn max_ordinal_present(&self) -> u64 {
1441            if let Some(_) = self.device_id {
1442                return 8;
1443            }
1444            if let Some(_) = self.lock_state {
1445                return 7;
1446            }
1447            if let Some(_) = self.repeat_sequence {
1448                return 6;
1449            }
1450            if let Some(_) = self.key_meaning {
1451                return 5;
1452            }
1453            if let Some(_) = self.modifiers {
1454                return 4;
1455            }
1456            if let Some(_) = self.key {
1457                return 3;
1458            }
1459            if let Some(_) = self.type_ {
1460                return 2;
1461            }
1462            if let Some(_) = self.timestamp {
1463                return 1;
1464            }
1465            0
1466        }
1467    }
1468
1469    impl fidl::encoding::ValueTypeMarker for KeyEvent {
1470        type Borrowed<'a> = &'a Self;
1471        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1472            value
1473        }
1474    }
1475
1476    unsafe impl fidl::encoding::TypeMarker for KeyEvent {
1477        type Owned = Self;
1478
1479        #[inline(always)]
1480        fn inline_align(_context: fidl::encoding::Context) -> usize {
1481            8
1482        }
1483
1484        #[inline(always)]
1485        fn inline_size(_context: fidl::encoding::Context) -> usize {
1486            16
1487        }
1488    }
1489
1490    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<KeyEvent, D> for &KeyEvent {
1491        unsafe fn encode(
1492            self,
1493            encoder: &mut fidl::encoding::Encoder<'_, D>,
1494            offset: usize,
1495            mut depth: fidl::encoding::Depth,
1496        ) -> fidl::Result<()> {
1497            encoder.debug_check_bounds::<KeyEvent>(offset);
1498            // Vector header
1499            let max_ordinal: u64 = self.max_ordinal_present();
1500            encoder.write_num(max_ordinal, offset);
1501            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1502            // Calling encoder.out_of_line_offset(0) is not allowed.
1503            if max_ordinal == 0 {
1504                return Ok(());
1505            }
1506            depth.increment()?;
1507            let envelope_size = 8;
1508            let bytes_len = max_ordinal as usize * envelope_size;
1509            #[allow(unused_variables)]
1510            let offset = encoder.out_of_line_offset(bytes_len);
1511            let mut _prev_end_offset: usize = 0;
1512            if 1 > max_ordinal {
1513                return Ok(());
1514            }
1515
1516            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1517            // are envelope_size bytes.
1518            let cur_offset: usize = (1 - 1) * envelope_size;
1519
1520            // Zero reserved fields.
1521            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1522
1523            // Safety:
1524            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1525            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1526            //   envelope_size bytes, there is always sufficient room.
1527            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1528                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1529                encoder,
1530                offset + cur_offset,
1531                depth,
1532            )?;
1533
1534            _prev_end_offset = cur_offset + envelope_size;
1535            if 2 > max_ordinal {
1536                return Ok(());
1537            }
1538
1539            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1540            // are envelope_size bytes.
1541            let cur_offset: usize = (2 - 1) * envelope_size;
1542
1543            // Zero reserved fields.
1544            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1545
1546            // Safety:
1547            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1548            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1549            //   envelope_size bytes, there is always sufficient room.
1550            fidl::encoding::encode_in_envelope_optional::<KeyEventType, D>(
1551                self.type_.as_ref().map(<KeyEventType as fidl::encoding::ValueTypeMarker>::borrow),
1552                encoder,
1553                offset + cur_offset,
1554                depth,
1555            )?;
1556
1557            _prev_end_offset = cur_offset + envelope_size;
1558            if 3 > max_ordinal {
1559                return Ok(());
1560            }
1561
1562            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1563            // are envelope_size bytes.
1564            let cur_offset: usize = (3 - 1) * envelope_size;
1565
1566            // Zero reserved fields.
1567            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1568
1569            // Safety:
1570            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1571            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1572            //   envelope_size bytes, there is always sufficient room.
1573            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_input__common::Key, D>(
1574                self.key.as_ref().map(
1575                    <fidl_fuchsia_input__common::Key as fidl::encoding::ValueTypeMarker>::borrow,
1576                ),
1577                encoder,
1578                offset + cur_offset,
1579                depth,
1580            )?;
1581
1582            _prev_end_offset = cur_offset + envelope_size;
1583            if 4 > max_ordinal {
1584                return Ok(());
1585            }
1586
1587            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1588            // are envelope_size bytes.
1589            let cur_offset: usize = (4 - 1) * envelope_size;
1590
1591            // Zero reserved fields.
1592            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1593
1594            // Safety:
1595            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1596            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1597            //   envelope_size bytes, there is always sufficient room.
1598            fidl::encoding::encode_in_envelope_optional::<Modifiers, D>(
1599                self.modifiers.as_ref().map(<Modifiers as fidl::encoding::ValueTypeMarker>::borrow),
1600                encoder,
1601                offset + cur_offset,
1602                depth,
1603            )?;
1604
1605            _prev_end_offset = cur_offset + envelope_size;
1606            if 5 > max_ordinal {
1607                return Ok(());
1608            }
1609
1610            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1611            // are envelope_size bytes.
1612            let cur_offset: usize = (5 - 1) * envelope_size;
1613
1614            // Zero reserved fields.
1615            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1616
1617            // Safety:
1618            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1619            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1620            //   envelope_size bytes, there is always sufficient room.
1621            fidl::encoding::encode_in_envelope_optional::<KeyMeaning, D>(
1622                self.key_meaning
1623                    .as_ref()
1624                    .map(<KeyMeaning as fidl::encoding::ValueTypeMarker>::borrow),
1625                encoder,
1626                offset + cur_offset,
1627                depth,
1628            )?;
1629
1630            _prev_end_offset = cur_offset + envelope_size;
1631            if 6 > max_ordinal {
1632                return Ok(());
1633            }
1634
1635            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1636            // are envelope_size bytes.
1637            let cur_offset: usize = (6 - 1) * envelope_size;
1638
1639            // Zero reserved fields.
1640            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1641
1642            // Safety:
1643            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1644            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1645            //   envelope_size bytes, there is always sufficient room.
1646            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1647                self.repeat_sequence.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1648                encoder,
1649                offset + cur_offset,
1650                depth,
1651            )?;
1652
1653            _prev_end_offset = cur_offset + envelope_size;
1654            if 7 > max_ordinal {
1655                return Ok(());
1656            }
1657
1658            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1659            // are envelope_size bytes.
1660            let cur_offset: usize = (7 - 1) * envelope_size;
1661
1662            // Zero reserved fields.
1663            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1664
1665            // Safety:
1666            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1667            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1668            //   envelope_size bytes, there is always sufficient room.
1669            fidl::encoding::encode_in_envelope_optional::<LockState, D>(
1670                self.lock_state
1671                    .as_ref()
1672                    .map(<LockState as fidl::encoding::ValueTypeMarker>::borrow),
1673                encoder,
1674                offset + cur_offset,
1675                depth,
1676            )?;
1677
1678            _prev_end_offset = cur_offset + envelope_size;
1679            if 8 > max_ordinal {
1680                return Ok(());
1681            }
1682
1683            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1684            // are envelope_size bytes.
1685            let cur_offset: usize = (8 - 1) * envelope_size;
1686
1687            // Zero reserved fields.
1688            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1689
1690            // Safety:
1691            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1692            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1693            //   envelope_size bytes, there is always sufficient room.
1694            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1695                self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1696                encoder,
1697                offset + cur_offset,
1698                depth,
1699            )?;
1700
1701            _prev_end_offset = cur_offset + envelope_size;
1702
1703            Ok(())
1704        }
1705    }
1706
1707    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEvent {
1708        #[inline(always)]
1709        fn new_empty() -> Self {
1710            Self::default()
1711        }
1712
1713        unsafe fn decode(
1714            &mut self,
1715            decoder: &mut fidl::encoding::Decoder<'_, D>,
1716            offset: usize,
1717            mut depth: fidl::encoding::Depth,
1718        ) -> fidl::Result<()> {
1719            decoder.debug_check_bounds::<Self>(offset);
1720            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1721                None => return Err(fidl::Error::NotNullable),
1722                Some(len) => len,
1723            };
1724            // Calling decoder.out_of_line_offset(0) is not allowed.
1725            if len == 0 {
1726                return Ok(());
1727            };
1728            depth.increment()?;
1729            let envelope_size = 8;
1730            let bytes_len = len * envelope_size;
1731            let offset = decoder.out_of_line_offset(bytes_len)?;
1732            // Decode the envelope for each type.
1733            let mut _next_ordinal_to_read = 0;
1734            let mut next_offset = offset;
1735            let end_offset = offset + bytes_len;
1736            _next_ordinal_to_read += 1;
1737            if next_offset >= end_offset {
1738                return Ok(());
1739            }
1740
1741            // Decode unknown envelopes for gaps in ordinals.
1742            while _next_ordinal_to_read < 1 {
1743                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1744                _next_ordinal_to_read += 1;
1745                next_offset += envelope_size;
1746            }
1747
1748            let next_out_of_line = decoder.next_out_of_line();
1749            let handles_before = decoder.remaining_handles();
1750            if let Some((inlined, num_bytes, num_handles)) =
1751                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1752            {
1753                let member_inline_size =
1754                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1755                if inlined != (member_inline_size <= 4) {
1756                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1757                }
1758                let inner_offset;
1759                let mut inner_depth = depth.clone();
1760                if inlined {
1761                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1762                    inner_offset = next_offset;
1763                } else {
1764                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1765                    inner_depth.increment()?;
1766                }
1767                let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
1768                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1769                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1770                {
1771                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1772                }
1773                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1774                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1775                }
1776            }
1777
1778            next_offset += envelope_size;
1779            _next_ordinal_to_read += 1;
1780            if next_offset >= end_offset {
1781                return Ok(());
1782            }
1783
1784            // Decode unknown envelopes for gaps in ordinals.
1785            while _next_ordinal_to_read < 2 {
1786                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1787                _next_ordinal_to_read += 1;
1788                next_offset += envelope_size;
1789            }
1790
1791            let next_out_of_line = decoder.next_out_of_line();
1792            let handles_before = decoder.remaining_handles();
1793            if let Some((inlined, num_bytes, num_handles)) =
1794                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1795            {
1796                let member_inline_size =
1797                    <KeyEventType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1798                if inlined != (member_inline_size <= 4) {
1799                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1800                }
1801                let inner_offset;
1802                let mut inner_depth = depth.clone();
1803                if inlined {
1804                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1805                    inner_offset = next_offset;
1806                } else {
1807                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1808                    inner_depth.increment()?;
1809                }
1810                let val_ref = self.type_.get_or_insert_with(|| fidl::new_empty!(KeyEventType, D));
1811                fidl::decode!(KeyEventType, D, val_ref, decoder, inner_offset, inner_depth)?;
1812                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1813                {
1814                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1815                }
1816                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1817                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1818                }
1819            }
1820
1821            next_offset += envelope_size;
1822            _next_ordinal_to_read += 1;
1823            if next_offset >= end_offset {
1824                return Ok(());
1825            }
1826
1827            // Decode unknown envelopes for gaps in ordinals.
1828            while _next_ordinal_to_read < 3 {
1829                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1830                _next_ordinal_to_read += 1;
1831                next_offset += envelope_size;
1832            }
1833
1834            let next_out_of_line = decoder.next_out_of_line();
1835            let handles_before = decoder.remaining_handles();
1836            if let Some((inlined, num_bytes, num_handles)) =
1837                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1838            {
1839                let member_inline_size =
1840                    <fidl_fuchsia_input__common::Key as fidl::encoding::TypeMarker>::inline_size(
1841                        decoder.context,
1842                    );
1843                if inlined != (member_inline_size <= 4) {
1844                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1845                }
1846                let inner_offset;
1847                let mut inner_depth = depth.clone();
1848                if inlined {
1849                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1850                    inner_offset = next_offset;
1851                } else {
1852                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1853                    inner_depth.increment()?;
1854                }
1855                let val_ref = self
1856                    .key
1857                    .get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_input__common::Key, D));
1858                fidl::decode!(
1859                    fidl_fuchsia_input__common::Key,
1860                    D,
1861                    val_ref,
1862                    decoder,
1863                    inner_offset,
1864                    inner_depth
1865                )?;
1866                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1867                {
1868                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1869                }
1870                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1871                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1872                }
1873            }
1874
1875            next_offset += envelope_size;
1876            _next_ordinal_to_read += 1;
1877            if next_offset >= end_offset {
1878                return Ok(());
1879            }
1880
1881            // Decode unknown envelopes for gaps in ordinals.
1882            while _next_ordinal_to_read < 4 {
1883                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1884                _next_ordinal_to_read += 1;
1885                next_offset += envelope_size;
1886            }
1887
1888            let next_out_of_line = decoder.next_out_of_line();
1889            let handles_before = decoder.remaining_handles();
1890            if let Some((inlined, num_bytes, num_handles)) =
1891                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1892            {
1893                let member_inline_size =
1894                    <Modifiers as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1895                if inlined != (member_inline_size <= 4) {
1896                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1897                }
1898                let inner_offset;
1899                let mut inner_depth = depth.clone();
1900                if inlined {
1901                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1902                    inner_offset = next_offset;
1903                } else {
1904                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1905                    inner_depth.increment()?;
1906                }
1907                let val_ref = self.modifiers.get_or_insert_with(|| fidl::new_empty!(Modifiers, D));
1908                fidl::decode!(Modifiers, D, val_ref, decoder, inner_offset, inner_depth)?;
1909                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1910                {
1911                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1912                }
1913                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1914                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1915                }
1916            }
1917
1918            next_offset += envelope_size;
1919            _next_ordinal_to_read += 1;
1920            if next_offset >= end_offset {
1921                return Ok(());
1922            }
1923
1924            // Decode unknown envelopes for gaps in ordinals.
1925            while _next_ordinal_to_read < 5 {
1926                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1927                _next_ordinal_to_read += 1;
1928                next_offset += envelope_size;
1929            }
1930
1931            let next_out_of_line = decoder.next_out_of_line();
1932            let handles_before = decoder.remaining_handles();
1933            if let Some((inlined, num_bytes, num_handles)) =
1934                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1935            {
1936                let member_inline_size =
1937                    <KeyMeaning as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1938                if inlined != (member_inline_size <= 4) {
1939                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1940                }
1941                let inner_offset;
1942                let mut inner_depth = depth.clone();
1943                if inlined {
1944                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1945                    inner_offset = next_offset;
1946                } else {
1947                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1948                    inner_depth.increment()?;
1949                }
1950                let val_ref =
1951                    self.key_meaning.get_or_insert_with(|| fidl::new_empty!(KeyMeaning, D));
1952                fidl::decode!(KeyMeaning, D, val_ref, decoder, inner_offset, inner_depth)?;
1953                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1954                {
1955                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1956                }
1957                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1958                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1959                }
1960            }
1961
1962            next_offset += envelope_size;
1963            _next_ordinal_to_read += 1;
1964            if next_offset >= end_offset {
1965                return Ok(());
1966            }
1967
1968            // Decode unknown envelopes for gaps in ordinals.
1969            while _next_ordinal_to_read < 6 {
1970                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1971                _next_ordinal_to_read += 1;
1972                next_offset += envelope_size;
1973            }
1974
1975            let next_out_of_line = decoder.next_out_of_line();
1976            let handles_before = decoder.remaining_handles();
1977            if let Some((inlined, num_bytes, num_handles)) =
1978                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1979            {
1980                let member_inline_size =
1981                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1982                if inlined != (member_inline_size <= 4) {
1983                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1984                }
1985                let inner_offset;
1986                let mut inner_depth = depth.clone();
1987                if inlined {
1988                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1989                    inner_offset = next_offset;
1990                } else {
1991                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1992                    inner_depth.increment()?;
1993                }
1994                let val_ref = self.repeat_sequence.get_or_insert_with(|| fidl::new_empty!(u32, D));
1995                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1996                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1997                {
1998                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1999                }
2000                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2001                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2002                }
2003            }
2004
2005            next_offset += envelope_size;
2006            _next_ordinal_to_read += 1;
2007            if next_offset >= end_offset {
2008                return Ok(());
2009            }
2010
2011            // Decode unknown envelopes for gaps in ordinals.
2012            while _next_ordinal_to_read < 7 {
2013                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2014                _next_ordinal_to_read += 1;
2015                next_offset += envelope_size;
2016            }
2017
2018            let next_out_of_line = decoder.next_out_of_line();
2019            let handles_before = decoder.remaining_handles();
2020            if let Some((inlined, num_bytes, num_handles)) =
2021                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2022            {
2023                let member_inline_size =
2024                    <LockState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2025                if inlined != (member_inline_size <= 4) {
2026                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2027                }
2028                let inner_offset;
2029                let mut inner_depth = depth.clone();
2030                if inlined {
2031                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2032                    inner_offset = next_offset;
2033                } else {
2034                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2035                    inner_depth.increment()?;
2036                }
2037                let val_ref = self.lock_state.get_or_insert_with(|| fidl::new_empty!(LockState, D));
2038                fidl::decode!(LockState, D, val_ref, decoder, inner_offset, inner_depth)?;
2039                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2040                {
2041                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2042                }
2043                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2044                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2045                }
2046            }
2047
2048            next_offset += envelope_size;
2049            _next_ordinal_to_read += 1;
2050            if next_offset >= end_offset {
2051                return Ok(());
2052            }
2053
2054            // Decode unknown envelopes for gaps in ordinals.
2055            while _next_ordinal_to_read < 8 {
2056                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2057                _next_ordinal_to_read += 1;
2058                next_offset += envelope_size;
2059            }
2060
2061            let next_out_of_line = decoder.next_out_of_line();
2062            let handles_before = decoder.remaining_handles();
2063            if let Some((inlined, num_bytes, num_handles)) =
2064                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2065            {
2066                let member_inline_size =
2067                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2068                if inlined != (member_inline_size <= 4) {
2069                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2070                }
2071                let inner_offset;
2072                let mut inner_depth = depth.clone();
2073                if inlined {
2074                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2075                    inner_offset = next_offset;
2076                } else {
2077                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2078                    inner_depth.increment()?;
2079                }
2080                let val_ref = self.device_id.get_or_insert_with(|| fidl::new_empty!(u32, D));
2081                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2082                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2083                {
2084                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2085                }
2086                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2087                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2088                }
2089            }
2090
2091            next_offset += envelope_size;
2092
2093            // Decode the remaining unknown envelopes.
2094            while next_offset < end_offset {
2095                _next_ordinal_to_read += 1;
2096                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2097                next_offset += envelope_size;
2098            }
2099
2100            Ok(())
2101        }
2102    }
2103
2104    impl fidl::encoding::ValueTypeMarker for KeyMeaning {
2105        type Borrowed<'a> = &'a Self;
2106        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2107            value
2108        }
2109    }
2110
2111    unsafe impl fidl::encoding::TypeMarker for KeyMeaning {
2112        type Owned = Self;
2113
2114        #[inline(always)]
2115        fn inline_align(_context: fidl::encoding::Context) -> usize {
2116            8
2117        }
2118
2119        #[inline(always)]
2120        fn inline_size(_context: fidl::encoding::Context) -> usize {
2121            16
2122        }
2123    }
2124
2125    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<KeyMeaning, D>
2126        for &KeyMeaning
2127    {
2128        #[inline]
2129        unsafe fn encode(
2130            self,
2131            encoder: &mut fidl::encoding::Encoder<'_, D>,
2132            offset: usize,
2133            _depth: fidl::encoding::Depth,
2134        ) -> fidl::Result<()> {
2135            encoder.debug_check_bounds::<KeyMeaning>(offset);
2136            encoder.write_num::<u64>(self.ordinal(), offset);
2137            match self {
2138                KeyMeaning::Codepoint(ref val) => fidl::encoding::encode_in_envelope::<u32, D>(
2139                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
2140                    encoder,
2141                    offset + 8,
2142                    _depth,
2143                ),
2144                KeyMeaning::NonPrintableKey(ref val) => {
2145                    fidl::encoding::encode_in_envelope::<NonPrintableKey, D>(
2146                        <NonPrintableKey as fidl::encoding::ValueTypeMarker>::borrow(val),
2147                        encoder,
2148                        offset + 8,
2149                        _depth,
2150                    )
2151                }
2152            }
2153        }
2154    }
2155
2156    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyMeaning {
2157        #[inline(always)]
2158        fn new_empty() -> Self {
2159            Self::Codepoint(fidl::new_empty!(u32, D))
2160        }
2161
2162        #[inline]
2163        unsafe fn decode(
2164            &mut self,
2165            decoder: &mut fidl::encoding::Decoder<'_, D>,
2166            offset: usize,
2167            mut depth: fidl::encoding::Depth,
2168        ) -> fidl::Result<()> {
2169            decoder.debug_check_bounds::<Self>(offset);
2170            #[allow(unused_variables)]
2171            let next_out_of_line = decoder.next_out_of_line();
2172            let handles_before = decoder.remaining_handles();
2173            let (ordinal, inlined, num_bytes, num_handles) =
2174                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2175
2176            let member_inline_size = match ordinal {
2177                1 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2178                2 => <NonPrintableKey as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2179                _ => return Err(fidl::Error::UnknownUnionTag),
2180            };
2181
2182            if inlined != (member_inline_size <= 4) {
2183                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2184            }
2185            let _inner_offset;
2186            if inlined {
2187                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2188                _inner_offset = offset + 8;
2189            } else {
2190                depth.increment()?;
2191                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2192            }
2193            match ordinal {
2194                1 => {
2195                    #[allow(irrefutable_let_patterns)]
2196                    if let KeyMeaning::Codepoint(_) = self {
2197                        // Do nothing, read the value into the object
2198                    } else {
2199                        // Initialize `self` to the right variant
2200                        *self = KeyMeaning::Codepoint(fidl::new_empty!(u32, D));
2201                    }
2202                    #[allow(irrefutable_let_patterns)]
2203                    if let KeyMeaning::Codepoint(ref mut val) = self {
2204                        fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
2205                    } else {
2206                        unreachable!()
2207                    }
2208                }
2209                2 => {
2210                    #[allow(irrefutable_let_patterns)]
2211                    if let KeyMeaning::NonPrintableKey(_) = self {
2212                        // Do nothing, read the value into the object
2213                    } else {
2214                        // Initialize `self` to the right variant
2215                        *self = KeyMeaning::NonPrintableKey(fidl::new_empty!(NonPrintableKey, D));
2216                    }
2217                    #[allow(irrefutable_let_patterns)]
2218                    if let KeyMeaning::NonPrintableKey(ref mut val) = self {
2219                        fidl::decode!(NonPrintableKey, D, val, decoder, _inner_offset, depth)?;
2220                    } else {
2221                        unreachable!()
2222                    }
2223                }
2224                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2225            }
2226            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2227                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2228            }
2229            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2230                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2231            }
2232            Ok(())
2233        }
2234    }
2235}