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