Skip to main content

fidl_fuchsia_tee/
fidl_fuchsia_tee.rs

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