fidl_fuchsia_starnix_runner/
fidl_fuchsia_starnix_runner.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::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_starnix_runner__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct ManagerAddWakeSourceRequest {
16    /// The job of the container that is meant to be woken by `signals` on `handle`.
17    pub container_job: Option<fidl::Job>,
18    /// The name of the wake source, used for debugging purposes.
19    pub name: Option<String>,
20    /// A handle that is used to prevent the container from suspending when `signals` are
21    /// raised. If one of `signals` is raised while the container is suspended, the
22    /// container will be woken up.
23    pub handle: Option<fidl::Handle>,
24    /// The signals on `handle` that are meant to wake the container.
25    pub signals: Option<u32>,
26    #[doc(hidden)]
27    pub __source_breaking: fidl::marker::SourceBreaking,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for ManagerAddWakeSourceRequest
32{
33}
34
35#[derive(Debug, Default, PartialEq)]
36pub struct ManagerCreatePagerRequest {
37    /// The backing vmo to use in the pager.
38    pub backing_vmo: Option<fidl::Vmo>,
39    /// The block size for the pager to use.
40    pub block_size: Option<u64>,
41    /// The `Pager` instance that will serve the pager requests.
42    pub pager: Option<fidl::endpoints::ServerEnd<PagerMarker>>,
43    #[doc(hidden)]
44    pub __source_breaking: fidl::marker::SourceBreaking,
45}
46
47impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ManagerCreatePagerRequest {}
48
49#[derive(Debug, Default, PartialEq)]
50pub struct ManagerProxyWakeChannelRequest {
51    /// The job of the container that holds the other end of `container_channel`.
52    pub container_job: Option<fidl::Job>,
53    /// The channel endpoint that is connected to the container.
54    pub container_channel: Option<fidl::Channel>,
55    /// The channel endpoint that is connected to a component outside the container.
56    pub remote_channel: Option<fidl::Channel>,
57    /// The name of the proxy, used for debugging purposes.
58    pub name: Option<String>,
59    /// A counter that is used to count how many unhandled requests have been sent to the
60    /// container. If this counter is non-zero, the container will not be able to suspend.
61    ///
62    /// Each time the client handles a message on the proxied channel, it is expected to
63    /// decrement the counter by 1. This decrement should only happen once the client is
64    /// ready to allow suspension. Often this means that a new hanging get has been sent on
65    /// the proxied channel.
66    pub counter: Option<fidl::Counter>,
67    #[doc(hidden)]
68    pub __source_breaking: fidl::marker::SourceBreaking,
69}
70
71impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
72    for ManagerProxyWakeChannelRequest
73{
74}
75
76#[derive(Debug, Default, PartialEq)]
77pub struct ManagerRegisterWakeWatcherRequest {
78    /// The event that will be signaled when the container's wake status changes.
79    pub watcher: Option<fidl::EventPair>,
80    #[doc(hidden)]
81    pub __source_breaking: fidl::marker::SourceBreaking,
82}
83
84impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
85    for ManagerRegisterWakeWatcherRequest
86{
87}
88
89#[derive(Debug, Default, PartialEq)]
90pub struct ManagerRemoveWakeSourceRequest {
91    /// The job of the container that `handle` is associated with.
92    pub container_job: Option<fidl::Job>,
93    /// The handle to the wake source that is to be removed.
94    pub handle: Option<fidl::Handle>,
95    #[doc(hidden)]
96    pub __source_breaking: fidl::marker::SourceBreaking,
97}
98
99impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
100    for ManagerRemoveWakeSourceRequest
101{
102}
103
104#[derive(Debug, Default, PartialEq)]
105pub struct ManagerSuspendContainerRequest {
106    /// The job of the container to suspend.
107    pub container_job: Option<fidl::Job>,
108    /// The event that is used to signal whether or not there are any active wake locks
109    /// in the container.
110    pub wake_locks: Option<fidl::EventPair>,
111    #[doc(hidden)]
112    pub __source_breaking: fidl::marker::SourceBreaking,
113}
114
115impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
116    for ManagerSuspendContainerRequest
117{
118}
119
120#[derive(Debug, Default, PartialEq)]
121pub struct PagerRegisterFileResponse {
122    /// A newly created child vmo.
123    pub vmo: Option<fidl::Vmo>,
124    #[doc(hidden)]
125    pub __source_breaking: fidl::marker::SourceBreaking,
126}
127
128impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PagerRegisterFileResponse {}
129
130#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
131pub struct ManagerMarker;
132
133impl fidl::endpoints::ProtocolMarker for ManagerMarker {
134    type Proxy = ManagerProxy;
135    type RequestStream = ManagerRequestStream;
136    #[cfg(target_os = "fuchsia")]
137    type SynchronousProxy = ManagerSynchronousProxy;
138
139    const DEBUG_NAME: &'static str = "fuchsia.starnix.runner.Manager";
140}
141impl fidl::endpoints::DiscoverableProtocolMarker for ManagerMarker {}
142pub type ManagerSuspendContainerResult = Result<ManagerSuspendContainerResponse, SuspendError>;
143
144pub trait ManagerProxyInterface: Send + Sync {
145    type SuspendContainerResponseFut: std::future::Future<Output = Result<ManagerSuspendContainerResult, fidl::Error>>
146        + Send;
147    fn r#suspend_container(
148        &self,
149        payload: ManagerSuspendContainerRequest,
150    ) -> Self::SuspendContainerResponseFut;
151    fn r#proxy_wake_channel(
152        &self,
153        payload: ManagerProxyWakeChannelRequest,
154    ) -> Result<(), fidl::Error>;
155    fn r#add_wake_source(&self, payload: ManagerAddWakeSourceRequest) -> Result<(), fidl::Error>;
156    fn r#remove_wake_source(
157        &self,
158        payload: ManagerRemoveWakeSourceRequest,
159    ) -> Result<(), fidl::Error>;
160    type RegisterWakeWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
161        + Send;
162    fn r#register_wake_watcher(
163        &self,
164        payload: ManagerRegisterWakeWatcherRequest,
165    ) -> Self::RegisterWakeWatcherResponseFut;
166    fn r#create_pager(&self, payload: ManagerCreatePagerRequest) -> Result<(), fidl::Error>;
167}
168#[derive(Debug)]
169#[cfg(target_os = "fuchsia")]
170pub struct ManagerSynchronousProxy {
171    client: fidl::client::sync::Client,
172}
173
174#[cfg(target_os = "fuchsia")]
175impl fidl::endpoints::SynchronousProxy for ManagerSynchronousProxy {
176    type Proxy = ManagerProxy;
177    type Protocol = ManagerMarker;
178
179    fn from_channel(inner: fidl::Channel) -> Self {
180        Self::new(inner)
181    }
182
183    fn into_channel(self) -> fidl::Channel {
184        self.client.into_channel()
185    }
186
187    fn as_channel(&self) -> &fidl::Channel {
188        self.client.as_channel()
189    }
190}
191
192#[cfg(target_os = "fuchsia")]
193impl ManagerSynchronousProxy {
194    pub fn new(channel: fidl::Channel) -> Self {
195        let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
196        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
197    }
198
199    pub fn into_channel(self) -> fidl::Channel {
200        self.client.into_channel()
201    }
202
203    /// Waits until an event arrives and returns it. It is safe for other
204    /// threads to make concurrent requests while waiting for an event.
205    pub fn wait_for_event(
206        &self,
207        deadline: zx::MonotonicInstant,
208    ) -> Result<ManagerEvent, fidl::Error> {
209        ManagerEvent::decode(self.client.wait_for_event(deadline)?)
210    }
211
212    /// Suspends the container running in `job`.
213    ///
214    /// The call will return successfully when `wake_event` has been signaled. Returns
215    /// an error if `wake_locks` is signaled at the end of suspension, or an error is
216    /// encountered when suspending the container's processes.
217    pub fn r#suspend_container(
218        &self,
219        mut payload: ManagerSuspendContainerRequest,
220        ___deadline: zx::MonotonicInstant,
221    ) -> Result<ManagerSuspendContainerResult, fidl::Error> {
222        let _response = self.client.send_query::<
223            ManagerSuspendContainerRequest,
224            fidl::encoding::FlexibleResultType<ManagerSuspendContainerResponse, SuspendError>,
225        >(
226            &mut payload,
227            0x928527927c9f2a7,
228            fidl::encoding::DynamicFlags::FLEXIBLE,
229            ___deadline,
230        )?
231        .into_result::<ManagerMarker>("suspend_container")?;
232        Ok(_response.map(|x| x))
233    }
234
235    /// Creates a pass-through proxy that forwards messages between the `container_channel` and the
236    /// `remote_channel`.
237    ///
238    /// If any messages arrive on `remote_channel` while the container is suspended via
239    /// `SuspendContainer`, the container will be resumed and `counter` will be incremented.
240    ///
241    /// Once that message is handled by the container, and it's ok to suspend the container again
242    /// (relative to that message), the counter is expected to be decremented.
243    pub fn r#proxy_wake_channel(
244        &self,
245        mut payload: ManagerProxyWakeChannelRequest,
246    ) -> Result<(), fidl::Error> {
247        self.client.send::<ManagerProxyWakeChannelRequest>(
248            &mut payload,
249            0x46a374ab73b23714,
250            fidl::encoding::DynamicFlags::FLEXIBLE,
251        )
252    }
253
254    /// Adds `signals` on `handle` as a way to prevent the container from suspending, or wake it
255    /// if it is already suspended.
256    pub fn r#add_wake_source(
257        &self,
258        mut payload: ManagerAddWakeSourceRequest,
259    ) -> Result<(), fidl::Error> {
260        self.client.send::<ManagerAddWakeSourceRequest>(
261            &mut payload,
262            0x45e94269f9722ac,
263            fidl::encoding::DynamicFlags::FLEXIBLE,
264        )
265    }
266
267    /// Removes a wake source handle from the `container_job`.
268    ///
269    /// If the container is currently suspended, the `handle` may still wake the container if
270    /// its signals are raised. To ensure that the wake source never wakes the container again
271    /// after this call, the client must make sure that the signals are cleared and not raised
272    /// again.
273    pub fn r#remove_wake_source(
274        &self,
275        mut payload: ManagerRemoveWakeSourceRequest,
276    ) -> Result<(), fidl::Error> {
277        self.client.send::<ManagerRemoveWakeSourceRequest>(
278            &mut payload,
279            0x25d311f5e801501a,
280            fidl::encoding::DynamicFlags::FLEXIBLE,
281        )
282    }
283
284    /// Registers an eventpair that will be signaled when the container is suspended or resumed.
285    /// The signals are ASLEEP(USER_1) and AWAKE(USER_0).
286    ///
287    /// The kernel returns AWAKE upon initial registration of the eventpair.
288    pub fn r#register_wake_watcher(
289        &self,
290        mut payload: ManagerRegisterWakeWatcherRequest,
291        ___deadline: zx::MonotonicInstant,
292    ) -> Result<(), fidl::Error> {
293        let _response = self.client.send_query::<
294            ManagerRegisterWakeWatcherRequest,
295            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
296        >(
297            &mut payload,
298            0x456d74519eb65b41,
299            fidl::encoding::DynamicFlags::FLEXIBLE,
300            ___deadline,
301        )?
302        .into_result::<ManagerMarker>("register_wake_watcher")?;
303        Ok(_response)
304    }
305
306    /// Creates a `Pager` instance with the provided `backing_vmo` and `block_size`.
307    pub fn r#create_pager(
308        &self,
309        mut payload: ManagerCreatePagerRequest,
310    ) -> Result<(), fidl::Error> {
311        self.client.send::<ManagerCreatePagerRequest>(
312            &mut payload,
313            0x49d14958b736198b,
314            fidl::encoding::DynamicFlags::FLEXIBLE,
315        )
316    }
317}
318
319#[cfg(target_os = "fuchsia")]
320impl From<ManagerSynchronousProxy> for zx::Handle {
321    fn from(value: ManagerSynchronousProxy) -> Self {
322        value.into_channel().into()
323    }
324}
325
326#[cfg(target_os = "fuchsia")]
327impl From<fidl::Channel> for ManagerSynchronousProxy {
328    fn from(value: fidl::Channel) -> Self {
329        Self::new(value)
330    }
331}
332
333#[cfg(target_os = "fuchsia")]
334impl fidl::endpoints::FromClient for ManagerSynchronousProxy {
335    type Protocol = ManagerMarker;
336
337    fn from_client(value: fidl::endpoints::ClientEnd<ManagerMarker>) -> Self {
338        Self::new(value.into_channel())
339    }
340}
341
342#[derive(Debug, Clone)]
343pub struct ManagerProxy {
344    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
345}
346
347impl fidl::endpoints::Proxy for ManagerProxy {
348    type Protocol = ManagerMarker;
349
350    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
351        Self::new(inner)
352    }
353
354    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
355        self.client.into_channel().map_err(|client| Self { client })
356    }
357
358    fn as_channel(&self) -> &::fidl::AsyncChannel {
359        self.client.as_channel()
360    }
361}
362
363impl ManagerProxy {
364    /// Create a new Proxy for fuchsia.starnix.runner/Manager.
365    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
366        let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
367        Self { client: fidl::client::Client::new(channel, protocol_name) }
368    }
369
370    /// Get a Stream of events from the remote end of the protocol.
371    ///
372    /// # Panics
373    ///
374    /// Panics if the event stream was already taken.
375    pub fn take_event_stream(&self) -> ManagerEventStream {
376        ManagerEventStream { event_receiver: self.client.take_event_receiver() }
377    }
378
379    /// Suspends the container running in `job`.
380    ///
381    /// The call will return successfully when `wake_event` has been signaled. Returns
382    /// an error if `wake_locks` is signaled at the end of suspension, or an error is
383    /// encountered when suspending the container's processes.
384    pub fn r#suspend_container(
385        &self,
386        mut payload: ManagerSuspendContainerRequest,
387    ) -> fidl::client::QueryResponseFut<
388        ManagerSuspendContainerResult,
389        fidl::encoding::DefaultFuchsiaResourceDialect,
390    > {
391        ManagerProxyInterface::r#suspend_container(self, payload)
392    }
393
394    /// Creates a pass-through proxy that forwards messages between the `container_channel` and the
395    /// `remote_channel`.
396    ///
397    /// If any messages arrive on `remote_channel` while the container is suspended via
398    /// `SuspendContainer`, the container will be resumed and `counter` will be incremented.
399    ///
400    /// Once that message is handled by the container, and it's ok to suspend the container again
401    /// (relative to that message), the counter is expected to be decremented.
402    pub fn r#proxy_wake_channel(
403        &self,
404        mut payload: ManagerProxyWakeChannelRequest,
405    ) -> Result<(), fidl::Error> {
406        ManagerProxyInterface::r#proxy_wake_channel(self, payload)
407    }
408
409    /// Adds `signals` on `handle` as a way to prevent the container from suspending, or wake it
410    /// if it is already suspended.
411    pub fn r#add_wake_source(
412        &self,
413        mut payload: ManagerAddWakeSourceRequest,
414    ) -> Result<(), fidl::Error> {
415        ManagerProxyInterface::r#add_wake_source(self, payload)
416    }
417
418    /// Removes a wake source handle from the `container_job`.
419    ///
420    /// If the container is currently suspended, the `handle` may still wake the container if
421    /// its signals are raised. To ensure that the wake source never wakes the container again
422    /// after this call, the client must make sure that the signals are cleared and not raised
423    /// again.
424    pub fn r#remove_wake_source(
425        &self,
426        mut payload: ManagerRemoveWakeSourceRequest,
427    ) -> Result<(), fidl::Error> {
428        ManagerProxyInterface::r#remove_wake_source(self, payload)
429    }
430
431    /// Registers an eventpair that will be signaled when the container is suspended or resumed.
432    /// The signals are ASLEEP(USER_1) and AWAKE(USER_0).
433    ///
434    /// The kernel returns AWAKE upon initial registration of the eventpair.
435    pub fn r#register_wake_watcher(
436        &self,
437        mut payload: ManagerRegisterWakeWatcherRequest,
438    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
439        ManagerProxyInterface::r#register_wake_watcher(self, payload)
440    }
441
442    /// Creates a `Pager` instance with the provided `backing_vmo` and `block_size`.
443    pub fn r#create_pager(
444        &self,
445        mut payload: ManagerCreatePagerRequest,
446    ) -> Result<(), fidl::Error> {
447        ManagerProxyInterface::r#create_pager(self, payload)
448    }
449}
450
451impl ManagerProxyInterface for ManagerProxy {
452    type SuspendContainerResponseFut = fidl::client::QueryResponseFut<
453        ManagerSuspendContainerResult,
454        fidl::encoding::DefaultFuchsiaResourceDialect,
455    >;
456    fn r#suspend_container(
457        &self,
458        mut payload: ManagerSuspendContainerRequest,
459    ) -> Self::SuspendContainerResponseFut {
460        fn _decode(
461            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
462        ) -> Result<ManagerSuspendContainerResult, fidl::Error> {
463            let _response = fidl::client::decode_transaction_body::<
464                fidl::encoding::FlexibleResultType<ManagerSuspendContainerResponse, SuspendError>,
465                fidl::encoding::DefaultFuchsiaResourceDialect,
466                0x928527927c9f2a7,
467            >(_buf?)?
468            .into_result::<ManagerMarker>("suspend_container")?;
469            Ok(_response.map(|x| x))
470        }
471        self.client
472            .send_query_and_decode::<ManagerSuspendContainerRequest, ManagerSuspendContainerResult>(
473                &mut payload,
474                0x928527927c9f2a7,
475                fidl::encoding::DynamicFlags::FLEXIBLE,
476                _decode,
477            )
478    }
479
480    fn r#proxy_wake_channel(
481        &self,
482        mut payload: ManagerProxyWakeChannelRequest,
483    ) -> Result<(), fidl::Error> {
484        self.client.send::<ManagerProxyWakeChannelRequest>(
485            &mut payload,
486            0x46a374ab73b23714,
487            fidl::encoding::DynamicFlags::FLEXIBLE,
488        )
489    }
490
491    fn r#add_wake_source(
492        &self,
493        mut payload: ManagerAddWakeSourceRequest,
494    ) -> Result<(), fidl::Error> {
495        self.client.send::<ManagerAddWakeSourceRequest>(
496            &mut payload,
497            0x45e94269f9722ac,
498            fidl::encoding::DynamicFlags::FLEXIBLE,
499        )
500    }
501
502    fn r#remove_wake_source(
503        &self,
504        mut payload: ManagerRemoveWakeSourceRequest,
505    ) -> Result<(), fidl::Error> {
506        self.client.send::<ManagerRemoveWakeSourceRequest>(
507            &mut payload,
508            0x25d311f5e801501a,
509            fidl::encoding::DynamicFlags::FLEXIBLE,
510        )
511    }
512
513    type RegisterWakeWatcherResponseFut =
514        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
515    fn r#register_wake_watcher(
516        &self,
517        mut payload: ManagerRegisterWakeWatcherRequest,
518    ) -> Self::RegisterWakeWatcherResponseFut {
519        fn _decode(
520            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
521        ) -> Result<(), fidl::Error> {
522            let _response = fidl::client::decode_transaction_body::<
523                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
524                fidl::encoding::DefaultFuchsiaResourceDialect,
525                0x456d74519eb65b41,
526            >(_buf?)?
527            .into_result::<ManagerMarker>("register_wake_watcher")?;
528            Ok(_response)
529        }
530        self.client.send_query_and_decode::<ManagerRegisterWakeWatcherRequest, ()>(
531            &mut payload,
532            0x456d74519eb65b41,
533            fidl::encoding::DynamicFlags::FLEXIBLE,
534            _decode,
535        )
536    }
537
538    fn r#create_pager(&self, mut payload: ManagerCreatePagerRequest) -> Result<(), fidl::Error> {
539        self.client.send::<ManagerCreatePagerRequest>(
540            &mut payload,
541            0x49d14958b736198b,
542            fidl::encoding::DynamicFlags::FLEXIBLE,
543        )
544    }
545}
546
547pub struct ManagerEventStream {
548    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
549}
550
551impl std::marker::Unpin for ManagerEventStream {}
552
553impl futures::stream::FusedStream for ManagerEventStream {
554    fn is_terminated(&self) -> bool {
555        self.event_receiver.is_terminated()
556    }
557}
558
559impl futures::Stream for ManagerEventStream {
560    type Item = Result<ManagerEvent, fidl::Error>;
561
562    fn poll_next(
563        mut self: std::pin::Pin<&mut Self>,
564        cx: &mut std::task::Context<'_>,
565    ) -> std::task::Poll<Option<Self::Item>> {
566        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
567            &mut self.event_receiver,
568            cx
569        )?) {
570            Some(buf) => std::task::Poll::Ready(Some(ManagerEvent::decode(buf))),
571            None => std::task::Poll::Ready(None),
572        }
573    }
574}
575
576#[derive(Debug)]
577pub enum ManagerEvent {
578    #[non_exhaustive]
579    _UnknownEvent {
580        /// Ordinal of the event that was sent.
581        ordinal: u64,
582    },
583}
584
585impl ManagerEvent {
586    /// Decodes a message buffer as a [`ManagerEvent`].
587    fn decode(
588        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
589    ) -> Result<ManagerEvent, fidl::Error> {
590        let (bytes, _handles) = buf.split_mut();
591        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
592        debug_assert_eq!(tx_header.tx_id, 0);
593        match tx_header.ordinal {
594            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
595                Ok(ManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
596            }
597            _ => Err(fidl::Error::UnknownOrdinal {
598                ordinal: tx_header.ordinal,
599                protocol_name: <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
600            }),
601        }
602    }
603}
604
605/// A Stream of incoming requests for fuchsia.starnix.runner/Manager.
606pub struct ManagerRequestStream {
607    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
608    is_terminated: bool,
609}
610
611impl std::marker::Unpin for ManagerRequestStream {}
612
613impl futures::stream::FusedStream for ManagerRequestStream {
614    fn is_terminated(&self) -> bool {
615        self.is_terminated
616    }
617}
618
619impl fidl::endpoints::RequestStream for ManagerRequestStream {
620    type Protocol = ManagerMarker;
621    type ControlHandle = ManagerControlHandle;
622
623    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
624        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
625    }
626
627    fn control_handle(&self) -> Self::ControlHandle {
628        ManagerControlHandle { inner: self.inner.clone() }
629    }
630
631    fn into_inner(
632        self,
633    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
634    {
635        (self.inner, self.is_terminated)
636    }
637
638    fn from_inner(
639        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
640        is_terminated: bool,
641    ) -> Self {
642        Self { inner, is_terminated }
643    }
644}
645
646impl futures::Stream for ManagerRequestStream {
647    type Item = Result<ManagerRequest, fidl::Error>;
648
649    fn poll_next(
650        mut self: std::pin::Pin<&mut Self>,
651        cx: &mut std::task::Context<'_>,
652    ) -> std::task::Poll<Option<Self::Item>> {
653        let this = &mut *self;
654        if this.inner.check_shutdown(cx) {
655            this.is_terminated = true;
656            return std::task::Poll::Ready(None);
657        }
658        if this.is_terminated {
659            panic!("polled ManagerRequestStream after completion");
660        }
661        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
662            |bytes, handles| {
663                match this.inner.channel().read_etc(cx, bytes, handles) {
664                    std::task::Poll::Ready(Ok(())) => {}
665                    std::task::Poll::Pending => return std::task::Poll::Pending,
666                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
667                        this.is_terminated = true;
668                        return std::task::Poll::Ready(None);
669                    }
670                    std::task::Poll::Ready(Err(e)) => {
671                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
672                            e.into(),
673                        ))));
674                    }
675                }
676
677                // A message has been received from the channel
678                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
679
680                std::task::Poll::Ready(Some(match header.ordinal {
681                    0x928527927c9f2a7 => {
682                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
683                        let mut req = fidl::new_empty!(
684                            ManagerSuspendContainerRequest,
685                            fidl::encoding::DefaultFuchsiaResourceDialect
686                        );
687                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerSuspendContainerRequest>(&header, _body_bytes, handles, &mut req)?;
688                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
689                        Ok(ManagerRequest::SuspendContainer {
690                            payload: req,
691                            responder: ManagerSuspendContainerResponder {
692                                control_handle: std::mem::ManuallyDrop::new(control_handle),
693                                tx_id: header.tx_id,
694                            },
695                        })
696                    }
697                    0x46a374ab73b23714 => {
698                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
699                        let mut req = fidl::new_empty!(
700                            ManagerProxyWakeChannelRequest,
701                            fidl::encoding::DefaultFuchsiaResourceDialect
702                        );
703                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerProxyWakeChannelRequest>(&header, _body_bytes, handles, &mut req)?;
704                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
705                        Ok(ManagerRequest::ProxyWakeChannel { payload: req, control_handle })
706                    }
707                    0x45e94269f9722ac => {
708                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
709                        let mut req = fidl::new_empty!(
710                            ManagerAddWakeSourceRequest,
711                            fidl::encoding::DefaultFuchsiaResourceDialect
712                        );
713                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerAddWakeSourceRequest>(&header, _body_bytes, handles, &mut req)?;
714                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
715                        Ok(ManagerRequest::AddWakeSource { payload: req, control_handle })
716                    }
717                    0x25d311f5e801501a => {
718                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
719                        let mut req = fidl::new_empty!(
720                            ManagerRemoveWakeSourceRequest,
721                            fidl::encoding::DefaultFuchsiaResourceDialect
722                        );
723                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerRemoveWakeSourceRequest>(&header, _body_bytes, handles, &mut req)?;
724                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
725                        Ok(ManagerRequest::RemoveWakeSource { payload: req, control_handle })
726                    }
727                    0x456d74519eb65b41 => {
728                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
729                        let mut req = fidl::new_empty!(
730                            ManagerRegisterWakeWatcherRequest,
731                            fidl::encoding::DefaultFuchsiaResourceDialect
732                        );
733                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerRegisterWakeWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
734                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
735                        Ok(ManagerRequest::RegisterWakeWatcher {
736                            payload: req,
737                            responder: ManagerRegisterWakeWatcherResponder {
738                                control_handle: std::mem::ManuallyDrop::new(control_handle),
739                                tx_id: header.tx_id,
740                            },
741                        })
742                    }
743                    0x49d14958b736198b => {
744                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
745                        let mut req = fidl::new_empty!(
746                            ManagerCreatePagerRequest,
747                            fidl::encoding::DefaultFuchsiaResourceDialect
748                        );
749                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerCreatePagerRequest>(&header, _body_bytes, handles, &mut req)?;
750                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
751                        Ok(ManagerRequest::CreatePager { payload: req, control_handle })
752                    }
753                    _ if header.tx_id == 0
754                        && header
755                            .dynamic_flags()
756                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
757                    {
758                        Ok(ManagerRequest::_UnknownMethod {
759                            ordinal: header.ordinal,
760                            control_handle: ManagerControlHandle { inner: this.inner.clone() },
761                            method_type: fidl::MethodType::OneWay,
762                        })
763                    }
764                    _ if header
765                        .dynamic_flags()
766                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
767                    {
768                        this.inner.send_framework_err(
769                            fidl::encoding::FrameworkErr::UnknownMethod,
770                            header.tx_id,
771                            header.ordinal,
772                            header.dynamic_flags(),
773                            (bytes, handles),
774                        )?;
775                        Ok(ManagerRequest::_UnknownMethod {
776                            ordinal: header.ordinal,
777                            control_handle: ManagerControlHandle { inner: this.inner.clone() },
778                            method_type: fidl::MethodType::TwoWay,
779                        })
780                    }
781                    _ => Err(fidl::Error::UnknownOrdinal {
782                        ordinal: header.ordinal,
783                        protocol_name:
784                            <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
785                    }),
786                }))
787            },
788        )
789    }
790}
791
792#[derive(Debug)]
793pub enum ManagerRequest {
794    /// Suspends the container running in `job`.
795    ///
796    /// The call will return successfully when `wake_event` has been signaled. Returns
797    /// an error if `wake_locks` is signaled at the end of suspension, or an error is
798    /// encountered when suspending the container's processes.
799    SuspendContainer {
800        payload: ManagerSuspendContainerRequest,
801        responder: ManagerSuspendContainerResponder,
802    },
803    /// Creates a pass-through proxy that forwards messages between the `container_channel` and the
804    /// `remote_channel`.
805    ///
806    /// If any messages arrive on `remote_channel` while the container is suspended via
807    /// `SuspendContainer`, the container will be resumed and `counter` will be incremented.
808    ///
809    /// Once that message is handled by the container, and it's ok to suspend the container again
810    /// (relative to that message), the counter is expected to be decremented.
811    ProxyWakeChannel {
812        payload: ManagerProxyWakeChannelRequest,
813        control_handle: ManagerControlHandle,
814    },
815    /// Adds `signals` on `handle` as a way to prevent the container from suspending, or wake it
816    /// if it is already suspended.
817    AddWakeSource { payload: ManagerAddWakeSourceRequest, control_handle: ManagerControlHandle },
818    /// Removes a wake source handle from the `container_job`.
819    ///
820    /// If the container is currently suspended, the `handle` may still wake the container if
821    /// its signals are raised. To ensure that the wake source never wakes the container again
822    /// after this call, the client must make sure that the signals are cleared and not raised
823    /// again.
824    RemoveWakeSource {
825        payload: ManagerRemoveWakeSourceRequest,
826        control_handle: ManagerControlHandle,
827    },
828    /// Registers an eventpair that will be signaled when the container is suspended or resumed.
829    /// The signals are ASLEEP(USER_1) and AWAKE(USER_0).
830    ///
831    /// The kernel returns AWAKE upon initial registration of the eventpair.
832    RegisterWakeWatcher {
833        payload: ManagerRegisterWakeWatcherRequest,
834        responder: ManagerRegisterWakeWatcherResponder,
835    },
836    /// Creates a `Pager` instance with the provided `backing_vmo` and `block_size`.
837    CreatePager { payload: ManagerCreatePagerRequest, control_handle: ManagerControlHandle },
838    /// An interaction was received which does not match any known method.
839    #[non_exhaustive]
840    _UnknownMethod {
841        /// Ordinal of the method that was called.
842        ordinal: u64,
843        control_handle: ManagerControlHandle,
844        method_type: fidl::MethodType,
845    },
846}
847
848impl ManagerRequest {
849    #[allow(irrefutable_let_patterns)]
850    pub fn into_suspend_container(
851        self,
852    ) -> Option<(ManagerSuspendContainerRequest, ManagerSuspendContainerResponder)> {
853        if let ManagerRequest::SuspendContainer { payload, responder } = self {
854            Some((payload, responder))
855        } else {
856            None
857        }
858    }
859
860    #[allow(irrefutable_let_patterns)]
861    pub fn into_proxy_wake_channel(
862        self,
863    ) -> Option<(ManagerProxyWakeChannelRequest, ManagerControlHandle)> {
864        if let ManagerRequest::ProxyWakeChannel { payload, control_handle } = self {
865            Some((payload, control_handle))
866        } else {
867            None
868        }
869    }
870
871    #[allow(irrefutable_let_patterns)]
872    pub fn into_add_wake_source(
873        self,
874    ) -> Option<(ManagerAddWakeSourceRequest, ManagerControlHandle)> {
875        if let ManagerRequest::AddWakeSource { payload, control_handle } = self {
876            Some((payload, control_handle))
877        } else {
878            None
879        }
880    }
881
882    #[allow(irrefutable_let_patterns)]
883    pub fn into_remove_wake_source(
884        self,
885    ) -> Option<(ManagerRemoveWakeSourceRequest, ManagerControlHandle)> {
886        if let ManagerRequest::RemoveWakeSource { payload, control_handle } = self {
887            Some((payload, control_handle))
888        } else {
889            None
890        }
891    }
892
893    #[allow(irrefutable_let_patterns)]
894    pub fn into_register_wake_watcher(
895        self,
896    ) -> Option<(ManagerRegisterWakeWatcherRequest, ManagerRegisterWakeWatcherResponder)> {
897        if let ManagerRequest::RegisterWakeWatcher { payload, responder } = self {
898            Some((payload, responder))
899        } else {
900            None
901        }
902    }
903
904    #[allow(irrefutable_let_patterns)]
905    pub fn into_create_pager(self) -> Option<(ManagerCreatePagerRequest, ManagerControlHandle)> {
906        if let ManagerRequest::CreatePager { payload, control_handle } = self {
907            Some((payload, control_handle))
908        } else {
909            None
910        }
911    }
912
913    /// Name of the method defined in FIDL
914    pub fn method_name(&self) -> &'static str {
915        match *self {
916            ManagerRequest::SuspendContainer { .. } => "suspend_container",
917            ManagerRequest::ProxyWakeChannel { .. } => "proxy_wake_channel",
918            ManagerRequest::AddWakeSource { .. } => "add_wake_source",
919            ManagerRequest::RemoveWakeSource { .. } => "remove_wake_source",
920            ManagerRequest::RegisterWakeWatcher { .. } => "register_wake_watcher",
921            ManagerRequest::CreatePager { .. } => "create_pager",
922            ManagerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
923                "unknown one-way method"
924            }
925            ManagerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
926                "unknown two-way method"
927            }
928        }
929    }
930}
931
932#[derive(Debug, Clone)]
933pub struct ManagerControlHandle {
934    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
935}
936
937impl fidl::endpoints::ControlHandle for ManagerControlHandle {
938    fn shutdown(&self) {
939        self.inner.shutdown()
940    }
941    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
942        self.inner.shutdown_with_epitaph(status)
943    }
944
945    fn is_closed(&self) -> bool {
946        self.inner.channel().is_closed()
947    }
948    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
949        self.inner.channel().on_closed()
950    }
951
952    #[cfg(target_os = "fuchsia")]
953    fn signal_peer(
954        &self,
955        clear_mask: zx::Signals,
956        set_mask: zx::Signals,
957    ) -> Result<(), zx_status::Status> {
958        use fidl::Peered;
959        self.inner.channel().signal_peer(clear_mask, set_mask)
960    }
961}
962
963impl ManagerControlHandle {}
964
965#[must_use = "FIDL methods require a response to be sent"]
966#[derive(Debug)]
967pub struct ManagerSuspendContainerResponder {
968    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
969    tx_id: u32,
970}
971
972/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
973/// if the responder is dropped without sending a response, so that the client
974/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
975impl std::ops::Drop for ManagerSuspendContainerResponder {
976    fn drop(&mut self) {
977        self.control_handle.shutdown();
978        // Safety: drops once, never accessed again
979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
980    }
981}
982
983impl fidl::endpoints::Responder for ManagerSuspendContainerResponder {
984    type ControlHandle = ManagerControlHandle;
985
986    fn control_handle(&self) -> &ManagerControlHandle {
987        &self.control_handle
988    }
989
990    fn drop_without_shutdown(mut self) {
991        // Safety: drops once, never accessed again due to mem::forget
992        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
993        // Prevent Drop from running (which would shut down the channel)
994        std::mem::forget(self);
995    }
996}
997
998impl ManagerSuspendContainerResponder {
999    /// Sends a response to the FIDL transaction.
1000    ///
1001    /// Sets the channel to shutdown if an error occurs.
1002    pub fn send(
1003        self,
1004        mut result: Result<&ManagerSuspendContainerResponse, SuspendError>,
1005    ) -> Result<(), fidl::Error> {
1006        let _result = self.send_raw(result);
1007        if _result.is_err() {
1008            self.control_handle.shutdown();
1009        }
1010        self.drop_without_shutdown();
1011        _result
1012    }
1013
1014    /// Similar to "send" but does not shutdown the channel if an error occurs.
1015    pub fn send_no_shutdown_on_err(
1016        self,
1017        mut result: Result<&ManagerSuspendContainerResponse, SuspendError>,
1018    ) -> Result<(), fidl::Error> {
1019        let _result = self.send_raw(result);
1020        self.drop_without_shutdown();
1021        _result
1022    }
1023
1024    fn send_raw(
1025        &self,
1026        mut result: Result<&ManagerSuspendContainerResponse, SuspendError>,
1027    ) -> Result<(), fidl::Error> {
1028        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1029            ManagerSuspendContainerResponse,
1030            SuspendError,
1031        >>(
1032            fidl::encoding::FlexibleResult::new(result),
1033            self.tx_id,
1034            0x928527927c9f2a7,
1035            fidl::encoding::DynamicFlags::FLEXIBLE,
1036        )
1037    }
1038}
1039
1040#[must_use = "FIDL methods require a response to be sent"]
1041#[derive(Debug)]
1042pub struct ManagerRegisterWakeWatcherResponder {
1043    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
1044    tx_id: u32,
1045}
1046
1047/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
1048/// if the responder is dropped without sending a response, so that the client
1049/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1050impl std::ops::Drop for ManagerRegisterWakeWatcherResponder {
1051    fn drop(&mut self) {
1052        self.control_handle.shutdown();
1053        // Safety: drops once, never accessed again
1054        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1055    }
1056}
1057
1058impl fidl::endpoints::Responder for ManagerRegisterWakeWatcherResponder {
1059    type ControlHandle = ManagerControlHandle;
1060
1061    fn control_handle(&self) -> &ManagerControlHandle {
1062        &self.control_handle
1063    }
1064
1065    fn drop_without_shutdown(mut self) {
1066        // Safety: drops once, never accessed again due to mem::forget
1067        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1068        // Prevent Drop from running (which would shut down the channel)
1069        std::mem::forget(self);
1070    }
1071}
1072
1073impl ManagerRegisterWakeWatcherResponder {
1074    /// Sends a response to the FIDL transaction.
1075    ///
1076    /// Sets the channel to shutdown if an error occurs.
1077    pub fn send(self) -> Result<(), fidl::Error> {
1078        let _result = self.send_raw();
1079        if _result.is_err() {
1080            self.control_handle.shutdown();
1081        }
1082        self.drop_without_shutdown();
1083        _result
1084    }
1085
1086    /// Similar to "send" but does not shutdown the channel if an error occurs.
1087    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1088        let _result = self.send_raw();
1089        self.drop_without_shutdown();
1090        _result
1091    }
1092
1093    fn send_raw(&self) -> Result<(), fidl::Error> {
1094        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1095            fidl::encoding::Flexible::new(()),
1096            self.tx_id,
1097            0x456d74519eb65b41,
1098            fidl::encoding::DynamicFlags::FLEXIBLE,
1099        )
1100    }
1101}
1102
1103#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1104pub struct PagerMarker;
1105
1106impl fidl::endpoints::ProtocolMarker for PagerMarker {
1107    type Proxy = PagerProxy;
1108    type RequestStream = PagerRequestStream;
1109    #[cfg(target_os = "fuchsia")]
1110    type SynchronousProxy = PagerSynchronousProxy;
1111
1112    const DEBUG_NAME: &'static str = "(anonymous) Pager";
1113}
1114pub type PagerRegisterFileResult = Result<PagerRegisterFileResponse, i32>;
1115
1116pub trait PagerProxyInterface: Send + Sync {
1117    type RegisterFileResponseFut: std::future::Future<Output = Result<PagerRegisterFileResult, fidl::Error>>
1118        + Send;
1119    fn r#register_file(&self, payload: &PagerRegisterFileRequest) -> Self::RegisterFileResponseFut;
1120}
1121#[derive(Debug)]
1122#[cfg(target_os = "fuchsia")]
1123pub struct PagerSynchronousProxy {
1124    client: fidl::client::sync::Client,
1125}
1126
1127#[cfg(target_os = "fuchsia")]
1128impl fidl::endpoints::SynchronousProxy for PagerSynchronousProxy {
1129    type Proxy = PagerProxy;
1130    type Protocol = PagerMarker;
1131
1132    fn from_channel(inner: fidl::Channel) -> Self {
1133        Self::new(inner)
1134    }
1135
1136    fn into_channel(self) -> fidl::Channel {
1137        self.client.into_channel()
1138    }
1139
1140    fn as_channel(&self) -> &fidl::Channel {
1141        self.client.as_channel()
1142    }
1143}
1144
1145#[cfg(target_os = "fuchsia")]
1146impl PagerSynchronousProxy {
1147    pub fn new(channel: fidl::Channel) -> Self {
1148        let protocol_name = <PagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1149        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1150    }
1151
1152    pub fn into_channel(self) -> fidl::Channel {
1153        self.client.into_channel()
1154    }
1155
1156    /// Waits until an event arrives and returns it. It is safe for other
1157    /// threads to make concurrent requests while waiting for an event.
1158    pub fn wait_for_event(
1159        &self,
1160        deadline: zx::MonotonicInstant,
1161    ) -> Result<PagerEvent, fidl::Error> {
1162        PagerEvent::decode(self.client.wait_for_event(deadline)?)
1163    }
1164
1165    /// Registers a file with the pager.
1166    pub fn r#register_file(
1167        &self,
1168        mut payload: &PagerRegisterFileRequest,
1169        ___deadline: zx::MonotonicInstant,
1170    ) -> Result<PagerRegisterFileResult, fidl::Error> {
1171        let _response = self.client.send_query::<
1172            PagerRegisterFileRequest,
1173            fidl::encoding::FlexibleResultType<PagerRegisterFileResponse, i32>,
1174        >(
1175            payload,
1176            0x4f85a2ce6cae4aed,
1177            fidl::encoding::DynamicFlags::FLEXIBLE,
1178            ___deadline,
1179        )?
1180        .into_result::<PagerMarker>("register_file")?;
1181        Ok(_response.map(|x| x))
1182    }
1183}
1184
1185#[cfg(target_os = "fuchsia")]
1186impl From<PagerSynchronousProxy> for zx::Handle {
1187    fn from(value: PagerSynchronousProxy) -> Self {
1188        value.into_channel().into()
1189    }
1190}
1191
1192#[cfg(target_os = "fuchsia")]
1193impl From<fidl::Channel> for PagerSynchronousProxy {
1194    fn from(value: fidl::Channel) -> Self {
1195        Self::new(value)
1196    }
1197}
1198
1199#[cfg(target_os = "fuchsia")]
1200impl fidl::endpoints::FromClient for PagerSynchronousProxy {
1201    type Protocol = PagerMarker;
1202
1203    fn from_client(value: fidl::endpoints::ClientEnd<PagerMarker>) -> Self {
1204        Self::new(value.into_channel())
1205    }
1206}
1207
1208#[derive(Debug, Clone)]
1209pub struct PagerProxy {
1210    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1211}
1212
1213impl fidl::endpoints::Proxy for PagerProxy {
1214    type Protocol = PagerMarker;
1215
1216    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1217        Self::new(inner)
1218    }
1219
1220    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1221        self.client.into_channel().map_err(|client| Self { client })
1222    }
1223
1224    fn as_channel(&self) -> &::fidl::AsyncChannel {
1225        self.client.as_channel()
1226    }
1227}
1228
1229impl PagerProxy {
1230    /// Create a new Proxy for fuchsia.starnix.runner/Pager.
1231    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1232        let protocol_name = <PagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1233        Self { client: fidl::client::Client::new(channel, protocol_name) }
1234    }
1235
1236    /// Get a Stream of events from the remote end of the protocol.
1237    ///
1238    /// # Panics
1239    ///
1240    /// Panics if the event stream was already taken.
1241    pub fn take_event_stream(&self) -> PagerEventStream {
1242        PagerEventStream { event_receiver: self.client.take_event_receiver() }
1243    }
1244
1245    /// Registers a file with the pager.
1246    pub fn r#register_file(
1247        &self,
1248        mut payload: &PagerRegisterFileRequest,
1249    ) -> fidl::client::QueryResponseFut<
1250        PagerRegisterFileResult,
1251        fidl::encoding::DefaultFuchsiaResourceDialect,
1252    > {
1253        PagerProxyInterface::r#register_file(self, payload)
1254    }
1255}
1256
1257impl PagerProxyInterface for PagerProxy {
1258    type RegisterFileResponseFut = fidl::client::QueryResponseFut<
1259        PagerRegisterFileResult,
1260        fidl::encoding::DefaultFuchsiaResourceDialect,
1261    >;
1262    fn r#register_file(
1263        &self,
1264        mut payload: &PagerRegisterFileRequest,
1265    ) -> Self::RegisterFileResponseFut {
1266        fn _decode(
1267            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1268        ) -> Result<PagerRegisterFileResult, fidl::Error> {
1269            let _response = fidl::client::decode_transaction_body::<
1270                fidl::encoding::FlexibleResultType<PagerRegisterFileResponse, i32>,
1271                fidl::encoding::DefaultFuchsiaResourceDialect,
1272                0x4f85a2ce6cae4aed,
1273            >(_buf?)?
1274            .into_result::<PagerMarker>("register_file")?;
1275            Ok(_response.map(|x| x))
1276        }
1277        self.client.send_query_and_decode::<PagerRegisterFileRequest, PagerRegisterFileResult>(
1278            payload,
1279            0x4f85a2ce6cae4aed,
1280            fidl::encoding::DynamicFlags::FLEXIBLE,
1281            _decode,
1282        )
1283    }
1284}
1285
1286pub struct PagerEventStream {
1287    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1288}
1289
1290impl std::marker::Unpin for PagerEventStream {}
1291
1292impl futures::stream::FusedStream for PagerEventStream {
1293    fn is_terminated(&self) -> bool {
1294        self.event_receiver.is_terminated()
1295    }
1296}
1297
1298impl futures::Stream for PagerEventStream {
1299    type Item = Result<PagerEvent, fidl::Error>;
1300
1301    fn poll_next(
1302        mut self: std::pin::Pin<&mut Self>,
1303        cx: &mut std::task::Context<'_>,
1304    ) -> std::task::Poll<Option<Self::Item>> {
1305        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1306            &mut self.event_receiver,
1307            cx
1308        )?) {
1309            Some(buf) => std::task::Poll::Ready(Some(PagerEvent::decode(buf))),
1310            None => std::task::Poll::Ready(None),
1311        }
1312    }
1313}
1314
1315#[derive(Debug)]
1316pub enum PagerEvent {
1317    #[non_exhaustive]
1318    _UnknownEvent {
1319        /// Ordinal of the event that was sent.
1320        ordinal: u64,
1321    },
1322}
1323
1324impl PagerEvent {
1325    /// Decodes a message buffer as a [`PagerEvent`].
1326    fn decode(
1327        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1328    ) -> Result<PagerEvent, fidl::Error> {
1329        let (bytes, _handles) = buf.split_mut();
1330        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1331        debug_assert_eq!(tx_header.tx_id, 0);
1332        match tx_header.ordinal {
1333            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1334                Ok(PagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1335            }
1336            _ => Err(fidl::Error::UnknownOrdinal {
1337                ordinal: tx_header.ordinal,
1338                protocol_name: <PagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1339            }),
1340        }
1341    }
1342}
1343
1344/// A Stream of incoming requests for fuchsia.starnix.runner/Pager.
1345pub struct PagerRequestStream {
1346    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1347    is_terminated: bool,
1348}
1349
1350impl std::marker::Unpin for PagerRequestStream {}
1351
1352impl futures::stream::FusedStream for PagerRequestStream {
1353    fn is_terminated(&self) -> bool {
1354        self.is_terminated
1355    }
1356}
1357
1358impl fidl::endpoints::RequestStream for PagerRequestStream {
1359    type Protocol = PagerMarker;
1360    type ControlHandle = PagerControlHandle;
1361
1362    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1363        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1364    }
1365
1366    fn control_handle(&self) -> Self::ControlHandle {
1367        PagerControlHandle { inner: self.inner.clone() }
1368    }
1369
1370    fn into_inner(
1371        self,
1372    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1373    {
1374        (self.inner, self.is_terminated)
1375    }
1376
1377    fn from_inner(
1378        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1379        is_terminated: bool,
1380    ) -> Self {
1381        Self { inner, is_terminated }
1382    }
1383}
1384
1385impl futures::Stream for PagerRequestStream {
1386    type Item = Result<PagerRequest, fidl::Error>;
1387
1388    fn poll_next(
1389        mut self: std::pin::Pin<&mut Self>,
1390        cx: &mut std::task::Context<'_>,
1391    ) -> std::task::Poll<Option<Self::Item>> {
1392        let this = &mut *self;
1393        if this.inner.check_shutdown(cx) {
1394            this.is_terminated = true;
1395            return std::task::Poll::Ready(None);
1396        }
1397        if this.is_terminated {
1398            panic!("polled PagerRequestStream after completion");
1399        }
1400        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1401            |bytes, handles| {
1402                match this.inner.channel().read_etc(cx, bytes, handles) {
1403                    std::task::Poll::Ready(Ok(())) => {}
1404                    std::task::Poll::Pending => return std::task::Poll::Pending,
1405                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1406                        this.is_terminated = true;
1407                        return std::task::Poll::Ready(None);
1408                    }
1409                    std::task::Poll::Ready(Err(e)) => {
1410                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1411                            e.into(),
1412                        ))));
1413                    }
1414                }
1415
1416                // A message has been received from the channel
1417                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1418
1419                std::task::Poll::Ready(Some(match header.ordinal {
1420                    0x4f85a2ce6cae4aed => {
1421                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1422                        let mut req = fidl::new_empty!(
1423                            PagerRegisterFileRequest,
1424                            fidl::encoding::DefaultFuchsiaResourceDialect
1425                        );
1426                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PagerRegisterFileRequest>(&header, _body_bytes, handles, &mut req)?;
1427                        let control_handle = PagerControlHandle { inner: this.inner.clone() };
1428                        Ok(PagerRequest::RegisterFile {
1429                            payload: req,
1430                            responder: PagerRegisterFileResponder {
1431                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1432                                tx_id: header.tx_id,
1433                            },
1434                        })
1435                    }
1436                    _ if header.tx_id == 0
1437                        && header
1438                            .dynamic_flags()
1439                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1440                    {
1441                        Ok(PagerRequest::_UnknownMethod {
1442                            ordinal: header.ordinal,
1443                            control_handle: PagerControlHandle { inner: this.inner.clone() },
1444                            method_type: fidl::MethodType::OneWay,
1445                        })
1446                    }
1447                    _ if header
1448                        .dynamic_flags()
1449                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1450                    {
1451                        this.inner.send_framework_err(
1452                            fidl::encoding::FrameworkErr::UnknownMethod,
1453                            header.tx_id,
1454                            header.ordinal,
1455                            header.dynamic_flags(),
1456                            (bytes, handles),
1457                        )?;
1458                        Ok(PagerRequest::_UnknownMethod {
1459                            ordinal: header.ordinal,
1460                            control_handle: PagerControlHandle { inner: this.inner.clone() },
1461                            method_type: fidl::MethodType::TwoWay,
1462                        })
1463                    }
1464                    _ => Err(fidl::Error::UnknownOrdinal {
1465                        ordinal: header.ordinal,
1466                        protocol_name: <PagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1467                    }),
1468                }))
1469            },
1470        )
1471    }
1472}
1473
1474#[derive(Debug)]
1475pub enum PagerRequest {
1476    /// Registers a file with the pager.
1477    RegisterFile { payload: PagerRegisterFileRequest, responder: PagerRegisterFileResponder },
1478    /// An interaction was received which does not match any known method.
1479    #[non_exhaustive]
1480    _UnknownMethod {
1481        /// Ordinal of the method that was called.
1482        ordinal: u64,
1483        control_handle: PagerControlHandle,
1484        method_type: fidl::MethodType,
1485    },
1486}
1487
1488impl PagerRequest {
1489    #[allow(irrefutable_let_patterns)]
1490    pub fn into_register_file(
1491        self,
1492    ) -> Option<(PagerRegisterFileRequest, PagerRegisterFileResponder)> {
1493        if let PagerRequest::RegisterFile { payload, responder } = self {
1494            Some((payload, responder))
1495        } else {
1496            None
1497        }
1498    }
1499
1500    /// Name of the method defined in FIDL
1501    pub fn method_name(&self) -> &'static str {
1502        match *self {
1503            PagerRequest::RegisterFile { .. } => "register_file",
1504            PagerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1505                "unknown one-way method"
1506            }
1507            PagerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1508                "unknown two-way method"
1509            }
1510        }
1511    }
1512}
1513
1514#[derive(Debug, Clone)]
1515pub struct PagerControlHandle {
1516    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1517}
1518
1519impl fidl::endpoints::ControlHandle for PagerControlHandle {
1520    fn shutdown(&self) {
1521        self.inner.shutdown()
1522    }
1523    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1524        self.inner.shutdown_with_epitaph(status)
1525    }
1526
1527    fn is_closed(&self) -> bool {
1528        self.inner.channel().is_closed()
1529    }
1530    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1531        self.inner.channel().on_closed()
1532    }
1533
1534    #[cfg(target_os = "fuchsia")]
1535    fn signal_peer(
1536        &self,
1537        clear_mask: zx::Signals,
1538        set_mask: zx::Signals,
1539    ) -> Result<(), zx_status::Status> {
1540        use fidl::Peered;
1541        self.inner.channel().signal_peer(clear_mask, set_mask)
1542    }
1543}
1544
1545impl PagerControlHandle {}
1546
1547#[must_use = "FIDL methods require a response to be sent"]
1548#[derive(Debug)]
1549pub struct PagerRegisterFileResponder {
1550    control_handle: std::mem::ManuallyDrop<PagerControlHandle>,
1551    tx_id: u32,
1552}
1553
1554/// Set the the channel to be shutdown (see [`PagerControlHandle::shutdown`])
1555/// if the responder is dropped without sending a response, so that the client
1556/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1557impl std::ops::Drop for PagerRegisterFileResponder {
1558    fn drop(&mut self) {
1559        self.control_handle.shutdown();
1560        // Safety: drops once, never accessed again
1561        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1562    }
1563}
1564
1565impl fidl::endpoints::Responder for PagerRegisterFileResponder {
1566    type ControlHandle = PagerControlHandle;
1567
1568    fn control_handle(&self) -> &PagerControlHandle {
1569        &self.control_handle
1570    }
1571
1572    fn drop_without_shutdown(mut self) {
1573        // Safety: drops once, never accessed again due to mem::forget
1574        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1575        // Prevent Drop from running (which would shut down the channel)
1576        std::mem::forget(self);
1577    }
1578}
1579
1580impl PagerRegisterFileResponder {
1581    /// Sends a response to the FIDL transaction.
1582    ///
1583    /// Sets the channel to shutdown if an error occurs.
1584    pub fn send(
1585        self,
1586        mut result: Result<PagerRegisterFileResponse, i32>,
1587    ) -> Result<(), fidl::Error> {
1588        let _result = self.send_raw(result);
1589        if _result.is_err() {
1590            self.control_handle.shutdown();
1591        }
1592        self.drop_without_shutdown();
1593        _result
1594    }
1595
1596    /// Similar to "send" but does not shutdown the channel if an error occurs.
1597    pub fn send_no_shutdown_on_err(
1598        self,
1599        mut result: Result<PagerRegisterFileResponse, i32>,
1600    ) -> Result<(), fidl::Error> {
1601        let _result = self.send_raw(result);
1602        self.drop_without_shutdown();
1603        _result
1604    }
1605
1606    fn send_raw(
1607        &self,
1608        mut result: Result<PagerRegisterFileResponse, i32>,
1609    ) -> Result<(), fidl::Error> {
1610        self.control_handle
1611            .inner
1612            .send::<fidl::encoding::FlexibleResultType<PagerRegisterFileResponse, i32>>(
1613                fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
1614                self.tx_id,
1615                0x4f85a2ce6cae4aed,
1616                fidl::encoding::DynamicFlags::FLEXIBLE,
1617            )
1618    }
1619}
1620
1621mod internal {
1622    use super::*;
1623
1624    impl ManagerAddWakeSourceRequest {
1625        #[inline(always)]
1626        fn max_ordinal_present(&self) -> u64 {
1627            if let Some(_) = self.signals {
1628                return 4;
1629            }
1630            if let Some(_) = self.handle {
1631                return 3;
1632            }
1633            if let Some(_) = self.name {
1634                return 2;
1635            }
1636            if let Some(_) = self.container_job {
1637                return 1;
1638            }
1639            0
1640        }
1641    }
1642
1643    impl fidl::encoding::ResourceTypeMarker for ManagerAddWakeSourceRequest {
1644        type Borrowed<'a> = &'a mut Self;
1645        fn take_or_borrow<'a>(
1646            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1647        ) -> Self::Borrowed<'a> {
1648            value
1649        }
1650    }
1651
1652    unsafe impl fidl::encoding::TypeMarker for ManagerAddWakeSourceRequest {
1653        type Owned = Self;
1654
1655        #[inline(always)]
1656        fn inline_align(_context: fidl::encoding::Context) -> usize {
1657            8
1658        }
1659
1660        #[inline(always)]
1661        fn inline_size(_context: fidl::encoding::Context) -> usize {
1662            16
1663        }
1664    }
1665
1666    unsafe impl
1667        fidl::encoding::Encode<
1668            ManagerAddWakeSourceRequest,
1669            fidl::encoding::DefaultFuchsiaResourceDialect,
1670        > for &mut ManagerAddWakeSourceRequest
1671    {
1672        unsafe fn encode(
1673            self,
1674            encoder: &mut fidl::encoding::Encoder<
1675                '_,
1676                fidl::encoding::DefaultFuchsiaResourceDialect,
1677            >,
1678            offset: usize,
1679            mut depth: fidl::encoding::Depth,
1680        ) -> fidl::Result<()> {
1681            encoder.debug_check_bounds::<ManagerAddWakeSourceRequest>(offset);
1682            // Vector header
1683            let max_ordinal: u64 = self.max_ordinal_present();
1684            encoder.write_num(max_ordinal, offset);
1685            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1686            // Calling encoder.out_of_line_offset(0) is not allowed.
1687            if max_ordinal == 0 {
1688                return Ok(());
1689            }
1690            depth.increment()?;
1691            let envelope_size = 8;
1692            let bytes_len = max_ordinal as usize * envelope_size;
1693            #[allow(unused_variables)]
1694            let offset = encoder.out_of_line_offset(bytes_len);
1695            let mut _prev_end_offset: usize = 0;
1696            if 1 > max_ordinal {
1697                return Ok(());
1698            }
1699
1700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1701            // are envelope_size bytes.
1702            let cur_offset: usize = (1 - 1) * envelope_size;
1703
1704            // Zero reserved fields.
1705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1706
1707            // Safety:
1708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1710            //   envelope_size bytes, there is always sufficient room.
1711            fidl::encoding::encode_in_envelope_optional::<
1712                fidl::encoding::HandleType<
1713                    fidl::Job,
1714                    { fidl::ObjectType::JOB.into_raw() },
1715                    2147483648,
1716                >,
1717                fidl::encoding::DefaultFuchsiaResourceDialect,
1718            >(
1719                self.container_job.as_mut().map(
1720                    <fidl::encoding::HandleType<
1721                        fidl::Job,
1722                        { fidl::ObjectType::JOB.into_raw() },
1723                        2147483648,
1724                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1725                ),
1726                encoder,
1727                offset + cur_offset,
1728                depth,
1729            )?;
1730
1731            _prev_end_offset = cur_offset + envelope_size;
1732            if 2 > max_ordinal {
1733                return Ok(());
1734            }
1735
1736            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1737            // are envelope_size bytes.
1738            let cur_offset: usize = (2 - 1) * envelope_size;
1739
1740            // Zero reserved fields.
1741            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1742
1743            // Safety:
1744            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1745            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1746            //   envelope_size bytes, there is always sufficient room.
1747            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<1024>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1748            self.name.as_ref().map(<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow),
1749            encoder, offset + cur_offset, depth
1750        )?;
1751
1752            _prev_end_offset = cur_offset + envelope_size;
1753            if 3 > max_ordinal {
1754                return Ok(());
1755            }
1756
1757            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1758            // are envelope_size bytes.
1759            let cur_offset: usize = (3 - 1) * envelope_size;
1760
1761            // Zero reserved fields.
1762            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1763
1764            // Safety:
1765            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1766            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1767            //   envelope_size bytes, there is always sufficient room.
1768            fidl::encoding::encode_in_envelope_optional::<
1769                fidl::encoding::HandleType<
1770                    fidl::Handle,
1771                    { fidl::ObjectType::NONE.into_raw() },
1772                    2147483648,
1773                >,
1774                fidl::encoding::DefaultFuchsiaResourceDialect,
1775            >(
1776                self.handle.as_mut().map(
1777                    <fidl::encoding::HandleType<
1778                        fidl::Handle,
1779                        { fidl::ObjectType::NONE.into_raw() },
1780                        2147483648,
1781                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1782                ),
1783                encoder,
1784                offset + cur_offset,
1785                depth,
1786            )?;
1787
1788            _prev_end_offset = cur_offset + envelope_size;
1789            if 4 > max_ordinal {
1790                return Ok(());
1791            }
1792
1793            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1794            // are envelope_size bytes.
1795            let cur_offset: usize = (4 - 1) * envelope_size;
1796
1797            // Zero reserved fields.
1798            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1799
1800            // Safety:
1801            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1802            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1803            //   envelope_size bytes, there is always sufficient room.
1804            fidl::encoding::encode_in_envelope_optional::<
1805                u32,
1806                fidl::encoding::DefaultFuchsiaResourceDialect,
1807            >(
1808                self.signals.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
1809                encoder,
1810                offset + cur_offset,
1811                depth,
1812            )?;
1813
1814            _prev_end_offset = cur_offset + envelope_size;
1815
1816            Ok(())
1817        }
1818    }
1819
1820    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1821        for ManagerAddWakeSourceRequest
1822    {
1823        #[inline(always)]
1824        fn new_empty() -> Self {
1825            Self::default()
1826        }
1827
1828        unsafe fn decode(
1829            &mut self,
1830            decoder: &mut fidl::encoding::Decoder<
1831                '_,
1832                fidl::encoding::DefaultFuchsiaResourceDialect,
1833            >,
1834            offset: usize,
1835            mut depth: fidl::encoding::Depth,
1836        ) -> fidl::Result<()> {
1837            decoder.debug_check_bounds::<Self>(offset);
1838            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1839                None => return Err(fidl::Error::NotNullable),
1840                Some(len) => len,
1841            };
1842            // Calling decoder.out_of_line_offset(0) is not allowed.
1843            if len == 0 {
1844                return Ok(());
1845            };
1846            depth.increment()?;
1847            let envelope_size = 8;
1848            let bytes_len = len * envelope_size;
1849            let offset = decoder.out_of_line_offset(bytes_len)?;
1850            // Decode the envelope for each type.
1851            let mut _next_ordinal_to_read = 0;
1852            let mut next_offset = offset;
1853            let end_offset = offset + bytes_len;
1854            _next_ordinal_to_read += 1;
1855            if next_offset >= end_offset {
1856                return Ok(());
1857            }
1858
1859            // Decode unknown envelopes for gaps in ordinals.
1860            while _next_ordinal_to_read < 1 {
1861                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1862                _next_ordinal_to_read += 1;
1863                next_offset += envelope_size;
1864            }
1865
1866            let next_out_of_line = decoder.next_out_of_line();
1867            let handles_before = decoder.remaining_handles();
1868            if let Some((inlined, num_bytes, num_handles)) =
1869                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1870            {
1871                let member_inline_size = <fidl::encoding::HandleType<
1872                    fidl::Job,
1873                    { fidl::ObjectType::JOB.into_raw() },
1874                    2147483648,
1875                > as fidl::encoding::TypeMarker>::inline_size(
1876                    decoder.context
1877                );
1878                if inlined != (member_inline_size <= 4) {
1879                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1880                }
1881                let inner_offset;
1882                let mut inner_depth = depth.clone();
1883                if inlined {
1884                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1885                    inner_offset = next_offset;
1886                } else {
1887                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1888                    inner_depth.increment()?;
1889                }
1890                let val_ref =
1891                self.container_job.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1892                fidl::decode!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
1893                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1894                {
1895                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1896                }
1897                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1898                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1899                }
1900            }
1901
1902            next_offset += envelope_size;
1903            _next_ordinal_to_read += 1;
1904            if next_offset >= end_offset {
1905                return Ok(());
1906            }
1907
1908            // Decode unknown envelopes for gaps in ordinals.
1909            while _next_ordinal_to_read < 2 {
1910                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1911                _next_ordinal_to_read += 1;
1912                next_offset += envelope_size;
1913            }
1914
1915            let next_out_of_line = decoder.next_out_of_line();
1916            let handles_before = decoder.remaining_handles();
1917            if let Some((inlined, num_bytes, num_handles)) =
1918                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1919            {
1920                let member_inline_size = <fidl::encoding::BoundedString<1024> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1921                if inlined != (member_inline_size <= 4) {
1922                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1923                }
1924                let inner_offset;
1925                let mut inner_depth = depth.clone();
1926                if inlined {
1927                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1928                    inner_offset = next_offset;
1929                } else {
1930                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1931                    inner_depth.increment()?;
1932                }
1933                let val_ref = self.name.get_or_insert_with(|| {
1934                    fidl::new_empty!(
1935                        fidl::encoding::BoundedString<1024>,
1936                        fidl::encoding::DefaultFuchsiaResourceDialect
1937                    )
1938                });
1939                fidl::decode!(
1940                    fidl::encoding::BoundedString<1024>,
1941                    fidl::encoding::DefaultFuchsiaResourceDialect,
1942                    val_ref,
1943                    decoder,
1944                    inner_offset,
1945                    inner_depth
1946                )?;
1947                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1948                {
1949                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1950                }
1951                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1952                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1953                }
1954            }
1955
1956            next_offset += envelope_size;
1957            _next_ordinal_to_read += 1;
1958            if next_offset >= end_offset {
1959                return Ok(());
1960            }
1961
1962            // Decode unknown envelopes for gaps in ordinals.
1963            while _next_ordinal_to_read < 3 {
1964                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1965                _next_ordinal_to_read += 1;
1966                next_offset += envelope_size;
1967            }
1968
1969            let next_out_of_line = decoder.next_out_of_line();
1970            let handles_before = decoder.remaining_handles();
1971            if let Some((inlined, num_bytes, num_handles)) =
1972                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1973            {
1974                let member_inline_size = <fidl::encoding::HandleType<
1975                    fidl::Handle,
1976                    { fidl::ObjectType::NONE.into_raw() },
1977                    2147483648,
1978                > as fidl::encoding::TypeMarker>::inline_size(
1979                    decoder.context
1980                );
1981                if inlined != (member_inline_size <= 4) {
1982                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1983                }
1984                let inner_offset;
1985                let mut inner_depth = depth.clone();
1986                if inlined {
1987                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1988                    inner_offset = next_offset;
1989                } else {
1990                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1991                    inner_depth.increment()?;
1992                }
1993                let val_ref =
1994                self.handle.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
1995                fidl::decode!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, 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 < 4 {
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                    <u32 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.signals.get_or_insert_with(|| {
2038                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
2039                });
2040                fidl::decode!(
2041                    u32,
2042                    fidl::encoding::DefaultFuchsiaResourceDialect,
2043                    val_ref,
2044                    decoder,
2045                    inner_offset,
2046                    inner_depth
2047                )?;
2048                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2049                {
2050                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2051                }
2052                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2053                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2054                }
2055            }
2056
2057            next_offset += envelope_size;
2058
2059            // Decode the remaining unknown envelopes.
2060            while next_offset < end_offset {
2061                _next_ordinal_to_read += 1;
2062                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2063                next_offset += envelope_size;
2064            }
2065
2066            Ok(())
2067        }
2068    }
2069
2070    impl ManagerCreatePagerRequest {
2071        #[inline(always)]
2072        fn max_ordinal_present(&self) -> u64 {
2073            if let Some(_) = self.pager {
2074                return 3;
2075            }
2076            if let Some(_) = self.block_size {
2077                return 2;
2078            }
2079            if let Some(_) = self.backing_vmo {
2080                return 1;
2081            }
2082            0
2083        }
2084    }
2085
2086    impl fidl::encoding::ResourceTypeMarker for ManagerCreatePagerRequest {
2087        type Borrowed<'a> = &'a mut Self;
2088        fn take_or_borrow<'a>(
2089            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2090        ) -> Self::Borrowed<'a> {
2091            value
2092        }
2093    }
2094
2095    unsafe impl fidl::encoding::TypeMarker for ManagerCreatePagerRequest {
2096        type Owned = Self;
2097
2098        #[inline(always)]
2099        fn inline_align(_context: fidl::encoding::Context) -> usize {
2100            8
2101        }
2102
2103        #[inline(always)]
2104        fn inline_size(_context: fidl::encoding::Context) -> usize {
2105            16
2106        }
2107    }
2108
2109    unsafe impl
2110        fidl::encoding::Encode<
2111            ManagerCreatePagerRequest,
2112            fidl::encoding::DefaultFuchsiaResourceDialect,
2113        > for &mut ManagerCreatePagerRequest
2114    {
2115        unsafe fn encode(
2116            self,
2117            encoder: &mut fidl::encoding::Encoder<
2118                '_,
2119                fidl::encoding::DefaultFuchsiaResourceDialect,
2120            >,
2121            offset: usize,
2122            mut depth: fidl::encoding::Depth,
2123        ) -> fidl::Result<()> {
2124            encoder.debug_check_bounds::<ManagerCreatePagerRequest>(offset);
2125            // Vector header
2126            let max_ordinal: u64 = self.max_ordinal_present();
2127            encoder.write_num(max_ordinal, offset);
2128            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2129            // Calling encoder.out_of_line_offset(0) is not allowed.
2130            if max_ordinal == 0 {
2131                return Ok(());
2132            }
2133            depth.increment()?;
2134            let envelope_size = 8;
2135            let bytes_len = max_ordinal as usize * envelope_size;
2136            #[allow(unused_variables)]
2137            let offset = encoder.out_of_line_offset(bytes_len);
2138            let mut _prev_end_offset: usize = 0;
2139            if 1 > max_ordinal {
2140                return Ok(());
2141            }
2142
2143            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2144            // are envelope_size bytes.
2145            let cur_offset: usize = (1 - 1) * envelope_size;
2146
2147            // Zero reserved fields.
2148            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2149
2150            // Safety:
2151            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2152            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2153            //   envelope_size bytes, there is always sufficient room.
2154            fidl::encoding::encode_in_envelope_optional::<
2155                fidl::encoding::HandleType<
2156                    fidl::Vmo,
2157                    { fidl::ObjectType::VMO.into_raw() },
2158                    2147483648,
2159                >,
2160                fidl::encoding::DefaultFuchsiaResourceDialect,
2161            >(
2162                self.backing_vmo.as_mut().map(
2163                    <fidl::encoding::HandleType<
2164                        fidl::Vmo,
2165                        { fidl::ObjectType::VMO.into_raw() },
2166                        2147483648,
2167                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2168                ),
2169                encoder,
2170                offset + cur_offset,
2171                depth,
2172            )?;
2173
2174            _prev_end_offset = cur_offset + envelope_size;
2175            if 2 > max_ordinal {
2176                return Ok(());
2177            }
2178
2179            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2180            // are envelope_size bytes.
2181            let cur_offset: usize = (2 - 1) * envelope_size;
2182
2183            // Zero reserved fields.
2184            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2185
2186            // Safety:
2187            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2188            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2189            //   envelope_size bytes, there is always sufficient room.
2190            fidl::encoding::encode_in_envelope_optional::<
2191                u64,
2192                fidl::encoding::DefaultFuchsiaResourceDialect,
2193            >(
2194                self.block_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2195                encoder,
2196                offset + cur_offset,
2197                depth,
2198            )?;
2199
2200            _prev_end_offset = cur_offset + envelope_size;
2201            if 3 > max_ordinal {
2202                return Ok(());
2203            }
2204
2205            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2206            // are envelope_size bytes.
2207            let cur_offset: usize = (3 - 1) * envelope_size;
2208
2209            // Zero reserved fields.
2210            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2211
2212            // Safety:
2213            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2214            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2215            //   envelope_size bytes, there is always sufficient room.
2216            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PagerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2217            self.pager.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PagerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2218            encoder, offset + cur_offset, depth
2219        )?;
2220
2221            _prev_end_offset = cur_offset + envelope_size;
2222
2223            Ok(())
2224        }
2225    }
2226
2227    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2228        for ManagerCreatePagerRequest
2229    {
2230        #[inline(always)]
2231        fn new_empty() -> Self {
2232            Self::default()
2233        }
2234
2235        unsafe fn decode(
2236            &mut self,
2237            decoder: &mut fidl::encoding::Decoder<
2238                '_,
2239                fidl::encoding::DefaultFuchsiaResourceDialect,
2240            >,
2241            offset: usize,
2242            mut depth: fidl::encoding::Depth,
2243        ) -> fidl::Result<()> {
2244            decoder.debug_check_bounds::<Self>(offset);
2245            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2246                None => return Err(fidl::Error::NotNullable),
2247                Some(len) => len,
2248            };
2249            // Calling decoder.out_of_line_offset(0) is not allowed.
2250            if len == 0 {
2251                return Ok(());
2252            };
2253            depth.increment()?;
2254            let envelope_size = 8;
2255            let bytes_len = len * envelope_size;
2256            let offset = decoder.out_of_line_offset(bytes_len)?;
2257            // Decode the envelope for each type.
2258            let mut _next_ordinal_to_read = 0;
2259            let mut next_offset = offset;
2260            let end_offset = offset + bytes_len;
2261            _next_ordinal_to_read += 1;
2262            if next_offset >= end_offset {
2263                return Ok(());
2264            }
2265
2266            // Decode unknown envelopes for gaps in ordinals.
2267            while _next_ordinal_to_read < 1 {
2268                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2269                _next_ordinal_to_read += 1;
2270                next_offset += envelope_size;
2271            }
2272
2273            let next_out_of_line = decoder.next_out_of_line();
2274            let handles_before = decoder.remaining_handles();
2275            if let Some((inlined, num_bytes, num_handles)) =
2276                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2277            {
2278                let member_inline_size = <fidl::encoding::HandleType<
2279                    fidl::Vmo,
2280                    { fidl::ObjectType::VMO.into_raw() },
2281                    2147483648,
2282                > as fidl::encoding::TypeMarker>::inline_size(
2283                    decoder.context
2284                );
2285                if inlined != (member_inline_size <= 4) {
2286                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2287                }
2288                let inner_offset;
2289                let mut inner_depth = depth.clone();
2290                if inlined {
2291                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2292                    inner_offset = next_offset;
2293                } else {
2294                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2295                    inner_depth.increment()?;
2296                }
2297                let val_ref =
2298                self.backing_vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2299                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2300                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2301                {
2302                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2303                }
2304                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2305                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2306                }
2307            }
2308
2309            next_offset += envelope_size;
2310            _next_ordinal_to_read += 1;
2311            if next_offset >= end_offset {
2312                return Ok(());
2313            }
2314
2315            // Decode unknown envelopes for gaps in ordinals.
2316            while _next_ordinal_to_read < 2 {
2317                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2318                _next_ordinal_to_read += 1;
2319                next_offset += envelope_size;
2320            }
2321
2322            let next_out_of_line = decoder.next_out_of_line();
2323            let handles_before = decoder.remaining_handles();
2324            if let Some((inlined, num_bytes, num_handles)) =
2325                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2326            {
2327                let member_inline_size =
2328                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2329                if inlined != (member_inline_size <= 4) {
2330                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2331                }
2332                let inner_offset;
2333                let mut inner_depth = depth.clone();
2334                if inlined {
2335                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2336                    inner_offset = next_offset;
2337                } else {
2338                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2339                    inner_depth.increment()?;
2340                }
2341                let val_ref = self.block_size.get_or_insert_with(|| {
2342                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2343                });
2344                fidl::decode!(
2345                    u64,
2346                    fidl::encoding::DefaultFuchsiaResourceDialect,
2347                    val_ref,
2348                    decoder,
2349                    inner_offset,
2350                    inner_depth
2351                )?;
2352                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2353                {
2354                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2355                }
2356                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2357                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2358                }
2359            }
2360
2361            next_offset += envelope_size;
2362            _next_ordinal_to_read += 1;
2363            if next_offset >= end_offset {
2364                return Ok(());
2365            }
2366
2367            // Decode unknown envelopes for gaps in ordinals.
2368            while _next_ordinal_to_read < 3 {
2369                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2370                _next_ordinal_to_read += 1;
2371                next_offset += envelope_size;
2372            }
2373
2374            let next_out_of_line = decoder.next_out_of_line();
2375            let handles_before = decoder.remaining_handles();
2376            if let Some((inlined, num_bytes, num_handles)) =
2377                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2378            {
2379                let member_inline_size = <fidl::encoding::Endpoint<
2380                    fidl::endpoints::ServerEnd<PagerMarker>,
2381                > as fidl::encoding::TypeMarker>::inline_size(
2382                    decoder.context
2383                );
2384                if inlined != (member_inline_size <= 4) {
2385                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2386                }
2387                let inner_offset;
2388                let mut inner_depth = depth.clone();
2389                if inlined {
2390                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2391                    inner_offset = next_offset;
2392                } else {
2393                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2394                    inner_depth.increment()?;
2395                }
2396                let val_ref = self.pager.get_or_insert_with(|| {
2397                    fidl::new_empty!(
2398                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PagerMarker>>,
2399                        fidl::encoding::DefaultFuchsiaResourceDialect
2400                    )
2401                });
2402                fidl::decode!(
2403                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PagerMarker>>,
2404                    fidl::encoding::DefaultFuchsiaResourceDialect,
2405                    val_ref,
2406                    decoder,
2407                    inner_offset,
2408                    inner_depth
2409                )?;
2410                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2411                {
2412                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2413                }
2414                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2415                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2416                }
2417            }
2418
2419            next_offset += envelope_size;
2420
2421            // Decode the remaining unknown envelopes.
2422            while next_offset < end_offset {
2423                _next_ordinal_to_read += 1;
2424                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2425                next_offset += envelope_size;
2426            }
2427
2428            Ok(())
2429        }
2430    }
2431
2432    impl ManagerProxyWakeChannelRequest {
2433        #[inline(always)]
2434        fn max_ordinal_present(&self) -> u64 {
2435            if let Some(_) = self.counter {
2436                return 5;
2437            }
2438            if let Some(_) = self.name {
2439                return 4;
2440            }
2441            if let Some(_) = self.remote_channel {
2442                return 3;
2443            }
2444            if let Some(_) = self.container_channel {
2445                return 2;
2446            }
2447            if let Some(_) = self.container_job {
2448                return 1;
2449            }
2450            0
2451        }
2452    }
2453
2454    impl fidl::encoding::ResourceTypeMarker for ManagerProxyWakeChannelRequest {
2455        type Borrowed<'a> = &'a mut Self;
2456        fn take_or_borrow<'a>(
2457            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2458        ) -> Self::Borrowed<'a> {
2459            value
2460        }
2461    }
2462
2463    unsafe impl fidl::encoding::TypeMarker for ManagerProxyWakeChannelRequest {
2464        type Owned = Self;
2465
2466        #[inline(always)]
2467        fn inline_align(_context: fidl::encoding::Context) -> usize {
2468            8
2469        }
2470
2471        #[inline(always)]
2472        fn inline_size(_context: fidl::encoding::Context) -> usize {
2473            16
2474        }
2475    }
2476
2477    unsafe impl
2478        fidl::encoding::Encode<
2479            ManagerProxyWakeChannelRequest,
2480            fidl::encoding::DefaultFuchsiaResourceDialect,
2481        > for &mut ManagerProxyWakeChannelRequest
2482    {
2483        unsafe fn encode(
2484            self,
2485            encoder: &mut fidl::encoding::Encoder<
2486                '_,
2487                fidl::encoding::DefaultFuchsiaResourceDialect,
2488            >,
2489            offset: usize,
2490            mut depth: fidl::encoding::Depth,
2491        ) -> fidl::Result<()> {
2492            encoder.debug_check_bounds::<ManagerProxyWakeChannelRequest>(offset);
2493            // Vector header
2494            let max_ordinal: u64 = self.max_ordinal_present();
2495            encoder.write_num(max_ordinal, offset);
2496            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2497            // Calling encoder.out_of_line_offset(0) is not allowed.
2498            if max_ordinal == 0 {
2499                return Ok(());
2500            }
2501            depth.increment()?;
2502            let envelope_size = 8;
2503            let bytes_len = max_ordinal as usize * envelope_size;
2504            #[allow(unused_variables)]
2505            let offset = encoder.out_of_line_offset(bytes_len);
2506            let mut _prev_end_offset: usize = 0;
2507            if 1 > max_ordinal {
2508                return Ok(());
2509            }
2510
2511            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2512            // are envelope_size bytes.
2513            let cur_offset: usize = (1 - 1) * envelope_size;
2514
2515            // Zero reserved fields.
2516            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2517
2518            // Safety:
2519            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2520            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2521            //   envelope_size bytes, there is always sufficient room.
2522            fidl::encoding::encode_in_envelope_optional::<
2523                fidl::encoding::HandleType<
2524                    fidl::Job,
2525                    { fidl::ObjectType::JOB.into_raw() },
2526                    2147483648,
2527                >,
2528                fidl::encoding::DefaultFuchsiaResourceDialect,
2529            >(
2530                self.container_job.as_mut().map(
2531                    <fidl::encoding::HandleType<
2532                        fidl::Job,
2533                        { fidl::ObjectType::JOB.into_raw() },
2534                        2147483648,
2535                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2536                ),
2537                encoder,
2538                offset + cur_offset,
2539                depth,
2540            )?;
2541
2542            _prev_end_offset = cur_offset + envelope_size;
2543            if 2 > max_ordinal {
2544                return Ok(());
2545            }
2546
2547            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2548            // are envelope_size bytes.
2549            let cur_offset: usize = (2 - 1) * envelope_size;
2550
2551            // Zero reserved fields.
2552            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2553
2554            // Safety:
2555            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2556            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2557            //   envelope_size bytes, there is always sufficient room.
2558            fidl::encoding::encode_in_envelope_optional::<
2559                fidl::encoding::HandleType<
2560                    fidl::Channel,
2561                    { fidl::ObjectType::CHANNEL.into_raw() },
2562                    2147483648,
2563                >,
2564                fidl::encoding::DefaultFuchsiaResourceDialect,
2565            >(
2566                self.container_channel.as_mut().map(
2567                    <fidl::encoding::HandleType<
2568                        fidl::Channel,
2569                        { fidl::ObjectType::CHANNEL.into_raw() },
2570                        2147483648,
2571                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2572                ),
2573                encoder,
2574                offset + cur_offset,
2575                depth,
2576            )?;
2577
2578            _prev_end_offset = cur_offset + envelope_size;
2579            if 3 > max_ordinal {
2580                return Ok(());
2581            }
2582
2583            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2584            // are envelope_size bytes.
2585            let cur_offset: usize = (3 - 1) * envelope_size;
2586
2587            // Zero reserved fields.
2588            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2589
2590            // Safety:
2591            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2592            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2593            //   envelope_size bytes, there is always sufficient room.
2594            fidl::encoding::encode_in_envelope_optional::<
2595                fidl::encoding::HandleType<
2596                    fidl::Channel,
2597                    { fidl::ObjectType::CHANNEL.into_raw() },
2598                    2147483648,
2599                >,
2600                fidl::encoding::DefaultFuchsiaResourceDialect,
2601            >(
2602                self.remote_channel.as_mut().map(
2603                    <fidl::encoding::HandleType<
2604                        fidl::Channel,
2605                        { fidl::ObjectType::CHANNEL.into_raw() },
2606                        2147483648,
2607                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2608                ),
2609                encoder,
2610                offset + cur_offset,
2611                depth,
2612            )?;
2613
2614            _prev_end_offset = cur_offset + envelope_size;
2615            if 4 > max_ordinal {
2616                return Ok(());
2617            }
2618
2619            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2620            // are envelope_size bytes.
2621            let cur_offset: usize = (4 - 1) * envelope_size;
2622
2623            // Zero reserved fields.
2624            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2625
2626            // Safety:
2627            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2628            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2629            //   envelope_size bytes, there is always sufficient room.
2630            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<1024>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2631            self.name.as_ref().map(<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow),
2632            encoder, offset + cur_offset, depth
2633        )?;
2634
2635            _prev_end_offset = cur_offset + envelope_size;
2636            if 5 > max_ordinal {
2637                return Ok(());
2638            }
2639
2640            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2641            // are envelope_size bytes.
2642            let cur_offset: usize = (5 - 1) * envelope_size;
2643
2644            // Zero reserved fields.
2645            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2646
2647            // Safety:
2648            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2649            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2650            //   envelope_size bytes, there is always sufficient room.
2651            fidl::encoding::encode_in_envelope_optional::<
2652                fidl::encoding::HandleType<
2653                    fidl::Counter,
2654                    { fidl::ObjectType::COUNTER.into_raw() },
2655                    2147483648,
2656                >,
2657                fidl::encoding::DefaultFuchsiaResourceDialect,
2658            >(
2659                self.counter.as_mut().map(
2660                    <fidl::encoding::HandleType<
2661                        fidl::Counter,
2662                        { fidl::ObjectType::COUNTER.into_raw() },
2663                        2147483648,
2664                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2665                ),
2666                encoder,
2667                offset + cur_offset,
2668                depth,
2669            )?;
2670
2671            _prev_end_offset = cur_offset + envelope_size;
2672
2673            Ok(())
2674        }
2675    }
2676
2677    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2678        for ManagerProxyWakeChannelRequest
2679    {
2680        #[inline(always)]
2681        fn new_empty() -> Self {
2682            Self::default()
2683        }
2684
2685        unsafe fn decode(
2686            &mut self,
2687            decoder: &mut fidl::encoding::Decoder<
2688                '_,
2689                fidl::encoding::DefaultFuchsiaResourceDialect,
2690            >,
2691            offset: usize,
2692            mut depth: fidl::encoding::Depth,
2693        ) -> fidl::Result<()> {
2694            decoder.debug_check_bounds::<Self>(offset);
2695            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2696                None => return Err(fidl::Error::NotNullable),
2697                Some(len) => len,
2698            };
2699            // Calling decoder.out_of_line_offset(0) is not allowed.
2700            if len == 0 {
2701                return Ok(());
2702            };
2703            depth.increment()?;
2704            let envelope_size = 8;
2705            let bytes_len = len * envelope_size;
2706            let offset = decoder.out_of_line_offset(bytes_len)?;
2707            // Decode the envelope for each type.
2708            let mut _next_ordinal_to_read = 0;
2709            let mut next_offset = offset;
2710            let end_offset = offset + bytes_len;
2711            _next_ordinal_to_read += 1;
2712            if next_offset >= end_offset {
2713                return Ok(());
2714            }
2715
2716            // Decode unknown envelopes for gaps in ordinals.
2717            while _next_ordinal_to_read < 1 {
2718                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2719                _next_ordinal_to_read += 1;
2720                next_offset += envelope_size;
2721            }
2722
2723            let next_out_of_line = decoder.next_out_of_line();
2724            let handles_before = decoder.remaining_handles();
2725            if let Some((inlined, num_bytes, num_handles)) =
2726                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2727            {
2728                let member_inline_size = <fidl::encoding::HandleType<
2729                    fidl::Job,
2730                    { fidl::ObjectType::JOB.into_raw() },
2731                    2147483648,
2732                > as fidl::encoding::TypeMarker>::inline_size(
2733                    decoder.context
2734                );
2735                if inlined != (member_inline_size <= 4) {
2736                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2737                }
2738                let inner_offset;
2739                let mut inner_depth = depth.clone();
2740                if inlined {
2741                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2742                    inner_offset = next_offset;
2743                } else {
2744                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2745                    inner_depth.increment()?;
2746                }
2747                let val_ref =
2748                self.container_job.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2749                fidl::decode!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2750                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2751                {
2752                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2753                }
2754                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2755                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2756                }
2757            }
2758
2759            next_offset += envelope_size;
2760            _next_ordinal_to_read += 1;
2761            if next_offset >= end_offset {
2762                return Ok(());
2763            }
2764
2765            // Decode unknown envelopes for gaps in ordinals.
2766            while _next_ordinal_to_read < 2 {
2767                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2768                _next_ordinal_to_read += 1;
2769                next_offset += envelope_size;
2770            }
2771
2772            let next_out_of_line = decoder.next_out_of_line();
2773            let handles_before = decoder.remaining_handles();
2774            if let Some((inlined, num_bytes, num_handles)) =
2775                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2776            {
2777                let member_inline_size = <fidl::encoding::HandleType<
2778                    fidl::Channel,
2779                    { fidl::ObjectType::CHANNEL.into_raw() },
2780                    2147483648,
2781                > as fidl::encoding::TypeMarker>::inline_size(
2782                    decoder.context
2783                );
2784                if inlined != (member_inline_size <= 4) {
2785                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2786                }
2787                let inner_offset;
2788                let mut inner_depth = depth.clone();
2789                if inlined {
2790                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2791                    inner_offset = next_offset;
2792                } else {
2793                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2794                    inner_depth.increment()?;
2795                }
2796                let val_ref =
2797                self.container_channel.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2798                fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2799                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2800                {
2801                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2802                }
2803                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2804                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2805                }
2806            }
2807
2808            next_offset += envelope_size;
2809            _next_ordinal_to_read += 1;
2810            if next_offset >= end_offset {
2811                return Ok(());
2812            }
2813
2814            // Decode unknown envelopes for gaps in ordinals.
2815            while _next_ordinal_to_read < 3 {
2816                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2817                _next_ordinal_to_read += 1;
2818                next_offset += envelope_size;
2819            }
2820
2821            let next_out_of_line = decoder.next_out_of_line();
2822            let handles_before = decoder.remaining_handles();
2823            if let Some((inlined, num_bytes, num_handles)) =
2824                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2825            {
2826                let member_inline_size = <fidl::encoding::HandleType<
2827                    fidl::Channel,
2828                    { fidl::ObjectType::CHANNEL.into_raw() },
2829                    2147483648,
2830                > as fidl::encoding::TypeMarker>::inline_size(
2831                    decoder.context
2832                );
2833                if inlined != (member_inline_size <= 4) {
2834                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2835                }
2836                let inner_offset;
2837                let mut inner_depth = depth.clone();
2838                if inlined {
2839                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2840                    inner_offset = next_offset;
2841                } else {
2842                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2843                    inner_depth.increment()?;
2844                }
2845                let val_ref =
2846                self.remote_channel.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2847                fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2848                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2849                {
2850                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2851                }
2852                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2853                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2854                }
2855            }
2856
2857            next_offset += envelope_size;
2858            _next_ordinal_to_read += 1;
2859            if next_offset >= end_offset {
2860                return Ok(());
2861            }
2862
2863            // Decode unknown envelopes for gaps in ordinals.
2864            while _next_ordinal_to_read < 4 {
2865                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2866                _next_ordinal_to_read += 1;
2867                next_offset += envelope_size;
2868            }
2869
2870            let next_out_of_line = decoder.next_out_of_line();
2871            let handles_before = decoder.remaining_handles();
2872            if let Some((inlined, num_bytes, num_handles)) =
2873                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2874            {
2875                let member_inline_size = <fidl::encoding::BoundedString<1024> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2876                if inlined != (member_inline_size <= 4) {
2877                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2878                }
2879                let inner_offset;
2880                let mut inner_depth = depth.clone();
2881                if inlined {
2882                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2883                    inner_offset = next_offset;
2884                } else {
2885                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2886                    inner_depth.increment()?;
2887                }
2888                let val_ref = self.name.get_or_insert_with(|| {
2889                    fidl::new_empty!(
2890                        fidl::encoding::BoundedString<1024>,
2891                        fidl::encoding::DefaultFuchsiaResourceDialect
2892                    )
2893                });
2894                fidl::decode!(
2895                    fidl::encoding::BoundedString<1024>,
2896                    fidl::encoding::DefaultFuchsiaResourceDialect,
2897                    val_ref,
2898                    decoder,
2899                    inner_offset,
2900                    inner_depth
2901                )?;
2902                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2903                {
2904                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2905                }
2906                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2907                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2908                }
2909            }
2910
2911            next_offset += envelope_size;
2912            _next_ordinal_to_read += 1;
2913            if next_offset >= end_offset {
2914                return Ok(());
2915            }
2916
2917            // Decode unknown envelopes for gaps in ordinals.
2918            while _next_ordinal_to_read < 5 {
2919                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2920                _next_ordinal_to_read += 1;
2921                next_offset += envelope_size;
2922            }
2923
2924            let next_out_of_line = decoder.next_out_of_line();
2925            let handles_before = decoder.remaining_handles();
2926            if let Some((inlined, num_bytes, num_handles)) =
2927                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2928            {
2929                let member_inline_size = <fidl::encoding::HandleType<
2930                    fidl::Counter,
2931                    { fidl::ObjectType::COUNTER.into_raw() },
2932                    2147483648,
2933                > as fidl::encoding::TypeMarker>::inline_size(
2934                    decoder.context
2935                );
2936                if inlined != (member_inline_size <= 4) {
2937                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2938                }
2939                let inner_offset;
2940                let mut inner_depth = depth.clone();
2941                if inlined {
2942                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2943                    inner_offset = next_offset;
2944                } else {
2945                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2946                    inner_depth.increment()?;
2947                }
2948                let val_ref =
2949                self.counter.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Counter, { fidl::ObjectType::COUNTER.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2950                fidl::decode!(fidl::encoding::HandleType<fidl::Counter, { fidl::ObjectType::COUNTER.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2951                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2952                {
2953                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2954                }
2955                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2956                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2957                }
2958            }
2959
2960            next_offset += envelope_size;
2961
2962            // Decode the remaining unknown envelopes.
2963            while next_offset < end_offset {
2964                _next_ordinal_to_read += 1;
2965                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2966                next_offset += envelope_size;
2967            }
2968
2969            Ok(())
2970        }
2971    }
2972
2973    impl ManagerRegisterWakeWatcherRequest {
2974        #[inline(always)]
2975        fn max_ordinal_present(&self) -> u64 {
2976            if let Some(_) = self.watcher {
2977                return 1;
2978            }
2979            0
2980        }
2981    }
2982
2983    impl fidl::encoding::ResourceTypeMarker for ManagerRegisterWakeWatcherRequest {
2984        type Borrowed<'a> = &'a mut Self;
2985        fn take_or_borrow<'a>(
2986            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2987        ) -> Self::Borrowed<'a> {
2988            value
2989        }
2990    }
2991
2992    unsafe impl fidl::encoding::TypeMarker for ManagerRegisterWakeWatcherRequest {
2993        type Owned = Self;
2994
2995        #[inline(always)]
2996        fn inline_align(_context: fidl::encoding::Context) -> usize {
2997            8
2998        }
2999
3000        #[inline(always)]
3001        fn inline_size(_context: fidl::encoding::Context) -> usize {
3002            16
3003        }
3004    }
3005
3006    unsafe impl
3007        fidl::encoding::Encode<
3008            ManagerRegisterWakeWatcherRequest,
3009            fidl::encoding::DefaultFuchsiaResourceDialect,
3010        > for &mut ManagerRegisterWakeWatcherRequest
3011    {
3012        unsafe fn encode(
3013            self,
3014            encoder: &mut fidl::encoding::Encoder<
3015                '_,
3016                fidl::encoding::DefaultFuchsiaResourceDialect,
3017            >,
3018            offset: usize,
3019            mut depth: fidl::encoding::Depth,
3020        ) -> fidl::Result<()> {
3021            encoder.debug_check_bounds::<ManagerRegisterWakeWatcherRequest>(offset);
3022            // Vector header
3023            let max_ordinal: u64 = self.max_ordinal_present();
3024            encoder.write_num(max_ordinal, offset);
3025            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3026            // Calling encoder.out_of_line_offset(0) is not allowed.
3027            if max_ordinal == 0 {
3028                return Ok(());
3029            }
3030            depth.increment()?;
3031            let envelope_size = 8;
3032            let bytes_len = max_ordinal as usize * envelope_size;
3033            #[allow(unused_variables)]
3034            let offset = encoder.out_of_line_offset(bytes_len);
3035            let mut _prev_end_offset: usize = 0;
3036            if 1 > max_ordinal {
3037                return Ok(());
3038            }
3039
3040            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3041            // are envelope_size bytes.
3042            let cur_offset: usize = (1 - 1) * envelope_size;
3043
3044            // Zero reserved fields.
3045            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3046
3047            // Safety:
3048            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3049            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3050            //   envelope_size bytes, there is always sufficient room.
3051            fidl::encoding::encode_in_envelope_optional::<
3052                fidl::encoding::HandleType<
3053                    fidl::EventPair,
3054                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3055                    2147483648,
3056                >,
3057                fidl::encoding::DefaultFuchsiaResourceDialect,
3058            >(
3059                self.watcher.as_mut().map(
3060                    <fidl::encoding::HandleType<
3061                        fidl::EventPair,
3062                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3063                        2147483648,
3064                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3065                ),
3066                encoder,
3067                offset + cur_offset,
3068                depth,
3069            )?;
3070
3071            _prev_end_offset = cur_offset + envelope_size;
3072
3073            Ok(())
3074        }
3075    }
3076
3077    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3078        for ManagerRegisterWakeWatcherRequest
3079    {
3080        #[inline(always)]
3081        fn new_empty() -> Self {
3082            Self::default()
3083        }
3084
3085        unsafe fn decode(
3086            &mut self,
3087            decoder: &mut fidl::encoding::Decoder<
3088                '_,
3089                fidl::encoding::DefaultFuchsiaResourceDialect,
3090            >,
3091            offset: usize,
3092            mut depth: fidl::encoding::Depth,
3093        ) -> fidl::Result<()> {
3094            decoder.debug_check_bounds::<Self>(offset);
3095            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3096                None => return Err(fidl::Error::NotNullable),
3097                Some(len) => len,
3098            };
3099            // Calling decoder.out_of_line_offset(0) is not allowed.
3100            if len == 0 {
3101                return Ok(());
3102            };
3103            depth.increment()?;
3104            let envelope_size = 8;
3105            let bytes_len = len * envelope_size;
3106            let offset = decoder.out_of_line_offset(bytes_len)?;
3107            // Decode the envelope for each type.
3108            let mut _next_ordinal_to_read = 0;
3109            let mut next_offset = offset;
3110            let end_offset = offset + bytes_len;
3111            _next_ordinal_to_read += 1;
3112            if next_offset >= end_offset {
3113                return Ok(());
3114            }
3115
3116            // Decode unknown envelopes for gaps in ordinals.
3117            while _next_ordinal_to_read < 1 {
3118                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3119                _next_ordinal_to_read += 1;
3120                next_offset += envelope_size;
3121            }
3122
3123            let next_out_of_line = decoder.next_out_of_line();
3124            let handles_before = decoder.remaining_handles();
3125            if let Some((inlined, num_bytes, num_handles)) =
3126                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3127            {
3128                let member_inline_size = <fidl::encoding::HandleType<
3129                    fidl::EventPair,
3130                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3131                    2147483648,
3132                > as fidl::encoding::TypeMarker>::inline_size(
3133                    decoder.context
3134                );
3135                if inlined != (member_inline_size <= 4) {
3136                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3137                }
3138                let inner_offset;
3139                let mut inner_depth = depth.clone();
3140                if inlined {
3141                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3142                    inner_offset = next_offset;
3143                } else {
3144                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3145                    inner_depth.increment()?;
3146                }
3147                let val_ref =
3148                self.watcher.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3149                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3150                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3151                {
3152                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3153                }
3154                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3155                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3156                }
3157            }
3158
3159            next_offset += envelope_size;
3160
3161            // Decode the remaining unknown envelopes.
3162            while next_offset < end_offset {
3163                _next_ordinal_to_read += 1;
3164                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3165                next_offset += envelope_size;
3166            }
3167
3168            Ok(())
3169        }
3170    }
3171
3172    impl ManagerRemoveWakeSourceRequest {
3173        #[inline(always)]
3174        fn max_ordinal_present(&self) -> u64 {
3175            if let Some(_) = self.handle {
3176                return 2;
3177            }
3178            if let Some(_) = self.container_job {
3179                return 1;
3180            }
3181            0
3182        }
3183    }
3184
3185    impl fidl::encoding::ResourceTypeMarker for ManagerRemoveWakeSourceRequest {
3186        type Borrowed<'a> = &'a mut Self;
3187        fn take_or_borrow<'a>(
3188            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3189        ) -> Self::Borrowed<'a> {
3190            value
3191        }
3192    }
3193
3194    unsafe impl fidl::encoding::TypeMarker for ManagerRemoveWakeSourceRequest {
3195        type Owned = Self;
3196
3197        #[inline(always)]
3198        fn inline_align(_context: fidl::encoding::Context) -> usize {
3199            8
3200        }
3201
3202        #[inline(always)]
3203        fn inline_size(_context: fidl::encoding::Context) -> usize {
3204            16
3205        }
3206    }
3207
3208    unsafe impl
3209        fidl::encoding::Encode<
3210            ManagerRemoveWakeSourceRequest,
3211            fidl::encoding::DefaultFuchsiaResourceDialect,
3212        > for &mut ManagerRemoveWakeSourceRequest
3213    {
3214        unsafe fn encode(
3215            self,
3216            encoder: &mut fidl::encoding::Encoder<
3217                '_,
3218                fidl::encoding::DefaultFuchsiaResourceDialect,
3219            >,
3220            offset: usize,
3221            mut depth: fidl::encoding::Depth,
3222        ) -> fidl::Result<()> {
3223            encoder.debug_check_bounds::<ManagerRemoveWakeSourceRequest>(offset);
3224            // Vector header
3225            let max_ordinal: u64 = self.max_ordinal_present();
3226            encoder.write_num(max_ordinal, offset);
3227            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3228            // Calling encoder.out_of_line_offset(0) is not allowed.
3229            if max_ordinal == 0 {
3230                return Ok(());
3231            }
3232            depth.increment()?;
3233            let envelope_size = 8;
3234            let bytes_len = max_ordinal as usize * envelope_size;
3235            #[allow(unused_variables)]
3236            let offset = encoder.out_of_line_offset(bytes_len);
3237            let mut _prev_end_offset: usize = 0;
3238            if 1 > max_ordinal {
3239                return Ok(());
3240            }
3241
3242            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3243            // are envelope_size bytes.
3244            let cur_offset: usize = (1 - 1) * envelope_size;
3245
3246            // Zero reserved fields.
3247            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3248
3249            // Safety:
3250            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3251            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3252            //   envelope_size bytes, there is always sufficient room.
3253            fidl::encoding::encode_in_envelope_optional::<
3254                fidl::encoding::HandleType<
3255                    fidl::Job,
3256                    { fidl::ObjectType::JOB.into_raw() },
3257                    2147483648,
3258                >,
3259                fidl::encoding::DefaultFuchsiaResourceDialect,
3260            >(
3261                self.container_job.as_mut().map(
3262                    <fidl::encoding::HandleType<
3263                        fidl::Job,
3264                        { fidl::ObjectType::JOB.into_raw() },
3265                        2147483648,
3266                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3267                ),
3268                encoder,
3269                offset + cur_offset,
3270                depth,
3271            )?;
3272
3273            _prev_end_offset = cur_offset + envelope_size;
3274            if 2 > max_ordinal {
3275                return Ok(());
3276            }
3277
3278            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3279            // are envelope_size bytes.
3280            let cur_offset: usize = (2 - 1) * envelope_size;
3281
3282            // Zero reserved fields.
3283            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3284
3285            // Safety:
3286            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3287            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3288            //   envelope_size bytes, there is always sufficient room.
3289            fidl::encoding::encode_in_envelope_optional::<
3290                fidl::encoding::HandleType<
3291                    fidl::Handle,
3292                    { fidl::ObjectType::NONE.into_raw() },
3293                    2147483648,
3294                >,
3295                fidl::encoding::DefaultFuchsiaResourceDialect,
3296            >(
3297                self.handle.as_mut().map(
3298                    <fidl::encoding::HandleType<
3299                        fidl::Handle,
3300                        { fidl::ObjectType::NONE.into_raw() },
3301                        2147483648,
3302                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3303                ),
3304                encoder,
3305                offset + cur_offset,
3306                depth,
3307            )?;
3308
3309            _prev_end_offset = cur_offset + envelope_size;
3310
3311            Ok(())
3312        }
3313    }
3314
3315    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3316        for ManagerRemoveWakeSourceRequest
3317    {
3318        #[inline(always)]
3319        fn new_empty() -> Self {
3320            Self::default()
3321        }
3322
3323        unsafe fn decode(
3324            &mut self,
3325            decoder: &mut fidl::encoding::Decoder<
3326                '_,
3327                fidl::encoding::DefaultFuchsiaResourceDialect,
3328            >,
3329            offset: usize,
3330            mut depth: fidl::encoding::Depth,
3331        ) -> fidl::Result<()> {
3332            decoder.debug_check_bounds::<Self>(offset);
3333            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3334                None => return Err(fidl::Error::NotNullable),
3335                Some(len) => len,
3336            };
3337            // Calling decoder.out_of_line_offset(0) is not allowed.
3338            if len == 0 {
3339                return Ok(());
3340            };
3341            depth.increment()?;
3342            let envelope_size = 8;
3343            let bytes_len = len * envelope_size;
3344            let offset = decoder.out_of_line_offset(bytes_len)?;
3345            // Decode the envelope for each type.
3346            let mut _next_ordinal_to_read = 0;
3347            let mut next_offset = offset;
3348            let end_offset = offset + bytes_len;
3349            _next_ordinal_to_read += 1;
3350            if next_offset >= end_offset {
3351                return Ok(());
3352            }
3353
3354            // Decode unknown envelopes for gaps in ordinals.
3355            while _next_ordinal_to_read < 1 {
3356                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3357                _next_ordinal_to_read += 1;
3358                next_offset += envelope_size;
3359            }
3360
3361            let next_out_of_line = decoder.next_out_of_line();
3362            let handles_before = decoder.remaining_handles();
3363            if let Some((inlined, num_bytes, num_handles)) =
3364                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3365            {
3366                let member_inline_size = <fidl::encoding::HandleType<
3367                    fidl::Job,
3368                    { fidl::ObjectType::JOB.into_raw() },
3369                    2147483648,
3370                > as fidl::encoding::TypeMarker>::inline_size(
3371                    decoder.context
3372                );
3373                if inlined != (member_inline_size <= 4) {
3374                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3375                }
3376                let inner_offset;
3377                let mut inner_depth = depth.clone();
3378                if inlined {
3379                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3380                    inner_offset = next_offset;
3381                } else {
3382                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3383                    inner_depth.increment()?;
3384                }
3385                let val_ref =
3386                self.container_job.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3387                fidl::decode!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3388                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3389                {
3390                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3391                }
3392                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3393                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3394                }
3395            }
3396
3397            next_offset += envelope_size;
3398            _next_ordinal_to_read += 1;
3399            if next_offset >= end_offset {
3400                return Ok(());
3401            }
3402
3403            // Decode unknown envelopes for gaps in ordinals.
3404            while _next_ordinal_to_read < 2 {
3405                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3406                _next_ordinal_to_read += 1;
3407                next_offset += envelope_size;
3408            }
3409
3410            let next_out_of_line = decoder.next_out_of_line();
3411            let handles_before = decoder.remaining_handles();
3412            if let Some((inlined, num_bytes, num_handles)) =
3413                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3414            {
3415                let member_inline_size = <fidl::encoding::HandleType<
3416                    fidl::Handle,
3417                    { fidl::ObjectType::NONE.into_raw() },
3418                    2147483648,
3419                > as fidl::encoding::TypeMarker>::inline_size(
3420                    decoder.context
3421                );
3422                if inlined != (member_inline_size <= 4) {
3423                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3424                }
3425                let inner_offset;
3426                let mut inner_depth = depth.clone();
3427                if inlined {
3428                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3429                    inner_offset = next_offset;
3430                } else {
3431                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3432                    inner_depth.increment()?;
3433                }
3434                let val_ref =
3435                self.handle.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3436                fidl::decode!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3437                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3438                {
3439                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3440                }
3441                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3442                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3443                }
3444            }
3445
3446            next_offset += envelope_size;
3447
3448            // Decode the remaining unknown envelopes.
3449            while next_offset < end_offset {
3450                _next_ordinal_to_read += 1;
3451                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3452                next_offset += envelope_size;
3453            }
3454
3455            Ok(())
3456        }
3457    }
3458
3459    impl ManagerSuspendContainerRequest {
3460        #[inline(always)]
3461        fn max_ordinal_present(&self) -> u64 {
3462            if let Some(_) = self.wake_locks {
3463                return 2;
3464            }
3465            if let Some(_) = self.container_job {
3466                return 1;
3467            }
3468            0
3469        }
3470    }
3471
3472    impl fidl::encoding::ResourceTypeMarker for ManagerSuspendContainerRequest {
3473        type Borrowed<'a> = &'a mut Self;
3474        fn take_or_borrow<'a>(
3475            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3476        ) -> Self::Borrowed<'a> {
3477            value
3478        }
3479    }
3480
3481    unsafe impl fidl::encoding::TypeMarker for ManagerSuspendContainerRequest {
3482        type Owned = Self;
3483
3484        #[inline(always)]
3485        fn inline_align(_context: fidl::encoding::Context) -> usize {
3486            8
3487        }
3488
3489        #[inline(always)]
3490        fn inline_size(_context: fidl::encoding::Context) -> usize {
3491            16
3492        }
3493    }
3494
3495    unsafe impl
3496        fidl::encoding::Encode<
3497            ManagerSuspendContainerRequest,
3498            fidl::encoding::DefaultFuchsiaResourceDialect,
3499        > for &mut ManagerSuspendContainerRequest
3500    {
3501        unsafe fn encode(
3502            self,
3503            encoder: &mut fidl::encoding::Encoder<
3504                '_,
3505                fidl::encoding::DefaultFuchsiaResourceDialect,
3506            >,
3507            offset: usize,
3508            mut depth: fidl::encoding::Depth,
3509        ) -> fidl::Result<()> {
3510            encoder.debug_check_bounds::<ManagerSuspendContainerRequest>(offset);
3511            // Vector header
3512            let max_ordinal: u64 = self.max_ordinal_present();
3513            encoder.write_num(max_ordinal, offset);
3514            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3515            // Calling encoder.out_of_line_offset(0) is not allowed.
3516            if max_ordinal == 0 {
3517                return Ok(());
3518            }
3519            depth.increment()?;
3520            let envelope_size = 8;
3521            let bytes_len = max_ordinal as usize * envelope_size;
3522            #[allow(unused_variables)]
3523            let offset = encoder.out_of_line_offset(bytes_len);
3524            let mut _prev_end_offset: usize = 0;
3525            if 1 > max_ordinal {
3526                return Ok(());
3527            }
3528
3529            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3530            // are envelope_size bytes.
3531            let cur_offset: usize = (1 - 1) * envelope_size;
3532
3533            // Zero reserved fields.
3534            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3535
3536            // Safety:
3537            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3538            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3539            //   envelope_size bytes, there is always sufficient room.
3540            fidl::encoding::encode_in_envelope_optional::<
3541                fidl::encoding::HandleType<
3542                    fidl::Job,
3543                    { fidl::ObjectType::JOB.into_raw() },
3544                    2147483648,
3545                >,
3546                fidl::encoding::DefaultFuchsiaResourceDialect,
3547            >(
3548                self.container_job.as_mut().map(
3549                    <fidl::encoding::HandleType<
3550                        fidl::Job,
3551                        { fidl::ObjectType::JOB.into_raw() },
3552                        2147483648,
3553                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3554                ),
3555                encoder,
3556                offset + cur_offset,
3557                depth,
3558            )?;
3559
3560            _prev_end_offset = cur_offset + envelope_size;
3561            if 2 > max_ordinal {
3562                return Ok(());
3563            }
3564
3565            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3566            // are envelope_size bytes.
3567            let cur_offset: usize = (2 - 1) * envelope_size;
3568
3569            // Zero reserved fields.
3570            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3571
3572            // Safety:
3573            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3574            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3575            //   envelope_size bytes, there is always sufficient room.
3576            fidl::encoding::encode_in_envelope_optional::<
3577                fidl::encoding::HandleType<
3578                    fidl::EventPair,
3579                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3580                    2147483648,
3581                >,
3582                fidl::encoding::DefaultFuchsiaResourceDialect,
3583            >(
3584                self.wake_locks.as_mut().map(
3585                    <fidl::encoding::HandleType<
3586                        fidl::EventPair,
3587                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3588                        2147483648,
3589                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3590                ),
3591                encoder,
3592                offset + cur_offset,
3593                depth,
3594            )?;
3595
3596            _prev_end_offset = cur_offset + envelope_size;
3597
3598            Ok(())
3599        }
3600    }
3601
3602    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3603        for ManagerSuspendContainerRequest
3604    {
3605        #[inline(always)]
3606        fn new_empty() -> Self {
3607            Self::default()
3608        }
3609
3610        unsafe fn decode(
3611            &mut self,
3612            decoder: &mut fidl::encoding::Decoder<
3613                '_,
3614                fidl::encoding::DefaultFuchsiaResourceDialect,
3615            >,
3616            offset: usize,
3617            mut depth: fidl::encoding::Depth,
3618        ) -> fidl::Result<()> {
3619            decoder.debug_check_bounds::<Self>(offset);
3620            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3621                None => return Err(fidl::Error::NotNullable),
3622                Some(len) => len,
3623            };
3624            // Calling decoder.out_of_line_offset(0) is not allowed.
3625            if len == 0 {
3626                return Ok(());
3627            };
3628            depth.increment()?;
3629            let envelope_size = 8;
3630            let bytes_len = len * envelope_size;
3631            let offset = decoder.out_of_line_offset(bytes_len)?;
3632            // Decode the envelope for each type.
3633            let mut _next_ordinal_to_read = 0;
3634            let mut next_offset = offset;
3635            let end_offset = offset + bytes_len;
3636            _next_ordinal_to_read += 1;
3637            if next_offset >= end_offset {
3638                return Ok(());
3639            }
3640
3641            // Decode unknown envelopes for gaps in ordinals.
3642            while _next_ordinal_to_read < 1 {
3643                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3644                _next_ordinal_to_read += 1;
3645                next_offset += envelope_size;
3646            }
3647
3648            let next_out_of_line = decoder.next_out_of_line();
3649            let handles_before = decoder.remaining_handles();
3650            if let Some((inlined, num_bytes, num_handles)) =
3651                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3652            {
3653                let member_inline_size = <fidl::encoding::HandleType<
3654                    fidl::Job,
3655                    { fidl::ObjectType::JOB.into_raw() },
3656                    2147483648,
3657                > as fidl::encoding::TypeMarker>::inline_size(
3658                    decoder.context
3659                );
3660                if inlined != (member_inline_size <= 4) {
3661                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3662                }
3663                let inner_offset;
3664                let mut inner_depth = depth.clone();
3665                if inlined {
3666                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3667                    inner_offset = next_offset;
3668                } else {
3669                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3670                    inner_depth.increment()?;
3671                }
3672                let val_ref =
3673                self.container_job.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3674                fidl::decode!(fidl::encoding::HandleType<fidl::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3675                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3676                {
3677                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3678                }
3679                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3680                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3681                }
3682            }
3683
3684            next_offset += envelope_size;
3685            _next_ordinal_to_read += 1;
3686            if next_offset >= end_offset {
3687                return Ok(());
3688            }
3689
3690            // Decode unknown envelopes for gaps in ordinals.
3691            while _next_ordinal_to_read < 2 {
3692                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3693                _next_ordinal_to_read += 1;
3694                next_offset += envelope_size;
3695            }
3696
3697            let next_out_of_line = decoder.next_out_of_line();
3698            let handles_before = decoder.remaining_handles();
3699            if let Some((inlined, num_bytes, num_handles)) =
3700                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3701            {
3702                let member_inline_size = <fidl::encoding::HandleType<
3703                    fidl::EventPair,
3704                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3705                    2147483648,
3706                > as fidl::encoding::TypeMarker>::inline_size(
3707                    decoder.context
3708                );
3709                if inlined != (member_inline_size <= 4) {
3710                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3711                }
3712                let inner_offset;
3713                let mut inner_depth = depth.clone();
3714                if inlined {
3715                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3716                    inner_offset = next_offset;
3717                } else {
3718                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3719                    inner_depth.increment()?;
3720                }
3721                let val_ref =
3722                self.wake_locks.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3723                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3724                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3725                {
3726                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3727                }
3728                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3729                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3730                }
3731            }
3732
3733            next_offset += envelope_size;
3734
3735            // Decode the remaining unknown envelopes.
3736            while next_offset < end_offset {
3737                _next_ordinal_to_read += 1;
3738                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3739                next_offset += envelope_size;
3740            }
3741
3742            Ok(())
3743        }
3744    }
3745
3746    impl PagerRegisterFileResponse {
3747        #[inline(always)]
3748        fn max_ordinal_present(&self) -> u64 {
3749            if let Some(_) = self.vmo {
3750                return 1;
3751            }
3752            0
3753        }
3754    }
3755
3756    impl fidl::encoding::ResourceTypeMarker for PagerRegisterFileResponse {
3757        type Borrowed<'a> = &'a mut Self;
3758        fn take_or_borrow<'a>(
3759            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3760        ) -> Self::Borrowed<'a> {
3761            value
3762        }
3763    }
3764
3765    unsafe impl fidl::encoding::TypeMarker for PagerRegisterFileResponse {
3766        type Owned = Self;
3767
3768        #[inline(always)]
3769        fn inline_align(_context: fidl::encoding::Context) -> usize {
3770            8
3771        }
3772
3773        #[inline(always)]
3774        fn inline_size(_context: fidl::encoding::Context) -> usize {
3775            16
3776        }
3777    }
3778
3779    unsafe impl
3780        fidl::encoding::Encode<
3781            PagerRegisterFileResponse,
3782            fidl::encoding::DefaultFuchsiaResourceDialect,
3783        > for &mut PagerRegisterFileResponse
3784    {
3785        unsafe fn encode(
3786            self,
3787            encoder: &mut fidl::encoding::Encoder<
3788                '_,
3789                fidl::encoding::DefaultFuchsiaResourceDialect,
3790            >,
3791            offset: usize,
3792            mut depth: fidl::encoding::Depth,
3793        ) -> fidl::Result<()> {
3794            encoder.debug_check_bounds::<PagerRegisterFileResponse>(offset);
3795            // Vector header
3796            let max_ordinal: u64 = self.max_ordinal_present();
3797            encoder.write_num(max_ordinal, offset);
3798            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3799            // Calling encoder.out_of_line_offset(0) is not allowed.
3800            if max_ordinal == 0 {
3801                return Ok(());
3802            }
3803            depth.increment()?;
3804            let envelope_size = 8;
3805            let bytes_len = max_ordinal as usize * envelope_size;
3806            #[allow(unused_variables)]
3807            let offset = encoder.out_of_line_offset(bytes_len);
3808            let mut _prev_end_offset: usize = 0;
3809            if 1 > max_ordinal {
3810                return Ok(());
3811            }
3812
3813            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3814            // are envelope_size bytes.
3815            let cur_offset: usize = (1 - 1) * envelope_size;
3816
3817            // Zero reserved fields.
3818            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3819
3820            // Safety:
3821            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3822            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3823            //   envelope_size bytes, there is always sufficient room.
3824            fidl::encoding::encode_in_envelope_optional::<
3825                fidl::encoding::HandleType<
3826                    fidl::Vmo,
3827                    { fidl::ObjectType::VMO.into_raw() },
3828                    2147483648,
3829                >,
3830                fidl::encoding::DefaultFuchsiaResourceDialect,
3831            >(
3832                self.vmo.as_mut().map(
3833                    <fidl::encoding::HandleType<
3834                        fidl::Vmo,
3835                        { fidl::ObjectType::VMO.into_raw() },
3836                        2147483648,
3837                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3838                ),
3839                encoder,
3840                offset + cur_offset,
3841                depth,
3842            )?;
3843
3844            _prev_end_offset = cur_offset + envelope_size;
3845
3846            Ok(())
3847        }
3848    }
3849
3850    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3851        for PagerRegisterFileResponse
3852    {
3853        #[inline(always)]
3854        fn new_empty() -> Self {
3855            Self::default()
3856        }
3857
3858        unsafe fn decode(
3859            &mut self,
3860            decoder: &mut fidl::encoding::Decoder<
3861                '_,
3862                fidl::encoding::DefaultFuchsiaResourceDialect,
3863            >,
3864            offset: usize,
3865            mut depth: fidl::encoding::Depth,
3866        ) -> fidl::Result<()> {
3867            decoder.debug_check_bounds::<Self>(offset);
3868            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3869                None => return Err(fidl::Error::NotNullable),
3870                Some(len) => len,
3871            };
3872            // Calling decoder.out_of_line_offset(0) is not allowed.
3873            if len == 0 {
3874                return Ok(());
3875            };
3876            depth.increment()?;
3877            let envelope_size = 8;
3878            let bytes_len = len * envelope_size;
3879            let offset = decoder.out_of_line_offset(bytes_len)?;
3880            // Decode the envelope for each type.
3881            let mut _next_ordinal_to_read = 0;
3882            let mut next_offset = offset;
3883            let end_offset = offset + bytes_len;
3884            _next_ordinal_to_read += 1;
3885            if next_offset >= end_offset {
3886                return Ok(());
3887            }
3888
3889            // Decode unknown envelopes for gaps in ordinals.
3890            while _next_ordinal_to_read < 1 {
3891                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3892                _next_ordinal_to_read += 1;
3893                next_offset += envelope_size;
3894            }
3895
3896            let next_out_of_line = decoder.next_out_of_line();
3897            let handles_before = decoder.remaining_handles();
3898            if let Some((inlined, num_bytes, num_handles)) =
3899                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3900            {
3901                let member_inline_size = <fidl::encoding::HandleType<
3902                    fidl::Vmo,
3903                    { fidl::ObjectType::VMO.into_raw() },
3904                    2147483648,
3905                > as fidl::encoding::TypeMarker>::inline_size(
3906                    decoder.context
3907                );
3908                if inlined != (member_inline_size <= 4) {
3909                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3910                }
3911                let inner_offset;
3912                let mut inner_depth = depth.clone();
3913                if inlined {
3914                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3915                    inner_offset = next_offset;
3916                } else {
3917                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3918                    inner_depth.increment()?;
3919                }
3920                let val_ref =
3921                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3922                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3923                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3924                {
3925                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3926                }
3927                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3928                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3929                }
3930            }
3931
3932            next_offset += envelope_size;
3933
3934            // Decode the remaining unknown envelopes.
3935            while next_offset < end_offset {
3936                _next_ordinal_to_read += 1;
3937                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3938                next_offset += envelope_size;
3939            }
3940
3941            Ok(())
3942        }
3943    }
3944}