fidl_fuchsia_tee/
fidl_fuchsia_tee.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_tee_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14pub type ParameterSet = Vec<Parameter>;
15
16#[derive(Debug, PartialEq)]
17pub struct ApplicationInvokeCommandRequest {
18    pub session_id: u32,
19    pub command_id: u32,
20    pub parameter_set: Vec<Parameter>,
21}
22
23impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
24    for ApplicationInvokeCommandRequest
25{
26}
27
28#[derive(Debug, PartialEq)]
29pub struct ApplicationInvokeCommandResponse {
30    pub op_result: OpResult,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
34    for ApplicationInvokeCommandResponse
35{
36}
37
38#[derive(Debug, PartialEq)]
39pub struct ApplicationOpenSession2Request {
40    pub parameter_set: Vec<Parameter>,
41}
42
43impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
44    for ApplicationOpenSession2Request
45{
46}
47
48#[derive(Debug, PartialEq)]
49pub struct ApplicationOpenSession2Response {
50    pub session_id: u32,
51    pub op_result: OpResult,
52}
53
54impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
55    for ApplicationOpenSession2Response
56{
57}
58
59/// Represents a buffer parameter.
60#[derive(Debug, Default, PartialEq)]
61pub struct Buffer {
62    pub direction: Option<Direction>,
63    /// The VMO is allowed to be not present for situations where the TEE allows for buffer size
64    /// checks.
65    ///
66    /// For example, if the operation to be performed needs an output buffer, but the user cannot
67    /// calculate how large that output buffer should be, they can attempt the operation without
68    /// a vmo and the Trusted Application will populate the size field so that the operation can
69    /// be performed again with an appropriately sized buffer.
70    pub vmo: Option<fidl::Vmo>,
71    pub offset: Option<u64>,
72    pub size: Option<u64>,
73    #[doc(hidden)]
74    pub __source_breaking: fidl::marker::SourceBreaking,
75}
76
77impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Buffer {}
78
79/// The result of an operation will include a return code, the origin of the result, and the return
80/// of the parameter set. The returned parameter set will be a copy of the input parameter set, but
81/// with the INOUT and OUTPUT parameters updated. If the parameter is a Buffer, it will update the
82/// Buffer.size to the number of bytes written.
83#[derive(Debug, Default, PartialEq)]
84pub struct OpResult {
85    pub return_code: Option<u64>,
86    pub return_origin: Option<ReturnOrigin>,
87    pub parameter_set: Option<Vec<Parameter>>,
88    #[doc(hidden)]
89    pub __source_breaking: fidl::marker::SourceBreaking,
90}
91
92impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for OpResult {}
93
94#[derive(Debug)]
95pub enum Parameter {
96    None(None_),
97    Buffer(Buffer),
98    Value(Value),
99    #[doc(hidden)]
100    __SourceBreaking {
101        unknown_ordinal: u64,
102    },
103}
104
105/// Pattern that matches an unknown `Parameter` member.
106#[macro_export]
107macro_rules! ParameterUnknown {
108    () => {
109        _
110    };
111}
112
113// Custom PartialEq so that unknown variants are not equal to themselves.
114impl PartialEq for Parameter {
115    fn eq(&self, other: &Self) -> bool {
116        match (self, other) {
117            (Self::None(x), Self::None(y)) => *x == *y,
118            (Self::Buffer(x), Self::Buffer(y)) => *x == *y,
119            (Self::Value(x), Self::Value(y)) => *x == *y,
120            _ => false,
121        }
122    }
123}
124
125impl Parameter {
126    #[inline]
127    pub fn ordinal(&self) -> u64 {
128        match *self {
129            Self::None(_) => 1,
130            Self::Buffer(_) => 2,
131            Self::Value(_) => 3,
132            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
133        }
134    }
135
136    #[inline]
137    pub fn unknown_variant_for_testing() -> Self {
138        Self::__SourceBreaking { unknown_ordinal: 0 }
139    }
140
141    #[inline]
142    pub fn is_unknown(&self) -> bool {
143        match self {
144            Self::__SourceBreaking { .. } => true,
145            _ => false,
146        }
147    }
148}
149
150impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Parameter {}
151
152#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
153pub struct ApplicationMarker;
154
155impl fidl::endpoints::ProtocolMarker for ApplicationMarker {
156    type Proxy = ApplicationProxy;
157    type RequestStream = ApplicationRequestStream;
158    #[cfg(target_os = "fuchsia")]
159    type SynchronousProxy = ApplicationSynchronousProxy;
160
161    const DEBUG_NAME: &'static str = "fuchsia.tee.Application";
162}
163impl fidl::endpoints::DiscoverableProtocolMarker for ApplicationMarker {}
164
165pub trait ApplicationProxyInterface: Send + Sync {
166    type OpenSession2ResponseFut: std::future::Future<Output = Result<(u32, OpResult), fidl::Error>>
167        + Send;
168    fn r#open_session2(&self, parameter_set: Vec<Parameter>) -> Self::OpenSession2ResponseFut;
169    type InvokeCommandResponseFut: std::future::Future<Output = Result<OpResult, fidl::Error>>
170        + Send;
171    fn r#invoke_command(
172        &self,
173        session_id: u32,
174        command_id: u32,
175        parameter_set: Vec<Parameter>,
176    ) -> Self::InvokeCommandResponseFut;
177    type CloseSessionResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
178    fn r#close_session(&self, session_id: u32) -> Self::CloseSessionResponseFut;
179}
180#[derive(Debug)]
181#[cfg(target_os = "fuchsia")]
182pub struct ApplicationSynchronousProxy {
183    client: fidl::client::sync::Client,
184}
185
186#[cfg(target_os = "fuchsia")]
187impl fidl::endpoints::SynchronousProxy for ApplicationSynchronousProxy {
188    type Proxy = ApplicationProxy;
189    type Protocol = ApplicationMarker;
190
191    fn from_channel(inner: fidl::Channel) -> Self {
192        Self::new(inner)
193    }
194
195    fn into_channel(self) -> fidl::Channel {
196        self.client.into_channel()
197    }
198
199    fn as_channel(&self) -> &fidl::Channel {
200        self.client.as_channel()
201    }
202}
203
204#[cfg(target_os = "fuchsia")]
205impl ApplicationSynchronousProxy {
206    pub fn new(channel: fidl::Channel) -> Self {
207        let protocol_name = <ApplicationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
208        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
209    }
210
211    pub fn into_channel(self) -> fidl::Channel {
212        self.client.into_channel()
213    }
214
215    /// Waits until an event arrives and returns it. It is safe for other
216    /// threads to make concurrent requests while waiting for an event.
217    pub fn wait_for_event(
218        &self,
219        deadline: zx::MonotonicInstant,
220    ) -> Result<ApplicationEvent, fidl::Error> {
221        ApplicationEvent::decode(self.client.wait_for_event(deadline)?)
222    }
223
224    /// Initiates a communication session with the trusted application.
225    pub fn r#open_session2(
226        &self,
227        mut parameter_set: Vec<Parameter>,
228        ___deadline: zx::MonotonicInstant,
229    ) -> Result<(u32, OpResult), fidl::Error> {
230        let _response = self
231            .client
232            .send_query::<ApplicationOpenSession2Request, ApplicationOpenSession2Response>(
233                (parameter_set.as_mut(),),
234                0x2b496a73ef4794bb,
235                fidl::encoding::DynamicFlags::empty(),
236                ___deadline,
237            )?;
238        Ok((_response.session_id, _response.op_result))
239    }
240
241    /// Requests the trusted application perform the provided command. The command is unique to the
242    /// trusted application.
243    pub fn r#invoke_command(
244        &self,
245        mut session_id: u32,
246        mut command_id: u32,
247        mut parameter_set: Vec<Parameter>,
248        ___deadline: zx::MonotonicInstant,
249    ) -> Result<OpResult, fidl::Error> {
250        let _response = self
251            .client
252            .send_query::<ApplicationInvokeCommandRequest, ApplicationInvokeCommandResponse>(
253                (session_id, command_id, parameter_set.as_mut()),
254                0x3864b0ced1fee616,
255                fidl::encoding::DynamicFlags::empty(),
256                ___deadline,
257            )?;
258        Ok(_response.op_result)
259    }
260
261    /// Closes an established session.
262    pub fn r#close_session(
263        &self,
264        mut session_id: u32,
265        ___deadline: zx::MonotonicInstant,
266    ) -> Result<(), fidl::Error> {
267        let _response = self
268            .client
269            .send_query::<ApplicationCloseSessionRequest, fidl::encoding::EmptyPayload>(
270                (session_id,),
271                0x6ae3b85bde7cc1f7,
272                fidl::encoding::DynamicFlags::empty(),
273                ___deadline,
274            )?;
275        Ok(_response)
276    }
277}
278
279#[cfg(target_os = "fuchsia")]
280impl From<ApplicationSynchronousProxy> for zx::Handle {
281    fn from(value: ApplicationSynchronousProxy) -> Self {
282        value.into_channel().into()
283    }
284}
285
286#[cfg(target_os = "fuchsia")]
287impl From<fidl::Channel> for ApplicationSynchronousProxy {
288    fn from(value: fidl::Channel) -> Self {
289        Self::new(value)
290    }
291}
292
293#[derive(Debug, Clone)]
294pub struct ApplicationProxy {
295    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
296}
297
298impl fidl::endpoints::Proxy for ApplicationProxy {
299    type Protocol = ApplicationMarker;
300
301    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
302        Self::new(inner)
303    }
304
305    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
306        self.client.into_channel().map_err(|client| Self { client })
307    }
308
309    fn as_channel(&self) -> &::fidl::AsyncChannel {
310        self.client.as_channel()
311    }
312}
313
314impl ApplicationProxy {
315    /// Create a new Proxy for fuchsia.tee/Application.
316    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
317        let protocol_name = <ApplicationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
318        Self { client: fidl::client::Client::new(channel, protocol_name) }
319    }
320
321    /// Get a Stream of events from the remote end of the protocol.
322    ///
323    /// # Panics
324    ///
325    /// Panics if the event stream was already taken.
326    pub fn take_event_stream(&self) -> ApplicationEventStream {
327        ApplicationEventStream { event_receiver: self.client.take_event_receiver() }
328    }
329
330    /// Initiates a communication session with the trusted application.
331    pub fn r#open_session2(
332        &self,
333        mut parameter_set: Vec<Parameter>,
334    ) -> fidl::client::QueryResponseFut<
335        (u32, OpResult),
336        fidl::encoding::DefaultFuchsiaResourceDialect,
337    > {
338        ApplicationProxyInterface::r#open_session2(self, parameter_set)
339    }
340
341    /// Requests the trusted application perform the provided command. The command is unique to the
342    /// trusted application.
343    pub fn r#invoke_command(
344        &self,
345        mut session_id: u32,
346        mut command_id: u32,
347        mut parameter_set: Vec<Parameter>,
348    ) -> fidl::client::QueryResponseFut<OpResult, fidl::encoding::DefaultFuchsiaResourceDialect>
349    {
350        ApplicationProxyInterface::r#invoke_command(self, session_id, command_id, parameter_set)
351    }
352
353    /// Closes an established session.
354    pub fn r#close_session(
355        &self,
356        mut session_id: u32,
357    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
358        ApplicationProxyInterface::r#close_session(self, session_id)
359    }
360}
361
362impl ApplicationProxyInterface for ApplicationProxy {
363    type OpenSession2ResponseFut = fidl::client::QueryResponseFut<
364        (u32, OpResult),
365        fidl::encoding::DefaultFuchsiaResourceDialect,
366    >;
367    fn r#open_session2(&self, mut parameter_set: Vec<Parameter>) -> Self::OpenSession2ResponseFut {
368        fn _decode(
369            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
370        ) -> Result<(u32, OpResult), fidl::Error> {
371            let _response = fidl::client::decode_transaction_body::<
372                ApplicationOpenSession2Response,
373                fidl::encoding::DefaultFuchsiaResourceDialect,
374                0x2b496a73ef4794bb,
375            >(_buf?)?;
376            Ok((_response.session_id, _response.op_result))
377        }
378        self.client.send_query_and_decode::<ApplicationOpenSession2Request, (u32, OpResult)>(
379            (parameter_set.as_mut(),),
380            0x2b496a73ef4794bb,
381            fidl::encoding::DynamicFlags::empty(),
382            _decode,
383        )
384    }
385
386    type InvokeCommandResponseFut =
387        fidl::client::QueryResponseFut<OpResult, fidl::encoding::DefaultFuchsiaResourceDialect>;
388    fn r#invoke_command(
389        &self,
390        mut session_id: u32,
391        mut command_id: u32,
392        mut parameter_set: Vec<Parameter>,
393    ) -> Self::InvokeCommandResponseFut {
394        fn _decode(
395            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
396        ) -> Result<OpResult, fidl::Error> {
397            let _response = fidl::client::decode_transaction_body::<
398                ApplicationInvokeCommandResponse,
399                fidl::encoding::DefaultFuchsiaResourceDialect,
400                0x3864b0ced1fee616,
401            >(_buf?)?;
402            Ok(_response.op_result)
403        }
404        self.client.send_query_and_decode::<ApplicationInvokeCommandRequest, OpResult>(
405            (session_id, command_id, parameter_set.as_mut()),
406            0x3864b0ced1fee616,
407            fidl::encoding::DynamicFlags::empty(),
408            _decode,
409        )
410    }
411
412    type CloseSessionResponseFut =
413        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
414    fn r#close_session(&self, mut session_id: u32) -> Self::CloseSessionResponseFut {
415        fn _decode(
416            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
417        ) -> Result<(), fidl::Error> {
418            let _response = fidl::client::decode_transaction_body::<
419                fidl::encoding::EmptyPayload,
420                fidl::encoding::DefaultFuchsiaResourceDialect,
421                0x6ae3b85bde7cc1f7,
422            >(_buf?)?;
423            Ok(_response)
424        }
425        self.client.send_query_and_decode::<ApplicationCloseSessionRequest, ()>(
426            (session_id,),
427            0x6ae3b85bde7cc1f7,
428            fidl::encoding::DynamicFlags::empty(),
429            _decode,
430        )
431    }
432}
433
434pub struct ApplicationEventStream {
435    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
436}
437
438impl std::marker::Unpin for ApplicationEventStream {}
439
440impl futures::stream::FusedStream for ApplicationEventStream {
441    fn is_terminated(&self) -> bool {
442        self.event_receiver.is_terminated()
443    }
444}
445
446impl futures::Stream for ApplicationEventStream {
447    type Item = Result<ApplicationEvent, fidl::Error>;
448
449    fn poll_next(
450        mut self: std::pin::Pin<&mut Self>,
451        cx: &mut std::task::Context<'_>,
452    ) -> std::task::Poll<Option<Self::Item>> {
453        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
454            &mut self.event_receiver,
455            cx
456        )?) {
457            Some(buf) => std::task::Poll::Ready(Some(ApplicationEvent::decode(buf))),
458            None => std::task::Poll::Ready(None),
459        }
460    }
461}
462
463#[derive(Debug)]
464pub enum ApplicationEvent {}
465
466impl ApplicationEvent {
467    /// Decodes a message buffer as a [`ApplicationEvent`].
468    fn decode(
469        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
470    ) -> Result<ApplicationEvent, fidl::Error> {
471        let (bytes, _handles) = buf.split_mut();
472        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
473        debug_assert_eq!(tx_header.tx_id, 0);
474        match tx_header.ordinal {
475            _ => Err(fidl::Error::UnknownOrdinal {
476                ordinal: tx_header.ordinal,
477                protocol_name: <ApplicationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
478            }),
479        }
480    }
481}
482
483/// A Stream of incoming requests for fuchsia.tee/Application.
484pub struct ApplicationRequestStream {
485    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
486    is_terminated: bool,
487}
488
489impl std::marker::Unpin for ApplicationRequestStream {}
490
491impl futures::stream::FusedStream for ApplicationRequestStream {
492    fn is_terminated(&self) -> bool {
493        self.is_terminated
494    }
495}
496
497impl fidl::endpoints::RequestStream for ApplicationRequestStream {
498    type Protocol = ApplicationMarker;
499    type ControlHandle = ApplicationControlHandle;
500
501    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
502        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
503    }
504
505    fn control_handle(&self) -> Self::ControlHandle {
506        ApplicationControlHandle { inner: self.inner.clone() }
507    }
508
509    fn into_inner(
510        self,
511    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
512    {
513        (self.inner, self.is_terminated)
514    }
515
516    fn from_inner(
517        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
518        is_terminated: bool,
519    ) -> Self {
520        Self { inner, is_terminated }
521    }
522}
523
524impl futures::Stream for ApplicationRequestStream {
525    type Item = Result<ApplicationRequest, fidl::Error>;
526
527    fn poll_next(
528        mut self: std::pin::Pin<&mut Self>,
529        cx: &mut std::task::Context<'_>,
530    ) -> std::task::Poll<Option<Self::Item>> {
531        let this = &mut *self;
532        if this.inner.check_shutdown(cx) {
533            this.is_terminated = true;
534            return std::task::Poll::Ready(None);
535        }
536        if this.is_terminated {
537            panic!("polled ApplicationRequestStream after completion");
538        }
539        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
540            |bytes, handles| {
541                match this.inner.channel().read_etc(cx, bytes, handles) {
542                    std::task::Poll::Ready(Ok(())) => {}
543                    std::task::Poll::Pending => return std::task::Poll::Pending,
544                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
545                        this.is_terminated = true;
546                        return std::task::Poll::Ready(None);
547                    }
548                    std::task::Poll::Ready(Err(e)) => {
549                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
550                            e.into(),
551                        ))))
552                    }
553                }
554
555                // A message has been received from the channel
556                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
557
558                std::task::Poll::Ready(Some(match header.ordinal {
559                    0x2b496a73ef4794bb => {
560                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
561                        let mut req = fidl::new_empty!(
562                            ApplicationOpenSession2Request,
563                            fidl::encoding::DefaultFuchsiaResourceDialect
564                        );
565                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ApplicationOpenSession2Request>(&header, _body_bytes, handles, &mut req)?;
566                        let control_handle = ApplicationControlHandle { inner: this.inner.clone() };
567                        Ok(ApplicationRequest::OpenSession2 {
568                            parameter_set: req.parameter_set,
569
570                            responder: ApplicationOpenSession2Responder {
571                                control_handle: std::mem::ManuallyDrop::new(control_handle),
572                                tx_id: header.tx_id,
573                            },
574                        })
575                    }
576                    0x3864b0ced1fee616 => {
577                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
578                        let mut req = fidl::new_empty!(
579                            ApplicationInvokeCommandRequest,
580                            fidl::encoding::DefaultFuchsiaResourceDialect
581                        );
582                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ApplicationInvokeCommandRequest>(&header, _body_bytes, handles, &mut req)?;
583                        let control_handle = ApplicationControlHandle { inner: this.inner.clone() };
584                        Ok(ApplicationRequest::InvokeCommand {
585                            session_id: req.session_id,
586                            command_id: req.command_id,
587                            parameter_set: req.parameter_set,
588
589                            responder: ApplicationInvokeCommandResponder {
590                                control_handle: std::mem::ManuallyDrop::new(control_handle),
591                                tx_id: header.tx_id,
592                            },
593                        })
594                    }
595                    0x6ae3b85bde7cc1f7 => {
596                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
597                        let mut req = fidl::new_empty!(
598                            ApplicationCloseSessionRequest,
599                            fidl::encoding::DefaultFuchsiaResourceDialect
600                        );
601                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ApplicationCloseSessionRequest>(&header, _body_bytes, handles, &mut req)?;
602                        let control_handle = ApplicationControlHandle { inner: this.inner.clone() };
603                        Ok(ApplicationRequest::CloseSession {
604                            session_id: req.session_id,
605
606                            responder: ApplicationCloseSessionResponder {
607                                control_handle: std::mem::ManuallyDrop::new(control_handle),
608                                tx_id: header.tx_id,
609                            },
610                        })
611                    }
612                    _ => Err(fidl::Error::UnknownOrdinal {
613                        ordinal: header.ordinal,
614                        protocol_name:
615                            <ApplicationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
616                    }),
617                }))
618            },
619        )
620    }
621}
622
623/// Represents a connection to an application running in the TEE.
624#[derive(Debug)]
625pub enum ApplicationRequest {
626    /// Initiates a communication session with the trusted application.
627    OpenSession2 { parameter_set: Vec<Parameter>, responder: ApplicationOpenSession2Responder },
628    /// Requests the trusted application perform the provided command. The command is unique to the
629    /// trusted application.
630    InvokeCommand {
631        session_id: u32,
632        command_id: u32,
633        parameter_set: Vec<Parameter>,
634        responder: ApplicationInvokeCommandResponder,
635    },
636    /// Closes an established session.
637    CloseSession { session_id: u32, responder: ApplicationCloseSessionResponder },
638}
639
640impl ApplicationRequest {
641    #[allow(irrefutable_let_patterns)]
642    pub fn into_open_session2(self) -> Option<(Vec<Parameter>, ApplicationOpenSession2Responder)> {
643        if let ApplicationRequest::OpenSession2 { parameter_set, responder } = self {
644            Some((parameter_set, responder))
645        } else {
646            None
647        }
648    }
649
650    #[allow(irrefutable_let_patterns)]
651    pub fn into_invoke_command(
652        self,
653    ) -> Option<(u32, u32, Vec<Parameter>, ApplicationInvokeCommandResponder)> {
654        if let ApplicationRequest::InvokeCommand {
655            session_id,
656            command_id,
657            parameter_set,
658            responder,
659        } = self
660        {
661            Some((session_id, command_id, parameter_set, responder))
662        } else {
663            None
664        }
665    }
666
667    #[allow(irrefutable_let_patterns)]
668    pub fn into_close_session(self) -> Option<(u32, ApplicationCloseSessionResponder)> {
669        if let ApplicationRequest::CloseSession { session_id, responder } = self {
670            Some((session_id, responder))
671        } else {
672            None
673        }
674    }
675
676    /// Name of the method defined in FIDL
677    pub fn method_name(&self) -> &'static str {
678        match *self {
679            ApplicationRequest::OpenSession2 { .. } => "open_session2",
680            ApplicationRequest::InvokeCommand { .. } => "invoke_command",
681            ApplicationRequest::CloseSession { .. } => "close_session",
682        }
683    }
684}
685
686#[derive(Debug, Clone)]
687pub struct ApplicationControlHandle {
688    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
689}
690
691impl fidl::endpoints::ControlHandle for ApplicationControlHandle {
692    fn shutdown(&self) {
693        self.inner.shutdown()
694    }
695    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
696        self.inner.shutdown_with_epitaph(status)
697    }
698
699    fn is_closed(&self) -> bool {
700        self.inner.channel().is_closed()
701    }
702    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
703        self.inner.channel().on_closed()
704    }
705
706    #[cfg(target_os = "fuchsia")]
707    fn signal_peer(
708        &self,
709        clear_mask: zx::Signals,
710        set_mask: zx::Signals,
711    ) -> Result<(), zx_status::Status> {
712        use fidl::Peered;
713        self.inner.channel().signal_peer(clear_mask, set_mask)
714    }
715}
716
717impl ApplicationControlHandle {}
718
719#[must_use = "FIDL methods require a response to be sent"]
720#[derive(Debug)]
721pub struct ApplicationOpenSession2Responder {
722    control_handle: std::mem::ManuallyDrop<ApplicationControlHandle>,
723    tx_id: u32,
724}
725
726/// Set the the channel to be shutdown (see [`ApplicationControlHandle::shutdown`])
727/// if the responder is dropped without sending a response, so that the client
728/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
729impl std::ops::Drop for ApplicationOpenSession2Responder {
730    fn drop(&mut self) {
731        self.control_handle.shutdown();
732        // Safety: drops once, never accessed again
733        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
734    }
735}
736
737impl fidl::endpoints::Responder for ApplicationOpenSession2Responder {
738    type ControlHandle = ApplicationControlHandle;
739
740    fn control_handle(&self) -> &ApplicationControlHandle {
741        &self.control_handle
742    }
743
744    fn drop_without_shutdown(mut self) {
745        // Safety: drops once, never accessed again due to mem::forget
746        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
747        // Prevent Drop from running (which would shut down the channel)
748        std::mem::forget(self);
749    }
750}
751
752impl ApplicationOpenSession2Responder {
753    /// Sends a response to the FIDL transaction.
754    ///
755    /// Sets the channel to shutdown if an error occurs.
756    pub fn send(self, mut session_id: u32, mut op_result: OpResult) -> Result<(), fidl::Error> {
757        let _result = self.send_raw(session_id, op_result);
758        if _result.is_err() {
759            self.control_handle.shutdown();
760        }
761        self.drop_without_shutdown();
762        _result
763    }
764
765    /// Similar to "send" but does not shutdown the channel if an error occurs.
766    pub fn send_no_shutdown_on_err(
767        self,
768        mut session_id: u32,
769        mut op_result: OpResult,
770    ) -> Result<(), fidl::Error> {
771        let _result = self.send_raw(session_id, op_result);
772        self.drop_without_shutdown();
773        _result
774    }
775
776    fn send_raw(&self, mut session_id: u32, mut op_result: OpResult) -> Result<(), fidl::Error> {
777        self.control_handle.inner.send::<ApplicationOpenSession2Response>(
778            (session_id, &mut op_result),
779            self.tx_id,
780            0x2b496a73ef4794bb,
781            fidl::encoding::DynamicFlags::empty(),
782        )
783    }
784}
785
786#[must_use = "FIDL methods require a response to be sent"]
787#[derive(Debug)]
788pub struct ApplicationInvokeCommandResponder {
789    control_handle: std::mem::ManuallyDrop<ApplicationControlHandle>,
790    tx_id: u32,
791}
792
793/// Set the the channel to be shutdown (see [`ApplicationControlHandle::shutdown`])
794/// if the responder is dropped without sending a response, so that the client
795/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
796impl std::ops::Drop for ApplicationInvokeCommandResponder {
797    fn drop(&mut self) {
798        self.control_handle.shutdown();
799        // Safety: drops once, never accessed again
800        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
801    }
802}
803
804impl fidl::endpoints::Responder for ApplicationInvokeCommandResponder {
805    type ControlHandle = ApplicationControlHandle;
806
807    fn control_handle(&self) -> &ApplicationControlHandle {
808        &self.control_handle
809    }
810
811    fn drop_without_shutdown(mut self) {
812        // Safety: drops once, never accessed again due to mem::forget
813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
814        // Prevent Drop from running (which would shut down the channel)
815        std::mem::forget(self);
816    }
817}
818
819impl ApplicationInvokeCommandResponder {
820    /// Sends a response to the FIDL transaction.
821    ///
822    /// Sets the channel to shutdown if an error occurs.
823    pub fn send(self, mut op_result: OpResult) -> Result<(), fidl::Error> {
824        let _result = self.send_raw(op_result);
825        if _result.is_err() {
826            self.control_handle.shutdown();
827        }
828        self.drop_without_shutdown();
829        _result
830    }
831
832    /// Similar to "send" but does not shutdown the channel if an error occurs.
833    pub fn send_no_shutdown_on_err(self, mut op_result: OpResult) -> Result<(), fidl::Error> {
834        let _result = self.send_raw(op_result);
835        self.drop_without_shutdown();
836        _result
837    }
838
839    fn send_raw(&self, mut op_result: OpResult) -> Result<(), fidl::Error> {
840        self.control_handle.inner.send::<ApplicationInvokeCommandResponse>(
841            (&mut op_result,),
842            self.tx_id,
843            0x3864b0ced1fee616,
844            fidl::encoding::DynamicFlags::empty(),
845        )
846    }
847}
848
849#[must_use = "FIDL methods require a response to be sent"]
850#[derive(Debug)]
851pub struct ApplicationCloseSessionResponder {
852    control_handle: std::mem::ManuallyDrop<ApplicationControlHandle>,
853    tx_id: u32,
854}
855
856/// Set the the channel to be shutdown (see [`ApplicationControlHandle::shutdown`])
857/// if the responder is dropped without sending a response, so that the client
858/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
859impl std::ops::Drop for ApplicationCloseSessionResponder {
860    fn drop(&mut self) {
861        self.control_handle.shutdown();
862        // Safety: drops once, never accessed again
863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
864    }
865}
866
867impl fidl::endpoints::Responder for ApplicationCloseSessionResponder {
868    type ControlHandle = ApplicationControlHandle;
869
870    fn control_handle(&self) -> &ApplicationControlHandle {
871        &self.control_handle
872    }
873
874    fn drop_without_shutdown(mut self) {
875        // Safety: drops once, never accessed again due to mem::forget
876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877        // Prevent Drop from running (which would shut down the channel)
878        std::mem::forget(self);
879    }
880}
881
882impl ApplicationCloseSessionResponder {
883    /// Sends a response to the FIDL transaction.
884    ///
885    /// Sets the channel to shutdown if an error occurs.
886    pub fn send(self) -> Result<(), fidl::Error> {
887        let _result = self.send_raw();
888        if _result.is_err() {
889            self.control_handle.shutdown();
890        }
891        self.drop_without_shutdown();
892        _result
893    }
894
895    /// Similar to "send" but does not shutdown the channel if an error occurs.
896    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
897        let _result = self.send_raw();
898        self.drop_without_shutdown();
899        _result
900    }
901
902    fn send_raw(&self) -> Result<(), fidl::Error> {
903        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
904            (),
905            self.tx_id,
906            0x6ae3b85bde7cc1f7,
907            fidl::encoding::DynamicFlags::empty(),
908        )
909    }
910}
911
912#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
913pub struct DeviceInfoMarker;
914
915impl fidl::endpoints::ProtocolMarker for DeviceInfoMarker {
916    type Proxy = DeviceInfoProxy;
917    type RequestStream = DeviceInfoRequestStream;
918    #[cfg(target_os = "fuchsia")]
919    type SynchronousProxy = DeviceInfoSynchronousProxy;
920
921    const DEBUG_NAME: &'static str = "fuchsia.tee.DeviceInfo";
922}
923impl fidl::endpoints::DiscoverableProtocolMarker for DeviceInfoMarker {}
924
925pub trait DeviceInfoProxyInterface: Send + Sync {
926    type GetOsInfoResponseFut: std::future::Future<Output = Result<OsInfo, fidl::Error>> + Send;
927    fn r#get_os_info(&self) -> Self::GetOsInfoResponseFut;
928}
929#[derive(Debug)]
930#[cfg(target_os = "fuchsia")]
931pub struct DeviceInfoSynchronousProxy {
932    client: fidl::client::sync::Client,
933}
934
935#[cfg(target_os = "fuchsia")]
936impl fidl::endpoints::SynchronousProxy for DeviceInfoSynchronousProxy {
937    type Proxy = DeviceInfoProxy;
938    type Protocol = DeviceInfoMarker;
939
940    fn from_channel(inner: fidl::Channel) -> Self {
941        Self::new(inner)
942    }
943
944    fn into_channel(self) -> fidl::Channel {
945        self.client.into_channel()
946    }
947
948    fn as_channel(&self) -> &fidl::Channel {
949        self.client.as_channel()
950    }
951}
952
953#[cfg(target_os = "fuchsia")]
954impl DeviceInfoSynchronousProxy {
955    pub fn new(channel: fidl::Channel) -> Self {
956        let protocol_name = <DeviceInfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
957        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
958    }
959
960    pub fn into_channel(self) -> fidl::Channel {
961        self.client.into_channel()
962    }
963
964    /// Waits until an event arrives and returns it. It is safe for other
965    /// threads to make concurrent requests while waiting for an event.
966    pub fn wait_for_event(
967        &self,
968        deadline: zx::MonotonicInstant,
969    ) -> Result<DeviceInfoEvent, fidl::Error> {
970        DeviceInfoEvent::decode(self.client.wait_for_event(deadline)?)
971    }
972
973    /// Obtains information about the TEE OS.
974    pub fn r#get_os_info(&self, ___deadline: zx::MonotonicInstant) -> Result<OsInfo, fidl::Error> {
975        let _response =
976            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceInfoGetOsInfoResponse>(
977                (),
978                0xf79d4f109b95dca,
979                fidl::encoding::DynamicFlags::empty(),
980                ___deadline,
981            )?;
982        Ok(_response.info)
983    }
984}
985
986#[cfg(target_os = "fuchsia")]
987impl From<DeviceInfoSynchronousProxy> for zx::Handle {
988    fn from(value: DeviceInfoSynchronousProxy) -> Self {
989        value.into_channel().into()
990    }
991}
992
993#[cfg(target_os = "fuchsia")]
994impl From<fidl::Channel> for DeviceInfoSynchronousProxy {
995    fn from(value: fidl::Channel) -> Self {
996        Self::new(value)
997    }
998}
999
1000#[derive(Debug, Clone)]
1001pub struct DeviceInfoProxy {
1002    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1003}
1004
1005impl fidl::endpoints::Proxy for DeviceInfoProxy {
1006    type Protocol = DeviceInfoMarker;
1007
1008    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1009        Self::new(inner)
1010    }
1011
1012    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1013        self.client.into_channel().map_err(|client| Self { client })
1014    }
1015
1016    fn as_channel(&self) -> &::fidl::AsyncChannel {
1017        self.client.as_channel()
1018    }
1019}
1020
1021impl DeviceInfoProxy {
1022    /// Create a new Proxy for fuchsia.tee/DeviceInfo.
1023    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1024        let protocol_name = <DeviceInfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1025        Self { client: fidl::client::Client::new(channel, protocol_name) }
1026    }
1027
1028    /// Get a Stream of events from the remote end of the protocol.
1029    ///
1030    /// # Panics
1031    ///
1032    /// Panics if the event stream was already taken.
1033    pub fn take_event_stream(&self) -> DeviceInfoEventStream {
1034        DeviceInfoEventStream { event_receiver: self.client.take_event_receiver() }
1035    }
1036
1037    /// Obtains information about the TEE OS.
1038    pub fn r#get_os_info(
1039        &self,
1040    ) -> fidl::client::QueryResponseFut<OsInfo, fidl::encoding::DefaultFuchsiaResourceDialect> {
1041        DeviceInfoProxyInterface::r#get_os_info(self)
1042    }
1043}
1044
1045impl DeviceInfoProxyInterface for DeviceInfoProxy {
1046    type GetOsInfoResponseFut =
1047        fidl::client::QueryResponseFut<OsInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
1048    fn r#get_os_info(&self) -> Self::GetOsInfoResponseFut {
1049        fn _decode(
1050            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1051        ) -> Result<OsInfo, fidl::Error> {
1052            let _response = fidl::client::decode_transaction_body::<
1053                DeviceInfoGetOsInfoResponse,
1054                fidl::encoding::DefaultFuchsiaResourceDialect,
1055                0xf79d4f109b95dca,
1056            >(_buf?)?;
1057            Ok(_response.info)
1058        }
1059        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, OsInfo>(
1060            (),
1061            0xf79d4f109b95dca,
1062            fidl::encoding::DynamicFlags::empty(),
1063            _decode,
1064        )
1065    }
1066}
1067
1068pub struct DeviceInfoEventStream {
1069    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1070}
1071
1072impl std::marker::Unpin for DeviceInfoEventStream {}
1073
1074impl futures::stream::FusedStream for DeviceInfoEventStream {
1075    fn is_terminated(&self) -> bool {
1076        self.event_receiver.is_terminated()
1077    }
1078}
1079
1080impl futures::Stream for DeviceInfoEventStream {
1081    type Item = Result<DeviceInfoEvent, fidl::Error>;
1082
1083    fn poll_next(
1084        mut self: std::pin::Pin<&mut Self>,
1085        cx: &mut std::task::Context<'_>,
1086    ) -> std::task::Poll<Option<Self::Item>> {
1087        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1088            &mut self.event_receiver,
1089            cx
1090        )?) {
1091            Some(buf) => std::task::Poll::Ready(Some(DeviceInfoEvent::decode(buf))),
1092            None => std::task::Poll::Ready(None),
1093        }
1094    }
1095}
1096
1097#[derive(Debug)]
1098pub enum DeviceInfoEvent {}
1099
1100impl DeviceInfoEvent {
1101    /// Decodes a message buffer as a [`DeviceInfoEvent`].
1102    fn decode(
1103        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1104    ) -> Result<DeviceInfoEvent, fidl::Error> {
1105        let (bytes, _handles) = buf.split_mut();
1106        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1107        debug_assert_eq!(tx_header.tx_id, 0);
1108        match tx_header.ordinal {
1109            _ => Err(fidl::Error::UnknownOrdinal {
1110                ordinal: tx_header.ordinal,
1111                protocol_name: <DeviceInfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1112            }),
1113        }
1114    }
1115}
1116
1117/// A Stream of incoming requests for fuchsia.tee/DeviceInfo.
1118pub struct DeviceInfoRequestStream {
1119    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1120    is_terminated: bool,
1121}
1122
1123impl std::marker::Unpin for DeviceInfoRequestStream {}
1124
1125impl futures::stream::FusedStream for DeviceInfoRequestStream {
1126    fn is_terminated(&self) -> bool {
1127        self.is_terminated
1128    }
1129}
1130
1131impl fidl::endpoints::RequestStream for DeviceInfoRequestStream {
1132    type Protocol = DeviceInfoMarker;
1133    type ControlHandle = DeviceInfoControlHandle;
1134
1135    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1136        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1137    }
1138
1139    fn control_handle(&self) -> Self::ControlHandle {
1140        DeviceInfoControlHandle { inner: self.inner.clone() }
1141    }
1142
1143    fn into_inner(
1144        self,
1145    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1146    {
1147        (self.inner, self.is_terminated)
1148    }
1149
1150    fn from_inner(
1151        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1152        is_terminated: bool,
1153    ) -> Self {
1154        Self { inner, is_terminated }
1155    }
1156}
1157
1158impl futures::Stream for DeviceInfoRequestStream {
1159    type Item = Result<DeviceInfoRequest, fidl::Error>;
1160
1161    fn poll_next(
1162        mut self: std::pin::Pin<&mut Self>,
1163        cx: &mut std::task::Context<'_>,
1164    ) -> std::task::Poll<Option<Self::Item>> {
1165        let this = &mut *self;
1166        if this.inner.check_shutdown(cx) {
1167            this.is_terminated = true;
1168            return std::task::Poll::Ready(None);
1169        }
1170        if this.is_terminated {
1171            panic!("polled DeviceInfoRequestStream after completion");
1172        }
1173        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1174            |bytes, handles| {
1175                match this.inner.channel().read_etc(cx, bytes, handles) {
1176                    std::task::Poll::Ready(Ok(())) => {}
1177                    std::task::Poll::Pending => return std::task::Poll::Pending,
1178                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1179                        this.is_terminated = true;
1180                        return std::task::Poll::Ready(None);
1181                    }
1182                    std::task::Poll::Ready(Err(e)) => {
1183                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1184                            e.into(),
1185                        ))))
1186                    }
1187                }
1188
1189                // A message has been received from the channel
1190                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1191
1192                std::task::Poll::Ready(Some(match header.ordinal {
1193                    0xf79d4f109b95dca => {
1194                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1195                        let mut req = fidl::new_empty!(
1196                            fidl::encoding::EmptyPayload,
1197                            fidl::encoding::DefaultFuchsiaResourceDialect
1198                        );
1199                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1200                        let control_handle = DeviceInfoControlHandle { inner: this.inner.clone() };
1201                        Ok(DeviceInfoRequest::GetOsInfo {
1202                            responder: DeviceInfoGetOsInfoResponder {
1203                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1204                                tx_id: header.tx_id,
1205                            },
1206                        })
1207                    }
1208                    _ => Err(fidl::Error::UnknownOrdinal {
1209                        ordinal: header.ordinal,
1210                        protocol_name:
1211                            <DeviceInfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1212                    }),
1213                }))
1214            },
1215        )
1216    }
1217}
1218
1219/// Provides information about the TEE device.
1220#[derive(Debug)]
1221pub enum DeviceInfoRequest {
1222    /// Obtains information about the TEE OS.
1223    GetOsInfo { responder: DeviceInfoGetOsInfoResponder },
1224}
1225
1226impl DeviceInfoRequest {
1227    #[allow(irrefutable_let_patterns)]
1228    pub fn into_get_os_info(self) -> Option<(DeviceInfoGetOsInfoResponder)> {
1229        if let DeviceInfoRequest::GetOsInfo { responder } = self {
1230            Some((responder))
1231        } else {
1232            None
1233        }
1234    }
1235
1236    /// Name of the method defined in FIDL
1237    pub fn method_name(&self) -> &'static str {
1238        match *self {
1239            DeviceInfoRequest::GetOsInfo { .. } => "get_os_info",
1240        }
1241    }
1242}
1243
1244#[derive(Debug, Clone)]
1245pub struct DeviceInfoControlHandle {
1246    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1247}
1248
1249impl fidl::endpoints::ControlHandle for DeviceInfoControlHandle {
1250    fn shutdown(&self) {
1251        self.inner.shutdown()
1252    }
1253    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1254        self.inner.shutdown_with_epitaph(status)
1255    }
1256
1257    fn is_closed(&self) -> bool {
1258        self.inner.channel().is_closed()
1259    }
1260    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1261        self.inner.channel().on_closed()
1262    }
1263
1264    #[cfg(target_os = "fuchsia")]
1265    fn signal_peer(
1266        &self,
1267        clear_mask: zx::Signals,
1268        set_mask: zx::Signals,
1269    ) -> Result<(), zx_status::Status> {
1270        use fidl::Peered;
1271        self.inner.channel().signal_peer(clear_mask, set_mask)
1272    }
1273}
1274
1275impl DeviceInfoControlHandle {}
1276
1277#[must_use = "FIDL methods require a response to be sent"]
1278#[derive(Debug)]
1279pub struct DeviceInfoGetOsInfoResponder {
1280    control_handle: std::mem::ManuallyDrop<DeviceInfoControlHandle>,
1281    tx_id: u32,
1282}
1283
1284/// Set the the channel to be shutdown (see [`DeviceInfoControlHandle::shutdown`])
1285/// if the responder is dropped without sending a response, so that the client
1286/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1287impl std::ops::Drop for DeviceInfoGetOsInfoResponder {
1288    fn drop(&mut self) {
1289        self.control_handle.shutdown();
1290        // Safety: drops once, never accessed again
1291        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1292    }
1293}
1294
1295impl fidl::endpoints::Responder for DeviceInfoGetOsInfoResponder {
1296    type ControlHandle = DeviceInfoControlHandle;
1297
1298    fn control_handle(&self) -> &DeviceInfoControlHandle {
1299        &self.control_handle
1300    }
1301
1302    fn drop_without_shutdown(mut self) {
1303        // Safety: drops once, never accessed again due to mem::forget
1304        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1305        // Prevent Drop from running (which would shut down the channel)
1306        std::mem::forget(self);
1307    }
1308}
1309
1310impl DeviceInfoGetOsInfoResponder {
1311    /// Sends a response to the FIDL transaction.
1312    ///
1313    /// Sets the channel to shutdown if an error occurs.
1314    pub fn send(self, mut info: &OsInfo) -> Result<(), fidl::Error> {
1315        let _result = self.send_raw(info);
1316        if _result.is_err() {
1317            self.control_handle.shutdown();
1318        }
1319        self.drop_without_shutdown();
1320        _result
1321    }
1322
1323    /// Similar to "send" but does not shutdown the channel if an error occurs.
1324    pub fn send_no_shutdown_on_err(self, mut info: &OsInfo) -> Result<(), fidl::Error> {
1325        let _result = self.send_raw(info);
1326        self.drop_without_shutdown();
1327        _result
1328    }
1329
1330    fn send_raw(&self, mut info: &OsInfo) -> Result<(), fidl::Error> {
1331        self.control_handle.inner.send::<DeviceInfoGetOsInfoResponse>(
1332            (info,),
1333            self.tx_id,
1334            0xf79d4f109b95dca,
1335            fidl::encoding::DynamicFlags::empty(),
1336        )
1337    }
1338}
1339
1340mod internal {
1341    use super::*;
1342
1343    impl fidl::encoding::ResourceTypeMarker for ApplicationInvokeCommandRequest {
1344        type Borrowed<'a> = &'a mut Self;
1345        fn take_or_borrow<'a>(
1346            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1347        ) -> Self::Borrowed<'a> {
1348            value
1349        }
1350    }
1351
1352    unsafe impl fidl::encoding::TypeMarker for ApplicationInvokeCommandRequest {
1353        type Owned = Self;
1354
1355        #[inline(always)]
1356        fn inline_align(_context: fidl::encoding::Context) -> usize {
1357            8
1358        }
1359
1360        #[inline(always)]
1361        fn inline_size(_context: fidl::encoding::Context) -> usize {
1362            24
1363        }
1364    }
1365
1366    unsafe impl
1367        fidl::encoding::Encode<
1368            ApplicationInvokeCommandRequest,
1369            fidl::encoding::DefaultFuchsiaResourceDialect,
1370        > for &mut ApplicationInvokeCommandRequest
1371    {
1372        #[inline]
1373        unsafe fn encode(
1374            self,
1375            encoder: &mut fidl::encoding::Encoder<
1376                '_,
1377                fidl::encoding::DefaultFuchsiaResourceDialect,
1378            >,
1379            offset: usize,
1380            _depth: fidl::encoding::Depth,
1381        ) -> fidl::Result<()> {
1382            encoder.debug_check_bounds::<ApplicationInvokeCommandRequest>(offset);
1383            // Delegate to tuple encoding.
1384            fidl::encoding::Encode::<ApplicationInvokeCommandRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1385                (
1386                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
1387                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.command_id),
1388                    <fidl::encoding::Vector<Parameter, 4> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parameter_set),
1389                ),
1390                encoder, offset, _depth
1391            )
1392        }
1393    }
1394    unsafe impl<
1395            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1396            T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1397            T2: fidl::encoding::Encode<
1398                fidl::encoding::Vector<Parameter, 4>,
1399                fidl::encoding::DefaultFuchsiaResourceDialect,
1400            >,
1401        >
1402        fidl::encoding::Encode<
1403            ApplicationInvokeCommandRequest,
1404            fidl::encoding::DefaultFuchsiaResourceDialect,
1405        > for (T0, T1, T2)
1406    {
1407        #[inline]
1408        unsafe fn encode(
1409            self,
1410            encoder: &mut fidl::encoding::Encoder<
1411                '_,
1412                fidl::encoding::DefaultFuchsiaResourceDialect,
1413            >,
1414            offset: usize,
1415            depth: fidl::encoding::Depth,
1416        ) -> fidl::Result<()> {
1417            encoder.debug_check_bounds::<ApplicationInvokeCommandRequest>(offset);
1418            // Zero out padding regions. There's no need to apply masks
1419            // because the unmasked parts will be overwritten by fields.
1420            // Write the fields.
1421            self.0.encode(encoder, offset + 0, depth)?;
1422            self.1.encode(encoder, offset + 4, depth)?;
1423            self.2.encode(encoder, offset + 8, depth)?;
1424            Ok(())
1425        }
1426    }
1427
1428    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1429        for ApplicationInvokeCommandRequest
1430    {
1431        #[inline(always)]
1432        fn new_empty() -> Self {
1433            Self {
1434                session_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1435                command_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1436                parameter_set: fidl::new_empty!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect),
1437            }
1438        }
1439
1440        #[inline]
1441        unsafe fn decode(
1442            &mut self,
1443            decoder: &mut fidl::encoding::Decoder<
1444                '_,
1445                fidl::encoding::DefaultFuchsiaResourceDialect,
1446            >,
1447            offset: usize,
1448            _depth: fidl::encoding::Depth,
1449        ) -> fidl::Result<()> {
1450            decoder.debug_check_bounds::<Self>(offset);
1451            // Verify that padding bytes are zero.
1452            fidl::decode!(
1453                u32,
1454                fidl::encoding::DefaultFuchsiaResourceDialect,
1455                &mut self.session_id,
1456                decoder,
1457                offset + 0,
1458                _depth
1459            )?;
1460            fidl::decode!(
1461                u32,
1462                fidl::encoding::DefaultFuchsiaResourceDialect,
1463                &mut self.command_id,
1464                decoder,
1465                offset + 4,
1466                _depth
1467            )?;
1468            fidl::decode!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.parameter_set, decoder, offset + 8, _depth)?;
1469            Ok(())
1470        }
1471    }
1472
1473    impl fidl::encoding::ResourceTypeMarker for ApplicationInvokeCommandResponse {
1474        type Borrowed<'a> = &'a mut Self;
1475        fn take_or_borrow<'a>(
1476            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1477        ) -> Self::Borrowed<'a> {
1478            value
1479        }
1480    }
1481
1482    unsafe impl fidl::encoding::TypeMarker for ApplicationInvokeCommandResponse {
1483        type Owned = Self;
1484
1485        #[inline(always)]
1486        fn inline_align(_context: fidl::encoding::Context) -> usize {
1487            8
1488        }
1489
1490        #[inline(always)]
1491        fn inline_size(_context: fidl::encoding::Context) -> usize {
1492            16
1493        }
1494    }
1495
1496    unsafe impl
1497        fidl::encoding::Encode<
1498            ApplicationInvokeCommandResponse,
1499            fidl::encoding::DefaultFuchsiaResourceDialect,
1500        > for &mut ApplicationInvokeCommandResponse
1501    {
1502        #[inline]
1503        unsafe fn encode(
1504            self,
1505            encoder: &mut fidl::encoding::Encoder<
1506                '_,
1507                fidl::encoding::DefaultFuchsiaResourceDialect,
1508            >,
1509            offset: usize,
1510            _depth: fidl::encoding::Depth,
1511        ) -> fidl::Result<()> {
1512            encoder.debug_check_bounds::<ApplicationInvokeCommandResponse>(offset);
1513            // Delegate to tuple encoding.
1514            fidl::encoding::Encode::<
1515                ApplicationInvokeCommandResponse,
1516                fidl::encoding::DefaultFuchsiaResourceDialect,
1517            >::encode(
1518                (<OpResult as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1519                    &mut self.op_result,
1520                ),),
1521                encoder,
1522                offset,
1523                _depth,
1524            )
1525        }
1526    }
1527    unsafe impl<T0: fidl::encoding::Encode<OpResult, fidl::encoding::DefaultFuchsiaResourceDialect>>
1528        fidl::encoding::Encode<
1529            ApplicationInvokeCommandResponse,
1530            fidl::encoding::DefaultFuchsiaResourceDialect,
1531        > for (T0,)
1532    {
1533        #[inline]
1534        unsafe fn encode(
1535            self,
1536            encoder: &mut fidl::encoding::Encoder<
1537                '_,
1538                fidl::encoding::DefaultFuchsiaResourceDialect,
1539            >,
1540            offset: usize,
1541            depth: fidl::encoding::Depth,
1542        ) -> fidl::Result<()> {
1543            encoder.debug_check_bounds::<ApplicationInvokeCommandResponse>(offset);
1544            // Zero out padding regions. There's no need to apply masks
1545            // because the unmasked parts will be overwritten by fields.
1546            // Write the fields.
1547            self.0.encode(encoder, offset + 0, depth)?;
1548            Ok(())
1549        }
1550    }
1551
1552    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1553        for ApplicationInvokeCommandResponse
1554    {
1555        #[inline(always)]
1556        fn new_empty() -> Self {
1557            Self {
1558                op_result: fidl::new_empty!(
1559                    OpResult,
1560                    fidl::encoding::DefaultFuchsiaResourceDialect
1561                ),
1562            }
1563        }
1564
1565        #[inline]
1566        unsafe fn decode(
1567            &mut self,
1568            decoder: &mut fidl::encoding::Decoder<
1569                '_,
1570                fidl::encoding::DefaultFuchsiaResourceDialect,
1571            >,
1572            offset: usize,
1573            _depth: fidl::encoding::Depth,
1574        ) -> fidl::Result<()> {
1575            decoder.debug_check_bounds::<Self>(offset);
1576            // Verify that padding bytes are zero.
1577            fidl::decode!(
1578                OpResult,
1579                fidl::encoding::DefaultFuchsiaResourceDialect,
1580                &mut self.op_result,
1581                decoder,
1582                offset + 0,
1583                _depth
1584            )?;
1585            Ok(())
1586        }
1587    }
1588
1589    impl fidl::encoding::ResourceTypeMarker for ApplicationOpenSession2Request {
1590        type Borrowed<'a> = &'a mut Self;
1591        fn take_or_borrow<'a>(
1592            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1593        ) -> Self::Borrowed<'a> {
1594            value
1595        }
1596    }
1597
1598    unsafe impl fidl::encoding::TypeMarker for ApplicationOpenSession2Request {
1599        type Owned = Self;
1600
1601        #[inline(always)]
1602        fn inline_align(_context: fidl::encoding::Context) -> usize {
1603            8
1604        }
1605
1606        #[inline(always)]
1607        fn inline_size(_context: fidl::encoding::Context) -> usize {
1608            16
1609        }
1610    }
1611
1612    unsafe impl
1613        fidl::encoding::Encode<
1614            ApplicationOpenSession2Request,
1615            fidl::encoding::DefaultFuchsiaResourceDialect,
1616        > for &mut ApplicationOpenSession2Request
1617    {
1618        #[inline]
1619        unsafe fn encode(
1620            self,
1621            encoder: &mut fidl::encoding::Encoder<
1622                '_,
1623                fidl::encoding::DefaultFuchsiaResourceDialect,
1624            >,
1625            offset: usize,
1626            _depth: fidl::encoding::Depth,
1627        ) -> fidl::Result<()> {
1628            encoder.debug_check_bounds::<ApplicationOpenSession2Request>(offset);
1629            // Delegate to tuple encoding.
1630            fidl::encoding::Encode::<ApplicationOpenSession2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1631                (
1632                    <fidl::encoding::Vector<Parameter, 4> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parameter_set),
1633                ),
1634                encoder, offset, _depth
1635            )
1636        }
1637    }
1638    unsafe impl<
1639            T0: fidl::encoding::Encode<
1640                fidl::encoding::Vector<Parameter, 4>,
1641                fidl::encoding::DefaultFuchsiaResourceDialect,
1642            >,
1643        >
1644        fidl::encoding::Encode<
1645            ApplicationOpenSession2Request,
1646            fidl::encoding::DefaultFuchsiaResourceDialect,
1647        > for (T0,)
1648    {
1649        #[inline]
1650        unsafe fn encode(
1651            self,
1652            encoder: &mut fidl::encoding::Encoder<
1653                '_,
1654                fidl::encoding::DefaultFuchsiaResourceDialect,
1655            >,
1656            offset: usize,
1657            depth: fidl::encoding::Depth,
1658        ) -> fidl::Result<()> {
1659            encoder.debug_check_bounds::<ApplicationOpenSession2Request>(offset);
1660            // Zero out padding regions. There's no need to apply masks
1661            // because the unmasked parts will be overwritten by fields.
1662            // Write the fields.
1663            self.0.encode(encoder, offset + 0, depth)?;
1664            Ok(())
1665        }
1666    }
1667
1668    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1669        for ApplicationOpenSession2Request
1670    {
1671        #[inline(always)]
1672        fn new_empty() -> Self {
1673            Self {
1674                parameter_set: fidl::new_empty!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect),
1675            }
1676        }
1677
1678        #[inline]
1679        unsafe fn decode(
1680            &mut self,
1681            decoder: &mut fidl::encoding::Decoder<
1682                '_,
1683                fidl::encoding::DefaultFuchsiaResourceDialect,
1684            >,
1685            offset: usize,
1686            _depth: fidl::encoding::Depth,
1687        ) -> fidl::Result<()> {
1688            decoder.debug_check_bounds::<Self>(offset);
1689            // Verify that padding bytes are zero.
1690            fidl::decode!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.parameter_set, decoder, offset + 0, _depth)?;
1691            Ok(())
1692        }
1693    }
1694
1695    impl fidl::encoding::ResourceTypeMarker for ApplicationOpenSession2Response {
1696        type Borrowed<'a> = &'a mut Self;
1697        fn take_or_borrow<'a>(
1698            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1699        ) -> Self::Borrowed<'a> {
1700            value
1701        }
1702    }
1703
1704    unsafe impl fidl::encoding::TypeMarker for ApplicationOpenSession2Response {
1705        type Owned = Self;
1706
1707        #[inline(always)]
1708        fn inline_align(_context: fidl::encoding::Context) -> usize {
1709            8
1710        }
1711
1712        #[inline(always)]
1713        fn inline_size(_context: fidl::encoding::Context) -> usize {
1714            24
1715        }
1716    }
1717
1718    unsafe impl
1719        fidl::encoding::Encode<
1720            ApplicationOpenSession2Response,
1721            fidl::encoding::DefaultFuchsiaResourceDialect,
1722        > for &mut ApplicationOpenSession2Response
1723    {
1724        #[inline]
1725        unsafe fn encode(
1726            self,
1727            encoder: &mut fidl::encoding::Encoder<
1728                '_,
1729                fidl::encoding::DefaultFuchsiaResourceDialect,
1730            >,
1731            offset: usize,
1732            _depth: fidl::encoding::Depth,
1733        ) -> fidl::Result<()> {
1734            encoder.debug_check_bounds::<ApplicationOpenSession2Response>(offset);
1735            // Delegate to tuple encoding.
1736            fidl::encoding::Encode::<
1737                ApplicationOpenSession2Response,
1738                fidl::encoding::DefaultFuchsiaResourceDialect,
1739            >::encode(
1740                (
1741                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
1742                    <OpResult as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1743                        &mut self.op_result,
1744                    ),
1745                ),
1746                encoder,
1747                offset,
1748                _depth,
1749            )
1750        }
1751    }
1752    unsafe impl<
1753            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1754            T1: fidl::encoding::Encode<OpResult, fidl::encoding::DefaultFuchsiaResourceDialect>,
1755        >
1756        fidl::encoding::Encode<
1757            ApplicationOpenSession2Response,
1758            fidl::encoding::DefaultFuchsiaResourceDialect,
1759        > for (T0, T1)
1760    {
1761        #[inline]
1762        unsafe fn encode(
1763            self,
1764            encoder: &mut fidl::encoding::Encoder<
1765                '_,
1766                fidl::encoding::DefaultFuchsiaResourceDialect,
1767            >,
1768            offset: usize,
1769            depth: fidl::encoding::Depth,
1770        ) -> fidl::Result<()> {
1771            encoder.debug_check_bounds::<ApplicationOpenSession2Response>(offset);
1772            // Zero out padding regions. There's no need to apply masks
1773            // because the unmasked parts will be overwritten by fields.
1774            unsafe {
1775                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1776                (ptr as *mut u64).write_unaligned(0);
1777            }
1778            // Write the fields.
1779            self.0.encode(encoder, offset + 0, depth)?;
1780            self.1.encode(encoder, offset + 8, depth)?;
1781            Ok(())
1782        }
1783    }
1784
1785    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1786        for ApplicationOpenSession2Response
1787    {
1788        #[inline(always)]
1789        fn new_empty() -> Self {
1790            Self {
1791                session_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1792                op_result: fidl::new_empty!(
1793                    OpResult,
1794                    fidl::encoding::DefaultFuchsiaResourceDialect
1795                ),
1796            }
1797        }
1798
1799        #[inline]
1800        unsafe fn decode(
1801            &mut self,
1802            decoder: &mut fidl::encoding::Decoder<
1803                '_,
1804                fidl::encoding::DefaultFuchsiaResourceDialect,
1805            >,
1806            offset: usize,
1807            _depth: fidl::encoding::Depth,
1808        ) -> fidl::Result<()> {
1809            decoder.debug_check_bounds::<Self>(offset);
1810            // Verify that padding bytes are zero.
1811            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1812            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1813            let mask = 0xffffffff00000000u64;
1814            let maskedval = padval & mask;
1815            if maskedval != 0 {
1816                return Err(fidl::Error::NonZeroPadding {
1817                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1818                });
1819            }
1820            fidl::decode!(
1821                u32,
1822                fidl::encoding::DefaultFuchsiaResourceDialect,
1823                &mut self.session_id,
1824                decoder,
1825                offset + 0,
1826                _depth
1827            )?;
1828            fidl::decode!(
1829                OpResult,
1830                fidl::encoding::DefaultFuchsiaResourceDialect,
1831                &mut self.op_result,
1832                decoder,
1833                offset + 8,
1834                _depth
1835            )?;
1836            Ok(())
1837        }
1838    }
1839
1840    impl Buffer {
1841        #[inline(always)]
1842        fn max_ordinal_present(&self) -> u64 {
1843            if let Some(_) = self.size {
1844                return 4;
1845            }
1846            if let Some(_) = self.offset {
1847                return 3;
1848            }
1849            if let Some(_) = self.vmo {
1850                return 2;
1851            }
1852            if let Some(_) = self.direction {
1853                return 1;
1854            }
1855            0
1856        }
1857    }
1858
1859    impl fidl::encoding::ResourceTypeMarker for Buffer {
1860        type Borrowed<'a> = &'a mut Self;
1861        fn take_or_borrow<'a>(
1862            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1863        ) -> Self::Borrowed<'a> {
1864            value
1865        }
1866    }
1867
1868    unsafe impl fidl::encoding::TypeMarker for Buffer {
1869        type Owned = Self;
1870
1871        #[inline(always)]
1872        fn inline_align(_context: fidl::encoding::Context) -> usize {
1873            8
1874        }
1875
1876        #[inline(always)]
1877        fn inline_size(_context: fidl::encoding::Context) -> usize {
1878            16
1879        }
1880    }
1881
1882    unsafe impl fidl::encoding::Encode<Buffer, fidl::encoding::DefaultFuchsiaResourceDialect>
1883        for &mut Buffer
1884    {
1885        unsafe fn encode(
1886            self,
1887            encoder: &mut fidl::encoding::Encoder<
1888                '_,
1889                fidl::encoding::DefaultFuchsiaResourceDialect,
1890            >,
1891            offset: usize,
1892            mut depth: fidl::encoding::Depth,
1893        ) -> fidl::Result<()> {
1894            encoder.debug_check_bounds::<Buffer>(offset);
1895            // Vector header
1896            let max_ordinal: u64 = self.max_ordinal_present();
1897            encoder.write_num(max_ordinal, offset);
1898            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1899            // Calling encoder.out_of_line_offset(0) is not allowed.
1900            if max_ordinal == 0 {
1901                return Ok(());
1902            }
1903            depth.increment()?;
1904            let envelope_size = 8;
1905            let bytes_len = max_ordinal as usize * envelope_size;
1906            #[allow(unused_variables)]
1907            let offset = encoder.out_of_line_offset(bytes_len);
1908            let mut _prev_end_offset: usize = 0;
1909            if 1 > max_ordinal {
1910                return Ok(());
1911            }
1912
1913            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1914            // are envelope_size bytes.
1915            let cur_offset: usize = (1 - 1) * envelope_size;
1916
1917            // Zero reserved fields.
1918            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1919
1920            // Safety:
1921            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1922            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1923            //   envelope_size bytes, there is always sufficient room.
1924            fidl::encoding::encode_in_envelope_optional::<
1925                Direction,
1926                fidl::encoding::DefaultFuchsiaResourceDialect,
1927            >(
1928                self.direction.as_ref().map(<Direction as fidl::encoding::ValueTypeMarker>::borrow),
1929                encoder,
1930                offset + cur_offset,
1931                depth,
1932            )?;
1933
1934            _prev_end_offset = cur_offset + envelope_size;
1935            if 2 > max_ordinal {
1936                return Ok(());
1937            }
1938
1939            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1940            // are envelope_size bytes.
1941            let cur_offset: usize = (2 - 1) * envelope_size;
1942
1943            // Zero reserved fields.
1944            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1945
1946            // Safety:
1947            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1948            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1949            //   envelope_size bytes, there is always sufficient room.
1950            fidl::encoding::encode_in_envelope_optional::<
1951                fidl::encoding::HandleType<
1952                    fidl::Vmo,
1953                    { fidl::ObjectType::VMO.into_raw() },
1954                    2147483648,
1955                >,
1956                fidl::encoding::DefaultFuchsiaResourceDialect,
1957            >(
1958                self.vmo.as_mut().map(
1959                    <fidl::encoding::HandleType<
1960                        fidl::Vmo,
1961                        { fidl::ObjectType::VMO.into_raw() },
1962                        2147483648,
1963                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1964                ),
1965                encoder,
1966                offset + cur_offset,
1967                depth,
1968            )?;
1969
1970            _prev_end_offset = cur_offset + envelope_size;
1971            if 3 > max_ordinal {
1972                return Ok(());
1973            }
1974
1975            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1976            // are envelope_size bytes.
1977            let cur_offset: usize = (3 - 1) * envelope_size;
1978
1979            // Zero reserved fields.
1980            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1981
1982            // Safety:
1983            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1984            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1985            //   envelope_size bytes, there is always sufficient room.
1986            fidl::encoding::encode_in_envelope_optional::<
1987                u64,
1988                fidl::encoding::DefaultFuchsiaResourceDialect,
1989            >(
1990                self.offset.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1991                encoder,
1992                offset + cur_offset,
1993                depth,
1994            )?;
1995
1996            _prev_end_offset = cur_offset + envelope_size;
1997            if 4 > max_ordinal {
1998                return Ok(());
1999            }
2000
2001            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2002            // are envelope_size bytes.
2003            let cur_offset: usize = (4 - 1) * envelope_size;
2004
2005            // Zero reserved fields.
2006            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2007
2008            // Safety:
2009            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2010            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2011            //   envelope_size bytes, there is always sufficient room.
2012            fidl::encoding::encode_in_envelope_optional::<
2013                u64,
2014                fidl::encoding::DefaultFuchsiaResourceDialect,
2015            >(
2016                self.size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2017                encoder,
2018                offset + cur_offset,
2019                depth,
2020            )?;
2021
2022            _prev_end_offset = cur_offset + envelope_size;
2023
2024            Ok(())
2025        }
2026    }
2027
2028    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Buffer {
2029        #[inline(always)]
2030        fn new_empty() -> Self {
2031            Self::default()
2032        }
2033
2034        unsafe fn decode(
2035            &mut self,
2036            decoder: &mut fidl::encoding::Decoder<
2037                '_,
2038                fidl::encoding::DefaultFuchsiaResourceDialect,
2039            >,
2040            offset: usize,
2041            mut depth: fidl::encoding::Depth,
2042        ) -> fidl::Result<()> {
2043            decoder.debug_check_bounds::<Self>(offset);
2044            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2045                None => return Err(fidl::Error::NotNullable),
2046                Some(len) => len,
2047            };
2048            // Calling decoder.out_of_line_offset(0) is not allowed.
2049            if len == 0 {
2050                return Ok(());
2051            };
2052            depth.increment()?;
2053            let envelope_size = 8;
2054            let bytes_len = len * envelope_size;
2055            let offset = decoder.out_of_line_offset(bytes_len)?;
2056            // Decode the envelope for each type.
2057            let mut _next_ordinal_to_read = 0;
2058            let mut next_offset = offset;
2059            let end_offset = offset + bytes_len;
2060            _next_ordinal_to_read += 1;
2061            if next_offset >= end_offset {
2062                return Ok(());
2063            }
2064
2065            // Decode unknown envelopes for gaps in ordinals.
2066            while _next_ordinal_to_read < 1 {
2067                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2068                _next_ordinal_to_read += 1;
2069                next_offset += envelope_size;
2070            }
2071
2072            let next_out_of_line = decoder.next_out_of_line();
2073            let handles_before = decoder.remaining_handles();
2074            if let Some((inlined, num_bytes, num_handles)) =
2075                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2076            {
2077                let member_inline_size =
2078                    <Direction as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2079                if inlined != (member_inline_size <= 4) {
2080                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2081                }
2082                let inner_offset;
2083                let mut inner_depth = depth.clone();
2084                if inlined {
2085                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2086                    inner_offset = next_offset;
2087                } else {
2088                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2089                    inner_depth.increment()?;
2090                }
2091                let val_ref = self.direction.get_or_insert_with(|| {
2092                    fidl::new_empty!(Direction, fidl::encoding::DefaultFuchsiaResourceDialect)
2093                });
2094                fidl::decode!(
2095                    Direction,
2096                    fidl::encoding::DefaultFuchsiaResourceDialect,
2097                    val_ref,
2098                    decoder,
2099                    inner_offset,
2100                    inner_depth
2101                )?;
2102                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2103                {
2104                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2105                }
2106                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2107                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2108                }
2109            }
2110
2111            next_offset += envelope_size;
2112            _next_ordinal_to_read += 1;
2113            if next_offset >= end_offset {
2114                return Ok(());
2115            }
2116
2117            // Decode unknown envelopes for gaps in ordinals.
2118            while _next_ordinal_to_read < 2 {
2119                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2120                _next_ordinal_to_read += 1;
2121                next_offset += envelope_size;
2122            }
2123
2124            let next_out_of_line = decoder.next_out_of_line();
2125            let handles_before = decoder.remaining_handles();
2126            if let Some((inlined, num_bytes, num_handles)) =
2127                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2128            {
2129                let member_inline_size = <fidl::encoding::HandleType<
2130                    fidl::Vmo,
2131                    { fidl::ObjectType::VMO.into_raw() },
2132                    2147483648,
2133                > as fidl::encoding::TypeMarker>::inline_size(
2134                    decoder.context
2135                );
2136                if inlined != (member_inline_size <= 4) {
2137                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2138                }
2139                let inner_offset;
2140                let mut inner_depth = depth.clone();
2141                if inlined {
2142                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2143                    inner_offset = next_offset;
2144                } else {
2145                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2146                    inner_depth.increment()?;
2147                }
2148                let val_ref =
2149                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2150                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2151                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2152                {
2153                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2154                }
2155                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2156                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2157                }
2158            }
2159
2160            next_offset += envelope_size;
2161            _next_ordinal_to_read += 1;
2162            if next_offset >= end_offset {
2163                return Ok(());
2164            }
2165
2166            // Decode unknown envelopes for gaps in ordinals.
2167            while _next_ordinal_to_read < 3 {
2168                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2169                _next_ordinal_to_read += 1;
2170                next_offset += envelope_size;
2171            }
2172
2173            let next_out_of_line = decoder.next_out_of_line();
2174            let handles_before = decoder.remaining_handles();
2175            if let Some((inlined, num_bytes, num_handles)) =
2176                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2177            {
2178                let member_inline_size =
2179                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2180                if inlined != (member_inline_size <= 4) {
2181                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2182                }
2183                let inner_offset;
2184                let mut inner_depth = depth.clone();
2185                if inlined {
2186                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2187                    inner_offset = next_offset;
2188                } else {
2189                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2190                    inner_depth.increment()?;
2191                }
2192                let val_ref = self.offset.get_or_insert_with(|| {
2193                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2194                });
2195                fidl::decode!(
2196                    u64,
2197                    fidl::encoding::DefaultFuchsiaResourceDialect,
2198                    val_ref,
2199                    decoder,
2200                    inner_offset,
2201                    inner_depth
2202                )?;
2203                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2204                {
2205                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2206                }
2207                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2208                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2209                }
2210            }
2211
2212            next_offset += envelope_size;
2213            _next_ordinal_to_read += 1;
2214            if next_offset >= end_offset {
2215                return Ok(());
2216            }
2217
2218            // Decode unknown envelopes for gaps in ordinals.
2219            while _next_ordinal_to_read < 4 {
2220                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2221                _next_ordinal_to_read += 1;
2222                next_offset += envelope_size;
2223            }
2224
2225            let next_out_of_line = decoder.next_out_of_line();
2226            let handles_before = decoder.remaining_handles();
2227            if let Some((inlined, num_bytes, num_handles)) =
2228                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2229            {
2230                let member_inline_size =
2231                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2232                if inlined != (member_inline_size <= 4) {
2233                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2234                }
2235                let inner_offset;
2236                let mut inner_depth = depth.clone();
2237                if inlined {
2238                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2239                    inner_offset = next_offset;
2240                } else {
2241                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2242                    inner_depth.increment()?;
2243                }
2244                let val_ref = self.size.get_or_insert_with(|| {
2245                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2246                });
2247                fidl::decode!(
2248                    u64,
2249                    fidl::encoding::DefaultFuchsiaResourceDialect,
2250                    val_ref,
2251                    decoder,
2252                    inner_offset,
2253                    inner_depth
2254                )?;
2255                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2256                {
2257                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2258                }
2259                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2260                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2261                }
2262            }
2263
2264            next_offset += envelope_size;
2265
2266            // Decode the remaining unknown envelopes.
2267            while next_offset < end_offset {
2268                _next_ordinal_to_read += 1;
2269                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2270                next_offset += envelope_size;
2271            }
2272
2273            Ok(())
2274        }
2275    }
2276
2277    impl OpResult {
2278        #[inline(always)]
2279        fn max_ordinal_present(&self) -> u64 {
2280            if let Some(_) = self.parameter_set {
2281                return 3;
2282            }
2283            if let Some(_) = self.return_origin {
2284                return 2;
2285            }
2286            if let Some(_) = self.return_code {
2287                return 1;
2288            }
2289            0
2290        }
2291    }
2292
2293    impl fidl::encoding::ResourceTypeMarker for OpResult {
2294        type Borrowed<'a> = &'a mut Self;
2295        fn take_or_borrow<'a>(
2296            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2297        ) -> Self::Borrowed<'a> {
2298            value
2299        }
2300    }
2301
2302    unsafe impl fidl::encoding::TypeMarker for OpResult {
2303        type Owned = Self;
2304
2305        #[inline(always)]
2306        fn inline_align(_context: fidl::encoding::Context) -> usize {
2307            8
2308        }
2309
2310        #[inline(always)]
2311        fn inline_size(_context: fidl::encoding::Context) -> usize {
2312            16
2313        }
2314    }
2315
2316    unsafe impl fidl::encoding::Encode<OpResult, fidl::encoding::DefaultFuchsiaResourceDialect>
2317        for &mut OpResult
2318    {
2319        unsafe fn encode(
2320            self,
2321            encoder: &mut fidl::encoding::Encoder<
2322                '_,
2323                fidl::encoding::DefaultFuchsiaResourceDialect,
2324            >,
2325            offset: usize,
2326            mut depth: fidl::encoding::Depth,
2327        ) -> fidl::Result<()> {
2328            encoder.debug_check_bounds::<OpResult>(offset);
2329            // Vector header
2330            let max_ordinal: u64 = self.max_ordinal_present();
2331            encoder.write_num(max_ordinal, offset);
2332            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2333            // Calling encoder.out_of_line_offset(0) is not allowed.
2334            if max_ordinal == 0 {
2335                return Ok(());
2336            }
2337            depth.increment()?;
2338            let envelope_size = 8;
2339            let bytes_len = max_ordinal as usize * envelope_size;
2340            #[allow(unused_variables)]
2341            let offset = encoder.out_of_line_offset(bytes_len);
2342            let mut _prev_end_offset: usize = 0;
2343            if 1 > max_ordinal {
2344                return Ok(());
2345            }
2346
2347            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2348            // are envelope_size bytes.
2349            let cur_offset: usize = (1 - 1) * envelope_size;
2350
2351            // Zero reserved fields.
2352            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2353
2354            // Safety:
2355            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2356            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2357            //   envelope_size bytes, there is always sufficient room.
2358            fidl::encoding::encode_in_envelope_optional::<
2359                u64,
2360                fidl::encoding::DefaultFuchsiaResourceDialect,
2361            >(
2362                self.return_code.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2363                encoder,
2364                offset + cur_offset,
2365                depth,
2366            )?;
2367
2368            _prev_end_offset = cur_offset + envelope_size;
2369            if 2 > max_ordinal {
2370                return Ok(());
2371            }
2372
2373            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2374            // are envelope_size bytes.
2375            let cur_offset: usize = (2 - 1) * envelope_size;
2376
2377            // Zero reserved fields.
2378            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2379
2380            // Safety:
2381            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2382            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2383            //   envelope_size bytes, there is always sufficient room.
2384            fidl::encoding::encode_in_envelope_optional::<
2385                ReturnOrigin,
2386                fidl::encoding::DefaultFuchsiaResourceDialect,
2387            >(
2388                self.return_origin
2389                    .as_ref()
2390                    .map(<ReturnOrigin as fidl::encoding::ValueTypeMarker>::borrow),
2391                encoder,
2392                offset + cur_offset,
2393                depth,
2394            )?;
2395
2396            _prev_end_offset = cur_offset + envelope_size;
2397            if 3 > max_ordinal {
2398                return Ok(());
2399            }
2400
2401            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2402            // are envelope_size bytes.
2403            let cur_offset: usize = (3 - 1) * envelope_size;
2404
2405            // Zero reserved fields.
2406            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2407
2408            // Safety:
2409            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2410            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2411            //   envelope_size bytes, there is always sufficient room.
2412            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2413            self.parameter_set.as_mut().map(<fidl::encoding::Vector<Parameter, 4> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2414            encoder, offset + cur_offset, depth
2415        )?;
2416
2417            _prev_end_offset = cur_offset + envelope_size;
2418
2419            Ok(())
2420        }
2421    }
2422
2423    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for OpResult {
2424        #[inline(always)]
2425        fn new_empty() -> Self {
2426            Self::default()
2427        }
2428
2429        unsafe fn decode(
2430            &mut self,
2431            decoder: &mut fidl::encoding::Decoder<
2432                '_,
2433                fidl::encoding::DefaultFuchsiaResourceDialect,
2434            >,
2435            offset: usize,
2436            mut depth: fidl::encoding::Depth,
2437        ) -> fidl::Result<()> {
2438            decoder.debug_check_bounds::<Self>(offset);
2439            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2440                None => return Err(fidl::Error::NotNullable),
2441                Some(len) => len,
2442            };
2443            // Calling decoder.out_of_line_offset(0) is not allowed.
2444            if len == 0 {
2445                return Ok(());
2446            };
2447            depth.increment()?;
2448            let envelope_size = 8;
2449            let bytes_len = len * envelope_size;
2450            let offset = decoder.out_of_line_offset(bytes_len)?;
2451            // Decode the envelope for each type.
2452            let mut _next_ordinal_to_read = 0;
2453            let mut next_offset = offset;
2454            let end_offset = offset + bytes_len;
2455            _next_ordinal_to_read += 1;
2456            if next_offset >= end_offset {
2457                return Ok(());
2458            }
2459
2460            // Decode unknown envelopes for gaps in ordinals.
2461            while _next_ordinal_to_read < 1 {
2462                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2463                _next_ordinal_to_read += 1;
2464                next_offset += envelope_size;
2465            }
2466
2467            let next_out_of_line = decoder.next_out_of_line();
2468            let handles_before = decoder.remaining_handles();
2469            if let Some((inlined, num_bytes, num_handles)) =
2470                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2471            {
2472                let member_inline_size =
2473                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2474                if inlined != (member_inline_size <= 4) {
2475                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2476                }
2477                let inner_offset;
2478                let mut inner_depth = depth.clone();
2479                if inlined {
2480                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2481                    inner_offset = next_offset;
2482                } else {
2483                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2484                    inner_depth.increment()?;
2485                }
2486                let val_ref = self.return_code.get_or_insert_with(|| {
2487                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2488                });
2489                fidl::decode!(
2490                    u64,
2491                    fidl::encoding::DefaultFuchsiaResourceDialect,
2492                    val_ref,
2493                    decoder,
2494                    inner_offset,
2495                    inner_depth
2496                )?;
2497                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2498                {
2499                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2500                }
2501                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2502                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2503                }
2504            }
2505
2506            next_offset += envelope_size;
2507            _next_ordinal_to_read += 1;
2508            if next_offset >= end_offset {
2509                return Ok(());
2510            }
2511
2512            // Decode unknown envelopes for gaps in ordinals.
2513            while _next_ordinal_to_read < 2 {
2514                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2515                _next_ordinal_to_read += 1;
2516                next_offset += envelope_size;
2517            }
2518
2519            let next_out_of_line = decoder.next_out_of_line();
2520            let handles_before = decoder.remaining_handles();
2521            if let Some((inlined, num_bytes, num_handles)) =
2522                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2523            {
2524                let member_inline_size =
2525                    <ReturnOrigin as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2526                if inlined != (member_inline_size <= 4) {
2527                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2528                }
2529                let inner_offset;
2530                let mut inner_depth = depth.clone();
2531                if inlined {
2532                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2533                    inner_offset = next_offset;
2534                } else {
2535                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2536                    inner_depth.increment()?;
2537                }
2538                let val_ref = self.return_origin.get_or_insert_with(|| {
2539                    fidl::new_empty!(ReturnOrigin, fidl::encoding::DefaultFuchsiaResourceDialect)
2540                });
2541                fidl::decode!(
2542                    ReturnOrigin,
2543                    fidl::encoding::DefaultFuchsiaResourceDialect,
2544                    val_ref,
2545                    decoder,
2546                    inner_offset,
2547                    inner_depth
2548                )?;
2549                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2550                {
2551                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2552                }
2553                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2554                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2555                }
2556            }
2557
2558            next_offset += envelope_size;
2559            _next_ordinal_to_read += 1;
2560            if next_offset >= end_offset {
2561                return Ok(());
2562            }
2563
2564            // Decode unknown envelopes for gaps in ordinals.
2565            while _next_ordinal_to_read < 3 {
2566                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2567                _next_ordinal_to_read += 1;
2568                next_offset += envelope_size;
2569            }
2570
2571            let next_out_of_line = decoder.next_out_of_line();
2572            let handles_before = decoder.remaining_handles();
2573            if let Some((inlined, num_bytes, num_handles)) =
2574                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2575            {
2576                let member_inline_size = <fidl::encoding::Vector<Parameter, 4> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2577                if inlined != (member_inline_size <= 4) {
2578                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2579                }
2580                let inner_offset;
2581                let mut inner_depth = depth.clone();
2582                if inlined {
2583                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2584                    inner_offset = next_offset;
2585                } else {
2586                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2587                    inner_depth.increment()?;
2588                }
2589                let val_ref =
2590                self.parameter_set.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect));
2591                fidl::decode!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2592                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2593                {
2594                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2595                }
2596                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2597                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2598                }
2599            }
2600
2601            next_offset += envelope_size;
2602
2603            // Decode the remaining unknown envelopes.
2604            while next_offset < end_offset {
2605                _next_ordinal_to_read += 1;
2606                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2607                next_offset += envelope_size;
2608            }
2609
2610            Ok(())
2611        }
2612    }
2613
2614    impl fidl::encoding::ResourceTypeMarker for Parameter {
2615        type Borrowed<'a> = &'a mut Self;
2616        fn take_or_borrow<'a>(
2617            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2618        ) -> Self::Borrowed<'a> {
2619            value
2620        }
2621    }
2622
2623    unsafe impl fidl::encoding::TypeMarker for Parameter {
2624        type Owned = Self;
2625
2626        #[inline(always)]
2627        fn inline_align(_context: fidl::encoding::Context) -> usize {
2628            8
2629        }
2630
2631        #[inline(always)]
2632        fn inline_size(_context: fidl::encoding::Context) -> usize {
2633            16
2634        }
2635    }
2636
2637    unsafe impl fidl::encoding::Encode<Parameter, fidl::encoding::DefaultFuchsiaResourceDialect>
2638        for &mut Parameter
2639    {
2640        #[inline]
2641        unsafe fn encode(
2642            self,
2643            encoder: &mut fidl::encoding::Encoder<
2644                '_,
2645                fidl::encoding::DefaultFuchsiaResourceDialect,
2646            >,
2647            offset: usize,
2648            _depth: fidl::encoding::Depth,
2649        ) -> fidl::Result<()> {
2650            encoder.debug_check_bounds::<Parameter>(offset);
2651            encoder.write_num::<u64>(self.ordinal(), offset);
2652            match self {
2653                Parameter::None(ref val) => fidl::encoding::encode_in_envelope::<
2654                    None_,
2655                    fidl::encoding::DefaultFuchsiaResourceDialect,
2656                >(
2657                    <None_ as fidl::encoding::ValueTypeMarker>::borrow(val),
2658                    encoder,
2659                    offset + 8,
2660                    _depth,
2661                ),
2662                Parameter::Buffer(ref mut val) => fidl::encoding::encode_in_envelope::<
2663                    Buffer,
2664                    fidl::encoding::DefaultFuchsiaResourceDialect,
2665                >(
2666                    <Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2667                    encoder,
2668                    offset + 8,
2669                    _depth,
2670                ),
2671                Parameter::Value(ref val) => fidl::encoding::encode_in_envelope::<
2672                    Value,
2673                    fidl::encoding::DefaultFuchsiaResourceDialect,
2674                >(
2675                    <Value as fidl::encoding::ValueTypeMarker>::borrow(val),
2676                    encoder,
2677                    offset + 8,
2678                    _depth,
2679                ),
2680                Parameter::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2681            }
2682        }
2683    }
2684
2685    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Parameter {
2686        #[inline(always)]
2687        fn new_empty() -> Self {
2688            Self::__SourceBreaking { unknown_ordinal: 0 }
2689        }
2690
2691        #[inline]
2692        unsafe fn decode(
2693            &mut self,
2694            decoder: &mut fidl::encoding::Decoder<
2695                '_,
2696                fidl::encoding::DefaultFuchsiaResourceDialect,
2697            >,
2698            offset: usize,
2699            mut depth: fidl::encoding::Depth,
2700        ) -> fidl::Result<()> {
2701            decoder.debug_check_bounds::<Self>(offset);
2702            #[allow(unused_variables)]
2703            let next_out_of_line = decoder.next_out_of_line();
2704            let handles_before = decoder.remaining_handles();
2705            let (ordinal, inlined, num_bytes, num_handles) =
2706                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2707
2708            let member_inline_size = match ordinal {
2709                1 => <None_ as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2710                2 => <Buffer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2711                3 => <Value as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2712                0 => return Err(fidl::Error::UnknownUnionTag),
2713                _ => num_bytes as usize,
2714            };
2715
2716            if inlined != (member_inline_size <= 4) {
2717                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2718            }
2719            let _inner_offset;
2720            if inlined {
2721                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2722                _inner_offset = offset + 8;
2723            } else {
2724                depth.increment()?;
2725                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2726            }
2727            match ordinal {
2728                1 => {
2729                    #[allow(irrefutable_let_patterns)]
2730                    if let Parameter::None(_) = self {
2731                        // Do nothing, read the value into the object
2732                    } else {
2733                        // Initialize `self` to the right variant
2734                        *self = Parameter::None(fidl::new_empty!(
2735                            None_,
2736                            fidl::encoding::DefaultFuchsiaResourceDialect
2737                        ));
2738                    }
2739                    #[allow(irrefutable_let_patterns)]
2740                    if let Parameter::None(ref mut val) = self {
2741                        fidl::decode!(
2742                            None_,
2743                            fidl::encoding::DefaultFuchsiaResourceDialect,
2744                            val,
2745                            decoder,
2746                            _inner_offset,
2747                            depth
2748                        )?;
2749                    } else {
2750                        unreachable!()
2751                    }
2752                }
2753                2 => {
2754                    #[allow(irrefutable_let_patterns)]
2755                    if let Parameter::Buffer(_) = self {
2756                        // Do nothing, read the value into the object
2757                    } else {
2758                        // Initialize `self` to the right variant
2759                        *self = Parameter::Buffer(fidl::new_empty!(
2760                            Buffer,
2761                            fidl::encoding::DefaultFuchsiaResourceDialect
2762                        ));
2763                    }
2764                    #[allow(irrefutable_let_patterns)]
2765                    if let Parameter::Buffer(ref mut val) = self {
2766                        fidl::decode!(
2767                            Buffer,
2768                            fidl::encoding::DefaultFuchsiaResourceDialect,
2769                            val,
2770                            decoder,
2771                            _inner_offset,
2772                            depth
2773                        )?;
2774                    } else {
2775                        unreachable!()
2776                    }
2777                }
2778                3 => {
2779                    #[allow(irrefutable_let_patterns)]
2780                    if let Parameter::Value(_) = self {
2781                        // Do nothing, read the value into the object
2782                    } else {
2783                        // Initialize `self` to the right variant
2784                        *self = Parameter::Value(fidl::new_empty!(
2785                            Value,
2786                            fidl::encoding::DefaultFuchsiaResourceDialect
2787                        ));
2788                    }
2789                    #[allow(irrefutable_let_patterns)]
2790                    if let Parameter::Value(ref mut val) = self {
2791                        fidl::decode!(
2792                            Value,
2793                            fidl::encoding::DefaultFuchsiaResourceDialect,
2794                            val,
2795                            decoder,
2796                            _inner_offset,
2797                            depth
2798                        )?;
2799                    } else {
2800                        unreachable!()
2801                    }
2802                }
2803                #[allow(deprecated)]
2804                ordinal => {
2805                    for _ in 0..num_handles {
2806                        decoder.drop_next_handle()?;
2807                    }
2808                    *self = Parameter::__SourceBreaking { unknown_ordinal: ordinal };
2809                }
2810            }
2811            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2812                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2813            }
2814            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2815                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2816            }
2817            Ok(())
2818        }
2819    }
2820}