fidl_fuchsia_tee/
fidl_fuchsia_tee.rs

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