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 { Some((responder)) } else { None }
1248    }
1249
1250    /// Name of the method defined in FIDL
1251    pub fn method_name(&self) -> &'static str {
1252        match *self {
1253            DeviceInfoRequest::GetOsInfo { .. } => "get_os_info",
1254        }
1255    }
1256}
1257
1258#[derive(Debug, Clone)]
1259pub struct DeviceInfoControlHandle {
1260    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1261}
1262
1263impl fidl::endpoints::ControlHandle for DeviceInfoControlHandle {
1264    fn shutdown(&self) {
1265        self.inner.shutdown()
1266    }
1267    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1268        self.inner.shutdown_with_epitaph(status)
1269    }
1270
1271    fn is_closed(&self) -> bool {
1272        self.inner.channel().is_closed()
1273    }
1274    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1275        self.inner.channel().on_closed()
1276    }
1277
1278    #[cfg(target_os = "fuchsia")]
1279    fn signal_peer(
1280        &self,
1281        clear_mask: zx::Signals,
1282        set_mask: zx::Signals,
1283    ) -> Result<(), zx_status::Status> {
1284        use fidl::Peered;
1285        self.inner.channel().signal_peer(clear_mask, set_mask)
1286    }
1287}
1288
1289impl DeviceInfoControlHandle {}
1290
1291#[must_use = "FIDL methods require a response to be sent"]
1292#[derive(Debug)]
1293pub struct DeviceInfoGetOsInfoResponder {
1294    control_handle: std::mem::ManuallyDrop<DeviceInfoControlHandle>,
1295    tx_id: u32,
1296}
1297
1298/// Set the the channel to be shutdown (see [`DeviceInfoControlHandle::shutdown`])
1299/// if the responder is dropped without sending a response, so that the client
1300/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1301impl std::ops::Drop for DeviceInfoGetOsInfoResponder {
1302    fn drop(&mut self) {
1303        self.control_handle.shutdown();
1304        // Safety: drops once, never accessed again
1305        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1306    }
1307}
1308
1309impl fidl::endpoints::Responder for DeviceInfoGetOsInfoResponder {
1310    type ControlHandle = DeviceInfoControlHandle;
1311
1312    fn control_handle(&self) -> &DeviceInfoControlHandle {
1313        &self.control_handle
1314    }
1315
1316    fn drop_without_shutdown(mut self) {
1317        // Safety: drops once, never accessed again due to mem::forget
1318        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1319        // Prevent Drop from running (which would shut down the channel)
1320        std::mem::forget(self);
1321    }
1322}
1323
1324impl DeviceInfoGetOsInfoResponder {
1325    /// Sends a response to the FIDL transaction.
1326    ///
1327    /// Sets the channel to shutdown if an error occurs.
1328    pub fn send(self, mut info: &OsInfo) -> Result<(), fidl::Error> {
1329        let _result = self.send_raw(info);
1330        if _result.is_err() {
1331            self.control_handle.shutdown();
1332        }
1333        self.drop_without_shutdown();
1334        _result
1335    }
1336
1337    /// Similar to "send" but does not shutdown the channel if an error occurs.
1338    pub fn send_no_shutdown_on_err(self, mut info: &OsInfo) -> Result<(), fidl::Error> {
1339        let _result = self.send_raw(info);
1340        self.drop_without_shutdown();
1341        _result
1342    }
1343
1344    fn send_raw(&self, mut info: &OsInfo) -> Result<(), fidl::Error> {
1345        self.control_handle.inner.send::<DeviceInfoGetOsInfoResponse>(
1346            (info,),
1347            self.tx_id,
1348            0xf79d4f109b95dca,
1349            fidl::encoding::DynamicFlags::empty(),
1350        )
1351    }
1352}
1353
1354mod internal {
1355    use super::*;
1356
1357    impl fidl::encoding::ResourceTypeMarker for ApplicationInvokeCommandRequest {
1358        type Borrowed<'a> = &'a mut Self;
1359        fn take_or_borrow<'a>(
1360            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1361        ) -> Self::Borrowed<'a> {
1362            value
1363        }
1364    }
1365
1366    unsafe impl fidl::encoding::TypeMarker for ApplicationInvokeCommandRequest {
1367        type Owned = Self;
1368
1369        #[inline(always)]
1370        fn inline_align(_context: fidl::encoding::Context) -> usize {
1371            8
1372        }
1373
1374        #[inline(always)]
1375        fn inline_size(_context: fidl::encoding::Context) -> usize {
1376            24
1377        }
1378    }
1379
1380    unsafe impl
1381        fidl::encoding::Encode<
1382            ApplicationInvokeCommandRequest,
1383            fidl::encoding::DefaultFuchsiaResourceDialect,
1384        > for &mut ApplicationInvokeCommandRequest
1385    {
1386        #[inline]
1387        unsafe fn encode(
1388            self,
1389            encoder: &mut fidl::encoding::Encoder<
1390                '_,
1391                fidl::encoding::DefaultFuchsiaResourceDialect,
1392            >,
1393            offset: usize,
1394            _depth: fidl::encoding::Depth,
1395        ) -> fidl::Result<()> {
1396            encoder.debug_check_bounds::<ApplicationInvokeCommandRequest>(offset);
1397            // Delegate to tuple encoding.
1398            fidl::encoding::Encode::<ApplicationInvokeCommandRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1399                (
1400                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
1401                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.command_id),
1402                    <fidl::encoding::Vector<Parameter, 4> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parameter_set),
1403                ),
1404                encoder, offset, _depth
1405            )
1406        }
1407    }
1408    unsafe impl<
1409        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1410        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1411        T2: fidl::encoding::Encode<
1412                fidl::encoding::Vector<Parameter, 4>,
1413                fidl::encoding::DefaultFuchsiaResourceDialect,
1414            >,
1415    >
1416        fidl::encoding::Encode<
1417            ApplicationInvokeCommandRequest,
1418            fidl::encoding::DefaultFuchsiaResourceDialect,
1419        > for (T0, T1, T2)
1420    {
1421        #[inline]
1422        unsafe fn encode(
1423            self,
1424            encoder: &mut fidl::encoding::Encoder<
1425                '_,
1426                fidl::encoding::DefaultFuchsiaResourceDialect,
1427            >,
1428            offset: usize,
1429            depth: fidl::encoding::Depth,
1430        ) -> fidl::Result<()> {
1431            encoder.debug_check_bounds::<ApplicationInvokeCommandRequest>(offset);
1432            // Zero out padding regions. There's no need to apply masks
1433            // because the unmasked parts will be overwritten by fields.
1434            // Write the fields.
1435            self.0.encode(encoder, offset + 0, depth)?;
1436            self.1.encode(encoder, offset + 4, depth)?;
1437            self.2.encode(encoder, offset + 8, depth)?;
1438            Ok(())
1439        }
1440    }
1441
1442    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1443        for ApplicationInvokeCommandRequest
1444    {
1445        #[inline(always)]
1446        fn new_empty() -> Self {
1447            Self {
1448                session_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1449                command_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1450                parameter_set: fidl::new_empty!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect),
1451            }
1452        }
1453
1454        #[inline]
1455        unsafe fn decode(
1456            &mut self,
1457            decoder: &mut fidl::encoding::Decoder<
1458                '_,
1459                fidl::encoding::DefaultFuchsiaResourceDialect,
1460            >,
1461            offset: usize,
1462            _depth: fidl::encoding::Depth,
1463        ) -> fidl::Result<()> {
1464            decoder.debug_check_bounds::<Self>(offset);
1465            // Verify that padding bytes are zero.
1466            fidl::decode!(
1467                u32,
1468                fidl::encoding::DefaultFuchsiaResourceDialect,
1469                &mut self.session_id,
1470                decoder,
1471                offset + 0,
1472                _depth
1473            )?;
1474            fidl::decode!(
1475                u32,
1476                fidl::encoding::DefaultFuchsiaResourceDialect,
1477                &mut self.command_id,
1478                decoder,
1479                offset + 4,
1480                _depth
1481            )?;
1482            fidl::decode!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.parameter_set, decoder, offset + 8, _depth)?;
1483            Ok(())
1484        }
1485    }
1486
1487    impl fidl::encoding::ResourceTypeMarker for ApplicationInvokeCommandResponse {
1488        type Borrowed<'a> = &'a mut Self;
1489        fn take_or_borrow<'a>(
1490            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1491        ) -> Self::Borrowed<'a> {
1492            value
1493        }
1494    }
1495
1496    unsafe impl fidl::encoding::TypeMarker for ApplicationInvokeCommandResponse {
1497        type Owned = Self;
1498
1499        #[inline(always)]
1500        fn inline_align(_context: fidl::encoding::Context) -> usize {
1501            8
1502        }
1503
1504        #[inline(always)]
1505        fn inline_size(_context: fidl::encoding::Context) -> usize {
1506            16
1507        }
1508    }
1509
1510    unsafe impl
1511        fidl::encoding::Encode<
1512            ApplicationInvokeCommandResponse,
1513            fidl::encoding::DefaultFuchsiaResourceDialect,
1514        > for &mut ApplicationInvokeCommandResponse
1515    {
1516        #[inline]
1517        unsafe fn encode(
1518            self,
1519            encoder: &mut fidl::encoding::Encoder<
1520                '_,
1521                fidl::encoding::DefaultFuchsiaResourceDialect,
1522            >,
1523            offset: usize,
1524            _depth: fidl::encoding::Depth,
1525        ) -> fidl::Result<()> {
1526            encoder.debug_check_bounds::<ApplicationInvokeCommandResponse>(offset);
1527            // Delegate to tuple encoding.
1528            fidl::encoding::Encode::<
1529                ApplicationInvokeCommandResponse,
1530                fidl::encoding::DefaultFuchsiaResourceDialect,
1531            >::encode(
1532                (<OpResult as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1533                    &mut self.op_result,
1534                ),),
1535                encoder,
1536                offset,
1537                _depth,
1538            )
1539        }
1540    }
1541    unsafe impl<T0: fidl::encoding::Encode<OpResult, fidl::encoding::DefaultFuchsiaResourceDialect>>
1542        fidl::encoding::Encode<
1543            ApplicationInvokeCommandResponse,
1544            fidl::encoding::DefaultFuchsiaResourceDialect,
1545        > for (T0,)
1546    {
1547        #[inline]
1548        unsafe fn encode(
1549            self,
1550            encoder: &mut fidl::encoding::Encoder<
1551                '_,
1552                fidl::encoding::DefaultFuchsiaResourceDialect,
1553            >,
1554            offset: usize,
1555            depth: fidl::encoding::Depth,
1556        ) -> fidl::Result<()> {
1557            encoder.debug_check_bounds::<ApplicationInvokeCommandResponse>(offset);
1558            // Zero out padding regions. There's no need to apply masks
1559            // because the unmasked parts will be overwritten by fields.
1560            // Write the fields.
1561            self.0.encode(encoder, offset + 0, depth)?;
1562            Ok(())
1563        }
1564    }
1565
1566    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1567        for ApplicationInvokeCommandResponse
1568    {
1569        #[inline(always)]
1570        fn new_empty() -> Self {
1571            Self {
1572                op_result: fidl::new_empty!(
1573                    OpResult,
1574                    fidl::encoding::DefaultFuchsiaResourceDialect
1575                ),
1576            }
1577        }
1578
1579        #[inline]
1580        unsafe fn decode(
1581            &mut self,
1582            decoder: &mut fidl::encoding::Decoder<
1583                '_,
1584                fidl::encoding::DefaultFuchsiaResourceDialect,
1585            >,
1586            offset: usize,
1587            _depth: fidl::encoding::Depth,
1588        ) -> fidl::Result<()> {
1589            decoder.debug_check_bounds::<Self>(offset);
1590            // Verify that padding bytes are zero.
1591            fidl::decode!(
1592                OpResult,
1593                fidl::encoding::DefaultFuchsiaResourceDialect,
1594                &mut self.op_result,
1595                decoder,
1596                offset + 0,
1597                _depth
1598            )?;
1599            Ok(())
1600        }
1601    }
1602
1603    impl fidl::encoding::ResourceTypeMarker for ApplicationOpenSession2Request {
1604        type Borrowed<'a> = &'a mut Self;
1605        fn take_or_borrow<'a>(
1606            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1607        ) -> Self::Borrowed<'a> {
1608            value
1609        }
1610    }
1611
1612    unsafe impl fidl::encoding::TypeMarker for ApplicationOpenSession2Request {
1613        type Owned = Self;
1614
1615        #[inline(always)]
1616        fn inline_align(_context: fidl::encoding::Context) -> usize {
1617            8
1618        }
1619
1620        #[inline(always)]
1621        fn inline_size(_context: fidl::encoding::Context) -> usize {
1622            16
1623        }
1624    }
1625
1626    unsafe impl
1627        fidl::encoding::Encode<
1628            ApplicationOpenSession2Request,
1629            fidl::encoding::DefaultFuchsiaResourceDialect,
1630        > for &mut ApplicationOpenSession2Request
1631    {
1632        #[inline]
1633        unsafe fn encode(
1634            self,
1635            encoder: &mut fidl::encoding::Encoder<
1636                '_,
1637                fidl::encoding::DefaultFuchsiaResourceDialect,
1638            >,
1639            offset: usize,
1640            _depth: fidl::encoding::Depth,
1641        ) -> fidl::Result<()> {
1642            encoder.debug_check_bounds::<ApplicationOpenSession2Request>(offset);
1643            // Delegate to tuple encoding.
1644            fidl::encoding::Encode::<ApplicationOpenSession2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1645                (
1646                    <fidl::encoding::Vector<Parameter, 4> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parameter_set),
1647                ),
1648                encoder, offset, _depth
1649            )
1650        }
1651    }
1652    unsafe impl<
1653        T0: fidl::encoding::Encode<
1654                fidl::encoding::Vector<Parameter, 4>,
1655                fidl::encoding::DefaultFuchsiaResourceDialect,
1656            >,
1657    >
1658        fidl::encoding::Encode<
1659            ApplicationOpenSession2Request,
1660            fidl::encoding::DefaultFuchsiaResourceDialect,
1661        > for (T0,)
1662    {
1663        #[inline]
1664        unsafe fn encode(
1665            self,
1666            encoder: &mut fidl::encoding::Encoder<
1667                '_,
1668                fidl::encoding::DefaultFuchsiaResourceDialect,
1669            >,
1670            offset: usize,
1671            depth: fidl::encoding::Depth,
1672        ) -> fidl::Result<()> {
1673            encoder.debug_check_bounds::<ApplicationOpenSession2Request>(offset);
1674            // Zero out padding regions. There's no need to apply masks
1675            // because the unmasked parts will be overwritten by fields.
1676            // Write the fields.
1677            self.0.encode(encoder, offset + 0, depth)?;
1678            Ok(())
1679        }
1680    }
1681
1682    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1683        for ApplicationOpenSession2Request
1684    {
1685        #[inline(always)]
1686        fn new_empty() -> Self {
1687            Self {
1688                parameter_set: fidl::new_empty!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect),
1689            }
1690        }
1691
1692        #[inline]
1693        unsafe fn decode(
1694            &mut self,
1695            decoder: &mut fidl::encoding::Decoder<
1696                '_,
1697                fidl::encoding::DefaultFuchsiaResourceDialect,
1698            >,
1699            offset: usize,
1700            _depth: fidl::encoding::Depth,
1701        ) -> fidl::Result<()> {
1702            decoder.debug_check_bounds::<Self>(offset);
1703            // Verify that padding bytes are zero.
1704            fidl::decode!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.parameter_set, decoder, offset + 0, _depth)?;
1705            Ok(())
1706        }
1707    }
1708
1709    impl fidl::encoding::ResourceTypeMarker for ApplicationOpenSession2Response {
1710        type Borrowed<'a> = &'a mut Self;
1711        fn take_or_borrow<'a>(
1712            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1713        ) -> Self::Borrowed<'a> {
1714            value
1715        }
1716    }
1717
1718    unsafe impl fidl::encoding::TypeMarker for ApplicationOpenSession2Response {
1719        type Owned = Self;
1720
1721        #[inline(always)]
1722        fn inline_align(_context: fidl::encoding::Context) -> usize {
1723            8
1724        }
1725
1726        #[inline(always)]
1727        fn inline_size(_context: fidl::encoding::Context) -> usize {
1728            24
1729        }
1730    }
1731
1732    unsafe impl
1733        fidl::encoding::Encode<
1734            ApplicationOpenSession2Response,
1735            fidl::encoding::DefaultFuchsiaResourceDialect,
1736        > for &mut ApplicationOpenSession2Response
1737    {
1738        #[inline]
1739        unsafe fn encode(
1740            self,
1741            encoder: &mut fidl::encoding::Encoder<
1742                '_,
1743                fidl::encoding::DefaultFuchsiaResourceDialect,
1744            >,
1745            offset: usize,
1746            _depth: fidl::encoding::Depth,
1747        ) -> fidl::Result<()> {
1748            encoder.debug_check_bounds::<ApplicationOpenSession2Response>(offset);
1749            // Delegate to tuple encoding.
1750            fidl::encoding::Encode::<
1751                ApplicationOpenSession2Response,
1752                fidl::encoding::DefaultFuchsiaResourceDialect,
1753            >::encode(
1754                (
1755                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
1756                    <OpResult as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1757                        &mut self.op_result,
1758                    ),
1759                ),
1760                encoder,
1761                offset,
1762                _depth,
1763            )
1764        }
1765    }
1766    unsafe impl<
1767        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1768        T1: fidl::encoding::Encode<OpResult, fidl::encoding::DefaultFuchsiaResourceDialect>,
1769    >
1770        fidl::encoding::Encode<
1771            ApplicationOpenSession2Response,
1772            fidl::encoding::DefaultFuchsiaResourceDialect,
1773        > for (T0, T1)
1774    {
1775        #[inline]
1776        unsafe fn encode(
1777            self,
1778            encoder: &mut fidl::encoding::Encoder<
1779                '_,
1780                fidl::encoding::DefaultFuchsiaResourceDialect,
1781            >,
1782            offset: usize,
1783            depth: fidl::encoding::Depth,
1784        ) -> fidl::Result<()> {
1785            encoder.debug_check_bounds::<ApplicationOpenSession2Response>(offset);
1786            // Zero out padding regions. There's no need to apply masks
1787            // because the unmasked parts will be overwritten by fields.
1788            unsafe {
1789                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1790                (ptr as *mut u64).write_unaligned(0);
1791            }
1792            // Write the fields.
1793            self.0.encode(encoder, offset + 0, depth)?;
1794            self.1.encode(encoder, offset + 8, depth)?;
1795            Ok(())
1796        }
1797    }
1798
1799    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1800        for ApplicationOpenSession2Response
1801    {
1802        #[inline(always)]
1803        fn new_empty() -> Self {
1804            Self {
1805                session_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
1806                op_result: fidl::new_empty!(
1807                    OpResult,
1808                    fidl::encoding::DefaultFuchsiaResourceDialect
1809                ),
1810            }
1811        }
1812
1813        #[inline]
1814        unsafe fn decode(
1815            &mut self,
1816            decoder: &mut fidl::encoding::Decoder<
1817                '_,
1818                fidl::encoding::DefaultFuchsiaResourceDialect,
1819            >,
1820            offset: usize,
1821            _depth: fidl::encoding::Depth,
1822        ) -> fidl::Result<()> {
1823            decoder.debug_check_bounds::<Self>(offset);
1824            // Verify that padding bytes are zero.
1825            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1826            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1827            let mask = 0xffffffff00000000u64;
1828            let maskedval = padval & mask;
1829            if maskedval != 0 {
1830                return Err(fidl::Error::NonZeroPadding {
1831                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1832                });
1833            }
1834            fidl::decode!(
1835                u32,
1836                fidl::encoding::DefaultFuchsiaResourceDialect,
1837                &mut self.session_id,
1838                decoder,
1839                offset + 0,
1840                _depth
1841            )?;
1842            fidl::decode!(
1843                OpResult,
1844                fidl::encoding::DefaultFuchsiaResourceDialect,
1845                &mut self.op_result,
1846                decoder,
1847                offset + 8,
1848                _depth
1849            )?;
1850            Ok(())
1851        }
1852    }
1853
1854    impl Buffer {
1855        #[inline(always)]
1856        fn max_ordinal_present(&self) -> u64 {
1857            if let Some(_) = self.size {
1858                return 4;
1859            }
1860            if let Some(_) = self.offset {
1861                return 3;
1862            }
1863            if let Some(_) = self.vmo {
1864                return 2;
1865            }
1866            if let Some(_) = self.direction {
1867                return 1;
1868            }
1869            0
1870        }
1871    }
1872
1873    impl fidl::encoding::ResourceTypeMarker for Buffer {
1874        type Borrowed<'a> = &'a mut Self;
1875        fn take_or_borrow<'a>(
1876            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1877        ) -> Self::Borrowed<'a> {
1878            value
1879        }
1880    }
1881
1882    unsafe impl fidl::encoding::TypeMarker for Buffer {
1883        type Owned = Self;
1884
1885        #[inline(always)]
1886        fn inline_align(_context: fidl::encoding::Context) -> usize {
1887            8
1888        }
1889
1890        #[inline(always)]
1891        fn inline_size(_context: fidl::encoding::Context) -> usize {
1892            16
1893        }
1894    }
1895
1896    unsafe impl fidl::encoding::Encode<Buffer, fidl::encoding::DefaultFuchsiaResourceDialect>
1897        for &mut Buffer
1898    {
1899        unsafe fn encode(
1900            self,
1901            encoder: &mut fidl::encoding::Encoder<
1902                '_,
1903                fidl::encoding::DefaultFuchsiaResourceDialect,
1904            >,
1905            offset: usize,
1906            mut depth: fidl::encoding::Depth,
1907        ) -> fidl::Result<()> {
1908            encoder.debug_check_bounds::<Buffer>(offset);
1909            // Vector header
1910            let max_ordinal: u64 = self.max_ordinal_present();
1911            encoder.write_num(max_ordinal, offset);
1912            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1913            // Calling encoder.out_of_line_offset(0) is not allowed.
1914            if max_ordinal == 0 {
1915                return Ok(());
1916            }
1917            depth.increment()?;
1918            let envelope_size = 8;
1919            let bytes_len = max_ordinal as usize * envelope_size;
1920            #[allow(unused_variables)]
1921            let offset = encoder.out_of_line_offset(bytes_len);
1922            let mut _prev_end_offset: usize = 0;
1923            if 1 > max_ordinal {
1924                return Ok(());
1925            }
1926
1927            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1928            // are envelope_size bytes.
1929            let cur_offset: usize = (1 - 1) * envelope_size;
1930
1931            // Zero reserved fields.
1932            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1933
1934            // Safety:
1935            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1936            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1937            //   envelope_size bytes, there is always sufficient room.
1938            fidl::encoding::encode_in_envelope_optional::<
1939                Direction,
1940                fidl::encoding::DefaultFuchsiaResourceDialect,
1941            >(
1942                self.direction.as_ref().map(<Direction as fidl::encoding::ValueTypeMarker>::borrow),
1943                encoder,
1944                offset + cur_offset,
1945                depth,
1946            )?;
1947
1948            _prev_end_offset = cur_offset + envelope_size;
1949            if 2 > max_ordinal {
1950                return Ok(());
1951            }
1952
1953            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1954            // are envelope_size bytes.
1955            let cur_offset: usize = (2 - 1) * envelope_size;
1956
1957            // Zero reserved fields.
1958            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1959
1960            // Safety:
1961            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1962            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1963            //   envelope_size bytes, there is always sufficient room.
1964            fidl::encoding::encode_in_envelope_optional::<
1965                fidl::encoding::HandleType<
1966                    fidl::Vmo,
1967                    { fidl::ObjectType::VMO.into_raw() },
1968                    2147483648,
1969                >,
1970                fidl::encoding::DefaultFuchsiaResourceDialect,
1971            >(
1972                self.vmo.as_mut().map(
1973                    <fidl::encoding::HandleType<
1974                        fidl::Vmo,
1975                        { fidl::ObjectType::VMO.into_raw() },
1976                        2147483648,
1977                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1978                ),
1979                encoder,
1980                offset + cur_offset,
1981                depth,
1982            )?;
1983
1984            _prev_end_offset = cur_offset + envelope_size;
1985            if 3 > max_ordinal {
1986                return Ok(());
1987            }
1988
1989            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1990            // are envelope_size bytes.
1991            let cur_offset: usize = (3 - 1) * envelope_size;
1992
1993            // Zero reserved fields.
1994            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1995
1996            // Safety:
1997            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1998            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1999            //   envelope_size bytes, there is always sufficient room.
2000            fidl::encoding::encode_in_envelope_optional::<
2001                u64,
2002                fidl::encoding::DefaultFuchsiaResourceDialect,
2003            >(
2004                self.offset.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2005                encoder,
2006                offset + cur_offset,
2007                depth,
2008            )?;
2009
2010            _prev_end_offset = cur_offset + envelope_size;
2011            if 4 > max_ordinal {
2012                return Ok(());
2013            }
2014
2015            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2016            // are envelope_size bytes.
2017            let cur_offset: usize = (4 - 1) * envelope_size;
2018
2019            // Zero reserved fields.
2020            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2021
2022            // Safety:
2023            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2024            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2025            //   envelope_size bytes, there is always sufficient room.
2026            fidl::encoding::encode_in_envelope_optional::<
2027                u64,
2028                fidl::encoding::DefaultFuchsiaResourceDialect,
2029            >(
2030                self.size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2031                encoder,
2032                offset + cur_offset,
2033                depth,
2034            )?;
2035
2036            _prev_end_offset = cur_offset + envelope_size;
2037
2038            Ok(())
2039        }
2040    }
2041
2042    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Buffer {
2043        #[inline(always)]
2044        fn new_empty() -> Self {
2045            Self::default()
2046        }
2047
2048        unsafe fn decode(
2049            &mut self,
2050            decoder: &mut fidl::encoding::Decoder<
2051                '_,
2052                fidl::encoding::DefaultFuchsiaResourceDialect,
2053            >,
2054            offset: usize,
2055            mut depth: fidl::encoding::Depth,
2056        ) -> fidl::Result<()> {
2057            decoder.debug_check_bounds::<Self>(offset);
2058            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2059                None => return Err(fidl::Error::NotNullable),
2060                Some(len) => len,
2061            };
2062            // Calling decoder.out_of_line_offset(0) is not allowed.
2063            if len == 0 {
2064                return Ok(());
2065            };
2066            depth.increment()?;
2067            let envelope_size = 8;
2068            let bytes_len = len * envelope_size;
2069            let offset = decoder.out_of_line_offset(bytes_len)?;
2070            // Decode the envelope for each type.
2071            let mut _next_ordinal_to_read = 0;
2072            let mut next_offset = offset;
2073            let end_offset = offset + bytes_len;
2074            _next_ordinal_to_read += 1;
2075            if next_offset >= end_offset {
2076                return Ok(());
2077            }
2078
2079            // Decode unknown envelopes for gaps in ordinals.
2080            while _next_ordinal_to_read < 1 {
2081                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2082                _next_ordinal_to_read += 1;
2083                next_offset += envelope_size;
2084            }
2085
2086            let next_out_of_line = decoder.next_out_of_line();
2087            let handles_before = decoder.remaining_handles();
2088            if let Some((inlined, num_bytes, num_handles)) =
2089                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2090            {
2091                let member_inline_size =
2092                    <Direction as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2093                if inlined != (member_inline_size <= 4) {
2094                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2095                }
2096                let inner_offset;
2097                let mut inner_depth = depth.clone();
2098                if inlined {
2099                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2100                    inner_offset = next_offset;
2101                } else {
2102                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2103                    inner_depth.increment()?;
2104                }
2105                let val_ref = self.direction.get_or_insert_with(|| {
2106                    fidl::new_empty!(Direction, fidl::encoding::DefaultFuchsiaResourceDialect)
2107                });
2108                fidl::decode!(
2109                    Direction,
2110                    fidl::encoding::DefaultFuchsiaResourceDialect,
2111                    val_ref,
2112                    decoder,
2113                    inner_offset,
2114                    inner_depth
2115                )?;
2116                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2117                {
2118                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2119                }
2120                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2121                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2122                }
2123            }
2124
2125            next_offset += envelope_size;
2126            _next_ordinal_to_read += 1;
2127            if next_offset >= end_offset {
2128                return Ok(());
2129            }
2130
2131            // Decode unknown envelopes for gaps in ordinals.
2132            while _next_ordinal_to_read < 2 {
2133                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2134                _next_ordinal_to_read += 1;
2135                next_offset += envelope_size;
2136            }
2137
2138            let next_out_of_line = decoder.next_out_of_line();
2139            let handles_before = decoder.remaining_handles();
2140            if let Some((inlined, num_bytes, num_handles)) =
2141                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2142            {
2143                let member_inline_size = <fidl::encoding::HandleType<
2144                    fidl::Vmo,
2145                    { fidl::ObjectType::VMO.into_raw() },
2146                    2147483648,
2147                > as fidl::encoding::TypeMarker>::inline_size(
2148                    decoder.context
2149                );
2150                if inlined != (member_inline_size <= 4) {
2151                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2152                }
2153                let inner_offset;
2154                let mut inner_depth = depth.clone();
2155                if inlined {
2156                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2157                    inner_offset = next_offset;
2158                } else {
2159                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2160                    inner_depth.increment()?;
2161                }
2162                let val_ref =
2163                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2164                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2165                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2166                {
2167                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2168                }
2169                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2170                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2171                }
2172            }
2173
2174            next_offset += envelope_size;
2175            _next_ordinal_to_read += 1;
2176            if next_offset >= end_offset {
2177                return Ok(());
2178            }
2179
2180            // Decode unknown envelopes for gaps in ordinals.
2181            while _next_ordinal_to_read < 3 {
2182                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2183                _next_ordinal_to_read += 1;
2184                next_offset += envelope_size;
2185            }
2186
2187            let next_out_of_line = decoder.next_out_of_line();
2188            let handles_before = decoder.remaining_handles();
2189            if let Some((inlined, num_bytes, num_handles)) =
2190                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2191            {
2192                let member_inline_size =
2193                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2194                if inlined != (member_inline_size <= 4) {
2195                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2196                }
2197                let inner_offset;
2198                let mut inner_depth = depth.clone();
2199                if inlined {
2200                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2201                    inner_offset = next_offset;
2202                } else {
2203                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2204                    inner_depth.increment()?;
2205                }
2206                let val_ref = self.offset.get_or_insert_with(|| {
2207                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2208                });
2209                fidl::decode!(
2210                    u64,
2211                    fidl::encoding::DefaultFuchsiaResourceDialect,
2212                    val_ref,
2213                    decoder,
2214                    inner_offset,
2215                    inner_depth
2216                )?;
2217                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2218                {
2219                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2220                }
2221                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2222                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2223                }
2224            }
2225
2226            next_offset += envelope_size;
2227            _next_ordinal_to_read += 1;
2228            if next_offset >= end_offset {
2229                return Ok(());
2230            }
2231
2232            // Decode unknown envelopes for gaps in ordinals.
2233            while _next_ordinal_to_read < 4 {
2234                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2235                _next_ordinal_to_read += 1;
2236                next_offset += envelope_size;
2237            }
2238
2239            let next_out_of_line = decoder.next_out_of_line();
2240            let handles_before = decoder.remaining_handles();
2241            if let Some((inlined, num_bytes, num_handles)) =
2242                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2243            {
2244                let member_inline_size =
2245                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2246                if inlined != (member_inline_size <= 4) {
2247                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2248                }
2249                let inner_offset;
2250                let mut inner_depth = depth.clone();
2251                if inlined {
2252                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2253                    inner_offset = next_offset;
2254                } else {
2255                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2256                    inner_depth.increment()?;
2257                }
2258                let val_ref = self.size.get_or_insert_with(|| {
2259                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2260                });
2261                fidl::decode!(
2262                    u64,
2263                    fidl::encoding::DefaultFuchsiaResourceDialect,
2264                    val_ref,
2265                    decoder,
2266                    inner_offset,
2267                    inner_depth
2268                )?;
2269                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2270                {
2271                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2272                }
2273                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2274                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2275                }
2276            }
2277
2278            next_offset += envelope_size;
2279
2280            // Decode the remaining unknown envelopes.
2281            while next_offset < end_offset {
2282                _next_ordinal_to_read += 1;
2283                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2284                next_offset += envelope_size;
2285            }
2286
2287            Ok(())
2288        }
2289    }
2290
2291    impl OpResult {
2292        #[inline(always)]
2293        fn max_ordinal_present(&self) -> u64 {
2294            if let Some(_) = self.parameter_set {
2295                return 3;
2296            }
2297            if let Some(_) = self.return_origin {
2298                return 2;
2299            }
2300            if let Some(_) = self.return_code {
2301                return 1;
2302            }
2303            0
2304        }
2305    }
2306
2307    impl fidl::encoding::ResourceTypeMarker for OpResult {
2308        type Borrowed<'a> = &'a mut Self;
2309        fn take_or_borrow<'a>(
2310            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2311        ) -> Self::Borrowed<'a> {
2312            value
2313        }
2314    }
2315
2316    unsafe impl fidl::encoding::TypeMarker for OpResult {
2317        type Owned = Self;
2318
2319        #[inline(always)]
2320        fn inline_align(_context: fidl::encoding::Context) -> usize {
2321            8
2322        }
2323
2324        #[inline(always)]
2325        fn inline_size(_context: fidl::encoding::Context) -> usize {
2326            16
2327        }
2328    }
2329
2330    unsafe impl fidl::encoding::Encode<OpResult, fidl::encoding::DefaultFuchsiaResourceDialect>
2331        for &mut OpResult
2332    {
2333        unsafe fn encode(
2334            self,
2335            encoder: &mut fidl::encoding::Encoder<
2336                '_,
2337                fidl::encoding::DefaultFuchsiaResourceDialect,
2338            >,
2339            offset: usize,
2340            mut depth: fidl::encoding::Depth,
2341        ) -> fidl::Result<()> {
2342            encoder.debug_check_bounds::<OpResult>(offset);
2343            // Vector header
2344            let max_ordinal: u64 = self.max_ordinal_present();
2345            encoder.write_num(max_ordinal, offset);
2346            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2347            // Calling encoder.out_of_line_offset(0) is not allowed.
2348            if max_ordinal == 0 {
2349                return Ok(());
2350            }
2351            depth.increment()?;
2352            let envelope_size = 8;
2353            let bytes_len = max_ordinal as usize * envelope_size;
2354            #[allow(unused_variables)]
2355            let offset = encoder.out_of_line_offset(bytes_len);
2356            let mut _prev_end_offset: usize = 0;
2357            if 1 > max_ordinal {
2358                return Ok(());
2359            }
2360
2361            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2362            // are envelope_size bytes.
2363            let cur_offset: usize = (1 - 1) * envelope_size;
2364
2365            // Zero reserved fields.
2366            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2367
2368            // Safety:
2369            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2370            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2371            //   envelope_size bytes, there is always sufficient room.
2372            fidl::encoding::encode_in_envelope_optional::<
2373                u64,
2374                fidl::encoding::DefaultFuchsiaResourceDialect,
2375            >(
2376                self.return_code.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2377                encoder,
2378                offset + cur_offset,
2379                depth,
2380            )?;
2381
2382            _prev_end_offset = cur_offset + envelope_size;
2383            if 2 > max_ordinal {
2384                return Ok(());
2385            }
2386
2387            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2388            // are envelope_size bytes.
2389            let cur_offset: usize = (2 - 1) * envelope_size;
2390
2391            // Zero reserved fields.
2392            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2393
2394            // Safety:
2395            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2396            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2397            //   envelope_size bytes, there is always sufficient room.
2398            fidl::encoding::encode_in_envelope_optional::<
2399                ReturnOrigin,
2400                fidl::encoding::DefaultFuchsiaResourceDialect,
2401            >(
2402                self.return_origin
2403                    .as_ref()
2404                    .map(<ReturnOrigin as fidl::encoding::ValueTypeMarker>::borrow),
2405                encoder,
2406                offset + cur_offset,
2407                depth,
2408            )?;
2409
2410            _prev_end_offset = cur_offset + envelope_size;
2411            if 3 > max_ordinal {
2412                return Ok(());
2413            }
2414
2415            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2416            // are envelope_size bytes.
2417            let cur_offset: usize = (3 - 1) * envelope_size;
2418
2419            // Zero reserved fields.
2420            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2421
2422            // Safety:
2423            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2424            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2425            //   envelope_size bytes, there is always sufficient room.
2426            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect>(
2427            self.parameter_set.as_mut().map(<fidl::encoding::Vector<Parameter, 4> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2428            encoder, offset + cur_offset, depth
2429        )?;
2430
2431            _prev_end_offset = cur_offset + envelope_size;
2432
2433            Ok(())
2434        }
2435    }
2436
2437    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for OpResult {
2438        #[inline(always)]
2439        fn new_empty() -> Self {
2440            Self::default()
2441        }
2442
2443        unsafe fn decode(
2444            &mut self,
2445            decoder: &mut fidl::encoding::Decoder<
2446                '_,
2447                fidl::encoding::DefaultFuchsiaResourceDialect,
2448            >,
2449            offset: usize,
2450            mut depth: fidl::encoding::Depth,
2451        ) -> fidl::Result<()> {
2452            decoder.debug_check_bounds::<Self>(offset);
2453            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2454                None => return Err(fidl::Error::NotNullable),
2455                Some(len) => len,
2456            };
2457            // Calling decoder.out_of_line_offset(0) is not allowed.
2458            if len == 0 {
2459                return Ok(());
2460            };
2461            depth.increment()?;
2462            let envelope_size = 8;
2463            let bytes_len = len * envelope_size;
2464            let offset = decoder.out_of_line_offset(bytes_len)?;
2465            // Decode the envelope for each type.
2466            let mut _next_ordinal_to_read = 0;
2467            let mut next_offset = offset;
2468            let end_offset = offset + bytes_len;
2469            _next_ordinal_to_read += 1;
2470            if next_offset >= end_offset {
2471                return Ok(());
2472            }
2473
2474            // Decode unknown envelopes for gaps in ordinals.
2475            while _next_ordinal_to_read < 1 {
2476                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2477                _next_ordinal_to_read += 1;
2478                next_offset += envelope_size;
2479            }
2480
2481            let next_out_of_line = decoder.next_out_of_line();
2482            let handles_before = decoder.remaining_handles();
2483            if let Some((inlined, num_bytes, num_handles)) =
2484                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2485            {
2486                let member_inline_size =
2487                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2488                if inlined != (member_inline_size <= 4) {
2489                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2490                }
2491                let inner_offset;
2492                let mut inner_depth = depth.clone();
2493                if inlined {
2494                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2495                    inner_offset = next_offset;
2496                } else {
2497                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2498                    inner_depth.increment()?;
2499                }
2500                let val_ref = self.return_code.get_or_insert_with(|| {
2501                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2502                });
2503                fidl::decode!(
2504                    u64,
2505                    fidl::encoding::DefaultFuchsiaResourceDialect,
2506                    val_ref,
2507                    decoder,
2508                    inner_offset,
2509                    inner_depth
2510                )?;
2511                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2512                {
2513                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2514                }
2515                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2516                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2517                }
2518            }
2519
2520            next_offset += envelope_size;
2521            _next_ordinal_to_read += 1;
2522            if next_offset >= end_offset {
2523                return Ok(());
2524            }
2525
2526            // Decode unknown envelopes for gaps in ordinals.
2527            while _next_ordinal_to_read < 2 {
2528                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2529                _next_ordinal_to_read += 1;
2530                next_offset += envelope_size;
2531            }
2532
2533            let next_out_of_line = decoder.next_out_of_line();
2534            let handles_before = decoder.remaining_handles();
2535            if let Some((inlined, num_bytes, num_handles)) =
2536                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2537            {
2538                let member_inline_size =
2539                    <ReturnOrigin as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2540                if inlined != (member_inline_size <= 4) {
2541                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2542                }
2543                let inner_offset;
2544                let mut inner_depth = depth.clone();
2545                if inlined {
2546                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2547                    inner_offset = next_offset;
2548                } else {
2549                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2550                    inner_depth.increment()?;
2551                }
2552                let val_ref = self.return_origin.get_or_insert_with(|| {
2553                    fidl::new_empty!(ReturnOrigin, fidl::encoding::DefaultFuchsiaResourceDialect)
2554                });
2555                fidl::decode!(
2556                    ReturnOrigin,
2557                    fidl::encoding::DefaultFuchsiaResourceDialect,
2558                    val_ref,
2559                    decoder,
2560                    inner_offset,
2561                    inner_depth
2562                )?;
2563                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2564                {
2565                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2566                }
2567                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2568                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2569                }
2570            }
2571
2572            next_offset += envelope_size;
2573            _next_ordinal_to_read += 1;
2574            if next_offset >= end_offset {
2575                return Ok(());
2576            }
2577
2578            // Decode unknown envelopes for gaps in ordinals.
2579            while _next_ordinal_to_read < 3 {
2580                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2581                _next_ordinal_to_read += 1;
2582                next_offset += envelope_size;
2583            }
2584
2585            let next_out_of_line = decoder.next_out_of_line();
2586            let handles_before = decoder.remaining_handles();
2587            if let Some((inlined, num_bytes, num_handles)) =
2588                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2589            {
2590                let member_inline_size = <fidl::encoding::Vector<Parameter, 4> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2591                if inlined != (member_inline_size <= 4) {
2592                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2593                }
2594                let inner_offset;
2595                let mut inner_depth = depth.clone();
2596                if inlined {
2597                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2598                    inner_offset = next_offset;
2599                } else {
2600                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2601                    inner_depth.increment()?;
2602                }
2603                let val_ref =
2604                self.parameter_set.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect));
2605                fidl::decode!(fidl::encoding::Vector<Parameter, 4>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2606                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2607                {
2608                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2609                }
2610                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2611                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2612                }
2613            }
2614
2615            next_offset += envelope_size;
2616
2617            // Decode the remaining unknown envelopes.
2618            while next_offset < end_offset {
2619                _next_ordinal_to_read += 1;
2620                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2621                next_offset += envelope_size;
2622            }
2623
2624            Ok(())
2625        }
2626    }
2627
2628    impl fidl::encoding::ResourceTypeMarker for Parameter {
2629        type Borrowed<'a> = &'a mut Self;
2630        fn take_or_borrow<'a>(
2631            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2632        ) -> Self::Borrowed<'a> {
2633            value
2634        }
2635    }
2636
2637    unsafe impl fidl::encoding::TypeMarker for Parameter {
2638        type Owned = Self;
2639
2640        #[inline(always)]
2641        fn inline_align(_context: fidl::encoding::Context) -> usize {
2642            8
2643        }
2644
2645        #[inline(always)]
2646        fn inline_size(_context: fidl::encoding::Context) -> usize {
2647            16
2648        }
2649    }
2650
2651    unsafe impl fidl::encoding::Encode<Parameter, fidl::encoding::DefaultFuchsiaResourceDialect>
2652        for &mut Parameter
2653    {
2654        #[inline]
2655        unsafe fn encode(
2656            self,
2657            encoder: &mut fidl::encoding::Encoder<
2658                '_,
2659                fidl::encoding::DefaultFuchsiaResourceDialect,
2660            >,
2661            offset: usize,
2662            _depth: fidl::encoding::Depth,
2663        ) -> fidl::Result<()> {
2664            encoder.debug_check_bounds::<Parameter>(offset);
2665            encoder.write_num::<u64>(self.ordinal(), offset);
2666            match self {
2667                Parameter::None(ref val) => fidl::encoding::encode_in_envelope::<
2668                    None_,
2669                    fidl::encoding::DefaultFuchsiaResourceDialect,
2670                >(
2671                    <None_ as fidl::encoding::ValueTypeMarker>::borrow(val),
2672                    encoder,
2673                    offset + 8,
2674                    _depth,
2675                ),
2676                Parameter::Buffer(ref mut val) => fidl::encoding::encode_in_envelope::<
2677                    Buffer,
2678                    fidl::encoding::DefaultFuchsiaResourceDialect,
2679                >(
2680                    <Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
2681                    encoder,
2682                    offset + 8,
2683                    _depth,
2684                ),
2685                Parameter::Value(ref val) => fidl::encoding::encode_in_envelope::<
2686                    Value,
2687                    fidl::encoding::DefaultFuchsiaResourceDialect,
2688                >(
2689                    <Value as fidl::encoding::ValueTypeMarker>::borrow(val),
2690                    encoder,
2691                    offset + 8,
2692                    _depth,
2693                ),
2694                Parameter::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2695            }
2696        }
2697    }
2698
2699    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Parameter {
2700        #[inline(always)]
2701        fn new_empty() -> Self {
2702            Self::__SourceBreaking { unknown_ordinal: 0 }
2703        }
2704
2705        #[inline]
2706        unsafe fn decode(
2707            &mut self,
2708            decoder: &mut fidl::encoding::Decoder<
2709                '_,
2710                fidl::encoding::DefaultFuchsiaResourceDialect,
2711            >,
2712            offset: usize,
2713            mut depth: fidl::encoding::Depth,
2714        ) -> fidl::Result<()> {
2715            decoder.debug_check_bounds::<Self>(offset);
2716            #[allow(unused_variables)]
2717            let next_out_of_line = decoder.next_out_of_line();
2718            let handles_before = decoder.remaining_handles();
2719            let (ordinal, inlined, num_bytes, num_handles) =
2720                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2721
2722            let member_inline_size = match ordinal {
2723                1 => <None_ as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2724                2 => <Buffer as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2725                3 => <Value as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2726                0 => return Err(fidl::Error::UnknownUnionTag),
2727                _ => num_bytes as usize,
2728            };
2729
2730            if inlined != (member_inline_size <= 4) {
2731                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2732            }
2733            let _inner_offset;
2734            if inlined {
2735                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2736                _inner_offset = offset + 8;
2737            } else {
2738                depth.increment()?;
2739                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2740            }
2741            match ordinal {
2742                1 => {
2743                    #[allow(irrefutable_let_patterns)]
2744                    if let Parameter::None(_) = self {
2745                        // Do nothing, read the value into the object
2746                    } else {
2747                        // Initialize `self` to the right variant
2748                        *self = Parameter::None(fidl::new_empty!(
2749                            None_,
2750                            fidl::encoding::DefaultFuchsiaResourceDialect
2751                        ));
2752                    }
2753                    #[allow(irrefutable_let_patterns)]
2754                    if let Parameter::None(ref mut val) = self {
2755                        fidl::decode!(
2756                            None_,
2757                            fidl::encoding::DefaultFuchsiaResourceDialect,
2758                            val,
2759                            decoder,
2760                            _inner_offset,
2761                            depth
2762                        )?;
2763                    } else {
2764                        unreachable!()
2765                    }
2766                }
2767                2 => {
2768                    #[allow(irrefutable_let_patterns)]
2769                    if let Parameter::Buffer(_) = self {
2770                        // Do nothing, read the value into the object
2771                    } else {
2772                        // Initialize `self` to the right variant
2773                        *self = Parameter::Buffer(fidl::new_empty!(
2774                            Buffer,
2775                            fidl::encoding::DefaultFuchsiaResourceDialect
2776                        ));
2777                    }
2778                    #[allow(irrefutable_let_patterns)]
2779                    if let Parameter::Buffer(ref mut val) = self {
2780                        fidl::decode!(
2781                            Buffer,
2782                            fidl::encoding::DefaultFuchsiaResourceDialect,
2783                            val,
2784                            decoder,
2785                            _inner_offset,
2786                            depth
2787                        )?;
2788                    } else {
2789                        unreachable!()
2790                    }
2791                }
2792                3 => {
2793                    #[allow(irrefutable_let_patterns)]
2794                    if let Parameter::Value(_) = self {
2795                        // Do nothing, read the value into the object
2796                    } else {
2797                        // Initialize `self` to the right variant
2798                        *self = Parameter::Value(fidl::new_empty!(
2799                            Value,
2800                            fidl::encoding::DefaultFuchsiaResourceDialect
2801                        ));
2802                    }
2803                    #[allow(irrefutable_let_patterns)]
2804                    if let Parameter::Value(ref mut val) = self {
2805                        fidl::decode!(
2806                            Value,
2807                            fidl::encoding::DefaultFuchsiaResourceDialect,
2808                            val,
2809                            decoder,
2810                            _inner_offset,
2811                            depth
2812                        )?;
2813                    } else {
2814                        unreachable!()
2815                    }
2816                }
2817                #[allow(deprecated)]
2818                ordinal => {
2819                    for _ in 0..num_handles {
2820                        decoder.drop_next_handle()?;
2821                    }
2822                    *self = Parameter::__SourceBreaking { unknown_ordinal: ordinal };
2823                }
2824            }
2825            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2826                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2827            }
2828            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2829                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2830            }
2831            Ok(())
2832        }
2833    }
2834}