Skip to main content

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