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