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::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
781mod internal {
782    use super::*;
783    unsafe impl fidl::encoding::TypeMarker for LockState {
784        type Owned = Self;
785
786        #[inline(always)]
787        fn inline_align(_context: fidl::encoding::Context) -> usize {
788            8
789        }
790
791        #[inline(always)]
792        fn inline_size(_context: fidl::encoding::Context) -> usize {
793            8
794        }
795    }
796
797    impl fidl::encoding::ValueTypeMarker for LockState {
798        type Borrowed<'a> = Self;
799        #[inline(always)]
800        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
801            *value
802        }
803    }
804
805    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LockState {
806        #[inline]
807        unsafe fn encode(
808            self,
809            encoder: &mut fidl::encoding::Encoder<'_, D>,
810            offset: usize,
811            _depth: fidl::encoding::Depth,
812        ) -> fidl::Result<()> {
813            encoder.debug_check_bounds::<Self>(offset);
814            encoder.write_num(self.bits(), offset);
815            Ok(())
816        }
817    }
818
819    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LockState {
820        #[inline(always)]
821        fn new_empty() -> Self {
822            Self::empty()
823        }
824
825        #[inline]
826        unsafe fn decode(
827            &mut self,
828            decoder: &mut fidl::encoding::Decoder<'_, D>,
829            offset: usize,
830            _depth: fidl::encoding::Depth,
831        ) -> fidl::Result<()> {
832            decoder.debug_check_bounds::<Self>(offset);
833            let prim = decoder.read_num::<u64>(offset);
834            *self = Self::from_bits_allow_unknown(prim);
835            Ok(())
836        }
837    }
838    unsafe impl fidl::encoding::TypeMarker for Modifiers {
839        type Owned = Self;
840
841        #[inline(always)]
842        fn inline_align(_context: fidl::encoding::Context) -> usize {
843            8
844        }
845
846        #[inline(always)]
847        fn inline_size(_context: fidl::encoding::Context) -> usize {
848            8
849        }
850    }
851
852    impl fidl::encoding::ValueTypeMarker for Modifiers {
853        type Borrowed<'a> = Self;
854        #[inline(always)]
855        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
856            *value
857        }
858    }
859
860    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Modifiers {
861        #[inline]
862        unsafe fn encode(
863            self,
864            encoder: &mut fidl::encoding::Encoder<'_, D>,
865            offset: usize,
866            _depth: fidl::encoding::Depth,
867        ) -> fidl::Result<()> {
868            encoder.debug_check_bounds::<Self>(offset);
869            encoder.write_num(self.bits(), offset);
870            Ok(())
871        }
872    }
873
874    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Modifiers {
875        #[inline(always)]
876        fn new_empty() -> Self {
877            Self::empty()
878        }
879
880        #[inline]
881        unsafe fn decode(
882            &mut self,
883            decoder: &mut fidl::encoding::Decoder<'_, D>,
884            offset: usize,
885            _depth: fidl::encoding::Depth,
886        ) -> fidl::Result<()> {
887            decoder.debug_check_bounds::<Self>(offset);
888            let prim = decoder.read_num::<u64>(offset);
889            *self = Self::from_bits_allow_unknown(prim);
890            Ok(())
891        }
892    }
893    unsafe impl fidl::encoding::TypeMarker for KeyEventStatus {
894        type Owned = Self;
895
896        #[inline(always)]
897        fn inline_align(_context: fidl::encoding::Context) -> usize {
898            std::mem::align_of::<u32>()
899        }
900
901        #[inline(always)]
902        fn inline_size(_context: fidl::encoding::Context) -> usize {
903            std::mem::size_of::<u32>()
904        }
905
906        #[inline(always)]
907        fn encode_is_copy() -> bool {
908            true
909        }
910
911        #[inline(always)]
912        fn decode_is_copy() -> bool {
913            false
914        }
915    }
916
917    impl fidl::encoding::ValueTypeMarker for KeyEventStatus {
918        type Borrowed<'a> = Self;
919        #[inline(always)]
920        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
921            *value
922        }
923    }
924
925    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for KeyEventStatus {
926        #[inline]
927        unsafe fn encode(
928            self,
929            encoder: &mut fidl::encoding::Encoder<'_, D>,
930            offset: usize,
931            _depth: fidl::encoding::Depth,
932        ) -> fidl::Result<()> {
933            encoder.debug_check_bounds::<Self>(offset);
934            encoder.write_num(self.into_primitive(), offset);
935            Ok(())
936        }
937    }
938
939    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEventStatus {
940        #[inline(always)]
941        fn new_empty() -> Self {
942            Self::Handled
943        }
944
945        #[inline]
946        unsafe fn decode(
947            &mut self,
948            decoder: &mut fidl::encoding::Decoder<'_, D>,
949            offset: usize,
950            _depth: fidl::encoding::Depth,
951        ) -> fidl::Result<()> {
952            decoder.debug_check_bounds::<Self>(offset);
953            let prim = decoder.read_num::<u32>(offset);
954
955            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
956            Ok(())
957        }
958    }
959    unsafe impl fidl::encoding::TypeMarker for KeyEventType {
960        type Owned = Self;
961
962        #[inline(always)]
963        fn inline_align(_context: fidl::encoding::Context) -> usize {
964            std::mem::align_of::<u32>()
965        }
966
967        #[inline(always)]
968        fn inline_size(_context: fidl::encoding::Context) -> usize {
969            std::mem::size_of::<u32>()
970        }
971
972        #[inline(always)]
973        fn encode_is_copy() -> bool {
974            true
975        }
976
977        #[inline(always)]
978        fn decode_is_copy() -> bool {
979            false
980        }
981    }
982
983    impl fidl::encoding::ValueTypeMarker for KeyEventType {
984        type Borrowed<'a> = Self;
985        #[inline(always)]
986        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
987            *value
988        }
989    }
990
991    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for KeyEventType {
992        #[inline]
993        unsafe fn encode(
994            self,
995            encoder: &mut fidl::encoding::Encoder<'_, D>,
996            offset: usize,
997            _depth: fidl::encoding::Depth,
998        ) -> fidl::Result<()> {
999            encoder.debug_check_bounds::<Self>(offset);
1000            encoder.write_num(self.into_primitive(), offset);
1001            Ok(())
1002        }
1003    }
1004
1005    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEventType {
1006        #[inline(always)]
1007        fn new_empty() -> Self {
1008            Self::Pressed
1009        }
1010
1011        #[inline]
1012        unsafe fn decode(
1013            &mut self,
1014            decoder: &mut fidl::encoding::Decoder<'_, D>,
1015            offset: usize,
1016            _depth: fidl::encoding::Depth,
1017        ) -> fidl::Result<()> {
1018            decoder.debug_check_bounds::<Self>(offset);
1019            let prim = decoder.read_num::<u32>(offset);
1020
1021            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1022            Ok(())
1023        }
1024    }
1025    unsafe impl fidl::encoding::TypeMarker for NonPrintableKey {
1026        type Owned = Self;
1027
1028        #[inline(always)]
1029        fn inline_align(_context: fidl::encoding::Context) -> usize {
1030            std::mem::align_of::<u32>()
1031        }
1032
1033        #[inline(always)]
1034        fn inline_size(_context: fidl::encoding::Context) -> usize {
1035            std::mem::size_of::<u32>()
1036        }
1037
1038        #[inline(always)]
1039        fn encode_is_copy() -> bool {
1040            false
1041        }
1042
1043        #[inline(always)]
1044        fn decode_is_copy() -> bool {
1045            false
1046        }
1047    }
1048
1049    impl fidl::encoding::ValueTypeMarker for NonPrintableKey {
1050        type Borrowed<'a> = Self;
1051        #[inline(always)]
1052        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1053            *value
1054        }
1055    }
1056
1057    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
1058        for NonPrintableKey
1059    {
1060        #[inline]
1061        unsafe fn encode(
1062            self,
1063            encoder: &mut fidl::encoding::Encoder<'_, D>,
1064            offset: usize,
1065            _depth: fidl::encoding::Depth,
1066        ) -> fidl::Result<()> {
1067            encoder.debug_check_bounds::<Self>(offset);
1068            encoder.write_num(self.into_primitive(), offset);
1069            Ok(())
1070        }
1071    }
1072
1073    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NonPrintableKey {
1074        #[inline(always)]
1075        fn new_empty() -> Self {
1076            Self::unknown()
1077        }
1078
1079        #[inline]
1080        unsafe fn decode(
1081            &mut self,
1082            decoder: &mut fidl::encoding::Decoder<'_, D>,
1083            offset: usize,
1084            _depth: fidl::encoding::Depth,
1085        ) -> fidl::Result<()> {
1086            decoder.debug_check_bounds::<Self>(offset);
1087            let prim = decoder.read_num::<u32>(offset);
1088
1089            *self = Self::from_primitive_allow_unknown(prim);
1090            Ok(())
1091        }
1092    }
1093
1094    impl fidl::encoding::ValueTypeMarker for KeyEventInjectorInjectRequest {
1095        type Borrowed<'a> = &'a Self;
1096        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1097            value
1098        }
1099    }
1100
1101    unsafe impl fidl::encoding::TypeMarker for KeyEventInjectorInjectRequest {
1102        type Owned = Self;
1103
1104        #[inline(always)]
1105        fn inline_align(_context: fidl::encoding::Context) -> usize {
1106            8
1107        }
1108
1109        #[inline(always)]
1110        fn inline_size(_context: fidl::encoding::Context) -> usize {
1111            16
1112        }
1113    }
1114
1115    unsafe impl<D: fidl::encoding::ResourceDialect>
1116        fidl::encoding::Encode<KeyEventInjectorInjectRequest, D>
1117        for &KeyEventInjectorInjectRequest
1118    {
1119        #[inline]
1120        unsafe fn encode(
1121            self,
1122            encoder: &mut fidl::encoding::Encoder<'_, D>,
1123            offset: usize,
1124            _depth: fidl::encoding::Depth,
1125        ) -> fidl::Result<()> {
1126            encoder.debug_check_bounds::<KeyEventInjectorInjectRequest>(offset);
1127            // Delegate to tuple encoding.
1128            fidl::encoding::Encode::<KeyEventInjectorInjectRequest, D>::encode(
1129                (<KeyEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.key_event),),
1130                encoder,
1131                offset,
1132                _depth,
1133            )
1134        }
1135    }
1136    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEvent, D>>
1137        fidl::encoding::Encode<KeyEventInjectorInjectRequest, D> for (T0,)
1138    {
1139        #[inline]
1140        unsafe fn encode(
1141            self,
1142            encoder: &mut fidl::encoding::Encoder<'_, D>,
1143            offset: usize,
1144            depth: fidl::encoding::Depth,
1145        ) -> fidl::Result<()> {
1146            encoder.debug_check_bounds::<KeyEventInjectorInjectRequest>(offset);
1147            // Zero out padding regions. There's no need to apply masks
1148            // because the unmasked parts will be overwritten by fields.
1149            // Write the fields.
1150            self.0.encode(encoder, offset + 0, depth)?;
1151            Ok(())
1152        }
1153    }
1154
1155    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1156        for KeyEventInjectorInjectRequest
1157    {
1158        #[inline(always)]
1159        fn new_empty() -> Self {
1160            Self { key_event: fidl::new_empty!(KeyEvent, D) }
1161        }
1162
1163        #[inline]
1164        unsafe fn decode(
1165            &mut self,
1166            decoder: &mut fidl::encoding::Decoder<'_, D>,
1167            offset: usize,
1168            _depth: fidl::encoding::Depth,
1169        ) -> fidl::Result<()> {
1170            decoder.debug_check_bounds::<Self>(offset);
1171            // Verify that padding bytes are zero.
1172            fidl::decode!(KeyEvent, D, &mut self.key_event, decoder, offset + 0, _depth)?;
1173            Ok(())
1174        }
1175    }
1176
1177    impl fidl::encoding::ValueTypeMarker for KeyEventInjectorInjectResponse {
1178        type Borrowed<'a> = &'a Self;
1179        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1180            value
1181        }
1182    }
1183
1184    unsafe impl fidl::encoding::TypeMarker for KeyEventInjectorInjectResponse {
1185        type Owned = Self;
1186
1187        #[inline(always)]
1188        fn inline_align(_context: fidl::encoding::Context) -> usize {
1189            4
1190        }
1191
1192        #[inline(always)]
1193        fn inline_size(_context: fidl::encoding::Context) -> usize {
1194            4
1195        }
1196    }
1197
1198    unsafe impl<D: fidl::encoding::ResourceDialect>
1199        fidl::encoding::Encode<KeyEventInjectorInjectResponse, D>
1200        for &KeyEventInjectorInjectResponse
1201    {
1202        #[inline]
1203        unsafe fn encode(
1204            self,
1205            encoder: &mut fidl::encoding::Encoder<'_, D>,
1206            offset: usize,
1207            _depth: fidl::encoding::Depth,
1208        ) -> fidl::Result<()> {
1209            encoder.debug_check_bounds::<KeyEventInjectorInjectResponse>(offset);
1210            // Delegate to tuple encoding.
1211            fidl::encoding::Encode::<KeyEventInjectorInjectResponse, D>::encode(
1212                (<KeyEventStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
1213                encoder,
1214                offset,
1215                _depth,
1216            )
1217        }
1218    }
1219    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEventStatus, D>>
1220        fidl::encoding::Encode<KeyEventInjectorInjectResponse, D> for (T0,)
1221    {
1222        #[inline]
1223        unsafe fn encode(
1224            self,
1225            encoder: &mut fidl::encoding::Encoder<'_, D>,
1226            offset: usize,
1227            depth: fidl::encoding::Depth,
1228        ) -> fidl::Result<()> {
1229            encoder.debug_check_bounds::<KeyEventInjectorInjectResponse>(offset);
1230            // Zero out padding regions. There's no need to apply masks
1231            // because the unmasked parts will be overwritten by fields.
1232            // Write the fields.
1233            self.0.encode(encoder, offset + 0, depth)?;
1234            Ok(())
1235        }
1236    }
1237
1238    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1239        for KeyEventInjectorInjectResponse
1240    {
1241        #[inline(always)]
1242        fn new_empty() -> Self {
1243            Self { status: fidl::new_empty!(KeyEventStatus, D) }
1244        }
1245
1246        #[inline]
1247        unsafe fn decode(
1248            &mut self,
1249            decoder: &mut fidl::encoding::Decoder<'_, D>,
1250            offset: usize,
1251            _depth: fidl::encoding::Depth,
1252        ) -> fidl::Result<()> {
1253            decoder.debug_check_bounds::<Self>(offset);
1254            // Verify that padding bytes are zero.
1255            fidl::decode!(KeyEventStatus, D, &mut self.status, decoder, offset + 0, _depth)?;
1256            Ok(())
1257        }
1258    }
1259
1260    impl fidl::encoding::ValueTypeMarker for KeyboardListenerOnKeyEventRequest {
1261        type Borrowed<'a> = &'a Self;
1262        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1263            value
1264        }
1265    }
1266
1267    unsafe impl fidl::encoding::TypeMarker for KeyboardListenerOnKeyEventRequest {
1268        type Owned = Self;
1269
1270        #[inline(always)]
1271        fn inline_align(_context: fidl::encoding::Context) -> usize {
1272            8
1273        }
1274
1275        #[inline(always)]
1276        fn inline_size(_context: fidl::encoding::Context) -> usize {
1277            16
1278        }
1279    }
1280
1281    unsafe impl<D: fidl::encoding::ResourceDialect>
1282        fidl::encoding::Encode<KeyboardListenerOnKeyEventRequest, D>
1283        for &KeyboardListenerOnKeyEventRequest
1284    {
1285        #[inline]
1286        unsafe fn encode(
1287            self,
1288            encoder: &mut fidl::encoding::Encoder<'_, D>,
1289            offset: usize,
1290            _depth: fidl::encoding::Depth,
1291        ) -> fidl::Result<()> {
1292            encoder.debug_check_bounds::<KeyboardListenerOnKeyEventRequest>(offset);
1293            // Delegate to tuple encoding.
1294            fidl::encoding::Encode::<KeyboardListenerOnKeyEventRequest, D>::encode(
1295                (<KeyEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.event),),
1296                encoder,
1297                offset,
1298                _depth,
1299            )
1300        }
1301    }
1302    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEvent, D>>
1303        fidl::encoding::Encode<KeyboardListenerOnKeyEventRequest, D> for (T0,)
1304    {
1305        #[inline]
1306        unsafe fn encode(
1307            self,
1308            encoder: &mut fidl::encoding::Encoder<'_, D>,
1309            offset: usize,
1310            depth: fidl::encoding::Depth,
1311        ) -> fidl::Result<()> {
1312            encoder.debug_check_bounds::<KeyboardListenerOnKeyEventRequest>(offset);
1313            // Zero out padding regions. There's no need to apply masks
1314            // because the unmasked parts will be overwritten by fields.
1315            // Write the fields.
1316            self.0.encode(encoder, offset + 0, depth)?;
1317            Ok(())
1318        }
1319    }
1320
1321    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1322        for KeyboardListenerOnKeyEventRequest
1323    {
1324        #[inline(always)]
1325        fn new_empty() -> Self {
1326            Self { event: fidl::new_empty!(KeyEvent, D) }
1327        }
1328
1329        #[inline]
1330        unsafe fn decode(
1331            &mut self,
1332            decoder: &mut fidl::encoding::Decoder<'_, D>,
1333            offset: usize,
1334            _depth: fidl::encoding::Depth,
1335        ) -> fidl::Result<()> {
1336            decoder.debug_check_bounds::<Self>(offset);
1337            // Verify that padding bytes are zero.
1338            fidl::decode!(KeyEvent, D, &mut self.event, decoder, offset + 0, _depth)?;
1339            Ok(())
1340        }
1341    }
1342
1343    impl fidl::encoding::ValueTypeMarker for KeyboardListenerOnKeyEventResponse {
1344        type Borrowed<'a> = &'a Self;
1345        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1346            value
1347        }
1348    }
1349
1350    unsafe impl fidl::encoding::TypeMarker for KeyboardListenerOnKeyEventResponse {
1351        type Owned = Self;
1352
1353        #[inline(always)]
1354        fn inline_align(_context: fidl::encoding::Context) -> usize {
1355            4
1356        }
1357
1358        #[inline(always)]
1359        fn inline_size(_context: fidl::encoding::Context) -> usize {
1360            4
1361        }
1362    }
1363
1364    unsafe impl<D: fidl::encoding::ResourceDialect>
1365        fidl::encoding::Encode<KeyboardListenerOnKeyEventResponse, D>
1366        for &KeyboardListenerOnKeyEventResponse
1367    {
1368        #[inline]
1369        unsafe fn encode(
1370            self,
1371            encoder: &mut fidl::encoding::Encoder<'_, D>,
1372            offset: usize,
1373            _depth: fidl::encoding::Depth,
1374        ) -> fidl::Result<()> {
1375            encoder.debug_check_bounds::<KeyboardListenerOnKeyEventResponse>(offset);
1376            // Delegate to tuple encoding.
1377            fidl::encoding::Encode::<KeyboardListenerOnKeyEventResponse, D>::encode(
1378                (<KeyEventStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
1379                encoder,
1380                offset,
1381                _depth,
1382            )
1383        }
1384    }
1385    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<KeyEventStatus, D>>
1386        fidl::encoding::Encode<KeyboardListenerOnKeyEventResponse, D> for (T0,)
1387    {
1388        #[inline]
1389        unsafe fn encode(
1390            self,
1391            encoder: &mut fidl::encoding::Encoder<'_, D>,
1392            offset: usize,
1393            depth: fidl::encoding::Depth,
1394        ) -> fidl::Result<()> {
1395            encoder.debug_check_bounds::<KeyboardListenerOnKeyEventResponse>(offset);
1396            // Zero out padding regions. There's no need to apply masks
1397            // because the unmasked parts will be overwritten by fields.
1398            // Write the fields.
1399            self.0.encode(encoder, offset + 0, depth)?;
1400            Ok(())
1401        }
1402    }
1403
1404    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1405        for KeyboardListenerOnKeyEventResponse
1406    {
1407        #[inline(always)]
1408        fn new_empty() -> Self {
1409            Self { status: fidl::new_empty!(KeyEventStatus, D) }
1410        }
1411
1412        #[inline]
1413        unsafe fn decode(
1414            &mut self,
1415            decoder: &mut fidl::encoding::Decoder<'_, D>,
1416            offset: usize,
1417            _depth: fidl::encoding::Depth,
1418        ) -> fidl::Result<()> {
1419            decoder.debug_check_bounds::<Self>(offset);
1420            // Verify that padding bytes are zero.
1421            fidl::decode!(KeyEventStatus, D, &mut self.status, decoder, offset + 0, _depth)?;
1422            Ok(())
1423        }
1424    }
1425
1426    impl KeyEvent {
1427        #[inline(always)]
1428        fn max_ordinal_present(&self) -> u64 {
1429            if let Some(_) = self.device_id {
1430                return 8;
1431            }
1432            if let Some(_) = self.lock_state {
1433                return 7;
1434            }
1435            if let Some(_) = self.repeat_sequence {
1436                return 6;
1437            }
1438            if let Some(_) = self.key_meaning {
1439                return 5;
1440            }
1441            if let Some(_) = self.modifiers {
1442                return 4;
1443            }
1444            if let Some(_) = self.key {
1445                return 3;
1446            }
1447            if let Some(_) = self.type_ {
1448                return 2;
1449            }
1450            if let Some(_) = self.timestamp {
1451                return 1;
1452            }
1453            0
1454        }
1455    }
1456
1457    impl fidl::encoding::ValueTypeMarker for KeyEvent {
1458        type Borrowed<'a> = &'a Self;
1459        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1460            value
1461        }
1462    }
1463
1464    unsafe impl fidl::encoding::TypeMarker for KeyEvent {
1465        type Owned = Self;
1466
1467        #[inline(always)]
1468        fn inline_align(_context: fidl::encoding::Context) -> usize {
1469            8
1470        }
1471
1472        #[inline(always)]
1473        fn inline_size(_context: fidl::encoding::Context) -> usize {
1474            16
1475        }
1476    }
1477
1478    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<KeyEvent, D> for &KeyEvent {
1479        unsafe fn encode(
1480            self,
1481            encoder: &mut fidl::encoding::Encoder<'_, D>,
1482            offset: usize,
1483            mut depth: fidl::encoding::Depth,
1484        ) -> fidl::Result<()> {
1485            encoder.debug_check_bounds::<KeyEvent>(offset);
1486            // Vector header
1487            let max_ordinal: u64 = self.max_ordinal_present();
1488            encoder.write_num(max_ordinal, offset);
1489            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1490            // Calling encoder.out_of_line_offset(0) is not allowed.
1491            if max_ordinal == 0 {
1492                return Ok(());
1493            }
1494            depth.increment()?;
1495            let envelope_size = 8;
1496            let bytes_len = max_ordinal as usize * envelope_size;
1497            #[allow(unused_variables)]
1498            let offset = encoder.out_of_line_offset(bytes_len);
1499            let mut _prev_end_offset: usize = 0;
1500            if 1 > max_ordinal {
1501                return Ok(());
1502            }
1503
1504            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1505            // are envelope_size bytes.
1506            let cur_offset: usize = (1 - 1) * envelope_size;
1507
1508            // Zero reserved fields.
1509            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1510
1511            // Safety:
1512            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1513            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1514            //   envelope_size bytes, there is always sufficient room.
1515            fidl::encoding::encode_in_envelope_optional::<i64, D>(
1516                self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
1517                encoder,
1518                offset + cur_offset,
1519                depth,
1520            )?;
1521
1522            _prev_end_offset = cur_offset + envelope_size;
1523            if 2 > max_ordinal {
1524                return Ok(());
1525            }
1526
1527            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1528            // are envelope_size bytes.
1529            let cur_offset: usize = (2 - 1) * envelope_size;
1530
1531            // Zero reserved fields.
1532            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1533
1534            // Safety:
1535            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1536            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1537            //   envelope_size bytes, there is always sufficient room.
1538            fidl::encoding::encode_in_envelope_optional::<KeyEventType, D>(
1539                self.type_.as_ref().map(<KeyEventType as fidl::encoding::ValueTypeMarker>::borrow),
1540                encoder,
1541                offset + cur_offset,
1542                depth,
1543            )?;
1544
1545            _prev_end_offset = cur_offset + envelope_size;
1546            if 3 > max_ordinal {
1547                return Ok(());
1548            }
1549
1550            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1551            // are envelope_size bytes.
1552            let cur_offset: usize = (3 - 1) * envelope_size;
1553
1554            // Zero reserved fields.
1555            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1556
1557            // Safety:
1558            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1559            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1560            //   envelope_size bytes, there is always sufficient room.
1561            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_input::Key, D>(
1562                self.key
1563                    .as_ref()
1564                    .map(<fidl_fuchsia_input::Key as fidl::encoding::ValueTypeMarker>::borrow),
1565                encoder,
1566                offset + cur_offset,
1567                depth,
1568            )?;
1569
1570            _prev_end_offset = cur_offset + envelope_size;
1571            if 4 > max_ordinal {
1572                return Ok(());
1573            }
1574
1575            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1576            // are envelope_size bytes.
1577            let cur_offset: usize = (4 - 1) * envelope_size;
1578
1579            // Zero reserved fields.
1580            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1581
1582            // Safety:
1583            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1584            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1585            //   envelope_size bytes, there is always sufficient room.
1586            fidl::encoding::encode_in_envelope_optional::<Modifiers, D>(
1587                self.modifiers.as_ref().map(<Modifiers as fidl::encoding::ValueTypeMarker>::borrow),
1588                encoder,
1589                offset + cur_offset,
1590                depth,
1591            )?;
1592
1593            _prev_end_offset = cur_offset + envelope_size;
1594            if 5 > max_ordinal {
1595                return Ok(());
1596            }
1597
1598            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1599            // are envelope_size bytes.
1600            let cur_offset: usize = (5 - 1) * envelope_size;
1601
1602            // Zero reserved fields.
1603            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1604
1605            // Safety:
1606            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1607            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1608            //   envelope_size bytes, there is always sufficient room.
1609            fidl::encoding::encode_in_envelope_optional::<KeyMeaning, D>(
1610                self.key_meaning
1611                    .as_ref()
1612                    .map(<KeyMeaning as fidl::encoding::ValueTypeMarker>::borrow),
1613                encoder,
1614                offset + cur_offset,
1615                depth,
1616            )?;
1617
1618            _prev_end_offset = cur_offset + envelope_size;
1619            if 6 > max_ordinal {
1620                return Ok(());
1621            }
1622
1623            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1624            // are envelope_size bytes.
1625            let cur_offset: usize = (6 - 1) * envelope_size;
1626
1627            // Zero reserved fields.
1628            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1629
1630            // Safety:
1631            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1632            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1633            //   envelope_size bytes, there is always sufficient room.
1634            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1635                self.repeat_sequence.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1636                encoder,
1637                offset + cur_offset,
1638                depth,
1639            )?;
1640
1641            _prev_end_offset = cur_offset + envelope_size;
1642            if 7 > max_ordinal {
1643                return Ok(());
1644            }
1645
1646            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1647            // are envelope_size bytes.
1648            let cur_offset: usize = (7 - 1) * envelope_size;
1649
1650            // Zero reserved fields.
1651            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1652
1653            // Safety:
1654            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1655            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1656            //   envelope_size bytes, there is always sufficient room.
1657            fidl::encoding::encode_in_envelope_optional::<LockState, D>(
1658                self.lock_state
1659                    .as_ref()
1660                    .map(<LockState as fidl::encoding::ValueTypeMarker>::borrow),
1661                encoder,
1662                offset + cur_offset,
1663                depth,
1664            )?;
1665
1666            _prev_end_offset = cur_offset + envelope_size;
1667            if 8 > max_ordinal {
1668                return Ok(());
1669            }
1670
1671            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1672            // are envelope_size bytes.
1673            let cur_offset: usize = (8 - 1) * envelope_size;
1674
1675            // Zero reserved fields.
1676            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1677
1678            // Safety:
1679            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1680            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1681            //   envelope_size bytes, there is always sufficient room.
1682            fidl::encoding::encode_in_envelope_optional::<u32, D>(
1683                self.device_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1684                encoder,
1685                offset + cur_offset,
1686                depth,
1687            )?;
1688
1689            _prev_end_offset = cur_offset + envelope_size;
1690
1691            Ok(())
1692        }
1693    }
1694
1695    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyEvent {
1696        #[inline(always)]
1697        fn new_empty() -> Self {
1698            Self::default()
1699        }
1700
1701        unsafe fn decode(
1702            &mut self,
1703            decoder: &mut fidl::encoding::Decoder<'_, D>,
1704            offset: usize,
1705            mut depth: fidl::encoding::Depth,
1706        ) -> fidl::Result<()> {
1707            decoder.debug_check_bounds::<Self>(offset);
1708            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1709                None => return Err(fidl::Error::NotNullable),
1710                Some(len) => len,
1711            };
1712            // Calling decoder.out_of_line_offset(0) is not allowed.
1713            if len == 0 {
1714                return Ok(());
1715            };
1716            depth.increment()?;
1717            let envelope_size = 8;
1718            let bytes_len = len * envelope_size;
1719            let offset = decoder.out_of_line_offset(bytes_len)?;
1720            // Decode the envelope for each type.
1721            let mut _next_ordinal_to_read = 0;
1722            let mut next_offset = offset;
1723            let end_offset = offset + bytes_len;
1724            _next_ordinal_to_read += 1;
1725            if next_offset >= end_offset {
1726                return Ok(());
1727            }
1728
1729            // Decode unknown envelopes for gaps in ordinals.
1730            while _next_ordinal_to_read < 1 {
1731                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1732                _next_ordinal_to_read += 1;
1733                next_offset += envelope_size;
1734            }
1735
1736            let next_out_of_line = decoder.next_out_of_line();
1737            let handles_before = decoder.remaining_handles();
1738            if let Some((inlined, num_bytes, num_handles)) =
1739                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1740            {
1741                let member_inline_size =
1742                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1743                if inlined != (member_inline_size <= 4) {
1744                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1745                }
1746                let inner_offset;
1747                let mut inner_depth = depth.clone();
1748                if inlined {
1749                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1750                    inner_offset = next_offset;
1751                } else {
1752                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1753                    inner_depth.increment()?;
1754                }
1755                let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
1756                fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
1757                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1758                {
1759                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1760                }
1761                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1762                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1763                }
1764            }
1765
1766            next_offset += envelope_size;
1767            _next_ordinal_to_read += 1;
1768            if next_offset >= end_offset {
1769                return Ok(());
1770            }
1771
1772            // Decode unknown envelopes for gaps in ordinals.
1773            while _next_ordinal_to_read < 2 {
1774                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1775                _next_ordinal_to_read += 1;
1776                next_offset += envelope_size;
1777            }
1778
1779            let next_out_of_line = decoder.next_out_of_line();
1780            let handles_before = decoder.remaining_handles();
1781            if let Some((inlined, num_bytes, num_handles)) =
1782                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1783            {
1784                let member_inline_size =
1785                    <KeyEventType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1786                if inlined != (member_inline_size <= 4) {
1787                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1788                }
1789                let inner_offset;
1790                let mut inner_depth = depth.clone();
1791                if inlined {
1792                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1793                    inner_offset = next_offset;
1794                } else {
1795                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1796                    inner_depth.increment()?;
1797                }
1798                let val_ref = self.type_.get_or_insert_with(|| fidl::new_empty!(KeyEventType, D));
1799                fidl::decode!(KeyEventType, D, val_ref, decoder, inner_offset, inner_depth)?;
1800                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1801                {
1802                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1803                }
1804                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1805                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1806                }
1807            }
1808
1809            next_offset += envelope_size;
1810            _next_ordinal_to_read += 1;
1811            if next_offset >= end_offset {
1812                return Ok(());
1813            }
1814
1815            // Decode unknown envelopes for gaps in ordinals.
1816            while _next_ordinal_to_read < 3 {
1817                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1818                _next_ordinal_to_read += 1;
1819                next_offset += envelope_size;
1820            }
1821
1822            let next_out_of_line = decoder.next_out_of_line();
1823            let handles_before = decoder.remaining_handles();
1824            if let Some((inlined, num_bytes, num_handles)) =
1825                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1826            {
1827                let member_inline_size =
1828                    <fidl_fuchsia_input::Key as fidl::encoding::TypeMarker>::inline_size(
1829                        decoder.context,
1830                    );
1831                if inlined != (member_inline_size <= 4) {
1832                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1833                }
1834                let inner_offset;
1835                let mut inner_depth = depth.clone();
1836                if inlined {
1837                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1838                    inner_offset = next_offset;
1839                } else {
1840                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1841                    inner_depth.increment()?;
1842                }
1843                let val_ref =
1844                    self.key.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_input::Key, D));
1845                fidl::decode!(
1846                    fidl_fuchsia_input::Key,
1847                    D,
1848                    val_ref,
1849                    decoder,
1850                    inner_offset,
1851                    inner_depth
1852                )?;
1853                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1854                {
1855                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1856                }
1857                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1858                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1859                }
1860            }
1861
1862            next_offset += envelope_size;
1863            _next_ordinal_to_read += 1;
1864            if next_offset >= end_offset {
1865                return Ok(());
1866            }
1867
1868            // Decode unknown envelopes for gaps in ordinals.
1869            while _next_ordinal_to_read < 4 {
1870                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1871                _next_ordinal_to_read += 1;
1872                next_offset += envelope_size;
1873            }
1874
1875            let next_out_of_line = decoder.next_out_of_line();
1876            let handles_before = decoder.remaining_handles();
1877            if let Some((inlined, num_bytes, num_handles)) =
1878                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1879            {
1880                let member_inline_size =
1881                    <Modifiers as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1882                if inlined != (member_inline_size <= 4) {
1883                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1884                }
1885                let inner_offset;
1886                let mut inner_depth = depth.clone();
1887                if inlined {
1888                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1889                    inner_offset = next_offset;
1890                } else {
1891                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1892                    inner_depth.increment()?;
1893                }
1894                let val_ref = self.modifiers.get_or_insert_with(|| fidl::new_empty!(Modifiers, D));
1895                fidl::decode!(Modifiers, D, val_ref, decoder, inner_offset, inner_depth)?;
1896                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1897                {
1898                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1899                }
1900                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1901                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1902                }
1903            }
1904
1905            next_offset += envelope_size;
1906            _next_ordinal_to_read += 1;
1907            if next_offset >= end_offset {
1908                return Ok(());
1909            }
1910
1911            // Decode unknown envelopes for gaps in ordinals.
1912            while _next_ordinal_to_read < 5 {
1913                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1914                _next_ordinal_to_read += 1;
1915                next_offset += envelope_size;
1916            }
1917
1918            let next_out_of_line = decoder.next_out_of_line();
1919            let handles_before = decoder.remaining_handles();
1920            if let Some((inlined, num_bytes, num_handles)) =
1921                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1922            {
1923                let member_inline_size =
1924                    <KeyMeaning as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1925                if inlined != (member_inline_size <= 4) {
1926                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1927                }
1928                let inner_offset;
1929                let mut inner_depth = depth.clone();
1930                if inlined {
1931                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1932                    inner_offset = next_offset;
1933                } else {
1934                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1935                    inner_depth.increment()?;
1936                }
1937                let val_ref =
1938                    self.key_meaning.get_or_insert_with(|| fidl::new_empty!(KeyMeaning, D));
1939                fidl::decode!(KeyMeaning, D, val_ref, decoder, inner_offset, inner_depth)?;
1940                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1941                {
1942                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1943                }
1944                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1945                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1946                }
1947            }
1948
1949            next_offset += envelope_size;
1950            _next_ordinal_to_read += 1;
1951            if next_offset >= end_offset {
1952                return Ok(());
1953            }
1954
1955            // Decode unknown envelopes for gaps in ordinals.
1956            while _next_ordinal_to_read < 6 {
1957                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1958                _next_ordinal_to_read += 1;
1959                next_offset += envelope_size;
1960            }
1961
1962            let next_out_of_line = decoder.next_out_of_line();
1963            let handles_before = decoder.remaining_handles();
1964            if let Some((inlined, num_bytes, num_handles)) =
1965                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1966            {
1967                let member_inline_size =
1968                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1969                if inlined != (member_inline_size <= 4) {
1970                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1971                }
1972                let inner_offset;
1973                let mut inner_depth = depth.clone();
1974                if inlined {
1975                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1976                    inner_offset = next_offset;
1977                } else {
1978                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1979                    inner_depth.increment()?;
1980                }
1981                let val_ref = self.repeat_sequence.get_or_insert_with(|| fidl::new_empty!(u32, D));
1982                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
1983                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1984                {
1985                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1986                }
1987                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1988                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1989                }
1990            }
1991
1992            next_offset += envelope_size;
1993            _next_ordinal_to_read += 1;
1994            if next_offset >= end_offset {
1995                return Ok(());
1996            }
1997
1998            // Decode unknown envelopes for gaps in ordinals.
1999            while _next_ordinal_to_read < 7 {
2000                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2001                _next_ordinal_to_read += 1;
2002                next_offset += envelope_size;
2003            }
2004
2005            let next_out_of_line = decoder.next_out_of_line();
2006            let handles_before = decoder.remaining_handles();
2007            if let Some((inlined, num_bytes, num_handles)) =
2008                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2009            {
2010                let member_inline_size =
2011                    <LockState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2012                if inlined != (member_inline_size <= 4) {
2013                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2014                }
2015                let inner_offset;
2016                let mut inner_depth = depth.clone();
2017                if inlined {
2018                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2019                    inner_offset = next_offset;
2020                } else {
2021                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2022                    inner_depth.increment()?;
2023                }
2024                let val_ref = self.lock_state.get_or_insert_with(|| fidl::new_empty!(LockState, D));
2025                fidl::decode!(LockState, D, val_ref, decoder, inner_offset, inner_depth)?;
2026                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2027                {
2028                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2029                }
2030                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2031                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2032                }
2033            }
2034
2035            next_offset += envelope_size;
2036            _next_ordinal_to_read += 1;
2037            if next_offset >= end_offset {
2038                return Ok(());
2039            }
2040
2041            // Decode unknown envelopes for gaps in ordinals.
2042            while _next_ordinal_to_read < 8 {
2043                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2044                _next_ordinal_to_read += 1;
2045                next_offset += envelope_size;
2046            }
2047
2048            let next_out_of_line = decoder.next_out_of_line();
2049            let handles_before = decoder.remaining_handles();
2050            if let Some((inlined, num_bytes, num_handles)) =
2051                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2052            {
2053                let member_inline_size =
2054                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2055                if inlined != (member_inline_size <= 4) {
2056                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2057                }
2058                let inner_offset;
2059                let mut inner_depth = depth.clone();
2060                if inlined {
2061                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2062                    inner_offset = next_offset;
2063                } else {
2064                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2065                    inner_depth.increment()?;
2066                }
2067                let val_ref = self.device_id.get_or_insert_with(|| fidl::new_empty!(u32, D));
2068                fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
2069                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2070                {
2071                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2072                }
2073                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2074                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2075                }
2076            }
2077
2078            next_offset += envelope_size;
2079
2080            // Decode the remaining unknown envelopes.
2081            while next_offset < end_offset {
2082                _next_ordinal_to_read += 1;
2083                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2084                next_offset += envelope_size;
2085            }
2086
2087            Ok(())
2088        }
2089    }
2090
2091    impl fidl::encoding::ValueTypeMarker for KeyMeaning {
2092        type Borrowed<'a> = &'a Self;
2093        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2094            value
2095        }
2096    }
2097
2098    unsafe impl fidl::encoding::TypeMarker for KeyMeaning {
2099        type Owned = Self;
2100
2101        #[inline(always)]
2102        fn inline_align(_context: fidl::encoding::Context) -> usize {
2103            8
2104        }
2105
2106        #[inline(always)]
2107        fn inline_size(_context: fidl::encoding::Context) -> usize {
2108            16
2109        }
2110    }
2111
2112    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<KeyMeaning, D>
2113        for &KeyMeaning
2114    {
2115        #[inline]
2116        unsafe fn encode(
2117            self,
2118            encoder: &mut fidl::encoding::Encoder<'_, D>,
2119            offset: usize,
2120            _depth: fidl::encoding::Depth,
2121        ) -> fidl::Result<()> {
2122            encoder.debug_check_bounds::<KeyMeaning>(offset);
2123            encoder.write_num::<u64>(self.ordinal(), offset);
2124            match self {
2125                KeyMeaning::Codepoint(ref val) => fidl::encoding::encode_in_envelope::<u32, D>(
2126                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
2127                    encoder,
2128                    offset + 8,
2129                    _depth,
2130                ),
2131                KeyMeaning::NonPrintableKey(ref val) => {
2132                    fidl::encoding::encode_in_envelope::<NonPrintableKey, D>(
2133                        <NonPrintableKey as fidl::encoding::ValueTypeMarker>::borrow(val),
2134                        encoder,
2135                        offset + 8,
2136                        _depth,
2137                    )
2138                }
2139            }
2140        }
2141    }
2142
2143    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for KeyMeaning {
2144        #[inline(always)]
2145        fn new_empty() -> Self {
2146            Self::Codepoint(fidl::new_empty!(u32, D))
2147        }
2148
2149        #[inline]
2150        unsafe fn decode(
2151            &mut self,
2152            decoder: &mut fidl::encoding::Decoder<'_, D>,
2153            offset: usize,
2154            mut depth: fidl::encoding::Depth,
2155        ) -> fidl::Result<()> {
2156            decoder.debug_check_bounds::<Self>(offset);
2157            #[allow(unused_variables)]
2158            let next_out_of_line = decoder.next_out_of_line();
2159            let handles_before = decoder.remaining_handles();
2160            let (ordinal, inlined, num_bytes, num_handles) =
2161                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2162
2163            let member_inline_size = match ordinal {
2164                1 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2165                2 => <NonPrintableKey as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2166                _ => return Err(fidl::Error::UnknownUnionTag),
2167            };
2168
2169            if inlined != (member_inline_size <= 4) {
2170                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2171            }
2172            let _inner_offset;
2173            if inlined {
2174                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2175                _inner_offset = offset + 8;
2176            } else {
2177                depth.increment()?;
2178                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2179            }
2180            match ordinal {
2181                1 => {
2182                    #[allow(irrefutable_let_patterns)]
2183                    if let KeyMeaning::Codepoint(_) = self {
2184                        // Do nothing, read the value into the object
2185                    } else {
2186                        // Initialize `self` to the right variant
2187                        *self = KeyMeaning::Codepoint(fidl::new_empty!(u32, D));
2188                    }
2189                    #[allow(irrefutable_let_patterns)]
2190                    if let KeyMeaning::Codepoint(ref mut val) = self {
2191                        fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
2192                    } else {
2193                        unreachable!()
2194                    }
2195                }
2196                2 => {
2197                    #[allow(irrefutable_let_patterns)]
2198                    if let KeyMeaning::NonPrintableKey(_) = self {
2199                        // Do nothing, read the value into the object
2200                    } else {
2201                        // Initialize `self` to the right variant
2202                        *self = KeyMeaning::NonPrintableKey(fidl::new_empty!(NonPrintableKey, D));
2203                    }
2204                    #[allow(irrefutable_let_patterns)]
2205                    if let KeyMeaning::NonPrintableKey(ref mut val) = self {
2206                        fidl::decode!(NonPrintableKey, D, val, decoder, _inner_offset, depth)?;
2207                    } else {
2208                        unreachable!()
2209                    }
2210                }
2211                ordinal => panic!("unexpected ordinal {:?}", ordinal),
2212            }
2213            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2214                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2215            }
2216            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2217                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2218            }
2219            Ok(())
2220        }
2221    }
2222}