fidl_fuchsia_gpu_magma/
fidl_fuchsia_gpu_magma.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_gpu_magma__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DependencyInjectionSetMemoryPressureProviderRequest {
16    pub provider: fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DependencyInjectionSetMemoryPressureProviderRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct DeviceConnect2Request {
26    pub client_id: u64,
27    pub primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
28    pub notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceConnect2Request {}
32
33#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct PerformanceCounterAccessGetPerformanceCountTokenResponse {
35    pub access_token: fidl::Event,
36}
37
38impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
39    for PerformanceCounterAccessGetPerformanceCountTokenResponse
40{
41}
42
43#[derive(Debug, PartialEq)]
44pub struct PowerElementProviderGetPowerGoalsResponse {
45    pub goals: Vec<PowerGoal>,
46}
47
48impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
49    for PowerElementProviderGetPowerGoalsResponse
50{
51}
52
53#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
54pub struct PrimaryCreatePerformanceCounterBufferPoolRequest {
55    pub pool_id: u64,
56    pub event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
57}
58
59impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
60    for PrimaryCreatePerformanceCounterBufferPoolRequest
61{
62}
63
64#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
65pub struct PrimaryEnablePerformanceCounterAccessRequest {
66    pub access_token: fidl::Event,
67}
68
69impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
70    for PrimaryEnablePerformanceCounterAccessRequest
71{
72}
73
74#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
75pub struct PrimaryImportObject2Request {
76    pub object: fidl::Handle,
77    pub object_type: ObjectType,
78    pub object_id: u64,
79}
80
81impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
82    for PrimaryImportObject2Request
83{
84}
85
86#[derive(Debug, Default, PartialEq)]
87pub struct PowerElementProviderGetClockSpeedLevelResponse {
88    /// Required. The fuchsia.power.broker.DependencyToken that must be leased.
89    pub token: Option<fidl::Event>,
90    /// Required. The level to lease `token` at.
91    pub level: Option<u8>,
92    /// Required. The target frequency that the level represents. If `allow_max==false' (or
93    /// allow_max isn't set) then this must be >= `hz`; otherwise, it can be any value relative
94    /// to `hz`.
95    pub actual_hz: Option<u64>,
96    #[doc(hidden)]
97    pub __source_breaking: fidl::marker::SourceBreaking,
98}
99
100impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
101    for PowerElementProviderGetClockSpeedLevelResponse
102{
103}
104
105#[derive(Debug, Default, PartialEq)]
106pub struct PowerElementProviderSetClockLimitResponse {
107    /// Required. A handle representing this request; the clock limit will be honored as long as
108    /// the handle is open.
109    pub handle: Option<fidl::EventPair>,
110    /// Required. The actual frequency the clock is limited to. This may be more or less than
111    /// `hz`.
112    pub actual_hz: Option<u64>,
113    #[doc(hidden)]
114    pub __source_breaking: fidl::marker::SourceBreaking,
115}
116
117impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
118    for PowerElementProviderSetClockLimitResponse
119{
120}
121
122/// This table represents a specific power goal. The client must acquire a lease on the token to
123/// activate the state.
124#[derive(Debug, Default, PartialEq)]
125pub struct PowerGoal {
126    /// Required.
127    pub type_: Option<PowerGoalType>,
128    /// Required. The fuchsia.power.broker.DependencyToken that must be leased at level 1 to achieve
129    /// the goal.
130    pub token: Option<fidl::Event>,
131    #[doc(hidden)]
132    pub __source_breaking: fidl::marker::SourceBreaking,
133}
134
135impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PowerGoal {}
136
137#[derive(Debug, Default, PartialEq)]
138pub struct PrimaryImportObjectRequest {
139    /// Required.
140    pub object: Option<Object>,
141    /// Required.
142    pub object_type: Option<ObjectType>,
143    /// Required.
144    pub object_id: Option<u64>,
145    /// Optional
146    pub flags: Option<ImportFlags>,
147    #[doc(hidden)]
148    pub __source_breaking: fidl::marker::SourceBreaking,
149}
150
151impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
152    for PrimaryImportObjectRequest
153{
154}
155
156#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
157pub enum DeviceQueryResponse {
158    SimpleResult(u64),
159    BufferResult(fidl::Vmo),
160}
161
162impl DeviceQueryResponse {
163    #[inline]
164    pub fn ordinal(&self) -> u64 {
165        match *self {
166            Self::SimpleResult(_) => 1,
167            Self::BufferResult(_) => 2,
168        }
169    }
170}
171
172impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceQueryResponse {}
173
174#[derive(Debug)]
175pub enum Object {
176    Semaphore(fidl::Event),
177    Buffer(fidl::Vmo),
178    VmoSemaphore(fidl::Vmo),
179    CounterSemaphore(fidl::Counter),
180    #[doc(hidden)]
181    __SourceBreaking {
182        unknown_ordinal: u64,
183    },
184}
185
186/// Pattern that matches an unknown `Object` member.
187#[macro_export]
188macro_rules! ObjectUnknown {
189    () => {
190        _
191    };
192}
193
194// Custom PartialEq so that unknown variants are not equal to themselves.
195impl PartialEq for Object {
196    fn eq(&self, other: &Self) -> bool {
197        match (self, other) {
198            (Self::Semaphore(x), Self::Semaphore(y)) => *x == *y,
199            (Self::Buffer(x), Self::Buffer(y)) => *x == *y,
200            (Self::VmoSemaphore(x), Self::VmoSemaphore(y)) => *x == *y,
201            (Self::CounterSemaphore(x), Self::CounterSemaphore(y)) => *x == *y,
202            _ => false,
203        }
204    }
205}
206
207impl Object {
208    #[inline]
209    pub fn ordinal(&self) -> u64 {
210        match *self {
211            Self::Semaphore(_) => 1,
212            Self::Buffer(_) => 2,
213            Self::VmoSemaphore(_) => 3,
214            Self::CounterSemaphore(_) => 4,
215            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
216        }
217    }
218
219    #[inline]
220    pub fn unknown_variant_for_testing() -> Self {
221        Self::__SourceBreaking { unknown_ordinal: 0 }
222    }
223
224    #[inline]
225    pub fn is_unknown(&self) -> bool {
226        match self {
227            Self::__SourceBreaking { .. } => true,
228            _ => false,
229        }
230    }
231}
232
233impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Object {}
234
235#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
236pub struct CombinedDeviceMarker;
237
238impl fidl::endpoints::ProtocolMarker for CombinedDeviceMarker {
239    type Proxy = CombinedDeviceProxy;
240    type RequestStream = CombinedDeviceRequestStream;
241    #[cfg(target_os = "fuchsia")]
242    type SynchronousProxy = CombinedDeviceSynchronousProxy;
243
244    const DEBUG_NAME: &'static str = "(anonymous) CombinedDevice";
245}
246
247pub trait CombinedDeviceProxyInterface: Send + Sync {
248    type QueryResponseFut: std::future::Future<Output = Result<DeviceQueryResult, fidl::Error>>
249        + Send;
250    fn r#query(&self, query_id: QueryId) -> Self::QueryResponseFut;
251    fn r#connect2(
252        &self,
253        client_id: u64,
254        primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
255        notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
256    ) -> Result<(), fidl::Error>;
257    fn r#dump_state(&self, dump_type: u32) -> Result<(), fidl::Error>;
258    type GetIcdListResponseFut: std::future::Future<Output = Result<Vec<IcdInfo>, fidl::Error>>
259        + Send;
260    fn r#get_icd_list(&self) -> Self::GetIcdListResponseFut;
261}
262#[derive(Debug)]
263#[cfg(target_os = "fuchsia")]
264pub struct CombinedDeviceSynchronousProxy {
265    client: fidl::client::sync::Client,
266}
267
268#[cfg(target_os = "fuchsia")]
269impl fidl::endpoints::SynchronousProxy for CombinedDeviceSynchronousProxy {
270    type Proxy = CombinedDeviceProxy;
271    type Protocol = CombinedDeviceMarker;
272
273    fn from_channel(inner: fidl::Channel) -> Self {
274        Self::new(inner)
275    }
276
277    fn into_channel(self) -> fidl::Channel {
278        self.client.into_channel()
279    }
280
281    fn as_channel(&self) -> &fidl::Channel {
282        self.client.as_channel()
283    }
284}
285
286#[cfg(target_os = "fuchsia")]
287impl CombinedDeviceSynchronousProxy {
288    pub fn new(channel: fidl::Channel) -> Self {
289        let protocol_name = <CombinedDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
290        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
291    }
292
293    pub fn into_channel(self) -> fidl::Channel {
294        self.client.into_channel()
295    }
296
297    /// Waits until an event arrives and returns it. It is safe for other
298    /// threads to make concurrent requests while waiting for an event.
299    pub fn wait_for_event(
300        &self,
301        deadline: zx::MonotonicInstant,
302    ) -> Result<CombinedDeviceEvent, fidl::Error> {
303        CombinedDeviceEvent::decode(self.client.wait_for_event(deadline)?)
304    }
305
306    /// On success, returns a result either in a buffer or a simple value.
307    pub fn r#query(
308        &self,
309        mut query_id: QueryId,
310        ___deadline: zx::MonotonicInstant,
311    ) -> Result<DeviceQueryResult, fidl::Error> {
312        let _response = self
313            .client
314            .send_query::<DeviceQueryRequest, fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
315                (query_id,),
316                0x627d4c6093b078e7,
317                fidl::encoding::DynamicFlags::empty(),
318                ___deadline,
319            )?;
320        Ok(_response.map(|x| x))
321    }
322
323    /// Creates a connection to the device comprised of two IPC channels.
324    /// The primary channel is for the Primary protocol (see below).  The notification channel is
325    /// used for vendor-specific messages which are sent only in the reverse (server-client)
326    /// direction, typically in response to client command completion.
327    pub fn r#connect2(
328        &self,
329        mut client_id: u64,
330        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
331        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
332    ) -> Result<(), fidl::Error> {
333        self.client.send::<DeviceConnect2Request>(
334            (client_id, primary_channel, notification_channel),
335            0x3a5b134714c67914,
336            fidl::encoding::DynamicFlags::empty(),
337        )
338    }
339
340    /// Dumps driver and hardware state to the log.
341    pub fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
342        self.client.send::<DiagnosticDeviceDumpStateRequest>(
343            (dump_type,),
344            0x5420df493d4fa915,
345            fidl::encoding::DynamicFlags::empty(),
346        )
347    }
348
349    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
350    /// descending order of preference.
351    pub fn r#get_icd_list(
352        &self,
353        ___deadline: zx::MonotonicInstant,
354    ) -> Result<Vec<IcdInfo>, fidl::Error> {
355        let _response = self
356            .client
357            .send_query::<fidl::encoding::EmptyPayload, IcdLoaderDeviceGetIcdListResponse>(
358                (),
359                0x7673e76395008257,
360                fidl::encoding::DynamicFlags::empty(),
361                ___deadline,
362            )?;
363        Ok(_response.icd_list)
364    }
365}
366
367#[cfg(target_os = "fuchsia")]
368impl From<CombinedDeviceSynchronousProxy> for zx::Handle {
369    fn from(value: CombinedDeviceSynchronousProxy) -> Self {
370        value.into_channel().into()
371    }
372}
373
374#[cfg(target_os = "fuchsia")]
375impl From<fidl::Channel> for CombinedDeviceSynchronousProxy {
376    fn from(value: fidl::Channel) -> Self {
377        Self::new(value)
378    }
379}
380
381#[derive(Debug, Clone)]
382pub struct CombinedDeviceProxy {
383    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
384}
385
386impl fidl::endpoints::Proxy for CombinedDeviceProxy {
387    type Protocol = CombinedDeviceMarker;
388
389    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
390        Self::new(inner)
391    }
392
393    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
394        self.client.into_channel().map_err(|client| Self { client })
395    }
396
397    fn as_channel(&self) -> &::fidl::AsyncChannel {
398        self.client.as_channel()
399    }
400}
401
402impl CombinedDeviceProxy {
403    /// Create a new Proxy for fuchsia.gpu.magma/CombinedDevice.
404    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
405        let protocol_name = <CombinedDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
406        Self { client: fidl::client::Client::new(channel, protocol_name) }
407    }
408
409    /// Get a Stream of events from the remote end of the protocol.
410    ///
411    /// # Panics
412    ///
413    /// Panics if the event stream was already taken.
414    pub fn take_event_stream(&self) -> CombinedDeviceEventStream {
415        CombinedDeviceEventStream { event_receiver: self.client.take_event_receiver() }
416    }
417
418    /// On success, returns a result either in a buffer or a simple value.
419    pub fn r#query(
420        &self,
421        mut query_id: QueryId,
422    ) -> fidl::client::QueryResponseFut<
423        DeviceQueryResult,
424        fidl::encoding::DefaultFuchsiaResourceDialect,
425    > {
426        CombinedDeviceProxyInterface::r#query(self, query_id)
427    }
428
429    /// Creates a connection to the device comprised of two IPC channels.
430    /// The primary channel is for the Primary protocol (see below).  The notification channel is
431    /// used for vendor-specific messages which are sent only in the reverse (server-client)
432    /// direction, typically in response to client command completion.
433    pub fn r#connect2(
434        &self,
435        mut client_id: u64,
436        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
437        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
438    ) -> Result<(), fidl::Error> {
439        CombinedDeviceProxyInterface::r#connect2(
440            self,
441            client_id,
442            primary_channel,
443            notification_channel,
444        )
445    }
446
447    /// Dumps driver and hardware state to the log.
448    pub fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
449        CombinedDeviceProxyInterface::r#dump_state(self, dump_type)
450    }
451
452    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
453    /// descending order of preference.
454    pub fn r#get_icd_list(
455        &self,
456    ) -> fidl::client::QueryResponseFut<Vec<IcdInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>
457    {
458        CombinedDeviceProxyInterface::r#get_icd_list(self)
459    }
460}
461
462impl CombinedDeviceProxyInterface for CombinedDeviceProxy {
463    type QueryResponseFut = fidl::client::QueryResponseFut<
464        DeviceQueryResult,
465        fidl::encoding::DefaultFuchsiaResourceDialect,
466    >;
467    fn r#query(&self, mut query_id: QueryId) -> Self::QueryResponseFut {
468        fn _decode(
469            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
470        ) -> Result<DeviceQueryResult, fidl::Error> {
471            let _response = fidl::client::decode_transaction_body::<
472                fidl::encoding::ResultType<DeviceQueryResponse, i32>,
473                fidl::encoding::DefaultFuchsiaResourceDialect,
474                0x627d4c6093b078e7,
475            >(_buf?)?;
476            Ok(_response.map(|x| x))
477        }
478        self.client.send_query_and_decode::<DeviceQueryRequest, DeviceQueryResult>(
479            (query_id,),
480            0x627d4c6093b078e7,
481            fidl::encoding::DynamicFlags::empty(),
482            _decode,
483        )
484    }
485
486    fn r#connect2(
487        &self,
488        mut client_id: u64,
489        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
490        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
491    ) -> Result<(), fidl::Error> {
492        self.client.send::<DeviceConnect2Request>(
493            (client_id, primary_channel, notification_channel),
494            0x3a5b134714c67914,
495            fidl::encoding::DynamicFlags::empty(),
496        )
497    }
498
499    fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
500        self.client.send::<DiagnosticDeviceDumpStateRequest>(
501            (dump_type,),
502            0x5420df493d4fa915,
503            fidl::encoding::DynamicFlags::empty(),
504        )
505    }
506
507    type GetIcdListResponseFut =
508        fidl::client::QueryResponseFut<Vec<IcdInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>;
509    fn r#get_icd_list(&self) -> Self::GetIcdListResponseFut {
510        fn _decode(
511            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
512        ) -> Result<Vec<IcdInfo>, fidl::Error> {
513            let _response = fidl::client::decode_transaction_body::<
514                IcdLoaderDeviceGetIcdListResponse,
515                fidl::encoding::DefaultFuchsiaResourceDialect,
516                0x7673e76395008257,
517            >(_buf?)?;
518            Ok(_response.icd_list)
519        }
520        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<IcdInfo>>(
521            (),
522            0x7673e76395008257,
523            fidl::encoding::DynamicFlags::empty(),
524            _decode,
525        )
526    }
527}
528
529pub struct CombinedDeviceEventStream {
530    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
531}
532
533impl std::marker::Unpin for CombinedDeviceEventStream {}
534
535impl futures::stream::FusedStream for CombinedDeviceEventStream {
536    fn is_terminated(&self) -> bool {
537        self.event_receiver.is_terminated()
538    }
539}
540
541impl futures::Stream for CombinedDeviceEventStream {
542    type Item = Result<CombinedDeviceEvent, fidl::Error>;
543
544    fn poll_next(
545        mut self: std::pin::Pin<&mut Self>,
546        cx: &mut std::task::Context<'_>,
547    ) -> std::task::Poll<Option<Self::Item>> {
548        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
549            &mut self.event_receiver,
550            cx
551        )?) {
552            Some(buf) => std::task::Poll::Ready(Some(CombinedDeviceEvent::decode(buf))),
553            None => std::task::Poll::Ready(None),
554        }
555    }
556}
557
558#[derive(Debug)]
559pub enum CombinedDeviceEvent {}
560
561impl CombinedDeviceEvent {
562    /// Decodes a message buffer as a [`CombinedDeviceEvent`].
563    fn decode(
564        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
565    ) -> Result<CombinedDeviceEvent, fidl::Error> {
566        let (bytes, _handles) = buf.split_mut();
567        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
568        debug_assert_eq!(tx_header.tx_id, 0);
569        match tx_header.ordinal {
570            _ => Err(fidl::Error::UnknownOrdinal {
571                ordinal: tx_header.ordinal,
572                protocol_name:
573                    <CombinedDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
574            }),
575        }
576    }
577}
578
579/// A Stream of incoming requests for fuchsia.gpu.magma/CombinedDevice.
580pub struct CombinedDeviceRequestStream {
581    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
582    is_terminated: bool,
583}
584
585impl std::marker::Unpin for CombinedDeviceRequestStream {}
586
587impl futures::stream::FusedStream for CombinedDeviceRequestStream {
588    fn is_terminated(&self) -> bool {
589        self.is_terminated
590    }
591}
592
593impl fidl::endpoints::RequestStream for CombinedDeviceRequestStream {
594    type Protocol = CombinedDeviceMarker;
595    type ControlHandle = CombinedDeviceControlHandle;
596
597    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
598        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
599    }
600
601    fn control_handle(&self) -> Self::ControlHandle {
602        CombinedDeviceControlHandle { inner: self.inner.clone() }
603    }
604
605    fn into_inner(
606        self,
607    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
608    {
609        (self.inner, self.is_terminated)
610    }
611
612    fn from_inner(
613        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
614        is_terminated: bool,
615    ) -> Self {
616        Self { inner, is_terminated }
617    }
618}
619
620impl futures::Stream for CombinedDeviceRequestStream {
621    type Item = Result<CombinedDeviceRequest, fidl::Error>;
622
623    fn poll_next(
624        mut self: std::pin::Pin<&mut Self>,
625        cx: &mut std::task::Context<'_>,
626    ) -> std::task::Poll<Option<Self::Item>> {
627        let this = &mut *self;
628        if this.inner.check_shutdown(cx) {
629            this.is_terminated = true;
630            return std::task::Poll::Ready(None);
631        }
632        if this.is_terminated {
633            panic!("polled CombinedDeviceRequestStream after completion");
634        }
635        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
636            |bytes, handles| {
637                match this.inner.channel().read_etc(cx, bytes, handles) {
638                    std::task::Poll::Ready(Ok(())) => {}
639                    std::task::Poll::Pending => return std::task::Poll::Pending,
640                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
641                        this.is_terminated = true;
642                        return std::task::Poll::Ready(None);
643                    }
644                    std::task::Poll::Ready(Err(e)) => {
645                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
646                            e.into(),
647                        ))))
648                    }
649                }
650
651                // A message has been received from the channel
652                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
653
654                std::task::Poll::Ready(Some(match header.ordinal {
655                    0x627d4c6093b078e7 => {
656                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
657                        let mut req = fidl::new_empty!(
658                            DeviceQueryRequest,
659                            fidl::encoding::DefaultFuchsiaResourceDialect
660                        );
661                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceQueryRequest>(&header, _body_bytes, handles, &mut req)?;
662                        let control_handle =
663                            CombinedDeviceControlHandle { inner: this.inner.clone() };
664                        Ok(CombinedDeviceRequest::Query {
665                            query_id: req.query_id,
666
667                            responder: CombinedDeviceQueryResponder {
668                                control_handle: std::mem::ManuallyDrop::new(control_handle),
669                                tx_id: header.tx_id,
670                            },
671                        })
672                    }
673                    0x3a5b134714c67914 => {
674                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
675                        let mut req = fidl::new_empty!(
676                            DeviceConnect2Request,
677                            fidl::encoding::DefaultFuchsiaResourceDialect
678                        );
679                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceConnect2Request>(&header, _body_bytes, handles, &mut req)?;
680                        let control_handle =
681                            CombinedDeviceControlHandle { inner: this.inner.clone() };
682                        Ok(CombinedDeviceRequest::Connect2 {
683                            client_id: req.client_id,
684                            primary_channel: req.primary_channel,
685                            notification_channel: req.notification_channel,
686
687                            control_handle,
688                        })
689                    }
690                    0x5420df493d4fa915 => {
691                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
692                        let mut req = fidl::new_empty!(
693                            DiagnosticDeviceDumpStateRequest,
694                            fidl::encoding::DefaultFuchsiaResourceDialect
695                        );
696                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DiagnosticDeviceDumpStateRequest>(&header, _body_bytes, handles, &mut req)?;
697                        let control_handle =
698                            CombinedDeviceControlHandle { inner: this.inner.clone() };
699                        Ok(CombinedDeviceRequest::DumpState {
700                            dump_type: req.dump_type,
701
702                            control_handle,
703                        })
704                    }
705                    0x7673e76395008257 => {
706                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
707                        let mut req = fidl::new_empty!(
708                            fidl::encoding::EmptyPayload,
709                            fidl::encoding::DefaultFuchsiaResourceDialect
710                        );
711                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
712                        let control_handle =
713                            CombinedDeviceControlHandle { inner: this.inner.clone() };
714                        Ok(CombinedDeviceRequest::GetIcdList {
715                            responder: CombinedDeviceGetIcdListResponder {
716                                control_handle: std::mem::ManuallyDrop::new(control_handle),
717                                tx_id: header.tx_id,
718                            },
719                        })
720                    }
721                    _ => Err(fidl::Error::UnknownOrdinal {
722                        ordinal: header.ordinal,
723                        protocol_name:
724                            <CombinedDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
725                    }),
726                }))
727            },
728        )
729    }
730}
731
732/// A combination of all the production |Device| protocols. This protocol is implemented on the
733/// Magma service side and should not be used by clients.
734#[derive(Debug)]
735pub enum CombinedDeviceRequest {
736    /// On success, returns a result either in a buffer or a simple value.
737    Query { query_id: QueryId, responder: CombinedDeviceQueryResponder },
738    /// Creates a connection to the device comprised of two IPC channels.
739    /// The primary channel is for the Primary protocol (see below).  The notification channel is
740    /// used for vendor-specific messages which are sent only in the reverse (server-client)
741    /// direction, typically in response to client command completion.
742    Connect2 {
743        client_id: u64,
744        primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
745        notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
746        control_handle: CombinedDeviceControlHandle,
747    },
748    /// Dumps driver and hardware state to the log.
749    DumpState { dump_type: u32, control_handle: CombinedDeviceControlHandle },
750    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
751    /// descending order of preference.
752    GetIcdList { responder: CombinedDeviceGetIcdListResponder },
753}
754
755impl CombinedDeviceRequest {
756    #[allow(irrefutable_let_patterns)]
757    pub fn into_query(self) -> Option<(QueryId, CombinedDeviceQueryResponder)> {
758        if let CombinedDeviceRequest::Query { query_id, responder } = self {
759            Some((query_id, responder))
760        } else {
761            None
762        }
763    }
764
765    #[allow(irrefutable_let_patterns)]
766    pub fn into_connect2(
767        self,
768    ) -> Option<(
769        u64,
770        fidl::endpoints::ServerEnd<PrimaryMarker>,
771        fidl::endpoints::ServerEnd<NotificationMarker>,
772        CombinedDeviceControlHandle,
773    )> {
774        if let CombinedDeviceRequest::Connect2 {
775            client_id,
776            primary_channel,
777            notification_channel,
778            control_handle,
779        } = self
780        {
781            Some((client_id, primary_channel, notification_channel, control_handle))
782        } else {
783            None
784        }
785    }
786
787    #[allow(irrefutable_let_patterns)]
788    pub fn into_dump_state(self) -> Option<(u32, CombinedDeviceControlHandle)> {
789        if let CombinedDeviceRequest::DumpState { dump_type, control_handle } = self {
790            Some((dump_type, control_handle))
791        } else {
792            None
793        }
794    }
795
796    #[allow(irrefutable_let_patterns)]
797    pub fn into_get_icd_list(self) -> Option<(CombinedDeviceGetIcdListResponder)> {
798        if let CombinedDeviceRequest::GetIcdList { responder } = self {
799            Some((responder))
800        } else {
801            None
802        }
803    }
804
805    /// Name of the method defined in FIDL
806    pub fn method_name(&self) -> &'static str {
807        match *self {
808            CombinedDeviceRequest::Query { .. } => "query",
809            CombinedDeviceRequest::Connect2 { .. } => "connect2",
810            CombinedDeviceRequest::DumpState { .. } => "dump_state",
811            CombinedDeviceRequest::GetIcdList { .. } => "get_icd_list",
812        }
813    }
814}
815
816#[derive(Debug, Clone)]
817pub struct CombinedDeviceControlHandle {
818    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
819}
820
821impl fidl::endpoints::ControlHandle for CombinedDeviceControlHandle {
822    fn shutdown(&self) {
823        self.inner.shutdown()
824    }
825    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
826        self.inner.shutdown_with_epitaph(status)
827    }
828
829    fn is_closed(&self) -> bool {
830        self.inner.channel().is_closed()
831    }
832    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
833        self.inner.channel().on_closed()
834    }
835
836    #[cfg(target_os = "fuchsia")]
837    fn signal_peer(
838        &self,
839        clear_mask: zx::Signals,
840        set_mask: zx::Signals,
841    ) -> Result<(), zx_status::Status> {
842        use fidl::Peered;
843        self.inner.channel().signal_peer(clear_mask, set_mask)
844    }
845}
846
847impl CombinedDeviceControlHandle {}
848
849#[must_use = "FIDL methods require a response to be sent"]
850#[derive(Debug)]
851pub struct CombinedDeviceQueryResponder {
852    control_handle: std::mem::ManuallyDrop<CombinedDeviceControlHandle>,
853    tx_id: u32,
854}
855
856/// Set the the channel to be shutdown (see [`CombinedDeviceControlHandle::shutdown`])
857/// if the responder is dropped without sending a response, so that the client
858/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
859impl std::ops::Drop for CombinedDeviceQueryResponder {
860    fn drop(&mut self) {
861        self.control_handle.shutdown();
862        // Safety: drops once, never accessed again
863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
864    }
865}
866
867impl fidl::endpoints::Responder for CombinedDeviceQueryResponder {
868    type ControlHandle = CombinedDeviceControlHandle;
869
870    fn control_handle(&self) -> &CombinedDeviceControlHandle {
871        &self.control_handle
872    }
873
874    fn drop_without_shutdown(mut self) {
875        // Safety: drops once, never accessed again due to mem::forget
876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877        // Prevent Drop from running (which would shut down the channel)
878        std::mem::forget(self);
879    }
880}
881
882impl CombinedDeviceQueryResponder {
883    /// Sends a response to the FIDL transaction.
884    ///
885    /// Sets the channel to shutdown if an error occurs.
886    pub fn send(self, mut result: Result<DeviceQueryResponse, i32>) -> Result<(), fidl::Error> {
887        let _result = self.send_raw(result);
888        if _result.is_err() {
889            self.control_handle.shutdown();
890        }
891        self.drop_without_shutdown();
892        _result
893    }
894
895    /// Similar to "send" but does not shutdown the channel if an error occurs.
896    pub fn send_no_shutdown_on_err(
897        self,
898        mut result: Result<DeviceQueryResponse, i32>,
899    ) -> Result<(), fidl::Error> {
900        let _result = self.send_raw(result);
901        self.drop_without_shutdown();
902        _result
903    }
904
905    fn send_raw(&self, mut result: Result<DeviceQueryResponse, i32>) -> Result<(), fidl::Error> {
906        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
907            result.as_mut().map_err(|e| *e),
908            self.tx_id,
909            0x627d4c6093b078e7,
910            fidl::encoding::DynamicFlags::empty(),
911        )
912    }
913}
914
915#[must_use = "FIDL methods require a response to be sent"]
916#[derive(Debug)]
917pub struct CombinedDeviceGetIcdListResponder {
918    control_handle: std::mem::ManuallyDrop<CombinedDeviceControlHandle>,
919    tx_id: u32,
920}
921
922/// Set the the channel to be shutdown (see [`CombinedDeviceControlHandle::shutdown`])
923/// if the responder is dropped without sending a response, so that the client
924/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
925impl std::ops::Drop for CombinedDeviceGetIcdListResponder {
926    fn drop(&mut self) {
927        self.control_handle.shutdown();
928        // Safety: drops once, never accessed again
929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
930    }
931}
932
933impl fidl::endpoints::Responder for CombinedDeviceGetIcdListResponder {
934    type ControlHandle = CombinedDeviceControlHandle;
935
936    fn control_handle(&self) -> &CombinedDeviceControlHandle {
937        &self.control_handle
938    }
939
940    fn drop_without_shutdown(mut self) {
941        // Safety: drops once, never accessed again due to mem::forget
942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
943        // Prevent Drop from running (which would shut down the channel)
944        std::mem::forget(self);
945    }
946}
947
948impl CombinedDeviceGetIcdListResponder {
949    /// Sends a response to the FIDL transaction.
950    ///
951    /// Sets the channel to shutdown if an error occurs.
952    pub fn send(self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
953        let _result = self.send_raw(icd_list);
954        if _result.is_err() {
955            self.control_handle.shutdown();
956        }
957        self.drop_without_shutdown();
958        _result
959    }
960
961    /// Similar to "send" but does not shutdown the channel if an error occurs.
962    pub fn send_no_shutdown_on_err(self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
963        let _result = self.send_raw(icd_list);
964        self.drop_without_shutdown();
965        _result
966    }
967
968    fn send_raw(&self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
969        self.control_handle.inner.send::<IcdLoaderDeviceGetIcdListResponse>(
970            (icd_list,),
971            self.tx_id,
972            0x7673e76395008257,
973            fidl::encoding::DynamicFlags::empty(),
974        )
975    }
976}
977
978#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
979pub struct DependencyInjectionMarker;
980
981impl fidl::endpoints::ProtocolMarker for DependencyInjectionMarker {
982    type Proxy = DependencyInjectionProxy;
983    type RequestStream = DependencyInjectionRequestStream;
984    #[cfg(target_os = "fuchsia")]
985    type SynchronousProxy = DependencyInjectionSynchronousProxy;
986
987    const DEBUG_NAME: &'static str = "(anonymous) DependencyInjection";
988}
989
990pub trait DependencyInjectionProxyInterface: Send + Sync {
991    fn r#set_memory_pressure_provider(
992        &self,
993        provider: fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
994    ) -> Result<(), fidl::Error>;
995}
996#[derive(Debug)]
997#[cfg(target_os = "fuchsia")]
998pub struct DependencyInjectionSynchronousProxy {
999    client: fidl::client::sync::Client,
1000}
1001
1002#[cfg(target_os = "fuchsia")]
1003impl fidl::endpoints::SynchronousProxy for DependencyInjectionSynchronousProxy {
1004    type Proxy = DependencyInjectionProxy;
1005    type Protocol = DependencyInjectionMarker;
1006
1007    fn from_channel(inner: fidl::Channel) -> Self {
1008        Self::new(inner)
1009    }
1010
1011    fn into_channel(self) -> fidl::Channel {
1012        self.client.into_channel()
1013    }
1014
1015    fn as_channel(&self) -> &fidl::Channel {
1016        self.client.as_channel()
1017    }
1018}
1019
1020#[cfg(target_os = "fuchsia")]
1021impl DependencyInjectionSynchronousProxy {
1022    pub fn new(channel: fidl::Channel) -> Self {
1023        let protocol_name =
1024            <DependencyInjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1025        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1026    }
1027
1028    pub fn into_channel(self) -> fidl::Channel {
1029        self.client.into_channel()
1030    }
1031
1032    /// Waits until an event arrives and returns it. It is safe for other
1033    /// threads to make concurrent requests while waiting for an event.
1034    pub fn wait_for_event(
1035        &self,
1036        deadline: zx::MonotonicInstant,
1037    ) -> Result<DependencyInjectionEvent, fidl::Error> {
1038        DependencyInjectionEvent::decode(self.client.wait_for_event(deadline)?)
1039    }
1040
1041    /// Provides a `fuchsia.memorypressure.Provider` implementation to the MSD.
1042    pub fn r#set_memory_pressure_provider(
1043        &self,
1044        mut provider: fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
1045    ) -> Result<(), fidl::Error> {
1046        self.client.send::<DependencyInjectionSetMemoryPressureProviderRequest>(
1047            (provider,),
1048            0x5ef0be960d4b0f4c,
1049            fidl::encoding::DynamicFlags::empty(),
1050        )
1051    }
1052}
1053
1054#[cfg(target_os = "fuchsia")]
1055impl From<DependencyInjectionSynchronousProxy> for zx::Handle {
1056    fn from(value: DependencyInjectionSynchronousProxy) -> Self {
1057        value.into_channel().into()
1058    }
1059}
1060
1061#[cfg(target_os = "fuchsia")]
1062impl From<fidl::Channel> for DependencyInjectionSynchronousProxy {
1063    fn from(value: fidl::Channel) -> Self {
1064        Self::new(value)
1065    }
1066}
1067
1068#[derive(Debug, Clone)]
1069pub struct DependencyInjectionProxy {
1070    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1071}
1072
1073impl fidl::endpoints::Proxy for DependencyInjectionProxy {
1074    type Protocol = DependencyInjectionMarker;
1075
1076    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1077        Self::new(inner)
1078    }
1079
1080    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1081        self.client.into_channel().map_err(|client| Self { client })
1082    }
1083
1084    fn as_channel(&self) -> &::fidl::AsyncChannel {
1085        self.client.as_channel()
1086    }
1087}
1088
1089impl DependencyInjectionProxy {
1090    /// Create a new Proxy for fuchsia.gpu.magma/DependencyInjection.
1091    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1092        let protocol_name =
1093            <DependencyInjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1094        Self { client: fidl::client::Client::new(channel, protocol_name) }
1095    }
1096
1097    /// Get a Stream of events from the remote end of the protocol.
1098    ///
1099    /// # Panics
1100    ///
1101    /// Panics if the event stream was already taken.
1102    pub fn take_event_stream(&self) -> DependencyInjectionEventStream {
1103        DependencyInjectionEventStream { event_receiver: self.client.take_event_receiver() }
1104    }
1105
1106    /// Provides a `fuchsia.memorypressure.Provider` implementation to the MSD.
1107    pub fn r#set_memory_pressure_provider(
1108        &self,
1109        mut provider: fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
1110    ) -> Result<(), fidl::Error> {
1111        DependencyInjectionProxyInterface::r#set_memory_pressure_provider(self, provider)
1112    }
1113}
1114
1115impl DependencyInjectionProxyInterface for DependencyInjectionProxy {
1116    fn r#set_memory_pressure_provider(
1117        &self,
1118        mut provider: fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
1119    ) -> Result<(), fidl::Error> {
1120        self.client.send::<DependencyInjectionSetMemoryPressureProviderRequest>(
1121            (provider,),
1122            0x5ef0be960d4b0f4c,
1123            fidl::encoding::DynamicFlags::empty(),
1124        )
1125    }
1126}
1127
1128pub struct DependencyInjectionEventStream {
1129    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1130}
1131
1132impl std::marker::Unpin for DependencyInjectionEventStream {}
1133
1134impl futures::stream::FusedStream for DependencyInjectionEventStream {
1135    fn is_terminated(&self) -> bool {
1136        self.event_receiver.is_terminated()
1137    }
1138}
1139
1140impl futures::Stream for DependencyInjectionEventStream {
1141    type Item = Result<DependencyInjectionEvent, fidl::Error>;
1142
1143    fn poll_next(
1144        mut self: std::pin::Pin<&mut Self>,
1145        cx: &mut std::task::Context<'_>,
1146    ) -> std::task::Poll<Option<Self::Item>> {
1147        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1148            &mut self.event_receiver,
1149            cx
1150        )?) {
1151            Some(buf) => std::task::Poll::Ready(Some(DependencyInjectionEvent::decode(buf))),
1152            None => std::task::Poll::Ready(None),
1153        }
1154    }
1155}
1156
1157#[derive(Debug)]
1158pub enum DependencyInjectionEvent {}
1159
1160impl DependencyInjectionEvent {
1161    /// Decodes a message buffer as a [`DependencyInjectionEvent`].
1162    fn decode(
1163        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1164    ) -> Result<DependencyInjectionEvent, fidl::Error> {
1165        let (bytes, _handles) = buf.split_mut();
1166        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1167        debug_assert_eq!(tx_header.tx_id, 0);
1168        match tx_header.ordinal {
1169            _ => Err(fidl::Error::UnknownOrdinal {
1170                ordinal: tx_header.ordinal,
1171                protocol_name:
1172                    <DependencyInjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1173            }),
1174        }
1175    }
1176}
1177
1178/// A Stream of incoming requests for fuchsia.gpu.magma/DependencyInjection.
1179pub struct DependencyInjectionRequestStream {
1180    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1181    is_terminated: bool,
1182}
1183
1184impl std::marker::Unpin for DependencyInjectionRequestStream {}
1185
1186impl futures::stream::FusedStream for DependencyInjectionRequestStream {
1187    fn is_terminated(&self) -> bool {
1188        self.is_terminated
1189    }
1190}
1191
1192impl fidl::endpoints::RequestStream for DependencyInjectionRequestStream {
1193    type Protocol = DependencyInjectionMarker;
1194    type ControlHandle = DependencyInjectionControlHandle;
1195
1196    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1197        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1198    }
1199
1200    fn control_handle(&self) -> Self::ControlHandle {
1201        DependencyInjectionControlHandle { inner: self.inner.clone() }
1202    }
1203
1204    fn into_inner(
1205        self,
1206    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1207    {
1208        (self.inner, self.is_terminated)
1209    }
1210
1211    fn from_inner(
1212        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1213        is_terminated: bool,
1214    ) -> Self {
1215        Self { inner, is_terminated }
1216    }
1217}
1218
1219impl futures::Stream for DependencyInjectionRequestStream {
1220    type Item = Result<DependencyInjectionRequest, fidl::Error>;
1221
1222    fn poll_next(
1223        mut self: std::pin::Pin<&mut Self>,
1224        cx: &mut std::task::Context<'_>,
1225    ) -> std::task::Poll<Option<Self::Item>> {
1226        let this = &mut *self;
1227        if this.inner.check_shutdown(cx) {
1228            this.is_terminated = true;
1229            return std::task::Poll::Ready(None);
1230        }
1231        if this.is_terminated {
1232            panic!("polled DependencyInjectionRequestStream after completion");
1233        }
1234        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1235            |bytes, handles| {
1236                match this.inner.channel().read_etc(cx, bytes, handles) {
1237                    std::task::Poll::Ready(Ok(())) => {}
1238                    std::task::Poll::Pending => return std::task::Poll::Pending,
1239                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1240                        this.is_terminated = true;
1241                        return std::task::Poll::Ready(None);
1242                    }
1243                    std::task::Poll::Ready(Err(e)) => {
1244                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1245                            e.into(),
1246                        ))))
1247                    }
1248                }
1249
1250                // A message has been received from the channel
1251                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1252
1253                std::task::Poll::Ready(Some(match header.ordinal {
1254                0x5ef0be960d4b0f4c => {
1255                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1256                    let mut req = fidl::new_empty!(DependencyInjectionSetMemoryPressureProviderRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1257                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DependencyInjectionSetMemoryPressureProviderRequest>(&header, _body_bytes, handles, &mut req)?;
1258                    let control_handle = DependencyInjectionControlHandle {
1259                        inner: this.inner.clone(),
1260                    };
1261                    Ok(DependencyInjectionRequest::SetMemoryPressureProvider {provider: req.provider,
1262
1263                        control_handle,
1264                    })
1265                }
1266                _ => Err(fidl::Error::UnknownOrdinal {
1267                    ordinal: header.ordinal,
1268                    protocol_name: <DependencyInjectionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1269                }),
1270            }))
1271            },
1272        )
1273    }
1274}
1275
1276/// This protocol is implemented by ZX_PROTOCOL_GPU_DEPENDENCY_INJECTION devices. It's used
1277/// to inject dependencies on other services into the MSD. It can be used
1278/// only by a privileged process.
1279#[derive(Debug)]
1280pub enum DependencyInjectionRequest {
1281    /// Provides a `fuchsia.memorypressure.Provider` implementation to the MSD.
1282    SetMemoryPressureProvider {
1283        provider: fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
1284        control_handle: DependencyInjectionControlHandle,
1285    },
1286}
1287
1288impl DependencyInjectionRequest {
1289    #[allow(irrefutable_let_patterns)]
1290    pub fn into_set_memory_pressure_provider(
1291        self,
1292    ) -> Option<(
1293        fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
1294        DependencyInjectionControlHandle,
1295    )> {
1296        if let DependencyInjectionRequest::SetMemoryPressureProvider { provider, control_handle } =
1297            self
1298        {
1299            Some((provider, control_handle))
1300        } else {
1301            None
1302        }
1303    }
1304
1305    /// Name of the method defined in FIDL
1306    pub fn method_name(&self) -> &'static str {
1307        match *self {
1308            DependencyInjectionRequest::SetMemoryPressureProvider { .. } => {
1309                "set_memory_pressure_provider"
1310            }
1311        }
1312    }
1313}
1314
1315#[derive(Debug, Clone)]
1316pub struct DependencyInjectionControlHandle {
1317    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1318}
1319
1320impl fidl::endpoints::ControlHandle for DependencyInjectionControlHandle {
1321    fn shutdown(&self) {
1322        self.inner.shutdown()
1323    }
1324    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1325        self.inner.shutdown_with_epitaph(status)
1326    }
1327
1328    fn is_closed(&self) -> bool {
1329        self.inner.channel().is_closed()
1330    }
1331    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1332        self.inner.channel().on_closed()
1333    }
1334
1335    #[cfg(target_os = "fuchsia")]
1336    fn signal_peer(
1337        &self,
1338        clear_mask: zx::Signals,
1339        set_mask: zx::Signals,
1340    ) -> Result<(), zx_status::Status> {
1341        use fidl::Peered;
1342        self.inner.channel().signal_peer(clear_mask, set_mask)
1343    }
1344}
1345
1346impl DependencyInjectionControlHandle {}
1347
1348#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1349pub struct DeviceMarker;
1350
1351impl fidl::endpoints::ProtocolMarker for DeviceMarker {
1352    type Proxy = DeviceProxy;
1353    type RequestStream = DeviceRequestStream;
1354    #[cfg(target_os = "fuchsia")]
1355    type SynchronousProxy = DeviceSynchronousProxy;
1356
1357    const DEBUG_NAME: &'static str = "(anonymous) Device";
1358}
1359pub type DeviceQueryResult = Result<DeviceQueryResponse, i32>;
1360
1361pub trait DeviceProxyInterface: Send + Sync {
1362    type QueryResponseFut: std::future::Future<Output = Result<DeviceQueryResult, fidl::Error>>
1363        + Send;
1364    fn r#query(&self, query_id: QueryId) -> Self::QueryResponseFut;
1365    fn r#connect2(
1366        &self,
1367        client_id: u64,
1368        primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
1369        notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
1370    ) -> Result<(), fidl::Error>;
1371}
1372#[derive(Debug)]
1373#[cfg(target_os = "fuchsia")]
1374pub struct DeviceSynchronousProxy {
1375    client: fidl::client::sync::Client,
1376}
1377
1378#[cfg(target_os = "fuchsia")]
1379impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
1380    type Proxy = DeviceProxy;
1381    type Protocol = DeviceMarker;
1382
1383    fn from_channel(inner: fidl::Channel) -> Self {
1384        Self::new(inner)
1385    }
1386
1387    fn into_channel(self) -> fidl::Channel {
1388        self.client.into_channel()
1389    }
1390
1391    fn as_channel(&self) -> &fidl::Channel {
1392        self.client.as_channel()
1393    }
1394}
1395
1396#[cfg(target_os = "fuchsia")]
1397impl DeviceSynchronousProxy {
1398    pub fn new(channel: fidl::Channel) -> Self {
1399        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1400        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1401    }
1402
1403    pub fn into_channel(self) -> fidl::Channel {
1404        self.client.into_channel()
1405    }
1406
1407    /// Waits until an event arrives and returns it. It is safe for other
1408    /// threads to make concurrent requests while waiting for an event.
1409    pub fn wait_for_event(
1410        &self,
1411        deadline: zx::MonotonicInstant,
1412    ) -> Result<DeviceEvent, fidl::Error> {
1413        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
1414    }
1415
1416    /// On success, returns a result either in a buffer or a simple value.
1417    pub fn r#query(
1418        &self,
1419        mut query_id: QueryId,
1420        ___deadline: zx::MonotonicInstant,
1421    ) -> Result<DeviceQueryResult, fidl::Error> {
1422        let _response = self
1423            .client
1424            .send_query::<DeviceQueryRequest, fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
1425                (query_id,),
1426                0x627d4c6093b078e7,
1427                fidl::encoding::DynamicFlags::empty(),
1428                ___deadline,
1429            )?;
1430        Ok(_response.map(|x| x))
1431    }
1432
1433    /// Creates a connection to the device comprised of two IPC channels.
1434    /// The primary channel is for the Primary protocol (see below).  The notification channel is
1435    /// used for vendor-specific messages which are sent only in the reverse (server-client)
1436    /// direction, typically in response to client command completion.
1437    pub fn r#connect2(
1438        &self,
1439        mut client_id: u64,
1440        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
1441        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
1442    ) -> Result<(), fidl::Error> {
1443        self.client.send::<DeviceConnect2Request>(
1444            (client_id, primary_channel, notification_channel),
1445            0x3a5b134714c67914,
1446            fidl::encoding::DynamicFlags::empty(),
1447        )
1448    }
1449}
1450
1451#[cfg(target_os = "fuchsia")]
1452impl From<DeviceSynchronousProxy> for zx::Handle {
1453    fn from(value: DeviceSynchronousProxy) -> Self {
1454        value.into_channel().into()
1455    }
1456}
1457
1458#[cfg(target_os = "fuchsia")]
1459impl From<fidl::Channel> for DeviceSynchronousProxy {
1460    fn from(value: fidl::Channel) -> Self {
1461        Self::new(value)
1462    }
1463}
1464
1465#[derive(Debug, Clone)]
1466pub struct DeviceProxy {
1467    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1468}
1469
1470impl fidl::endpoints::Proxy for DeviceProxy {
1471    type Protocol = DeviceMarker;
1472
1473    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1474        Self::new(inner)
1475    }
1476
1477    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1478        self.client.into_channel().map_err(|client| Self { client })
1479    }
1480
1481    fn as_channel(&self) -> &::fidl::AsyncChannel {
1482        self.client.as_channel()
1483    }
1484}
1485
1486impl DeviceProxy {
1487    /// Create a new Proxy for fuchsia.gpu.magma/Device.
1488    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1489        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1490        Self { client: fidl::client::Client::new(channel, protocol_name) }
1491    }
1492
1493    /// Get a Stream of events from the remote end of the protocol.
1494    ///
1495    /// # Panics
1496    ///
1497    /// Panics if the event stream was already taken.
1498    pub fn take_event_stream(&self) -> DeviceEventStream {
1499        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
1500    }
1501
1502    /// On success, returns a result either in a buffer or a simple value.
1503    pub fn r#query(
1504        &self,
1505        mut query_id: QueryId,
1506    ) -> fidl::client::QueryResponseFut<
1507        DeviceQueryResult,
1508        fidl::encoding::DefaultFuchsiaResourceDialect,
1509    > {
1510        DeviceProxyInterface::r#query(self, query_id)
1511    }
1512
1513    /// Creates a connection to the device comprised of two IPC channels.
1514    /// The primary channel is for the Primary protocol (see below).  The notification channel is
1515    /// used for vendor-specific messages which are sent only in the reverse (server-client)
1516    /// direction, typically in response to client command completion.
1517    pub fn r#connect2(
1518        &self,
1519        mut client_id: u64,
1520        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
1521        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
1522    ) -> Result<(), fidl::Error> {
1523        DeviceProxyInterface::r#connect2(self, client_id, primary_channel, notification_channel)
1524    }
1525}
1526
1527impl DeviceProxyInterface for DeviceProxy {
1528    type QueryResponseFut = fidl::client::QueryResponseFut<
1529        DeviceQueryResult,
1530        fidl::encoding::DefaultFuchsiaResourceDialect,
1531    >;
1532    fn r#query(&self, mut query_id: QueryId) -> Self::QueryResponseFut {
1533        fn _decode(
1534            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1535        ) -> Result<DeviceQueryResult, fidl::Error> {
1536            let _response = fidl::client::decode_transaction_body::<
1537                fidl::encoding::ResultType<DeviceQueryResponse, i32>,
1538                fidl::encoding::DefaultFuchsiaResourceDialect,
1539                0x627d4c6093b078e7,
1540            >(_buf?)?;
1541            Ok(_response.map(|x| x))
1542        }
1543        self.client.send_query_and_decode::<DeviceQueryRequest, DeviceQueryResult>(
1544            (query_id,),
1545            0x627d4c6093b078e7,
1546            fidl::encoding::DynamicFlags::empty(),
1547            _decode,
1548        )
1549    }
1550
1551    fn r#connect2(
1552        &self,
1553        mut client_id: u64,
1554        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
1555        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
1556    ) -> Result<(), fidl::Error> {
1557        self.client.send::<DeviceConnect2Request>(
1558            (client_id, primary_channel, notification_channel),
1559            0x3a5b134714c67914,
1560            fidl::encoding::DynamicFlags::empty(),
1561        )
1562    }
1563}
1564
1565pub struct DeviceEventStream {
1566    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1567}
1568
1569impl std::marker::Unpin for DeviceEventStream {}
1570
1571impl futures::stream::FusedStream for DeviceEventStream {
1572    fn is_terminated(&self) -> bool {
1573        self.event_receiver.is_terminated()
1574    }
1575}
1576
1577impl futures::Stream for DeviceEventStream {
1578    type Item = Result<DeviceEvent, fidl::Error>;
1579
1580    fn poll_next(
1581        mut self: std::pin::Pin<&mut Self>,
1582        cx: &mut std::task::Context<'_>,
1583    ) -> std::task::Poll<Option<Self::Item>> {
1584        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1585            &mut self.event_receiver,
1586            cx
1587        )?) {
1588            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1589            None => std::task::Poll::Ready(None),
1590        }
1591    }
1592}
1593
1594#[derive(Debug)]
1595pub enum DeviceEvent {}
1596
1597impl DeviceEvent {
1598    /// Decodes a message buffer as a [`DeviceEvent`].
1599    fn decode(
1600        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1601    ) -> Result<DeviceEvent, fidl::Error> {
1602        let (bytes, _handles) = buf.split_mut();
1603        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1604        debug_assert_eq!(tx_header.tx_id, 0);
1605        match tx_header.ordinal {
1606            _ => Err(fidl::Error::UnknownOrdinal {
1607                ordinal: tx_header.ordinal,
1608                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1609            }),
1610        }
1611    }
1612}
1613
1614/// A Stream of incoming requests for fuchsia.gpu.magma/Device.
1615pub struct DeviceRequestStream {
1616    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1617    is_terminated: bool,
1618}
1619
1620impl std::marker::Unpin for DeviceRequestStream {}
1621
1622impl futures::stream::FusedStream for DeviceRequestStream {
1623    fn is_terminated(&self) -> bool {
1624        self.is_terminated
1625    }
1626}
1627
1628impl fidl::endpoints::RequestStream for DeviceRequestStream {
1629    type Protocol = DeviceMarker;
1630    type ControlHandle = DeviceControlHandle;
1631
1632    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1633        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1634    }
1635
1636    fn control_handle(&self) -> Self::ControlHandle {
1637        DeviceControlHandle { inner: self.inner.clone() }
1638    }
1639
1640    fn into_inner(
1641        self,
1642    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1643    {
1644        (self.inner, self.is_terminated)
1645    }
1646
1647    fn from_inner(
1648        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1649        is_terminated: bool,
1650    ) -> Self {
1651        Self { inner, is_terminated }
1652    }
1653}
1654
1655impl futures::Stream for DeviceRequestStream {
1656    type Item = Result<DeviceRequest, fidl::Error>;
1657
1658    fn poll_next(
1659        mut self: std::pin::Pin<&mut Self>,
1660        cx: &mut std::task::Context<'_>,
1661    ) -> std::task::Poll<Option<Self::Item>> {
1662        let this = &mut *self;
1663        if this.inner.check_shutdown(cx) {
1664            this.is_terminated = true;
1665            return std::task::Poll::Ready(None);
1666        }
1667        if this.is_terminated {
1668            panic!("polled DeviceRequestStream after completion");
1669        }
1670        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1671            |bytes, handles| {
1672                match this.inner.channel().read_etc(cx, bytes, handles) {
1673                    std::task::Poll::Ready(Ok(())) => {}
1674                    std::task::Poll::Pending => return std::task::Poll::Pending,
1675                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1676                        this.is_terminated = true;
1677                        return std::task::Poll::Ready(None);
1678                    }
1679                    std::task::Poll::Ready(Err(e)) => {
1680                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1681                            e.into(),
1682                        ))))
1683                    }
1684                }
1685
1686                // A message has been received from the channel
1687                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1688
1689                std::task::Poll::Ready(Some(match header.ordinal {
1690                    0x627d4c6093b078e7 => {
1691                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1692                        let mut req = fidl::new_empty!(
1693                            DeviceQueryRequest,
1694                            fidl::encoding::DefaultFuchsiaResourceDialect
1695                        );
1696                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceQueryRequest>(&header, _body_bytes, handles, &mut req)?;
1697                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1698                        Ok(DeviceRequest::Query {
1699                            query_id: req.query_id,
1700
1701                            responder: DeviceQueryResponder {
1702                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1703                                tx_id: header.tx_id,
1704                            },
1705                        })
1706                    }
1707                    0x3a5b134714c67914 => {
1708                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1709                        let mut req = fidl::new_empty!(
1710                            DeviceConnect2Request,
1711                            fidl::encoding::DefaultFuchsiaResourceDialect
1712                        );
1713                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceConnect2Request>(&header, _body_bytes, handles, &mut req)?;
1714                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1715                        Ok(DeviceRequest::Connect2 {
1716                            client_id: req.client_id,
1717                            primary_channel: req.primary_channel,
1718                            notification_channel: req.notification_channel,
1719
1720                            control_handle,
1721                        })
1722                    }
1723                    _ => Err(fidl::Error::UnknownOrdinal {
1724                        ordinal: header.ordinal,
1725                        protocol_name:
1726                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1727                    }),
1728                }))
1729            },
1730        )
1731    }
1732}
1733
1734/// The Magma Device protocol allow clients to learn about the hardware by making queries, such as
1735/// device and vendor IDs, and which client drivers are supported by the device's system driver.  
1736/// To engage further with the device, clients may establish connections formed of channel pairs:
1737/// a primary channel for making requests (see Primary protocol below), and a secondary channel
1738/// for receiving notification messages (see Notification protocol below).
1739#[derive(Debug)]
1740pub enum DeviceRequest {
1741    /// On success, returns a result either in a buffer or a simple value.
1742    Query { query_id: QueryId, responder: DeviceQueryResponder },
1743    /// Creates a connection to the device comprised of two IPC channels.
1744    /// The primary channel is for the Primary protocol (see below).  The notification channel is
1745    /// used for vendor-specific messages which are sent only in the reverse (server-client)
1746    /// direction, typically in response to client command completion.
1747    Connect2 {
1748        client_id: u64,
1749        primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
1750        notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
1751        control_handle: DeviceControlHandle,
1752    },
1753}
1754
1755impl DeviceRequest {
1756    #[allow(irrefutable_let_patterns)]
1757    pub fn into_query(self) -> Option<(QueryId, DeviceQueryResponder)> {
1758        if let DeviceRequest::Query { query_id, responder } = self {
1759            Some((query_id, responder))
1760        } else {
1761            None
1762        }
1763    }
1764
1765    #[allow(irrefutable_let_patterns)]
1766    pub fn into_connect2(
1767        self,
1768    ) -> Option<(
1769        u64,
1770        fidl::endpoints::ServerEnd<PrimaryMarker>,
1771        fidl::endpoints::ServerEnd<NotificationMarker>,
1772        DeviceControlHandle,
1773    )> {
1774        if let DeviceRequest::Connect2 {
1775            client_id,
1776            primary_channel,
1777            notification_channel,
1778            control_handle,
1779        } = self
1780        {
1781            Some((client_id, primary_channel, notification_channel, control_handle))
1782        } else {
1783            None
1784        }
1785    }
1786
1787    /// Name of the method defined in FIDL
1788    pub fn method_name(&self) -> &'static str {
1789        match *self {
1790            DeviceRequest::Query { .. } => "query",
1791            DeviceRequest::Connect2 { .. } => "connect2",
1792        }
1793    }
1794}
1795
1796#[derive(Debug, Clone)]
1797pub struct DeviceControlHandle {
1798    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1799}
1800
1801impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1802    fn shutdown(&self) {
1803        self.inner.shutdown()
1804    }
1805    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1806        self.inner.shutdown_with_epitaph(status)
1807    }
1808
1809    fn is_closed(&self) -> bool {
1810        self.inner.channel().is_closed()
1811    }
1812    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1813        self.inner.channel().on_closed()
1814    }
1815
1816    #[cfg(target_os = "fuchsia")]
1817    fn signal_peer(
1818        &self,
1819        clear_mask: zx::Signals,
1820        set_mask: zx::Signals,
1821    ) -> Result<(), zx_status::Status> {
1822        use fidl::Peered;
1823        self.inner.channel().signal_peer(clear_mask, set_mask)
1824    }
1825}
1826
1827impl DeviceControlHandle {}
1828
1829#[must_use = "FIDL methods require a response to be sent"]
1830#[derive(Debug)]
1831pub struct DeviceQueryResponder {
1832    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1833    tx_id: u32,
1834}
1835
1836/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1837/// if the responder is dropped without sending a response, so that the client
1838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1839impl std::ops::Drop for DeviceQueryResponder {
1840    fn drop(&mut self) {
1841        self.control_handle.shutdown();
1842        // Safety: drops once, never accessed again
1843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1844    }
1845}
1846
1847impl fidl::endpoints::Responder for DeviceQueryResponder {
1848    type ControlHandle = DeviceControlHandle;
1849
1850    fn control_handle(&self) -> &DeviceControlHandle {
1851        &self.control_handle
1852    }
1853
1854    fn drop_without_shutdown(mut self) {
1855        // Safety: drops once, never accessed again due to mem::forget
1856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1857        // Prevent Drop from running (which would shut down the channel)
1858        std::mem::forget(self);
1859    }
1860}
1861
1862impl DeviceQueryResponder {
1863    /// Sends a response to the FIDL transaction.
1864    ///
1865    /// Sets the channel to shutdown if an error occurs.
1866    pub fn send(self, mut result: Result<DeviceQueryResponse, i32>) -> Result<(), fidl::Error> {
1867        let _result = self.send_raw(result);
1868        if _result.is_err() {
1869            self.control_handle.shutdown();
1870        }
1871        self.drop_without_shutdown();
1872        _result
1873    }
1874
1875    /// Similar to "send" but does not shutdown the channel if an error occurs.
1876    pub fn send_no_shutdown_on_err(
1877        self,
1878        mut result: Result<DeviceQueryResponse, i32>,
1879    ) -> Result<(), fidl::Error> {
1880        let _result = self.send_raw(result);
1881        self.drop_without_shutdown();
1882        _result
1883    }
1884
1885    fn send_raw(&self, mut result: Result<DeviceQueryResponse, i32>) -> Result<(), fidl::Error> {
1886        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
1887            result.as_mut().map_err(|e| *e),
1888            self.tx_id,
1889            0x627d4c6093b078e7,
1890            fidl::encoding::DynamicFlags::empty(),
1891        )
1892    }
1893}
1894
1895#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1896pub struct DiagnosticDeviceMarker;
1897
1898impl fidl::endpoints::ProtocolMarker for DiagnosticDeviceMarker {
1899    type Proxy = DiagnosticDeviceProxy;
1900    type RequestStream = DiagnosticDeviceRequestStream;
1901    #[cfg(target_os = "fuchsia")]
1902    type SynchronousProxy = DiagnosticDeviceSynchronousProxy;
1903
1904    const DEBUG_NAME: &'static str = "(anonymous) DiagnosticDevice";
1905}
1906
1907pub trait DiagnosticDeviceProxyInterface: Send + Sync {
1908    fn r#dump_state(&self, dump_type: u32) -> Result<(), fidl::Error>;
1909}
1910#[derive(Debug)]
1911#[cfg(target_os = "fuchsia")]
1912pub struct DiagnosticDeviceSynchronousProxy {
1913    client: fidl::client::sync::Client,
1914}
1915
1916#[cfg(target_os = "fuchsia")]
1917impl fidl::endpoints::SynchronousProxy for DiagnosticDeviceSynchronousProxy {
1918    type Proxy = DiagnosticDeviceProxy;
1919    type Protocol = DiagnosticDeviceMarker;
1920
1921    fn from_channel(inner: fidl::Channel) -> Self {
1922        Self::new(inner)
1923    }
1924
1925    fn into_channel(self) -> fidl::Channel {
1926        self.client.into_channel()
1927    }
1928
1929    fn as_channel(&self) -> &fidl::Channel {
1930        self.client.as_channel()
1931    }
1932}
1933
1934#[cfg(target_os = "fuchsia")]
1935impl DiagnosticDeviceSynchronousProxy {
1936    pub fn new(channel: fidl::Channel) -> Self {
1937        let protocol_name = <DiagnosticDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1938        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1939    }
1940
1941    pub fn into_channel(self) -> fidl::Channel {
1942        self.client.into_channel()
1943    }
1944
1945    /// Waits until an event arrives and returns it. It is safe for other
1946    /// threads to make concurrent requests while waiting for an event.
1947    pub fn wait_for_event(
1948        &self,
1949        deadline: zx::MonotonicInstant,
1950    ) -> Result<DiagnosticDeviceEvent, fidl::Error> {
1951        DiagnosticDeviceEvent::decode(self.client.wait_for_event(deadline)?)
1952    }
1953
1954    /// Dumps driver and hardware state to the log.
1955    pub fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
1956        self.client.send::<DiagnosticDeviceDumpStateRequest>(
1957            (dump_type,),
1958            0x5420df493d4fa915,
1959            fidl::encoding::DynamicFlags::empty(),
1960        )
1961    }
1962}
1963
1964#[cfg(target_os = "fuchsia")]
1965impl From<DiagnosticDeviceSynchronousProxy> for zx::Handle {
1966    fn from(value: DiagnosticDeviceSynchronousProxy) -> Self {
1967        value.into_channel().into()
1968    }
1969}
1970
1971#[cfg(target_os = "fuchsia")]
1972impl From<fidl::Channel> for DiagnosticDeviceSynchronousProxy {
1973    fn from(value: fidl::Channel) -> Self {
1974        Self::new(value)
1975    }
1976}
1977
1978#[derive(Debug, Clone)]
1979pub struct DiagnosticDeviceProxy {
1980    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1981}
1982
1983impl fidl::endpoints::Proxy for DiagnosticDeviceProxy {
1984    type Protocol = DiagnosticDeviceMarker;
1985
1986    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1987        Self::new(inner)
1988    }
1989
1990    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1991        self.client.into_channel().map_err(|client| Self { client })
1992    }
1993
1994    fn as_channel(&self) -> &::fidl::AsyncChannel {
1995        self.client.as_channel()
1996    }
1997}
1998
1999impl DiagnosticDeviceProxy {
2000    /// Create a new Proxy for fuchsia.gpu.magma/DiagnosticDevice.
2001    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2002        let protocol_name = <DiagnosticDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2003        Self { client: fidl::client::Client::new(channel, protocol_name) }
2004    }
2005
2006    /// Get a Stream of events from the remote end of the protocol.
2007    ///
2008    /// # Panics
2009    ///
2010    /// Panics if the event stream was already taken.
2011    pub fn take_event_stream(&self) -> DiagnosticDeviceEventStream {
2012        DiagnosticDeviceEventStream { event_receiver: self.client.take_event_receiver() }
2013    }
2014
2015    /// Dumps driver and hardware state to the log.
2016    pub fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
2017        DiagnosticDeviceProxyInterface::r#dump_state(self, dump_type)
2018    }
2019}
2020
2021impl DiagnosticDeviceProxyInterface for DiagnosticDeviceProxy {
2022    fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
2023        self.client.send::<DiagnosticDeviceDumpStateRequest>(
2024            (dump_type,),
2025            0x5420df493d4fa915,
2026            fidl::encoding::DynamicFlags::empty(),
2027        )
2028    }
2029}
2030
2031pub struct DiagnosticDeviceEventStream {
2032    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2033}
2034
2035impl std::marker::Unpin for DiagnosticDeviceEventStream {}
2036
2037impl futures::stream::FusedStream for DiagnosticDeviceEventStream {
2038    fn is_terminated(&self) -> bool {
2039        self.event_receiver.is_terminated()
2040    }
2041}
2042
2043impl futures::Stream for DiagnosticDeviceEventStream {
2044    type Item = Result<DiagnosticDeviceEvent, fidl::Error>;
2045
2046    fn poll_next(
2047        mut self: std::pin::Pin<&mut Self>,
2048        cx: &mut std::task::Context<'_>,
2049    ) -> std::task::Poll<Option<Self::Item>> {
2050        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2051            &mut self.event_receiver,
2052            cx
2053        )?) {
2054            Some(buf) => std::task::Poll::Ready(Some(DiagnosticDeviceEvent::decode(buf))),
2055            None => std::task::Poll::Ready(None),
2056        }
2057    }
2058}
2059
2060#[derive(Debug)]
2061pub enum DiagnosticDeviceEvent {}
2062
2063impl DiagnosticDeviceEvent {
2064    /// Decodes a message buffer as a [`DiagnosticDeviceEvent`].
2065    fn decode(
2066        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2067    ) -> Result<DiagnosticDeviceEvent, fidl::Error> {
2068        let (bytes, _handles) = buf.split_mut();
2069        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2070        debug_assert_eq!(tx_header.tx_id, 0);
2071        match tx_header.ordinal {
2072            _ => Err(fidl::Error::UnknownOrdinal {
2073                ordinal: tx_header.ordinal,
2074                protocol_name:
2075                    <DiagnosticDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2076            }),
2077        }
2078    }
2079}
2080
2081/// A Stream of incoming requests for fuchsia.gpu.magma/DiagnosticDevice.
2082pub struct DiagnosticDeviceRequestStream {
2083    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2084    is_terminated: bool,
2085}
2086
2087impl std::marker::Unpin for DiagnosticDeviceRequestStream {}
2088
2089impl futures::stream::FusedStream for DiagnosticDeviceRequestStream {
2090    fn is_terminated(&self) -> bool {
2091        self.is_terminated
2092    }
2093}
2094
2095impl fidl::endpoints::RequestStream for DiagnosticDeviceRequestStream {
2096    type Protocol = DiagnosticDeviceMarker;
2097    type ControlHandle = DiagnosticDeviceControlHandle;
2098
2099    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2100        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2101    }
2102
2103    fn control_handle(&self) -> Self::ControlHandle {
2104        DiagnosticDeviceControlHandle { inner: self.inner.clone() }
2105    }
2106
2107    fn into_inner(
2108        self,
2109    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2110    {
2111        (self.inner, self.is_terminated)
2112    }
2113
2114    fn from_inner(
2115        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2116        is_terminated: bool,
2117    ) -> Self {
2118        Self { inner, is_terminated }
2119    }
2120}
2121
2122impl futures::Stream for DiagnosticDeviceRequestStream {
2123    type Item = Result<DiagnosticDeviceRequest, fidl::Error>;
2124
2125    fn poll_next(
2126        mut self: std::pin::Pin<&mut Self>,
2127        cx: &mut std::task::Context<'_>,
2128    ) -> std::task::Poll<Option<Self::Item>> {
2129        let this = &mut *self;
2130        if this.inner.check_shutdown(cx) {
2131            this.is_terminated = true;
2132            return std::task::Poll::Ready(None);
2133        }
2134        if this.is_terminated {
2135            panic!("polled DiagnosticDeviceRequestStream after completion");
2136        }
2137        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2138            |bytes, handles| {
2139                match this.inner.channel().read_etc(cx, bytes, handles) {
2140                    std::task::Poll::Ready(Ok(())) => {}
2141                    std::task::Poll::Pending => return std::task::Poll::Pending,
2142                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2143                        this.is_terminated = true;
2144                        return std::task::Poll::Ready(None);
2145                    }
2146                    std::task::Poll::Ready(Err(e)) => {
2147                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2148                            e.into(),
2149                        ))))
2150                    }
2151                }
2152
2153                // A message has been received from the channel
2154                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2155
2156                std::task::Poll::Ready(Some(match header.ordinal {
2157                    0x5420df493d4fa915 => {
2158                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2159                        let mut req = fidl::new_empty!(
2160                            DiagnosticDeviceDumpStateRequest,
2161                            fidl::encoding::DefaultFuchsiaResourceDialect
2162                        );
2163                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DiagnosticDeviceDumpStateRequest>(&header, _body_bytes, handles, &mut req)?;
2164                        let control_handle =
2165                            DiagnosticDeviceControlHandle { inner: this.inner.clone() };
2166                        Ok(DiagnosticDeviceRequest::DumpState {
2167                            dump_type: req.dump_type,
2168
2169                            control_handle,
2170                        })
2171                    }
2172                    _ => Err(fidl::Error::UnknownOrdinal {
2173                        ordinal: header.ordinal,
2174                        protocol_name:
2175                            <DiagnosticDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2176                    }),
2177                }))
2178            },
2179        )
2180    }
2181}
2182
2183/// Methods used to expose diagnostics from the Magma device.
2184#[derive(Debug)]
2185pub enum DiagnosticDeviceRequest {
2186    /// Dumps driver and hardware state to the log.
2187    DumpState { dump_type: u32, control_handle: DiagnosticDeviceControlHandle },
2188}
2189
2190impl DiagnosticDeviceRequest {
2191    #[allow(irrefutable_let_patterns)]
2192    pub fn into_dump_state(self) -> Option<(u32, DiagnosticDeviceControlHandle)> {
2193        if let DiagnosticDeviceRequest::DumpState { dump_type, control_handle } = self {
2194            Some((dump_type, control_handle))
2195        } else {
2196            None
2197        }
2198    }
2199
2200    /// Name of the method defined in FIDL
2201    pub fn method_name(&self) -> &'static str {
2202        match *self {
2203            DiagnosticDeviceRequest::DumpState { .. } => "dump_state",
2204        }
2205    }
2206}
2207
2208#[derive(Debug, Clone)]
2209pub struct DiagnosticDeviceControlHandle {
2210    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2211}
2212
2213impl fidl::endpoints::ControlHandle for DiagnosticDeviceControlHandle {
2214    fn shutdown(&self) {
2215        self.inner.shutdown()
2216    }
2217    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2218        self.inner.shutdown_with_epitaph(status)
2219    }
2220
2221    fn is_closed(&self) -> bool {
2222        self.inner.channel().is_closed()
2223    }
2224    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2225        self.inner.channel().on_closed()
2226    }
2227
2228    #[cfg(target_os = "fuchsia")]
2229    fn signal_peer(
2230        &self,
2231        clear_mask: zx::Signals,
2232        set_mask: zx::Signals,
2233    ) -> Result<(), zx_status::Status> {
2234        use fidl::Peered;
2235        self.inner.channel().signal_peer(clear_mask, set_mask)
2236    }
2237}
2238
2239impl DiagnosticDeviceControlHandle {}
2240
2241#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2242pub struct IcdLoaderDeviceMarker;
2243
2244impl fidl::endpoints::ProtocolMarker for IcdLoaderDeviceMarker {
2245    type Proxy = IcdLoaderDeviceProxy;
2246    type RequestStream = IcdLoaderDeviceRequestStream;
2247    #[cfg(target_os = "fuchsia")]
2248    type SynchronousProxy = IcdLoaderDeviceSynchronousProxy;
2249
2250    const DEBUG_NAME: &'static str = "(anonymous) IcdLoaderDevice";
2251}
2252
2253pub trait IcdLoaderDeviceProxyInterface: Send + Sync {
2254    type GetIcdListResponseFut: std::future::Future<Output = Result<Vec<IcdInfo>, fidl::Error>>
2255        + Send;
2256    fn r#get_icd_list(&self) -> Self::GetIcdListResponseFut;
2257}
2258#[derive(Debug)]
2259#[cfg(target_os = "fuchsia")]
2260pub struct IcdLoaderDeviceSynchronousProxy {
2261    client: fidl::client::sync::Client,
2262}
2263
2264#[cfg(target_os = "fuchsia")]
2265impl fidl::endpoints::SynchronousProxy for IcdLoaderDeviceSynchronousProxy {
2266    type Proxy = IcdLoaderDeviceProxy;
2267    type Protocol = IcdLoaderDeviceMarker;
2268
2269    fn from_channel(inner: fidl::Channel) -> Self {
2270        Self::new(inner)
2271    }
2272
2273    fn into_channel(self) -> fidl::Channel {
2274        self.client.into_channel()
2275    }
2276
2277    fn as_channel(&self) -> &fidl::Channel {
2278        self.client.as_channel()
2279    }
2280}
2281
2282#[cfg(target_os = "fuchsia")]
2283impl IcdLoaderDeviceSynchronousProxy {
2284    pub fn new(channel: fidl::Channel) -> Self {
2285        let protocol_name = <IcdLoaderDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2286        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2287    }
2288
2289    pub fn into_channel(self) -> fidl::Channel {
2290        self.client.into_channel()
2291    }
2292
2293    /// Waits until an event arrives and returns it. It is safe for other
2294    /// threads to make concurrent requests while waiting for an event.
2295    pub fn wait_for_event(
2296        &self,
2297        deadline: zx::MonotonicInstant,
2298    ) -> Result<IcdLoaderDeviceEvent, fidl::Error> {
2299        IcdLoaderDeviceEvent::decode(self.client.wait_for_event(deadline)?)
2300    }
2301
2302    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
2303    /// descending order of preference.
2304    pub fn r#get_icd_list(
2305        &self,
2306        ___deadline: zx::MonotonicInstant,
2307    ) -> Result<Vec<IcdInfo>, fidl::Error> {
2308        let _response = self
2309            .client
2310            .send_query::<fidl::encoding::EmptyPayload, IcdLoaderDeviceGetIcdListResponse>(
2311                (),
2312                0x7673e76395008257,
2313                fidl::encoding::DynamicFlags::empty(),
2314                ___deadline,
2315            )?;
2316        Ok(_response.icd_list)
2317    }
2318}
2319
2320#[cfg(target_os = "fuchsia")]
2321impl From<IcdLoaderDeviceSynchronousProxy> for zx::Handle {
2322    fn from(value: IcdLoaderDeviceSynchronousProxy) -> Self {
2323        value.into_channel().into()
2324    }
2325}
2326
2327#[cfg(target_os = "fuchsia")]
2328impl From<fidl::Channel> for IcdLoaderDeviceSynchronousProxy {
2329    fn from(value: fidl::Channel) -> Self {
2330        Self::new(value)
2331    }
2332}
2333
2334#[derive(Debug, Clone)]
2335pub struct IcdLoaderDeviceProxy {
2336    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2337}
2338
2339impl fidl::endpoints::Proxy for IcdLoaderDeviceProxy {
2340    type Protocol = IcdLoaderDeviceMarker;
2341
2342    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2343        Self::new(inner)
2344    }
2345
2346    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2347        self.client.into_channel().map_err(|client| Self { client })
2348    }
2349
2350    fn as_channel(&self) -> &::fidl::AsyncChannel {
2351        self.client.as_channel()
2352    }
2353}
2354
2355impl IcdLoaderDeviceProxy {
2356    /// Create a new Proxy for fuchsia.gpu.magma/IcdLoaderDevice.
2357    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2358        let protocol_name = <IcdLoaderDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2359        Self { client: fidl::client::Client::new(channel, protocol_name) }
2360    }
2361
2362    /// Get a Stream of events from the remote end of the protocol.
2363    ///
2364    /// # Panics
2365    ///
2366    /// Panics if the event stream was already taken.
2367    pub fn take_event_stream(&self) -> IcdLoaderDeviceEventStream {
2368        IcdLoaderDeviceEventStream { event_receiver: self.client.take_event_receiver() }
2369    }
2370
2371    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
2372    /// descending order of preference.
2373    pub fn r#get_icd_list(
2374        &self,
2375    ) -> fidl::client::QueryResponseFut<Vec<IcdInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>
2376    {
2377        IcdLoaderDeviceProxyInterface::r#get_icd_list(self)
2378    }
2379}
2380
2381impl IcdLoaderDeviceProxyInterface for IcdLoaderDeviceProxy {
2382    type GetIcdListResponseFut =
2383        fidl::client::QueryResponseFut<Vec<IcdInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>;
2384    fn r#get_icd_list(&self) -> Self::GetIcdListResponseFut {
2385        fn _decode(
2386            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2387        ) -> Result<Vec<IcdInfo>, fidl::Error> {
2388            let _response = fidl::client::decode_transaction_body::<
2389                IcdLoaderDeviceGetIcdListResponse,
2390                fidl::encoding::DefaultFuchsiaResourceDialect,
2391                0x7673e76395008257,
2392            >(_buf?)?;
2393            Ok(_response.icd_list)
2394        }
2395        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<IcdInfo>>(
2396            (),
2397            0x7673e76395008257,
2398            fidl::encoding::DynamicFlags::empty(),
2399            _decode,
2400        )
2401    }
2402}
2403
2404pub struct IcdLoaderDeviceEventStream {
2405    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2406}
2407
2408impl std::marker::Unpin for IcdLoaderDeviceEventStream {}
2409
2410impl futures::stream::FusedStream for IcdLoaderDeviceEventStream {
2411    fn is_terminated(&self) -> bool {
2412        self.event_receiver.is_terminated()
2413    }
2414}
2415
2416impl futures::Stream for IcdLoaderDeviceEventStream {
2417    type Item = Result<IcdLoaderDeviceEvent, fidl::Error>;
2418
2419    fn poll_next(
2420        mut self: std::pin::Pin<&mut Self>,
2421        cx: &mut std::task::Context<'_>,
2422    ) -> std::task::Poll<Option<Self::Item>> {
2423        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2424            &mut self.event_receiver,
2425            cx
2426        )?) {
2427            Some(buf) => std::task::Poll::Ready(Some(IcdLoaderDeviceEvent::decode(buf))),
2428            None => std::task::Poll::Ready(None),
2429        }
2430    }
2431}
2432
2433#[derive(Debug)]
2434pub enum IcdLoaderDeviceEvent {}
2435
2436impl IcdLoaderDeviceEvent {
2437    /// Decodes a message buffer as a [`IcdLoaderDeviceEvent`].
2438    fn decode(
2439        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2440    ) -> Result<IcdLoaderDeviceEvent, fidl::Error> {
2441        let (bytes, _handles) = buf.split_mut();
2442        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2443        debug_assert_eq!(tx_header.tx_id, 0);
2444        match tx_header.ordinal {
2445            _ => Err(fidl::Error::UnknownOrdinal {
2446                ordinal: tx_header.ordinal,
2447                protocol_name:
2448                    <IcdLoaderDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2449            }),
2450        }
2451    }
2452}
2453
2454/// A Stream of incoming requests for fuchsia.gpu.magma/IcdLoaderDevice.
2455pub struct IcdLoaderDeviceRequestStream {
2456    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2457    is_terminated: bool,
2458}
2459
2460impl std::marker::Unpin for IcdLoaderDeviceRequestStream {}
2461
2462impl futures::stream::FusedStream for IcdLoaderDeviceRequestStream {
2463    fn is_terminated(&self) -> bool {
2464        self.is_terminated
2465    }
2466}
2467
2468impl fidl::endpoints::RequestStream for IcdLoaderDeviceRequestStream {
2469    type Protocol = IcdLoaderDeviceMarker;
2470    type ControlHandle = IcdLoaderDeviceControlHandle;
2471
2472    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2473        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2474    }
2475
2476    fn control_handle(&self) -> Self::ControlHandle {
2477        IcdLoaderDeviceControlHandle { inner: self.inner.clone() }
2478    }
2479
2480    fn into_inner(
2481        self,
2482    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2483    {
2484        (self.inner, self.is_terminated)
2485    }
2486
2487    fn from_inner(
2488        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2489        is_terminated: bool,
2490    ) -> Self {
2491        Self { inner, is_terminated }
2492    }
2493}
2494
2495impl futures::Stream for IcdLoaderDeviceRequestStream {
2496    type Item = Result<IcdLoaderDeviceRequest, fidl::Error>;
2497
2498    fn poll_next(
2499        mut self: std::pin::Pin<&mut Self>,
2500        cx: &mut std::task::Context<'_>,
2501    ) -> std::task::Poll<Option<Self::Item>> {
2502        let this = &mut *self;
2503        if this.inner.check_shutdown(cx) {
2504            this.is_terminated = true;
2505            return std::task::Poll::Ready(None);
2506        }
2507        if this.is_terminated {
2508            panic!("polled IcdLoaderDeviceRequestStream after completion");
2509        }
2510        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2511            |bytes, handles| {
2512                match this.inner.channel().read_etc(cx, bytes, handles) {
2513                    std::task::Poll::Ready(Ok(())) => {}
2514                    std::task::Poll::Pending => return std::task::Poll::Pending,
2515                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2516                        this.is_terminated = true;
2517                        return std::task::Poll::Ready(None);
2518                    }
2519                    std::task::Poll::Ready(Err(e)) => {
2520                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2521                            e.into(),
2522                        ))))
2523                    }
2524                }
2525
2526                // A message has been received from the channel
2527                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2528
2529                std::task::Poll::Ready(Some(match header.ordinal {
2530                    0x7673e76395008257 => {
2531                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2532                        let mut req = fidl::new_empty!(
2533                            fidl::encoding::EmptyPayload,
2534                            fidl::encoding::DefaultFuchsiaResourceDialect
2535                        );
2536                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2537                        let control_handle =
2538                            IcdLoaderDeviceControlHandle { inner: this.inner.clone() };
2539                        Ok(IcdLoaderDeviceRequest::GetIcdList {
2540                            responder: IcdLoaderDeviceGetIcdListResponder {
2541                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2542                                tx_id: header.tx_id,
2543                            },
2544                        })
2545                    }
2546                    _ => Err(fidl::Error::UnknownOrdinal {
2547                        ordinal: header.ordinal,
2548                        protocol_name:
2549                            <IcdLoaderDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2550                    }),
2551                }))
2552            },
2553        )
2554    }
2555}
2556
2557/// Methods implemented by an MSD and exposed for use of an ICD loader.
2558#[derive(Debug)]
2559pub enum IcdLoaderDeviceRequest {
2560    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
2561    /// descending order of preference.
2562    GetIcdList { responder: IcdLoaderDeviceGetIcdListResponder },
2563}
2564
2565impl IcdLoaderDeviceRequest {
2566    #[allow(irrefutable_let_patterns)]
2567    pub fn into_get_icd_list(self) -> Option<(IcdLoaderDeviceGetIcdListResponder)> {
2568        if let IcdLoaderDeviceRequest::GetIcdList { responder } = self {
2569            Some((responder))
2570        } else {
2571            None
2572        }
2573    }
2574
2575    /// Name of the method defined in FIDL
2576    pub fn method_name(&self) -> &'static str {
2577        match *self {
2578            IcdLoaderDeviceRequest::GetIcdList { .. } => "get_icd_list",
2579        }
2580    }
2581}
2582
2583#[derive(Debug, Clone)]
2584pub struct IcdLoaderDeviceControlHandle {
2585    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2586}
2587
2588impl fidl::endpoints::ControlHandle for IcdLoaderDeviceControlHandle {
2589    fn shutdown(&self) {
2590        self.inner.shutdown()
2591    }
2592    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2593        self.inner.shutdown_with_epitaph(status)
2594    }
2595
2596    fn is_closed(&self) -> bool {
2597        self.inner.channel().is_closed()
2598    }
2599    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2600        self.inner.channel().on_closed()
2601    }
2602
2603    #[cfg(target_os = "fuchsia")]
2604    fn signal_peer(
2605        &self,
2606        clear_mask: zx::Signals,
2607        set_mask: zx::Signals,
2608    ) -> Result<(), zx_status::Status> {
2609        use fidl::Peered;
2610        self.inner.channel().signal_peer(clear_mask, set_mask)
2611    }
2612}
2613
2614impl IcdLoaderDeviceControlHandle {}
2615
2616#[must_use = "FIDL methods require a response to be sent"]
2617#[derive(Debug)]
2618pub struct IcdLoaderDeviceGetIcdListResponder {
2619    control_handle: std::mem::ManuallyDrop<IcdLoaderDeviceControlHandle>,
2620    tx_id: u32,
2621}
2622
2623/// Set the the channel to be shutdown (see [`IcdLoaderDeviceControlHandle::shutdown`])
2624/// if the responder is dropped without sending a response, so that the client
2625/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2626impl std::ops::Drop for IcdLoaderDeviceGetIcdListResponder {
2627    fn drop(&mut self) {
2628        self.control_handle.shutdown();
2629        // Safety: drops once, never accessed again
2630        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2631    }
2632}
2633
2634impl fidl::endpoints::Responder for IcdLoaderDeviceGetIcdListResponder {
2635    type ControlHandle = IcdLoaderDeviceControlHandle;
2636
2637    fn control_handle(&self) -> &IcdLoaderDeviceControlHandle {
2638        &self.control_handle
2639    }
2640
2641    fn drop_without_shutdown(mut self) {
2642        // Safety: drops once, never accessed again due to mem::forget
2643        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2644        // Prevent Drop from running (which would shut down the channel)
2645        std::mem::forget(self);
2646    }
2647}
2648
2649impl IcdLoaderDeviceGetIcdListResponder {
2650    /// Sends a response to the FIDL transaction.
2651    ///
2652    /// Sets the channel to shutdown if an error occurs.
2653    pub fn send(self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
2654        let _result = self.send_raw(icd_list);
2655        if _result.is_err() {
2656            self.control_handle.shutdown();
2657        }
2658        self.drop_without_shutdown();
2659        _result
2660    }
2661
2662    /// Similar to "send" but does not shutdown the channel if an error occurs.
2663    pub fn send_no_shutdown_on_err(self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
2664        let _result = self.send_raw(icd_list);
2665        self.drop_without_shutdown();
2666        _result
2667    }
2668
2669    fn send_raw(&self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
2670        self.control_handle.inner.send::<IcdLoaderDeviceGetIcdListResponse>(
2671            (icd_list,),
2672            self.tx_id,
2673            0x7673e76395008257,
2674            fidl::encoding::DynamicFlags::empty(),
2675        )
2676    }
2677}
2678
2679#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2680pub struct NotificationMarker;
2681
2682impl fidl::endpoints::ProtocolMarker for NotificationMarker {
2683    type Proxy = NotificationProxy;
2684    type RequestStream = NotificationRequestStream;
2685    #[cfg(target_os = "fuchsia")]
2686    type SynchronousProxy = NotificationSynchronousProxy;
2687
2688    const DEBUG_NAME: &'static str = "(anonymous) Notification";
2689}
2690
2691pub trait NotificationProxyInterface: Send + Sync {}
2692#[derive(Debug)]
2693#[cfg(target_os = "fuchsia")]
2694pub struct NotificationSynchronousProxy {
2695    client: fidl::client::sync::Client,
2696}
2697
2698#[cfg(target_os = "fuchsia")]
2699impl fidl::endpoints::SynchronousProxy for NotificationSynchronousProxy {
2700    type Proxy = NotificationProxy;
2701    type Protocol = NotificationMarker;
2702
2703    fn from_channel(inner: fidl::Channel) -> Self {
2704        Self::new(inner)
2705    }
2706
2707    fn into_channel(self) -> fidl::Channel {
2708        self.client.into_channel()
2709    }
2710
2711    fn as_channel(&self) -> &fidl::Channel {
2712        self.client.as_channel()
2713    }
2714}
2715
2716#[cfg(target_os = "fuchsia")]
2717impl NotificationSynchronousProxy {
2718    pub fn new(channel: fidl::Channel) -> Self {
2719        let protocol_name = <NotificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2720        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2721    }
2722
2723    pub fn into_channel(self) -> fidl::Channel {
2724        self.client.into_channel()
2725    }
2726
2727    /// Waits until an event arrives and returns it. It is safe for other
2728    /// threads to make concurrent requests while waiting for an event.
2729    pub fn wait_for_event(
2730        &self,
2731        deadline: zx::MonotonicInstant,
2732    ) -> Result<NotificationEvent, fidl::Error> {
2733        NotificationEvent::decode(self.client.wait_for_event(deadline)?)
2734    }
2735}
2736
2737#[cfg(target_os = "fuchsia")]
2738impl From<NotificationSynchronousProxy> for zx::Handle {
2739    fn from(value: NotificationSynchronousProxy) -> Self {
2740        value.into_channel().into()
2741    }
2742}
2743
2744#[cfg(target_os = "fuchsia")]
2745impl From<fidl::Channel> for NotificationSynchronousProxy {
2746    fn from(value: fidl::Channel) -> Self {
2747        Self::new(value)
2748    }
2749}
2750
2751#[derive(Debug, Clone)]
2752pub struct NotificationProxy {
2753    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2754}
2755
2756impl fidl::endpoints::Proxy for NotificationProxy {
2757    type Protocol = NotificationMarker;
2758
2759    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2760        Self::new(inner)
2761    }
2762
2763    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2764        self.client.into_channel().map_err(|client| Self { client })
2765    }
2766
2767    fn as_channel(&self) -> &::fidl::AsyncChannel {
2768        self.client.as_channel()
2769    }
2770}
2771
2772impl NotificationProxy {
2773    /// Create a new Proxy for fuchsia.gpu.magma/Notification.
2774    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2775        let protocol_name = <NotificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2776        Self { client: fidl::client::Client::new(channel, protocol_name) }
2777    }
2778
2779    /// Get a Stream of events from the remote end of the protocol.
2780    ///
2781    /// # Panics
2782    ///
2783    /// Panics if the event stream was already taken.
2784    pub fn take_event_stream(&self) -> NotificationEventStream {
2785        NotificationEventStream { event_receiver: self.client.take_event_receiver() }
2786    }
2787}
2788
2789impl NotificationProxyInterface for NotificationProxy {}
2790
2791pub struct NotificationEventStream {
2792    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2793}
2794
2795impl std::marker::Unpin for NotificationEventStream {}
2796
2797impl futures::stream::FusedStream for NotificationEventStream {
2798    fn is_terminated(&self) -> bool {
2799        self.event_receiver.is_terminated()
2800    }
2801}
2802
2803impl futures::Stream for NotificationEventStream {
2804    type Item = Result<NotificationEvent, fidl::Error>;
2805
2806    fn poll_next(
2807        mut self: std::pin::Pin<&mut Self>,
2808        cx: &mut std::task::Context<'_>,
2809    ) -> std::task::Poll<Option<Self::Item>> {
2810        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2811            &mut self.event_receiver,
2812            cx
2813        )?) {
2814            Some(buf) => std::task::Poll::Ready(Some(NotificationEvent::decode(buf))),
2815            None => std::task::Poll::Ready(None),
2816        }
2817    }
2818}
2819
2820#[derive(Debug)]
2821pub enum NotificationEvent {}
2822
2823impl NotificationEvent {
2824    /// Decodes a message buffer as a [`NotificationEvent`].
2825    fn decode(
2826        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2827    ) -> Result<NotificationEvent, fidl::Error> {
2828        let (bytes, _handles) = buf.split_mut();
2829        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2830        debug_assert_eq!(tx_header.tx_id, 0);
2831        match tx_header.ordinal {
2832            _ => Err(fidl::Error::UnknownOrdinal {
2833                ordinal: tx_header.ordinal,
2834                protocol_name: <NotificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2835            }),
2836        }
2837    }
2838}
2839
2840/// A Stream of incoming requests for fuchsia.gpu.magma/Notification.
2841pub struct NotificationRequestStream {
2842    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2843    is_terminated: bool,
2844}
2845
2846impl std::marker::Unpin for NotificationRequestStream {}
2847
2848impl futures::stream::FusedStream for NotificationRequestStream {
2849    fn is_terminated(&self) -> bool {
2850        self.is_terminated
2851    }
2852}
2853
2854impl fidl::endpoints::RequestStream for NotificationRequestStream {
2855    type Protocol = NotificationMarker;
2856    type ControlHandle = NotificationControlHandle;
2857
2858    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2859        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2860    }
2861
2862    fn control_handle(&self) -> Self::ControlHandle {
2863        NotificationControlHandle { inner: self.inner.clone() }
2864    }
2865
2866    fn into_inner(
2867        self,
2868    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2869    {
2870        (self.inner, self.is_terminated)
2871    }
2872
2873    fn from_inner(
2874        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2875        is_terminated: bool,
2876    ) -> Self {
2877        Self { inner, is_terminated }
2878    }
2879}
2880
2881impl futures::Stream for NotificationRequestStream {
2882    type Item = Result<NotificationRequest, fidl::Error>;
2883
2884    fn poll_next(
2885        mut self: std::pin::Pin<&mut Self>,
2886        cx: &mut std::task::Context<'_>,
2887    ) -> std::task::Poll<Option<Self::Item>> {
2888        let this = &mut *self;
2889        if this.inner.check_shutdown(cx) {
2890            this.is_terminated = true;
2891            return std::task::Poll::Ready(None);
2892        }
2893        if this.is_terminated {
2894            panic!("polled NotificationRequestStream after completion");
2895        }
2896        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2897            |bytes, handles| {
2898                match this.inner.channel().read_etc(cx, bytes, handles) {
2899                    std::task::Poll::Ready(Ok(())) => {}
2900                    std::task::Poll::Pending => return std::task::Poll::Pending,
2901                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2902                        this.is_terminated = true;
2903                        return std::task::Poll::Ready(None);
2904                    }
2905                    std::task::Poll::Ready(Err(e)) => {
2906                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2907                            e.into(),
2908                        ))))
2909                    }
2910                }
2911
2912                // A message has been received from the channel
2913                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2914
2915                std::task::Poll::Ready(Some(match header.ordinal {
2916                    _ => Err(fidl::Error::UnknownOrdinal {
2917                        ordinal: header.ordinal,
2918                        protocol_name:
2919                            <NotificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2920                    }),
2921                }))
2922            },
2923        )
2924    }
2925}
2926
2927/// This protocol is empty as the message contents are vendor specific.
2928#[derive(Debug)]
2929pub enum NotificationRequest {}
2930
2931impl NotificationRequest {
2932    /// Name of the method defined in FIDL
2933    pub fn method_name(&self) -> &'static str {
2934        match *self {}
2935    }
2936}
2937
2938#[derive(Debug, Clone)]
2939pub struct NotificationControlHandle {
2940    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2941}
2942
2943impl fidl::endpoints::ControlHandle for NotificationControlHandle {
2944    fn shutdown(&self) {
2945        self.inner.shutdown()
2946    }
2947    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2948        self.inner.shutdown_with_epitaph(status)
2949    }
2950
2951    fn is_closed(&self) -> bool {
2952        self.inner.channel().is_closed()
2953    }
2954    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2955        self.inner.channel().on_closed()
2956    }
2957
2958    #[cfg(target_os = "fuchsia")]
2959    fn signal_peer(
2960        &self,
2961        clear_mask: zx::Signals,
2962        set_mask: zx::Signals,
2963    ) -> Result<(), zx_status::Status> {
2964        use fidl::Peered;
2965        self.inner.channel().signal_peer(clear_mask, set_mask)
2966    }
2967}
2968
2969impl NotificationControlHandle {}
2970
2971#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2972pub struct PerformanceCounterAccessMarker;
2973
2974impl fidl::endpoints::ProtocolMarker for PerformanceCounterAccessMarker {
2975    type Proxy = PerformanceCounterAccessProxy;
2976    type RequestStream = PerformanceCounterAccessRequestStream;
2977    #[cfg(target_os = "fuchsia")]
2978    type SynchronousProxy = PerformanceCounterAccessSynchronousProxy;
2979
2980    const DEBUG_NAME: &'static str = "(anonymous) PerformanceCounterAccess";
2981}
2982
2983pub trait PerformanceCounterAccessProxyInterface: Send + Sync {
2984    type GetPerformanceCountTokenResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
2985        + Send;
2986    fn r#get_performance_count_token(&self) -> Self::GetPerformanceCountTokenResponseFut;
2987}
2988#[derive(Debug)]
2989#[cfg(target_os = "fuchsia")]
2990pub struct PerformanceCounterAccessSynchronousProxy {
2991    client: fidl::client::sync::Client,
2992}
2993
2994#[cfg(target_os = "fuchsia")]
2995impl fidl::endpoints::SynchronousProxy for PerformanceCounterAccessSynchronousProxy {
2996    type Proxy = PerformanceCounterAccessProxy;
2997    type Protocol = PerformanceCounterAccessMarker;
2998
2999    fn from_channel(inner: fidl::Channel) -> Self {
3000        Self::new(inner)
3001    }
3002
3003    fn into_channel(self) -> fidl::Channel {
3004        self.client.into_channel()
3005    }
3006
3007    fn as_channel(&self) -> &fidl::Channel {
3008        self.client.as_channel()
3009    }
3010}
3011
3012#[cfg(target_os = "fuchsia")]
3013impl PerformanceCounterAccessSynchronousProxy {
3014    pub fn new(channel: fidl::Channel) -> Self {
3015        let protocol_name =
3016            <PerformanceCounterAccessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3017        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3018    }
3019
3020    pub fn into_channel(self) -> fidl::Channel {
3021        self.client.into_channel()
3022    }
3023
3024    /// Waits until an event arrives and returns it. It is safe for other
3025    /// threads to make concurrent requests while waiting for an event.
3026    pub fn wait_for_event(
3027        &self,
3028        deadline: zx::MonotonicInstant,
3029    ) -> Result<PerformanceCounterAccessEvent, fidl::Error> {
3030        PerformanceCounterAccessEvent::decode(self.client.wait_for_event(deadline)?)
3031    }
3032
3033    /// This access token is not used as an event, but is instead passed to
3034    /// Primary.EnablePerformanceCounterAccess.
3035    pub fn r#get_performance_count_token(
3036        &self,
3037        ___deadline: zx::MonotonicInstant,
3038    ) -> Result<fidl::Event, fidl::Error> {
3039        let _response = self.client.send_query::<
3040            fidl::encoding::EmptyPayload,
3041            PerformanceCounterAccessGetPerformanceCountTokenResponse,
3042        >(
3043            (),
3044            0x48410470c5f00f92,
3045            fidl::encoding::DynamicFlags::empty(),
3046            ___deadline,
3047        )?;
3048        Ok(_response.access_token)
3049    }
3050}
3051
3052#[cfg(target_os = "fuchsia")]
3053impl From<PerformanceCounterAccessSynchronousProxy> for zx::Handle {
3054    fn from(value: PerformanceCounterAccessSynchronousProxy) -> Self {
3055        value.into_channel().into()
3056    }
3057}
3058
3059#[cfg(target_os = "fuchsia")]
3060impl From<fidl::Channel> for PerformanceCounterAccessSynchronousProxy {
3061    fn from(value: fidl::Channel) -> Self {
3062        Self::new(value)
3063    }
3064}
3065
3066#[derive(Debug, Clone)]
3067pub struct PerformanceCounterAccessProxy {
3068    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3069}
3070
3071impl fidl::endpoints::Proxy for PerformanceCounterAccessProxy {
3072    type Protocol = PerformanceCounterAccessMarker;
3073
3074    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3075        Self::new(inner)
3076    }
3077
3078    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3079        self.client.into_channel().map_err(|client| Self { client })
3080    }
3081
3082    fn as_channel(&self) -> &::fidl::AsyncChannel {
3083        self.client.as_channel()
3084    }
3085}
3086
3087impl PerformanceCounterAccessProxy {
3088    /// Create a new Proxy for fuchsia.gpu.magma/PerformanceCounterAccess.
3089    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3090        let protocol_name =
3091            <PerformanceCounterAccessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3092        Self { client: fidl::client::Client::new(channel, protocol_name) }
3093    }
3094
3095    /// Get a Stream of events from the remote end of the protocol.
3096    ///
3097    /// # Panics
3098    ///
3099    /// Panics if the event stream was already taken.
3100    pub fn take_event_stream(&self) -> PerformanceCounterAccessEventStream {
3101        PerformanceCounterAccessEventStream { event_receiver: self.client.take_event_receiver() }
3102    }
3103
3104    /// This access token is not used as an event, but is instead passed to
3105    /// Primary.EnablePerformanceCounterAccess.
3106    pub fn r#get_performance_count_token(
3107        &self,
3108    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
3109    {
3110        PerformanceCounterAccessProxyInterface::r#get_performance_count_token(self)
3111    }
3112}
3113
3114impl PerformanceCounterAccessProxyInterface for PerformanceCounterAccessProxy {
3115    type GetPerformanceCountTokenResponseFut =
3116        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
3117    fn r#get_performance_count_token(&self) -> Self::GetPerformanceCountTokenResponseFut {
3118        fn _decode(
3119            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3120        ) -> Result<fidl::Event, fidl::Error> {
3121            let _response = fidl::client::decode_transaction_body::<
3122                PerformanceCounterAccessGetPerformanceCountTokenResponse,
3123                fidl::encoding::DefaultFuchsiaResourceDialect,
3124                0x48410470c5f00f92,
3125            >(_buf?)?;
3126            Ok(_response.access_token)
3127        }
3128        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
3129            (),
3130            0x48410470c5f00f92,
3131            fidl::encoding::DynamicFlags::empty(),
3132            _decode,
3133        )
3134    }
3135}
3136
3137pub struct PerformanceCounterAccessEventStream {
3138    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3139}
3140
3141impl std::marker::Unpin for PerformanceCounterAccessEventStream {}
3142
3143impl futures::stream::FusedStream for PerformanceCounterAccessEventStream {
3144    fn is_terminated(&self) -> bool {
3145        self.event_receiver.is_terminated()
3146    }
3147}
3148
3149impl futures::Stream for PerformanceCounterAccessEventStream {
3150    type Item = Result<PerformanceCounterAccessEvent, fidl::Error>;
3151
3152    fn poll_next(
3153        mut self: std::pin::Pin<&mut Self>,
3154        cx: &mut std::task::Context<'_>,
3155    ) -> std::task::Poll<Option<Self::Item>> {
3156        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3157            &mut self.event_receiver,
3158            cx
3159        )?) {
3160            Some(buf) => std::task::Poll::Ready(Some(PerformanceCounterAccessEvent::decode(buf))),
3161            None => std::task::Poll::Ready(None),
3162        }
3163    }
3164}
3165
3166#[derive(Debug)]
3167pub enum PerformanceCounterAccessEvent {}
3168
3169impl PerformanceCounterAccessEvent {
3170    /// Decodes a message buffer as a [`PerformanceCounterAccessEvent`].
3171    fn decode(
3172        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3173    ) -> Result<PerformanceCounterAccessEvent, fidl::Error> {
3174        let (bytes, _handles) = buf.split_mut();
3175        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3176        debug_assert_eq!(tx_header.tx_id, 0);
3177        match tx_header.ordinal {
3178            _ => Err(fidl::Error::UnknownOrdinal {
3179                ordinal: tx_header.ordinal,
3180                protocol_name:
3181                    <PerformanceCounterAccessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3182            }),
3183        }
3184    }
3185}
3186
3187/// A Stream of incoming requests for fuchsia.gpu.magma/PerformanceCounterAccess.
3188pub struct PerformanceCounterAccessRequestStream {
3189    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3190    is_terminated: bool,
3191}
3192
3193impl std::marker::Unpin for PerformanceCounterAccessRequestStream {}
3194
3195impl futures::stream::FusedStream for PerformanceCounterAccessRequestStream {
3196    fn is_terminated(&self) -> bool {
3197        self.is_terminated
3198    }
3199}
3200
3201impl fidl::endpoints::RequestStream for PerformanceCounterAccessRequestStream {
3202    type Protocol = PerformanceCounterAccessMarker;
3203    type ControlHandle = PerformanceCounterAccessControlHandle;
3204
3205    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3206        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3207    }
3208
3209    fn control_handle(&self) -> Self::ControlHandle {
3210        PerformanceCounterAccessControlHandle { inner: self.inner.clone() }
3211    }
3212
3213    fn into_inner(
3214        self,
3215    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3216    {
3217        (self.inner, self.is_terminated)
3218    }
3219
3220    fn from_inner(
3221        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3222        is_terminated: bool,
3223    ) -> Self {
3224        Self { inner, is_terminated }
3225    }
3226}
3227
3228impl futures::Stream for PerformanceCounterAccessRequestStream {
3229    type Item = Result<PerformanceCounterAccessRequest, fidl::Error>;
3230
3231    fn poll_next(
3232        mut self: std::pin::Pin<&mut Self>,
3233        cx: &mut std::task::Context<'_>,
3234    ) -> std::task::Poll<Option<Self::Item>> {
3235        let this = &mut *self;
3236        if this.inner.check_shutdown(cx) {
3237            this.is_terminated = true;
3238            return std::task::Poll::Ready(None);
3239        }
3240        if this.is_terminated {
3241            panic!("polled PerformanceCounterAccessRequestStream after completion");
3242        }
3243        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3244            |bytes, handles| {
3245                match this.inner.channel().read_etc(cx, bytes, handles) {
3246                    std::task::Poll::Ready(Ok(())) => {}
3247                    std::task::Poll::Pending => return std::task::Poll::Pending,
3248                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3249                        this.is_terminated = true;
3250                        return std::task::Poll::Ready(None);
3251                    }
3252                    std::task::Poll::Ready(Err(e)) => {
3253                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3254                            e.into(),
3255                        ))))
3256                    }
3257                }
3258
3259                // A message has been received from the channel
3260                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3261
3262                std::task::Poll::Ready(Some(match header.ordinal {
3263                0x48410470c5f00f92 => {
3264                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3265                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
3266                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3267                    let control_handle = PerformanceCounterAccessControlHandle {
3268                        inner: this.inner.clone(),
3269                    };
3270                    Ok(PerformanceCounterAccessRequest::GetPerformanceCountToken {
3271                        responder: PerformanceCounterAccessGetPerformanceCountTokenResponder {
3272                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3273                            tx_id: header.tx_id,
3274                        },
3275                    })
3276                }
3277                _ => Err(fidl::Error::UnknownOrdinal {
3278                    ordinal: header.ordinal,
3279                    protocol_name: <PerformanceCounterAccessMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3280                }),
3281            }))
3282            },
3283        )
3284    }
3285}
3286
3287/// This protocol is implemented by ZX_PROTOCOL_GPU_PERFORMANCE_COUNTERS devices.
3288#[derive(Debug)]
3289pub enum PerformanceCounterAccessRequest {
3290    /// This access token is not used as an event, but is instead passed to
3291    /// Primary.EnablePerformanceCounterAccess.
3292    GetPerformanceCountToken {
3293        responder: PerformanceCounterAccessGetPerformanceCountTokenResponder,
3294    },
3295}
3296
3297impl PerformanceCounterAccessRequest {
3298    #[allow(irrefutable_let_patterns)]
3299    pub fn into_get_performance_count_token(
3300        self,
3301    ) -> Option<(PerformanceCounterAccessGetPerformanceCountTokenResponder)> {
3302        if let PerformanceCounterAccessRequest::GetPerformanceCountToken { responder } = self {
3303            Some((responder))
3304        } else {
3305            None
3306        }
3307    }
3308
3309    /// Name of the method defined in FIDL
3310    pub fn method_name(&self) -> &'static str {
3311        match *self {
3312            PerformanceCounterAccessRequest::GetPerformanceCountToken { .. } => {
3313                "get_performance_count_token"
3314            }
3315        }
3316    }
3317}
3318
3319#[derive(Debug, Clone)]
3320pub struct PerformanceCounterAccessControlHandle {
3321    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3322}
3323
3324impl fidl::endpoints::ControlHandle for PerformanceCounterAccessControlHandle {
3325    fn shutdown(&self) {
3326        self.inner.shutdown()
3327    }
3328    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3329        self.inner.shutdown_with_epitaph(status)
3330    }
3331
3332    fn is_closed(&self) -> bool {
3333        self.inner.channel().is_closed()
3334    }
3335    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3336        self.inner.channel().on_closed()
3337    }
3338
3339    #[cfg(target_os = "fuchsia")]
3340    fn signal_peer(
3341        &self,
3342        clear_mask: zx::Signals,
3343        set_mask: zx::Signals,
3344    ) -> Result<(), zx_status::Status> {
3345        use fidl::Peered;
3346        self.inner.channel().signal_peer(clear_mask, set_mask)
3347    }
3348}
3349
3350impl PerformanceCounterAccessControlHandle {}
3351
3352#[must_use = "FIDL methods require a response to be sent"]
3353#[derive(Debug)]
3354pub struct PerformanceCounterAccessGetPerformanceCountTokenResponder {
3355    control_handle: std::mem::ManuallyDrop<PerformanceCounterAccessControlHandle>,
3356    tx_id: u32,
3357}
3358
3359/// Set the the channel to be shutdown (see [`PerformanceCounterAccessControlHandle::shutdown`])
3360/// if the responder is dropped without sending a response, so that the client
3361/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3362impl std::ops::Drop for PerformanceCounterAccessGetPerformanceCountTokenResponder {
3363    fn drop(&mut self) {
3364        self.control_handle.shutdown();
3365        // Safety: drops once, never accessed again
3366        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3367    }
3368}
3369
3370impl fidl::endpoints::Responder for PerformanceCounterAccessGetPerformanceCountTokenResponder {
3371    type ControlHandle = PerformanceCounterAccessControlHandle;
3372
3373    fn control_handle(&self) -> &PerformanceCounterAccessControlHandle {
3374        &self.control_handle
3375    }
3376
3377    fn drop_without_shutdown(mut self) {
3378        // Safety: drops once, never accessed again due to mem::forget
3379        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3380        // Prevent Drop from running (which would shut down the channel)
3381        std::mem::forget(self);
3382    }
3383}
3384
3385impl PerformanceCounterAccessGetPerformanceCountTokenResponder {
3386    /// Sends a response to the FIDL transaction.
3387    ///
3388    /// Sets the channel to shutdown if an error occurs.
3389    pub fn send(self, mut access_token: fidl::Event) -> Result<(), fidl::Error> {
3390        let _result = self.send_raw(access_token);
3391        if _result.is_err() {
3392            self.control_handle.shutdown();
3393        }
3394        self.drop_without_shutdown();
3395        _result
3396    }
3397
3398    /// Similar to "send" but does not shutdown the channel if an error occurs.
3399    pub fn send_no_shutdown_on_err(self, mut access_token: fidl::Event) -> Result<(), fidl::Error> {
3400        let _result = self.send_raw(access_token);
3401        self.drop_without_shutdown();
3402        _result
3403    }
3404
3405    fn send_raw(&self, mut access_token: fidl::Event) -> Result<(), fidl::Error> {
3406        self.control_handle.inner.send::<PerformanceCounterAccessGetPerformanceCountTokenResponse>(
3407            (access_token,),
3408            self.tx_id,
3409            0x48410470c5f00f92,
3410            fidl::encoding::DynamicFlags::empty(),
3411        )
3412    }
3413}
3414
3415#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3416pub struct PerformanceCounterEventsMarker;
3417
3418impl fidl::endpoints::ProtocolMarker for PerformanceCounterEventsMarker {
3419    type Proxy = PerformanceCounterEventsProxy;
3420    type RequestStream = PerformanceCounterEventsRequestStream;
3421    #[cfg(target_os = "fuchsia")]
3422    type SynchronousProxy = PerformanceCounterEventsSynchronousProxy;
3423
3424    const DEBUG_NAME: &'static str = "(anonymous) PerformanceCounterEvents";
3425}
3426
3427pub trait PerformanceCounterEventsProxyInterface: Send + Sync {}
3428#[derive(Debug)]
3429#[cfg(target_os = "fuchsia")]
3430pub struct PerformanceCounterEventsSynchronousProxy {
3431    client: fidl::client::sync::Client,
3432}
3433
3434#[cfg(target_os = "fuchsia")]
3435impl fidl::endpoints::SynchronousProxy for PerformanceCounterEventsSynchronousProxy {
3436    type Proxy = PerformanceCounterEventsProxy;
3437    type Protocol = PerformanceCounterEventsMarker;
3438
3439    fn from_channel(inner: fidl::Channel) -> Self {
3440        Self::new(inner)
3441    }
3442
3443    fn into_channel(self) -> fidl::Channel {
3444        self.client.into_channel()
3445    }
3446
3447    fn as_channel(&self) -> &fidl::Channel {
3448        self.client.as_channel()
3449    }
3450}
3451
3452#[cfg(target_os = "fuchsia")]
3453impl PerformanceCounterEventsSynchronousProxy {
3454    pub fn new(channel: fidl::Channel) -> Self {
3455        let protocol_name =
3456            <PerformanceCounterEventsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3457        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3458    }
3459
3460    pub fn into_channel(self) -> fidl::Channel {
3461        self.client.into_channel()
3462    }
3463
3464    /// Waits until an event arrives and returns it. It is safe for other
3465    /// threads to make concurrent requests while waiting for an event.
3466    pub fn wait_for_event(
3467        &self,
3468        deadline: zx::MonotonicInstant,
3469    ) -> Result<PerformanceCounterEventsEvent, fidl::Error> {
3470        PerformanceCounterEventsEvent::decode(self.client.wait_for_event(deadline)?)
3471    }
3472}
3473
3474#[cfg(target_os = "fuchsia")]
3475impl From<PerformanceCounterEventsSynchronousProxy> for zx::Handle {
3476    fn from(value: PerformanceCounterEventsSynchronousProxy) -> Self {
3477        value.into_channel().into()
3478    }
3479}
3480
3481#[cfg(target_os = "fuchsia")]
3482impl From<fidl::Channel> for PerformanceCounterEventsSynchronousProxy {
3483    fn from(value: fidl::Channel) -> Self {
3484        Self::new(value)
3485    }
3486}
3487
3488#[derive(Debug, Clone)]
3489pub struct PerformanceCounterEventsProxy {
3490    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3491}
3492
3493impl fidl::endpoints::Proxy for PerformanceCounterEventsProxy {
3494    type Protocol = PerformanceCounterEventsMarker;
3495
3496    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3497        Self::new(inner)
3498    }
3499
3500    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3501        self.client.into_channel().map_err(|client| Self { client })
3502    }
3503
3504    fn as_channel(&self) -> &::fidl::AsyncChannel {
3505        self.client.as_channel()
3506    }
3507}
3508
3509impl PerformanceCounterEventsProxy {
3510    /// Create a new Proxy for fuchsia.gpu.magma/PerformanceCounterEvents.
3511    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3512        let protocol_name =
3513            <PerformanceCounterEventsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3514        Self { client: fidl::client::Client::new(channel, protocol_name) }
3515    }
3516
3517    /// Get a Stream of events from the remote end of the protocol.
3518    ///
3519    /// # Panics
3520    ///
3521    /// Panics if the event stream was already taken.
3522    pub fn take_event_stream(&self) -> PerformanceCounterEventsEventStream {
3523        PerformanceCounterEventsEventStream { event_receiver: self.client.take_event_receiver() }
3524    }
3525}
3526
3527impl PerformanceCounterEventsProxyInterface for PerformanceCounterEventsProxy {}
3528
3529pub struct PerformanceCounterEventsEventStream {
3530    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3531}
3532
3533impl std::marker::Unpin for PerformanceCounterEventsEventStream {}
3534
3535impl futures::stream::FusedStream for PerformanceCounterEventsEventStream {
3536    fn is_terminated(&self) -> bool {
3537        self.event_receiver.is_terminated()
3538    }
3539}
3540
3541impl futures::Stream for PerformanceCounterEventsEventStream {
3542    type Item = Result<PerformanceCounterEventsEvent, fidl::Error>;
3543
3544    fn poll_next(
3545        mut self: std::pin::Pin<&mut Self>,
3546        cx: &mut std::task::Context<'_>,
3547    ) -> std::task::Poll<Option<Self::Item>> {
3548        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3549            &mut self.event_receiver,
3550            cx
3551        )?) {
3552            Some(buf) => std::task::Poll::Ready(Some(PerformanceCounterEventsEvent::decode(buf))),
3553            None => std::task::Poll::Ready(None),
3554        }
3555    }
3556}
3557
3558#[derive(Debug)]
3559pub enum PerformanceCounterEventsEvent {
3560    OnPerformanceCounterReadCompleted {
3561        payload: PerformanceCounterEventsOnPerformanceCounterReadCompletedRequest,
3562    },
3563}
3564
3565impl PerformanceCounterEventsEvent {
3566    #[allow(irrefutable_let_patterns)]
3567    pub fn into_on_performance_counter_read_completed(
3568        self,
3569    ) -> Option<PerformanceCounterEventsOnPerformanceCounterReadCompletedRequest> {
3570        if let PerformanceCounterEventsEvent::OnPerformanceCounterReadCompleted { payload } = self {
3571            Some((payload))
3572        } else {
3573            None
3574        }
3575    }
3576
3577    /// Decodes a message buffer as a [`PerformanceCounterEventsEvent`].
3578    fn decode(
3579        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3580    ) -> Result<PerformanceCounterEventsEvent, fidl::Error> {
3581        let (bytes, _handles) = buf.split_mut();
3582        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3583        debug_assert_eq!(tx_header.tx_id, 0);
3584        match tx_header.ordinal {
3585            0x3f134926720d44d7 => {
3586                let mut out = fidl::new_empty!(
3587                    PerformanceCounterEventsOnPerformanceCounterReadCompletedRequest,
3588                    fidl::encoding::DefaultFuchsiaResourceDialect
3589                );
3590                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PerformanceCounterEventsOnPerformanceCounterReadCompletedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3591                Ok((PerformanceCounterEventsEvent::OnPerformanceCounterReadCompleted {
3592                    payload: out,
3593                }))
3594            }
3595            _ => Err(fidl::Error::UnknownOrdinal {
3596                ordinal: tx_header.ordinal,
3597                protocol_name:
3598                    <PerformanceCounterEventsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3599            }),
3600        }
3601    }
3602}
3603
3604/// A Stream of incoming requests for fuchsia.gpu.magma/PerformanceCounterEvents.
3605pub struct PerformanceCounterEventsRequestStream {
3606    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3607    is_terminated: bool,
3608}
3609
3610impl std::marker::Unpin for PerformanceCounterEventsRequestStream {}
3611
3612impl futures::stream::FusedStream for PerformanceCounterEventsRequestStream {
3613    fn is_terminated(&self) -> bool {
3614        self.is_terminated
3615    }
3616}
3617
3618impl fidl::endpoints::RequestStream for PerformanceCounterEventsRequestStream {
3619    type Protocol = PerformanceCounterEventsMarker;
3620    type ControlHandle = PerformanceCounterEventsControlHandle;
3621
3622    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3623        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3624    }
3625
3626    fn control_handle(&self) -> Self::ControlHandle {
3627        PerformanceCounterEventsControlHandle { inner: self.inner.clone() }
3628    }
3629
3630    fn into_inner(
3631        self,
3632    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3633    {
3634        (self.inner, self.is_terminated)
3635    }
3636
3637    fn from_inner(
3638        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3639        is_terminated: bool,
3640    ) -> Self {
3641        Self { inner, is_terminated }
3642    }
3643}
3644
3645impl futures::Stream for PerformanceCounterEventsRequestStream {
3646    type Item = Result<PerformanceCounterEventsRequest, fidl::Error>;
3647
3648    fn poll_next(
3649        mut self: std::pin::Pin<&mut Self>,
3650        cx: &mut std::task::Context<'_>,
3651    ) -> std::task::Poll<Option<Self::Item>> {
3652        let this = &mut *self;
3653        if this.inner.check_shutdown(cx) {
3654            this.is_terminated = true;
3655            return std::task::Poll::Ready(None);
3656        }
3657        if this.is_terminated {
3658            panic!("polled PerformanceCounterEventsRequestStream after completion");
3659        }
3660        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3661            |bytes, handles| {
3662                match this.inner.channel().read_etc(cx, bytes, handles) {
3663                    std::task::Poll::Ready(Ok(())) => {}
3664                    std::task::Poll::Pending => return std::task::Poll::Pending,
3665                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3666                        this.is_terminated = true;
3667                        return std::task::Poll::Ready(None);
3668                    }
3669                    std::task::Poll::Ready(Err(e)) => {
3670                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3671                            e.into(),
3672                        ))))
3673                    }
3674                }
3675
3676                // A message has been received from the channel
3677                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3678
3679                std::task::Poll::Ready(Some(match header.ordinal {
3680                _ => Err(fidl::Error::UnknownOrdinal {
3681                    ordinal: header.ordinal,
3682                    protocol_name: <PerformanceCounterEventsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3683                }),
3684            }))
3685            },
3686        )
3687    }
3688}
3689
3690#[derive(Debug)]
3691pub enum PerformanceCounterEventsRequest {}
3692
3693impl PerformanceCounterEventsRequest {
3694    /// Name of the method defined in FIDL
3695    pub fn method_name(&self) -> &'static str {
3696        match *self {}
3697    }
3698}
3699
3700#[derive(Debug, Clone)]
3701pub struct PerformanceCounterEventsControlHandle {
3702    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3703}
3704
3705impl fidl::endpoints::ControlHandle for PerformanceCounterEventsControlHandle {
3706    fn shutdown(&self) {
3707        self.inner.shutdown()
3708    }
3709    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3710        self.inner.shutdown_with_epitaph(status)
3711    }
3712
3713    fn is_closed(&self) -> bool {
3714        self.inner.channel().is_closed()
3715    }
3716    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3717        self.inner.channel().on_closed()
3718    }
3719
3720    #[cfg(target_os = "fuchsia")]
3721    fn signal_peer(
3722        &self,
3723        clear_mask: zx::Signals,
3724        set_mask: zx::Signals,
3725    ) -> Result<(), zx_status::Status> {
3726        use fidl::Peered;
3727        self.inner.channel().signal_peer(clear_mask, set_mask)
3728    }
3729}
3730
3731impl PerformanceCounterEventsControlHandle {
3732    pub fn send_on_performance_counter_read_completed(
3733        &self,
3734        mut payload: &PerformanceCounterEventsOnPerformanceCounterReadCompletedRequest,
3735    ) -> Result<(), fidl::Error> {
3736        self.inner.send::<PerformanceCounterEventsOnPerformanceCounterReadCompletedRequest>(
3737            payload,
3738            0,
3739            0x3f134926720d44d7,
3740            fidl::encoding::DynamicFlags::empty(),
3741        )
3742    }
3743}
3744
3745#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3746pub struct PowerElementProviderMarker;
3747
3748impl fidl::endpoints::ProtocolMarker for PowerElementProviderMarker {
3749    type Proxy = PowerElementProviderProxy;
3750    type RequestStream = PowerElementProviderRequestStream;
3751    #[cfg(target_os = "fuchsia")]
3752    type SynchronousProxy = PowerElementProviderSynchronousProxy;
3753
3754    const DEBUG_NAME: &'static str = "(anonymous) PowerElementProvider";
3755}
3756pub type PowerElementProviderGetClockSpeedLevelResult =
3757    Result<PowerElementProviderGetClockSpeedLevelResponse, i32>;
3758pub type PowerElementProviderSetClockLimitResult =
3759    Result<PowerElementProviderSetClockLimitResponse, i32>;
3760
3761pub trait PowerElementProviderProxyInterface: Send + Sync {
3762    type GetPowerGoalsResponseFut: std::future::Future<Output = Result<Vec<PowerGoal>, fidl::Error>>
3763        + Send;
3764    fn r#get_power_goals(&self) -> Self::GetPowerGoalsResponseFut;
3765    type GetClockSpeedLevelResponseFut: std::future::Future<
3766            Output = Result<PowerElementProviderGetClockSpeedLevelResult, fidl::Error>,
3767        > + Send;
3768    fn r#get_clock_speed_level(
3769        &self,
3770        payload: &PowerElementProviderGetClockSpeedLevelRequest,
3771    ) -> Self::GetClockSpeedLevelResponseFut;
3772    type SetClockLimitResponseFut: std::future::Future<Output = Result<PowerElementProviderSetClockLimitResult, fidl::Error>>
3773        + Send;
3774    fn r#set_clock_limit(
3775        &self,
3776        payload: &PowerElementProviderSetClockLimitRequest,
3777    ) -> Self::SetClockLimitResponseFut;
3778}
3779#[derive(Debug)]
3780#[cfg(target_os = "fuchsia")]
3781pub struct PowerElementProviderSynchronousProxy {
3782    client: fidl::client::sync::Client,
3783}
3784
3785#[cfg(target_os = "fuchsia")]
3786impl fidl::endpoints::SynchronousProxy for PowerElementProviderSynchronousProxy {
3787    type Proxy = PowerElementProviderProxy;
3788    type Protocol = PowerElementProviderMarker;
3789
3790    fn from_channel(inner: fidl::Channel) -> Self {
3791        Self::new(inner)
3792    }
3793
3794    fn into_channel(self) -> fidl::Channel {
3795        self.client.into_channel()
3796    }
3797
3798    fn as_channel(&self) -> &fidl::Channel {
3799        self.client.as_channel()
3800    }
3801}
3802
3803#[cfg(target_os = "fuchsia")]
3804impl PowerElementProviderSynchronousProxy {
3805    pub fn new(channel: fidl::Channel) -> Self {
3806        let protocol_name =
3807            <PowerElementProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3808        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3809    }
3810
3811    pub fn into_channel(self) -> fidl::Channel {
3812        self.client.into_channel()
3813    }
3814
3815    /// Waits until an event arrives and returns it. It is safe for other
3816    /// threads to make concurrent requests while waiting for an event.
3817    pub fn wait_for_event(
3818        &self,
3819        deadline: zx::MonotonicInstant,
3820    ) -> Result<PowerElementProviderEvent, fidl::Error> {
3821        PowerElementProviderEvent::decode(self.client.wait_for_event(deadline)?)
3822    }
3823
3824    /// Retrieve a list of power goals that the hardware can attempt to achieve.
3825    pub fn r#get_power_goals(
3826        &self,
3827        ___deadline: zx::MonotonicInstant,
3828    ) -> Result<Vec<PowerGoal>, fidl::Error> {
3829        let _response = self.client.send_query::<
3830            fidl::encoding::EmptyPayload,
3831            fidl::encoding::FlexibleType<PowerElementProviderGetPowerGoalsResponse>,
3832        >(
3833            (),
3834            0x2ff49ddffb0e07c0,
3835            fidl::encoding::DynamicFlags::FLEXIBLE,
3836            ___deadline,
3837        )?
3838        .into_result::<PowerElementProviderMarker>("get_power_goals")?;
3839        Ok(_response.goals)
3840    }
3841
3842    /// Get a power level that represents the GPU clock being set to at least a target frequency.
3843    /// The power level may allow the GPU to idle or turn off, as long as the clock frequency
3844    /// remains the same.
3845    pub fn r#get_clock_speed_level(
3846        &self,
3847        mut payload: &PowerElementProviderGetClockSpeedLevelRequest,
3848        ___deadline: zx::MonotonicInstant,
3849    ) -> Result<PowerElementProviderGetClockSpeedLevelResult, fidl::Error> {
3850        let _response = self.client.send_query::<
3851            PowerElementProviderGetClockSpeedLevelRequest,
3852            fidl::encoding::FlexibleResultType<PowerElementProviderGetClockSpeedLevelResponse, i32>,
3853        >(
3854            payload,
3855            0x5315a9bc44a9c53c,
3856            fidl::encoding::DynamicFlags::FLEXIBLE,
3857            ___deadline,
3858        )?
3859        .into_result::<PowerElementProviderMarker>("get_clock_speed_level")?;
3860        Ok(_response.map(|x| x))
3861    }
3862
3863    /// Limit the clock to at most a specific frequency.
3864    pub fn r#set_clock_limit(
3865        &self,
3866        mut payload: &PowerElementProviderSetClockLimitRequest,
3867        ___deadline: zx::MonotonicInstant,
3868    ) -> Result<PowerElementProviderSetClockLimitResult, fidl::Error> {
3869        let _response = self.client.send_query::<
3870            PowerElementProviderSetClockLimitRequest,
3871            fidl::encoding::FlexibleResultType<PowerElementProviderSetClockLimitResponse, i32>,
3872        >(
3873            payload,
3874            0x614bf25c3a1571b4,
3875            fidl::encoding::DynamicFlags::FLEXIBLE,
3876            ___deadline,
3877        )?
3878        .into_result::<PowerElementProviderMarker>("set_clock_limit")?;
3879        Ok(_response.map(|x| x))
3880    }
3881}
3882
3883#[cfg(target_os = "fuchsia")]
3884impl From<PowerElementProviderSynchronousProxy> for zx::Handle {
3885    fn from(value: PowerElementProviderSynchronousProxy) -> Self {
3886        value.into_channel().into()
3887    }
3888}
3889
3890#[cfg(target_os = "fuchsia")]
3891impl From<fidl::Channel> for PowerElementProviderSynchronousProxy {
3892    fn from(value: fidl::Channel) -> Self {
3893        Self::new(value)
3894    }
3895}
3896
3897#[derive(Debug, Clone)]
3898pub struct PowerElementProviderProxy {
3899    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3900}
3901
3902impl fidl::endpoints::Proxy for PowerElementProviderProxy {
3903    type Protocol = PowerElementProviderMarker;
3904
3905    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3906        Self::new(inner)
3907    }
3908
3909    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3910        self.client.into_channel().map_err(|client| Self { client })
3911    }
3912
3913    fn as_channel(&self) -> &::fidl::AsyncChannel {
3914        self.client.as_channel()
3915    }
3916}
3917
3918impl PowerElementProviderProxy {
3919    /// Create a new Proxy for fuchsia.gpu.magma/PowerElementProvider.
3920    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3921        let protocol_name =
3922            <PowerElementProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3923        Self { client: fidl::client::Client::new(channel, protocol_name) }
3924    }
3925
3926    /// Get a Stream of events from the remote end of the protocol.
3927    ///
3928    /// # Panics
3929    ///
3930    /// Panics if the event stream was already taken.
3931    pub fn take_event_stream(&self) -> PowerElementProviderEventStream {
3932        PowerElementProviderEventStream { event_receiver: self.client.take_event_receiver() }
3933    }
3934
3935    /// Retrieve a list of power goals that the hardware can attempt to achieve.
3936    pub fn r#get_power_goals(
3937        &self,
3938    ) -> fidl::client::QueryResponseFut<Vec<PowerGoal>, fidl::encoding::DefaultFuchsiaResourceDialect>
3939    {
3940        PowerElementProviderProxyInterface::r#get_power_goals(self)
3941    }
3942
3943    /// Get a power level that represents the GPU clock being set to at least a target frequency.
3944    /// The power level may allow the GPU to idle or turn off, as long as the clock frequency
3945    /// remains the same.
3946    pub fn r#get_clock_speed_level(
3947        &self,
3948        mut payload: &PowerElementProviderGetClockSpeedLevelRequest,
3949    ) -> fidl::client::QueryResponseFut<
3950        PowerElementProviderGetClockSpeedLevelResult,
3951        fidl::encoding::DefaultFuchsiaResourceDialect,
3952    > {
3953        PowerElementProviderProxyInterface::r#get_clock_speed_level(self, payload)
3954    }
3955
3956    /// Limit the clock to at most a specific frequency.
3957    pub fn r#set_clock_limit(
3958        &self,
3959        mut payload: &PowerElementProviderSetClockLimitRequest,
3960    ) -> fidl::client::QueryResponseFut<
3961        PowerElementProviderSetClockLimitResult,
3962        fidl::encoding::DefaultFuchsiaResourceDialect,
3963    > {
3964        PowerElementProviderProxyInterface::r#set_clock_limit(self, payload)
3965    }
3966}
3967
3968impl PowerElementProviderProxyInterface for PowerElementProviderProxy {
3969    type GetPowerGoalsResponseFut = fidl::client::QueryResponseFut<
3970        Vec<PowerGoal>,
3971        fidl::encoding::DefaultFuchsiaResourceDialect,
3972    >;
3973    fn r#get_power_goals(&self) -> Self::GetPowerGoalsResponseFut {
3974        fn _decode(
3975            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3976        ) -> Result<Vec<PowerGoal>, fidl::Error> {
3977            let _response = fidl::client::decode_transaction_body::<
3978                fidl::encoding::FlexibleType<PowerElementProviderGetPowerGoalsResponse>,
3979                fidl::encoding::DefaultFuchsiaResourceDialect,
3980                0x2ff49ddffb0e07c0,
3981            >(_buf?)?
3982            .into_result::<PowerElementProviderMarker>("get_power_goals")?;
3983            Ok(_response.goals)
3984        }
3985        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<PowerGoal>>(
3986            (),
3987            0x2ff49ddffb0e07c0,
3988            fidl::encoding::DynamicFlags::FLEXIBLE,
3989            _decode,
3990        )
3991    }
3992
3993    type GetClockSpeedLevelResponseFut = fidl::client::QueryResponseFut<
3994        PowerElementProviderGetClockSpeedLevelResult,
3995        fidl::encoding::DefaultFuchsiaResourceDialect,
3996    >;
3997    fn r#get_clock_speed_level(
3998        &self,
3999        mut payload: &PowerElementProviderGetClockSpeedLevelRequest,
4000    ) -> Self::GetClockSpeedLevelResponseFut {
4001        fn _decode(
4002            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4003        ) -> Result<PowerElementProviderGetClockSpeedLevelResult, fidl::Error> {
4004            let _response = fidl::client::decode_transaction_body::<
4005                fidl::encoding::FlexibleResultType<
4006                    PowerElementProviderGetClockSpeedLevelResponse,
4007                    i32,
4008                >,
4009                fidl::encoding::DefaultFuchsiaResourceDialect,
4010                0x5315a9bc44a9c53c,
4011            >(_buf?)?
4012            .into_result::<PowerElementProviderMarker>("get_clock_speed_level")?;
4013            Ok(_response.map(|x| x))
4014        }
4015        self.client.send_query_and_decode::<
4016            PowerElementProviderGetClockSpeedLevelRequest,
4017            PowerElementProviderGetClockSpeedLevelResult,
4018        >(
4019            payload,
4020            0x5315a9bc44a9c53c,
4021            fidl::encoding::DynamicFlags::FLEXIBLE,
4022            _decode,
4023        )
4024    }
4025
4026    type SetClockLimitResponseFut = fidl::client::QueryResponseFut<
4027        PowerElementProviderSetClockLimitResult,
4028        fidl::encoding::DefaultFuchsiaResourceDialect,
4029    >;
4030    fn r#set_clock_limit(
4031        &self,
4032        mut payload: &PowerElementProviderSetClockLimitRequest,
4033    ) -> Self::SetClockLimitResponseFut {
4034        fn _decode(
4035            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4036        ) -> Result<PowerElementProviderSetClockLimitResult, fidl::Error> {
4037            let _response = fidl::client::decode_transaction_body::<
4038                fidl::encoding::FlexibleResultType<PowerElementProviderSetClockLimitResponse, i32>,
4039                fidl::encoding::DefaultFuchsiaResourceDialect,
4040                0x614bf25c3a1571b4,
4041            >(_buf?)?
4042            .into_result::<PowerElementProviderMarker>("set_clock_limit")?;
4043            Ok(_response.map(|x| x))
4044        }
4045        self.client.send_query_and_decode::<
4046            PowerElementProviderSetClockLimitRequest,
4047            PowerElementProviderSetClockLimitResult,
4048        >(
4049            payload,
4050            0x614bf25c3a1571b4,
4051            fidl::encoding::DynamicFlags::FLEXIBLE,
4052            _decode,
4053        )
4054    }
4055}
4056
4057pub struct PowerElementProviderEventStream {
4058    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4059}
4060
4061impl std::marker::Unpin for PowerElementProviderEventStream {}
4062
4063impl futures::stream::FusedStream for PowerElementProviderEventStream {
4064    fn is_terminated(&self) -> bool {
4065        self.event_receiver.is_terminated()
4066    }
4067}
4068
4069impl futures::Stream for PowerElementProviderEventStream {
4070    type Item = Result<PowerElementProviderEvent, fidl::Error>;
4071
4072    fn poll_next(
4073        mut self: std::pin::Pin<&mut Self>,
4074        cx: &mut std::task::Context<'_>,
4075    ) -> std::task::Poll<Option<Self::Item>> {
4076        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4077            &mut self.event_receiver,
4078            cx
4079        )?) {
4080            Some(buf) => std::task::Poll::Ready(Some(PowerElementProviderEvent::decode(buf))),
4081            None => std::task::Poll::Ready(None),
4082        }
4083    }
4084}
4085
4086#[derive(Debug)]
4087pub enum PowerElementProviderEvent {
4088    #[non_exhaustive]
4089    _UnknownEvent {
4090        /// Ordinal of the event that was sent.
4091        ordinal: u64,
4092    },
4093}
4094
4095impl PowerElementProviderEvent {
4096    /// Decodes a message buffer as a [`PowerElementProviderEvent`].
4097    fn decode(
4098        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4099    ) -> Result<PowerElementProviderEvent, fidl::Error> {
4100        let (bytes, _handles) = buf.split_mut();
4101        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4102        debug_assert_eq!(tx_header.tx_id, 0);
4103        match tx_header.ordinal {
4104            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4105                Ok(PowerElementProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4106            }
4107            _ => Err(fidl::Error::UnknownOrdinal {
4108                ordinal: tx_header.ordinal,
4109                protocol_name:
4110                    <PowerElementProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4111            }),
4112        }
4113    }
4114}
4115
4116/// A Stream of incoming requests for fuchsia.gpu.magma/PowerElementProvider.
4117pub struct PowerElementProviderRequestStream {
4118    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4119    is_terminated: bool,
4120}
4121
4122impl std::marker::Unpin for PowerElementProviderRequestStream {}
4123
4124impl futures::stream::FusedStream for PowerElementProviderRequestStream {
4125    fn is_terminated(&self) -> bool {
4126        self.is_terminated
4127    }
4128}
4129
4130impl fidl::endpoints::RequestStream for PowerElementProviderRequestStream {
4131    type Protocol = PowerElementProviderMarker;
4132    type ControlHandle = PowerElementProviderControlHandle;
4133
4134    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4135        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4136    }
4137
4138    fn control_handle(&self) -> Self::ControlHandle {
4139        PowerElementProviderControlHandle { inner: self.inner.clone() }
4140    }
4141
4142    fn into_inner(
4143        self,
4144    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4145    {
4146        (self.inner, self.is_terminated)
4147    }
4148
4149    fn from_inner(
4150        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4151        is_terminated: bool,
4152    ) -> Self {
4153        Self { inner, is_terminated }
4154    }
4155}
4156
4157impl futures::Stream for PowerElementProviderRequestStream {
4158    type Item = Result<PowerElementProviderRequest, fidl::Error>;
4159
4160    fn poll_next(
4161        mut self: std::pin::Pin<&mut Self>,
4162        cx: &mut std::task::Context<'_>,
4163    ) -> std::task::Poll<Option<Self::Item>> {
4164        let this = &mut *self;
4165        if this.inner.check_shutdown(cx) {
4166            this.is_terminated = true;
4167            return std::task::Poll::Ready(None);
4168        }
4169        if this.is_terminated {
4170            panic!("polled PowerElementProviderRequestStream after completion");
4171        }
4172        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4173            |bytes, handles| {
4174                match this.inner.channel().read_etc(cx, bytes, handles) {
4175                    std::task::Poll::Ready(Ok(())) => {}
4176                    std::task::Poll::Pending => return std::task::Poll::Pending,
4177                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4178                        this.is_terminated = true;
4179                        return std::task::Poll::Ready(None);
4180                    }
4181                    std::task::Poll::Ready(Err(e)) => {
4182                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4183                            e.into(),
4184                        ))))
4185                    }
4186                }
4187
4188                // A message has been received from the channel
4189                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4190
4191                std::task::Poll::Ready(Some(match header.ordinal {
4192                0x2ff49ddffb0e07c0 => {
4193                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4194                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
4195                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4196                    let control_handle = PowerElementProviderControlHandle {
4197                        inner: this.inner.clone(),
4198                    };
4199                    Ok(PowerElementProviderRequest::GetPowerGoals {
4200                        responder: PowerElementProviderGetPowerGoalsResponder {
4201                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4202                            tx_id: header.tx_id,
4203                        },
4204                    })
4205                }
4206                0x5315a9bc44a9c53c => {
4207                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4208                    let mut req = fidl::new_empty!(PowerElementProviderGetClockSpeedLevelRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4209                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PowerElementProviderGetClockSpeedLevelRequest>(&header, _body_bytes, handles, &mut req)?;
4210                    let control_handle = PowerElementProviderControlHandle {
4211                        inner: this.inner.clone(),
4212                    };
4213                    Ok(PowerElementProviderRequest::GetClockSpeedLevel {payload: req,
4214                        responder: PowerElementProviderGetClockSpeedLevelResponder {
4215                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4216                            tx_id: header.tx_id,
4217                        },
4218                    })
4219                }
4220                0x614bf25c3a1571b4 => {
4221                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4222                    let mut req = fidl::new_empty!(PowerElementProviderSetClockLimitRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
4223                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PowerElementProviderSetClockLimitRequest>(&header, _body_bytes, handles, &mut req)?;
4224                    let control_handle = PowerElementProviderControlHandle {
4225                        inner: this.inner.clone(),
4226                    };
4227                    Ok(PowerElementProviderRequest::SetClockLimit {payload: req,
4228                        responder: PowerElementProviderSetClockLimitResponder {
4229                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4230                            tx_id: header.tx_id,
4231                        },
4232                    })
4233                }
4234                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4235                    Ok(PowerElementProviderRequest::_UnknownMethod {
4236                        ordinal: header.ordinal,
4237                        control_handle: PowerElementProviderControlHandle { inner: this.inner.clone() },
4238                        method_type: fidl::MethodType::OneWay,
4239                    })
4240                }
4241                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4242                    this.inner.send_framework_err(
4243                        fidl::encoding::FrameworkErr::UnknownMethod,
4244                        header.tx_id,
4245                        header.ordinal,
4246                        header.dynamic_flags(),
4247                        (bytes, handles),
4248                    )?;
4249                    Ok(PowerElementProviderRequest::_UnknownMethod {
4250                        ordinal: header.ordinal,
4251                        control_handle: PowerElementProviderControlHandle { inner: this.inner.clone() },
4252                        method_type: fidl::MethodType::TwoWay,
4253                    })
4254                }
4255                _ => Err(fidl::Error::UnknownOrdinal {
4256                    ordinal: header.ordinal,
4257                    protocol_name: <PowerElementProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4258                }),
4259            }))
4260            },
4261        )
4262    }
4263}
4264
4265/// This protocol is used to retrieve information on the power levels that this driver provides.
4266#[derive(Debug)]
4267pub enum PowerElementProviderRequest {
4268    /// Retrieve a list of power goals that the hardware can attempt to achieve.
4269    GetPowerGoals { responder: PowerElementProviderGetPowerGoalsResponder },
4270    /// Get a power level that represents the GPU clock being set to at least a target frequency.
4271    /// The power level may allow the GPU to idle or turn off, as long as the clock frequency
4272    /// remains the same.
4273    GetClockSpeedLevel {
4274        payload: PowerElementProviderGetClockSpeedLevelRequest,
4275        responder: PowerElementProviderGetClockSpeedLevelResponder,
4276    },
4277    /// Limit the clock to at most a specific frequency.
4278    SetClockLimit {
4279        payload: PowerElementProviderSetClockLimitRequest,
4280        responder: PowerElementProviderSetClockLimitResponder,
4281    },
4282    /// An interaction was received which does not match any known method.
4283    #[non_exhaustive]
4284    _UnknownMethod {
4285        /// Ordinal of the method that was called.
4286        ordinal: u64,
4287        control_handle: PowerElementProviderControlHandle,
4288        method_type: fidl::MethodType,
4289    },
4290}
4291
4292impl PowerElementProviderRequest {
4293    #[allow(irrefutable_let_patterns)]
4294    pub fn into_get_power_goals(self) -> Option<(PowerElementProviderGetPowerGoalsResponder)> {
4295        if let PowerElementProviderRequest::GetPowerGoals { responder } = self {
4296            Some((responder))
4297        } else {
4298            None
4299        }
4300    }
4301
4302    #[allow(irrefutable_let_patterns)]
4303    pub fn into_get_clock_speed_level(
4304        self,
4305    ) -> Option<(
4306        PowerElementProviderGetClockSpeedLevelRequest,
4307        PowerElementProviderGetClockSpeedLevelResponder,
4308    )> {
4309        if let PowerElementProviderRequest::GetClockSpeedLevel { payload, responder } = self {
4310            Some((payload, responder))
4311        } else {
4312            None
4313        }
4314    }
4315
4316    #[allow(irrefutable_let_patterns)]
4317    pub fn into_set_clock_limit(
4318        self,
4319    ) -> Option<(
4320        PowerElementProviderSetClockLimitRequest,
4321        PowerElementProviderSetClockLimitResponder,
4322    )> {
4323        if let PowerElementProviderRequest::SetClockLimit { payload, responder } = self {
4324            Some((payload, responder))
4325        } else {
4326            None
4327        }
4328    }
4329
4330    /// Name of the method defined in FIDL
4331    pub fn method_name(&self) -> &'static str {
4332        match *self {
4333            PowerElementProviderRequest::GetPowerGoals { .. } => "get_power_goals",
4334            PowerElementProviderRequest::GetClockSpeedLevel { .. } => "get_clock_speed_level",
4335            PowerElementProviderRequest::SetClockLimit { .. } => "set_clock_limit",
4336            PowerElementProviderRequest::_UnknownMethod {
4337                method_type: fidl::MethodType::OneWay,
4338                ..
4339            } => "unknown one-way method",
4340            PowerElementProviderRequest::_UnknownMethod {
4341                method_type: fidl::MethodType::TwoWay,
4342                ..
4343            } => "unknown two-way method",
4344        }
4345    }
4346}
4347
4348#[derive(Debug, Clone)]
4349pub struct PowerElementProviderControlHandle {
4350    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4351}
4352
4353impl fidl::endpoints::ControlHandle for PowerElementProviderControlHandle {
4354    fn shutdown(&self) {
4355        self.inner.shutdown()
4356    }
4357    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4358        self.inner.shutdown_with_epitaph(status)
4359    }
4360
4361    fn is_closed(&self) -> bool {
4362        self.inner.channel().is_closed()
4363    }
4364    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4365        self.inner.channel().on_closed()
4366    }
4367
4368    #[cfg(target_os = "fuchsia")]
4369    fn signal_peer(
4370        &self,
4371        clear_mask: zx::Signals,
4372        set_mask: zx::Signals,
4373    ) -> Result<(), zx_status::Status> {
4374        use fidl::Peered;
4375        self.inner.channel().signal_peer(clear_mask, set_mask)
4376    }
4377}
4378
4379impl PowerElementProviderControlHandle {}
4380
4381#[must_use = "FIDL methods require a response to be sent"]
4382#[derive(Debug)]
4383pub struct PowerElementProviderGetPowerGoalsResponder {
4384    control_handle: std::mem::ManuallyDrop<PowerElementProviderControlHandle>,
4385    tx_id: u32,
4386}
4387
4388/// Set the the channel to be shutdown (see [`PowerElementProviderControlHandle::shutdown`])
4389/// if the responder is dropped without sending a response, so that the client
4390/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4391impl std::ops::Drop for PowerElementProviderGetPowerGoalsResponder {
4392    fn drop(&mut self) {
4393        self.control_handle.shutdown();
4394        // Safety: drops once, never accessed again
4395        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4396    }
4397}
4398
4399impl fidl::endpoints::Responder for PowerElementProviderGetPowerGoalsResponder {
4400    type ControlHandle = PowerElementProviderControlHandle;
4401
4402    fn control_handle(&self) -> &PowerElementProviderControlHandle {
4403        &self.control_handle
4404    }
4405
4406    fn drop_without_shutdown(mut self) {
4407        // Safety: drops once, never accessed again due to mem::forget
4408        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4409        // Prevent Drop from running (which would shut down the channel)
4410        std::mem::forget(self);
4411    }
4412}
4413
4414impl PowerElementProviderGetPowerGoalsResponder {
4415    /// Sends a response to the FIDL transaction.
4416    ///
4417    /// Sets the channel to shutdown if an error occurs.
4418    pub fn send(self, mut goals: Vec<PowerGoal>) -> Result<(), fidl::Error> {
4419        let _result = self.send_raw(goals);
4420        if _result.is_err() {
4421            self.control_handle.shutdown();
4422        }
4423        self.drop_without_shutdown();
4424        _result
4425    }
4426
4427    /// Similar to "send" but does not shutdown the channel if an error occurs.
4428    pub fn send_no_shutdown_on_err(self, mut goals: Vec<PowerGoal>) -> Result<(), fidl::Error> {
4429        let _result = self.send_raw(goals);
4430        self.drop_without_shutdown();
4431        _result
4432    }
4433
4434    fn send_raw(&self, mut goals: Vec<PowerGoal>) -> Result<(), fidl::Error> {
4435        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
4436            PowerElementProviderGetPowerGoalsResponse,
4437        >>(
4438            fidl::encoding::Flexible::new((goals.as_mut(),)),
4439            self.tx_id,
4440            0x2ff49ddffb0e07c0,
4441            fidl::encoding::DynamicFlags::FLEXIBLE,
4442        )
4443    }
4444}
4445
4446#[must_use = "FIDL methods require a response to be sent"]
4447#[derive(Debug)]
4448pub struct PowerElementProviderGetClockSpeedLevelResponder {
4449    control_handle: std::mem::ManuallyDrop<PowerElementProviderControlHandle>,
4450    tx_id: u32,
4451}
4452
4453/// Set the the channel to be shutdown (see [`PowerElementProviderControlHandle::shutdown`])
4454/// if the responder is dropped without sending a response, so that the client
4455/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4456impl std::ops::Drop for PowerElementProviderGetClockSpeedLevelResponder {
4457    fn drop(&mut self) {
4458        self.control_handle.shutdown();
4459        // Safety: drops once, never accessed again
4460        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4461    }
4462}
4463
4464impl fidl::endpoints::Responder for PowerElementProviderGetClockSpeedLevelResponder {
4465    type ControlHandle = PowerElementProviderControlHandle;
4466
4467    fn control_handle(&self) -> &PowerElementProviderControlHandle {
4468        &self.control_handle
4469    }
4470
4471    fn drop_without_shutdown(mut self) {
4472        // Safety: drops once, never accessed again due to mem::forget
4473        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4474        // Prevent Drop from running (which would shut down the channel)
4475        std::mem::forget(self);
4476    }
4477}
4478
4479impl PowerElementProviderGetClockSpeedLevelResponder {
4480    /// Sends a response to the FIDL transaction.
4481    ///
4482    /// Sets the channel to shutdown if an error occurs.
4483    pub fn send(
4484        self,
4485        mut result: Result<PowerElementProviderGetClockSpeedLevelResponse, i32>,
4486    ) -> Result<(), fidl::Error> {
4487        let _result = self.send_raw(result);
4488        if _result.is_err() {
4489            self.control_handle.shutdown();
4490        }
4491        self.drop_without_shutdown();
4492        _result
4493    }
4494
4495    /// Similar to "send" but does not shutdown the channel if an error occurs.
4496    pub fn send_no_shutdown_on_err(
4497        self,
4498        mut result: Result<PowerElementProviderGetClockSpeedLevelResponse, i32>,
4499    ) -> Result<(), fidl::Error> {
4500        let _result = self.send_raw(result);
4501        self.drop_without_shutdown();
4502        _result
4503    }
4504
4505    fn send_raw(
4506        &self,
4507        mut result: Result<PowerElementProviderGetClockSpeedLevelResponse, i32>,
4508    ) -> Result<(), fidl::Error> {
4509        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4510            PowerElementProviderGetClockSpeedLevelResponse,
4511            i32,
4512        >>(
4513            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4514            self.tx_id,
4515            0x5315a9bc44a9c53c,
4516            fidl::encoding::DynamicFlags::FLEXIBLE,
4517        )
4518    }
4519}
4520
4521#[must_use = "FIDL methods require a response to be sent"]
4522#[derive(Debug)]
4523pub struct PowerElementProviderSetClockLimitResponder {
4524    control_handle: std::mem::ManuallyDrop<PowerElementProviderControlHandle>,
4525    tx_id: u32,
4526}
4527
4528/// Set the the channel to be shutdown (see [`PowerElementProviderControlHandle::shutdown`])
4529/// if the responder is dropped without sending a response, so that the client
4530/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4531impl std::ops::Drop for PowerElementProviderSetClockLimitResponder {
4532    fn drop(&mut self) {
4533        self.control_handle.shutdown();
4534        // Safety: drops once, never accessed again
4535        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4536    }
4537}
4538
4539impl fidl::endpoints::Responder for PowerElementProviderSetClockLimitResponder {
4540    type ControlHandle = PowerElementProviderControlHandle;
4541
4542    fn control_handle(&self) -> &PowerElementProviderControlHandle {
4543        &self.control_handle
4544    }
4545
4546    fn drop_without_shutdown(mut self) {
4547        // Safety: drops once, never accessed again due to mem::forget
4548        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4549        // Prevent Drop from running (which would shut down the channel)
4550        std::mem::forget(self);
4551    }
4552}
4553
4554impl PowerElementProviderSetClockLimitResponder {
4555    /// Sends a response to the FIDL transaction.
4556    ///
4557    /// Sets the channel to shutdown if an error occurs.
4558    pub fn send(
4559        self,
4560        mut result: Result<PowerElementProviderSetClockLimitResponse, i32>,
4561    ) -> Result<(), fidl::Error> {
4562        let _result = self.send_raw(result);
4563        if _result.is_err() {
4564            self.control_handle.shutdown();
4565        }
4566        self.drop_without_shutdown();
4567        _result
4568    }
4569
4570    /// Similar to "send" but does not shutdown the channel if an error occurs.
4571    pub fn send_no_shutdown_on_err(
4572        self,
4573        mut result: Result<PowerElementProviderSetClockLimitResponse, i32>,
4574    ) -> Result<(), fidl::Error> {
4575        let _result = self.send_raw(result);
4576        self.drop_without_shutdown();
4577        _result
4578    }
4579
4580    fn send_raw(
4581        &self,
4582        mut result: Result<PowerElementProviderSetClockLimitResponse, i32>,
4583    ) -> Result<(), fidl::Error> {
4584        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4585            PowerElementProviderSetClockLimitResponse,
4586            i32,
4587        >>(
4588            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4589            self.tx_id,
4590            0x614bf25c3a1571b4,
4591            fidl::encoding::DynamicFlags::FLEXIBLE,
4592        )
4593    }
4594}
4595
4596#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4597pub struct PrimaryMarker;
4598
4599impl fidl::endpoints::ProtocolMarker for PrimaryMarker {
4600    type Proxy = PrimaryProxy;
4601    type RequestStream = PrimaryRequestStream;
4602    #[cfg(target_os = "fuchsia")]
4603    type SynchronousProxy = PrimarySynchronousProxy;
4604
4605    const DEBUG_NAME: &'static str = "(anonymous) Primary";
4606}
4607
4608pub trait PrimaryProxyInterface: Send + Sync {
4609    fn r#import_object2(
4610        &self,
4611        object: fidl::Handle,
4612        object_type: ObjectType,
4613        object_id: u64,
4614    ) -> Result<(), fidl::Error>;
4615    fn r#import_object(&self, payload: PrimaryImportObjectRequest) -> Result<(), fidl::Error>;
4616    fn r#release_object(&self, object_id: u64, object_type: ObjectType) -> Result<(), fidl::Error>;
4617    fn r#create_context(&self, context_id: u32) -> Result<(), fidl::Error>;
4618    fn r#create_context2(&self, context_id: u32, priority: Priority) -> Result<(), fidl::Error>;
4619    fn r#destroy_context(&self, context_id: u32) -> Result<(), fidl::Error>;
4620    fn r#execute_command(
4621        &self,
4622        context_id: u32,
4623        resources: &[BufferRange],
4624        command_buffers: &[CommandBuffer],
4625        wait_semaphores: &[u64],
4626        signal_semaphores: &[u64],
4627        flags: CommandBufferFlags,
4628    ) -> Result<(), fidl::Error>;
4629    fn r#execute_immediate_commands(
4630        &self,
4631        context_id: u32,
4632        command_data: &[u8],
4633        semaphores: &[u64],
4634    ) -> Result<(), fidl::Error>;
4635    fn r#execute_inline_commands(
4636        &self,
4637        context_id: u32,
4638        commands: &[InlineCommand],
4639    ) -> Result<(), fidl::Error>;
4640    type FlushResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4641    fn r#flush(&self) -> Self::FlushResponseFut;
4642    fn r#map_buffer(&self, payload: &PrimaryMapBufferRequest) -> Result<(), fidl::Error>;
4643    fn r#unmap_buffer(&self, payload: &PrimaryUnmapBufferRequest) -> Result<(), fidl::Error>;
4644    fn r#buffer_range_op2(&self, op: BufferOp, range: &BufferRange) -> Result<(), fidl::Error>;
4645    fn r#enable_flow_control(&self) -> Result<(), fidl::Error>;
4646    fn r#enable_performance_counter_access(
4647        &self,
4648        access_token: fidl::Event,
4649    ) -> Result<(), fidl::Error>;
4650    type IsPerformanceCounterAccessAllowedResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
4651        + Send;
4652    fn r#is_performance_counter_access_allowed(
4653        &self,
4654    ) -> Self::IsPerformanceCounterAccessAllowedResponseFut;
4655    fn r#enable_performance_counters(&self, counters: &[u64]) -> Result<(), fidl::Error>;
4656    fn r#create_performance_counter_buffer_pool(
4657        &self,
4658        pool_id: u64,
4659        event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
4660    ) -> Result<(), fidl::Error>;
4661    fn r#release_performance_counter_buffer_pool(&self, pool_id: u64) -> Result<(), fidl::Error>;
4662    fn r#add_performance_counter_buffer_offsets_to_pool(
4663        &self,
4664        pool_id: u64,
4665        offsets: &[BufferRange],
4666    ) -> Result<(), fidl::Error>;
4667    fn r#remove_performance_counter_buffer_from_pool(
4668        &self,
4669        pool_id: u64,
4670        buffer_id: u64,
4671    ) -> Result<(), fidl::Error>;
4672    fn r#dump_performance_counters(&self, pool_id: u64, trigger_id: u32)
4673        -> Result<(), fidl::Error>;
4674    fn r#clear_performance_counters(&self, counters: &[u64]) -> Result<(), fidl::Error>;
4675}
4676#[derive(Debug)]
4677#[cfg(target_os = "fuchsia")]
4678pub struct PrimarySynchronousProxy {
4679    client: fidl::client::sync::Client,
4680}
4681
4682#[cfg(target_os = "fuchsia")]
4683impl fidl::endpoints::SynchronousProxy for PrimarySynchronousProxy {
4684    type Proxy = PrimaryProxy;
4685    type Protocol = PrimaryMarker;
4686
4687    fn from_channel(inner: fidl::Channel) -> Self {
4688        Self::new(inner)
4689    }
4690
4691    fn into_channel(self) -> fidl::Channel {
4692        self.client.into_channel()
4693    }
4694
4695    fn as_channel(&self) -> &fidl::Channel {
4696        self.client.as_channel()
4697    }
4698}
4699
4700#[cfg(target_os = "fuchsia")]
4701impl PrimarySynchronousProxy {
4702    pub fn new(channel: fidl::Channel) -> Self {
4703        let protocol_name = <PrimaryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4704        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
4705    }
4706
4707    pub fn into_channel(self) -> fidl::Channel {
4708        self.client.into_channel()
4709    }
4710
4711    /// Waits until an event arrives and returns it. It is safe for other
4712    /// threads to make concurrent requests while waiting for an event.
4713    pub fn wait_for_event(
4714        &self,
4715        deadline: zx::MonotonicInstant,
4716    ) -> Result<PrimaryEvent, fidl::Error> {
4717        PrimaryEvent::decode(self.client.wait_for_event(deadline)?)
4718    }
4719
4720    pub fn r#import_object2(
4721        &self,
4722        mut object: fidl::Handle,
4723        mut object_type: ObjectType,
4724        mut object_id: u64,
4725    ) -> Result<(), fidl::Error> {
4726        self.client.send::<PrimaryImportObject2Request>(
4727            (object, object_type, object_id),
4728            0x774ef4bc434f6b40,
4729            fidl::encoding::DynamicFlags::empty(),
4730        )
4731    }
4732
4733    /// Imports an object for use in the system driver.
4734    pub fn r#import_object(
4735        &self,
4736        mut payload: PrimaryImportObjectRequest,
4737    ) -> Result<(), fidl::Error> {
4738        self.client.send::<PrimaryImportObjectRequest>(
4739            &mut payload,
4740            0x5f5a247abb1d9354,
4741            fidl::encoding::DynamicFlags::empty(),
4742        )
4743    }
4744
4745    /// Destroys the object with `object_id` within this connection.
4746    pub fn r#release_object(
4747        &self,
4748        mut object_id: u64,
4749        mut object_type: ObjectType,
4750    ) -> Result<(), fidl::Error> {
4751        self.client.send::<PrimaryReleaseObjectRequest>(
4752            (object_id, object_type),
4753            0x4a65d5885da5e88f,
4754            fidl::encoding::DynamicFlags::empty(),
4755        )
4756    }
4757
4758    /// Creates context `context_id` for use in command execution.  A context may be associated
4759    /// with hardware state.
4760    /// DEPRECATED: Please use CreateContext2.
4761    /// TODO(https://fxbug.dev/413030654): Fully deprecate this API.
4762    pub fn r#create_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
4763        self.client.send::<PrimaryCreateContextRequest>(
4764            (context_id,),
4765            0x5a9a91c8b88b5da4,
4766            fidl::encoding::DynamicFlags::empty(),
4767        )
4768    }
4769
4770    /// Creates context `context_id` for use in command execution.  A context may be associated
4771    /// with hardware state.
4772    pub fn r#create_context2(
4773        &self,
4774        mut context_id: u32,
4775        mut priority: Priority,
4776    ) -> Result<(), fidl::Error> {
4777        self.client.send::<PrimaryCreateContext2Request>(
4778            (context_id, priority),
4779            0x5f7e3a5137e758f6,
4780            fidl::encoding::DynamicFlags::empty(),
4781        )
4782    }
4783
4784    /// Destroys context `context_id`.
4785    pub fn r#destroy_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
4786        self.client.send::<PrimaryDestroyContextRequest>(
4787            (context_id,),
4788            0x26b626e6be162ef0,
4789            fidl::encoding::DynamicFlags::empty(),
4790        )
4791    }
4792
4793    /// Submits command buffers for execution on the hardware, with associated `resources`.
4794    /// `resources` must refer to buffers that have been imported.
4795    /// `wait_semaphores` and `signal_semaphores` must refer to events that have been imported.
4796    /// `wait_semaphores` must all be signaled before execution begins, then are reset.
4797    /// `signal_semaphores` will be signaled after the command buffer is completed.
4798    pub fn r#execute_command(
4799        &self,
4800        mut context_id: u32,
4801        mut resources: &[BufferRange],
4802        mut command_buffers: &[CommandBuffer],
4803        mut wait_semaphores: &[u64],
4804        mut signal_semaphores: &[u64],
4805        mut flags: CommandBufferFlags,
4806    ) -> Result<(), fidl::Error> {
4807        self.client.send::<PrimaryExecuteCommandRequest>(
4808            (context_id, resources, command_buffers, wait_semaphores, signal_semaphores, flags),
4809            0xf2799643aadb0db,
4810            fidl::encoding::DynamicFlags::empty(),
4811        )
4812    }
4813
4814    /// Submits a series of commands for execution on the hardware without using a command buffer.
4815    /// `semaphores` must refer to events that have been imported, and will be signaled after
4816    /// the commands are completed.
4817    pub fn r#execute_immediate_commands(
4818        &self,
4819        mut context_id: u32,
4820        mut command_data: &[u8],
4821        mut semaphores: &[u64],
4822    ) -> Result<(), fidl::Error> {
4823        self.client.send::<PrimaryExecuteImmediateCommandsRequest>(
4824            (context_id, command_data, semaphores),
4825            0x3d7e0dcdbfd4b61f,
4826            fidl::encoding::DynamicFlags::empty(),
4827        )
4828    }
4829
4830    /// Submits a series of commands for execution on the hardware without using a command buffer.
4831    /// The number of commands sent should be calculated so that the total message size is less than
4832    /// MAX_INLINE_COMMANDS_DATA_SIZE.
4833    pub fn r#execute_inline_commands(
4834        &self,
4835        mut context_id: u32,
4836        mut commands: &[InlineCommand],
4837    ) -> Result<(), fidl::Error> {
4838        self.client.send::<PrimaryExecuteInlineCommandsRequest>(
4839            (context_id, commands),
4840            0x766d5c86f35468a6,
4841            fidl::encoding::DynamicFlags::empty(),
4842        )
4843    }
4844
4845    /// Incurs a round-trip to the system driver, used to ensure all previous messages have been
4846    /// observed, but not necessarily completed.
4847    pub fn r#flush(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
4848        let _response =
4849            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
4850                (),
4851                0x54ccb5572d886039,
4852                fidl::encoding::DynamicFlags::empty(),
4853                ___deadline,
4854            )?;
4855        Ok(_response)
4856    }
4857
4858    /// Maps a page range onto the hardware in the connection's address space at address `hw_va`.
4859    /// `flags` is a set of flags from MapFlags that specify how the hardware can access the buffer.
4860    pub fn r#map_buffer(&self, mut payload: &PrimaryMapBufferRequest) -> Result<(), fidl::Error> {
4861        self.client.send::<PrimaryMapBufferRequest>(
4862            payload,
4863            0x56baa5d2092c8e33,
4864            fidl::encoding::DynamicFlags::empty(),
4865        )
4866    }
4867
4868    /// Releases the mapping at address `hw_va` from the hardware for the given `buffer_id`.
4869    /// Buffers will also be implicitly unmapped when released.
4870    pub fn r#unmap_buffer(
4871        &self,
4872        mut payload: &PrimaryUnmapBufferRequest,
4873    ) -> Result<(), fidl::Error> {
4874        self.client.send::<PrimaryUnmapBufferRequest>(
4875            payload,
4876            0x305188ebd8bcd95c,
4877            fidl::encoding::DynamicFlags::empty(),
4878        )
4879    }
4880
4881    /// Perform an operation on a range of the buffer.
4882    pub fn r#buffer_range_op2(
4883        &self,
4884        mut op: BufferOp,
4885        mut range: &BufferRange,
4886    ) -> Result<(), fidl::Error> {
4887        self.client.send::<PrimaryBufferRangeOp2Request>(
4888            (op, range),
4889            0x4175c8dfef355396,
4890            fidl::encoding::DynamicFlags::empty(),
4891        )
4892    }
4893
4894    /// Enables the events OnNotifyMessagesConsumed and OnNotifyMemoryImported.
4895    pub fn r#enable_flow_control(&self) -> Result<(), fidl::Error> {
4896        self.client.send::<fidl::encoding::EmptyPayload>(
4897            (),
4898            0x8b5e68f3ee0b22e,
4899            fidl::encoding::DynamicFlags::empty(),
4900        )
4901    }
4902
4903    /// Tries to enable performance counter FIDL messages. To be successful, |access_token| must
4904    /// have been returned by PerformanceCounterAccess.GetPerformanceCountToken() from the matching
4905    /// device.
4906    pub fn r#enable_performance_counter_access(
4907        &self,
4908        mut access_token: fidl::Event,
4909    ) -> Result<(), fidl::Error> {
4910        self.client.send::<PrimaryEnablePerformanceCounterAccessRequest>(
4911            (access_token,),
4912            0x51b369ac16588831,
4913            fidl::encoding::DynamicFlags::empty(),
4914        )
4915    }
4916
4917    /// Returns true if any EnablePerformanceCounterAccess message has succeeded.
4918    pub fn r#is_performance_counter_access_allowed(
4919        &self,
4920        ___deadline: zx::MonotonicInstant,
4921    ) -> Result<bool, fidl::Error> {
4922        let _response = self.client.send_query::<
4923            fidl::encoding::EmptyPayload,
4924            PrimaryIsPerformanceCounterAccessAllowedResponse,
4925        >(
4926            (),
4927            0x1933b70c06cc5702,
4928            fidl::encoding::DynamicFlags::empty(),
4929            ___deadline,
4930        )?;
4931        Ok(_response.enabled)
4932    }
4933
4934    /// Enables a set of performance counters.  Disables enabled performance counters that are not
4935    /// in the new set. Performance counters will also be automatically disabled on connection
4936    /// close. Performance counter access must have been enabled using
4937    /// EnablePerformanceCounterAccess before calling this method.
4938    pub fn r#enable_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
4939        self.client.send::<PrimaryEnablePerformanceCountersRequest>(
4940            (counters,),
4941            0x52c4db74b601aaa7,
4942            fidl::encoding::DynamicFlags::empty(),
4943        )
4944    }
4945
4946    /// Creates a pool of buffers that performance counters can be dumped into. Performance counter
4947    /// access must have been enabled using EnablePerformanceCounterAccess before calling this
4948    /// method.
4949    pub fn r#create_performance_counter_buffer_pool(
4950        &self,
4951        mut pool_id: u64,
4952        mut event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
4953    ) -> Result<(), fidl::Error> {
4954        self.client.send::<PrimaryCreatePerformanceCounterBufferPoolRequest>(
4955            (pool_id, event_channel),
4956            0x48ccf6519bbbc638,
4957            fidl::encoding::DynamicFlags::empty(),
4958        )
4959    }
4960
4961    /// Releases a pool of performance counter buffers. Performance counter access must have been
4962    /// enabled using EnablePerformanceCounterAccess before calling this method.
4963    pub fn r#release_performance_counter_buffer_pool(
4964        &self,
4965        mut pool_id: u64,
4966    ) -> Result<(), fidl::Error> {
4967        self.client.send::<PrimaryReleasePerformanceCounterBufferPoolRequest>(
4968            (pool_id,),
4969            0x18374c4b3ef0b4da,
4970            fidl::encoding::DynamicFlags::empty(),
4971        )
4972    }
4973
4974    /// Adds a set of offsets into buffers to the pool. |offsets[n].buffer_id| is the id of a
4975    /// buffer that was previously imported using ImportBuffer(). The same buffer may be added to
4976    /// multiple pools. The pool will hold on to a reference to the buffer even after ReleaseBuffer
4977    /// is called.  When dumped into this entry, counters will be written starting at
4978    /// |offsets[n].buffer_offset| bytes into the buffer, and up to |offsets[n].buffer_offset| +
4979    /// |offsets[n].buffer_size|. |offsets[n].buffer_size| must be large enough to fit all enabled
4980    /// counters. Performance counter access must have been enabled using
4981    /// EnablePerformanceCounterAccess before calling this method.
4982    pub fn r#add_performance_counter_buffer_offsets_to_pool(
4983        &self,
4984        mut pool_id: u64,
4985        mut offsets: &[BufferRange],
4986    ) -> Result<(), fidl::Error> {
4987        self.client.send::<PrimaryAddPerformanceCounterBufferOffsetsToPoolRequest>(
4988            (pool_id, offsets),
4989            0x1f7889571111386b,
4990            fidl::encoding::DynamicFlags::empty(),
4991        )
4992    }
4993
4994    /// Removes every offset of a buffer from the pool. Once this method is finished being handled
4995    /// on the server, no more dumps will be processed into this buffer. In-flight dumps into this
4996    /// buffer may be lost.  Performance counter access must have been enabled using
4997    /// EnablePerformanceCounterAccess before calling this method.
4998    pub fn r#remove_performance_counter_buffer_from_pool(
4999        &self,
5000        mut pool_id: u64,
5001        mut buffer_id: u64,
5002    ) -> Result<(), fidl::Error> {
5003        self.client.send::<PrimaryRemovePerformanceCounterBufferFromPoolRequest>(
5004            (pool_id, buffer_id),
5005            0xbf1275f5a36258e,
5006            fidl::encoding::DynamicFlags::empty(),
5007        )
5008    }
5009
5010    /// Triggers dumping of the performance counters into a buffer pool. May fail silently if there
5011    /// are no buffers in the pool. |trigger_id| is an arbitrary ID assigned by the client that can
5012    /// be returned in OnPerformanceCounterReadCompleted. Performance counter access must have been
5013    /// enabled using EnablePerformanceCounterAccess before calling this method.
5014    pub fn r#dump_performance_counters(
5015        &self,
5016        mut pool_id: u64,
5017        mut trigger_id: u32,
5018    ) -> Result<(), fidl::Error> {
5019        self.client.send::<PrimaryDumpPerformanceCountersRequest>(
5020            (pool_id, trigger_id),
5021            0x250b29340be28807,
5022            fidl::encoding::DynamicFlags::empty(),
5023        )
5024    }
5025
5026    /// Sets the values of all listed performance counters to 0. May not be supported by some
5027    /// hardware. Performance counter access must have been enabled using
5028    /// EnablePerformanceCounterAccess before calling this method.
5029    pub fn r#clear_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5030        self.client.send::<PrimaryClearPerformanceCountersRequest>(
5031            (counters,),
5032            0x236831822eff741a,
5033            fidl::encoding::DynamicFlags::empty(),
5034        )
5035    }
5036}
5037
5038#[cfg(target_os = "fuchsia")]
5039impl From<PrimarySynchronousProxy> for zx::Handle {
5040    fn from(value: PrimarySynchronousProxy) -> Self {
5041        value.into_channel().into()
5042    }
5043}
5044
5045#[cfg(target_os = "fuchsia")]
5046impl From<fidl::Channel> for PrimarySynchronousProxy {
5047    fn from(value: fidl::Channel) -> Self {
5048        Self::new(value)
5049    }
5050}
5051
5052#[derive(Debug, Clone)]
5053pub struct PrimaryProxy {
5054    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5055}
5056
5057impl fidl::endpoints::Proxy for PrimaryProxy {
5058    type Protocol = PrimaryMarker;
5059
5060    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5061        Self::new(inner)
5062    }
5063
5064    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5065        self.client.into_channel().map_err(|client| Self { client })
5066    }
5067
5068    fn as_channel(&self) -> &::fidl::AsyncChannel {
5069        self.client.as_channel()
5070    }
5071}
5072
5073impl PrimaryProxy {
5074    /// Create a new Proxy for fuchsia.gpu.magma/Primary.
5075    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5076        let protocol_name = <PrimaryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5077        Self { client: fidl::client::Client::new(channel, protocol_name) }
5078    }
5079
5080    /// Get a Stream of events from the remote end of the protocol.
5081    ///
5082    /// # Panics
5083    ///
5084    /// Panics if the event stream was already taken.
5085    pub fn take_event_stream(&self) -> PrimaryEventStream {
5086        PrimaryEventStream { event_receiver: self.client.take_event_receiver() }
5087    }
5088
5089    pub fn r#import_object2(
5090        &self,
5091        mut object: fidl::Handle,
5092        mut object_type: ObjectType,
5093        mut object_id: u64,
5094    ) -> Result<(), fidl::Error> {
5095        PrimaryProxyInterface::r#import_object2(self, object, object_type, object_id)
5096    }
5097
5098    /// Imports an object for use in the system driver.
5099    pub fn r#import_object(
5100        &self,
5101        mut payload: PrimaryImportObjectRequest,
5102    ) -> Result<(), fidl::Error> {
5103        PrimaryProxyInterface::r#import_object(self, payload)
5104    }
5105
5106    /// Destroys the object with `object_id` within this connection.
5107    pub fn r#release_object(
5108        &self,
5109        mut object_id: u64,
5110        mut object_type: ObjectType,
5111    ) -> Result<(), fidl::Error> {
5112        PrimaryProxyInterface::r#release_object(self, object_id, object_type)
5113    }
5114
5115    /// Creates context `context_id` for use in command execution.  A context may be associated
5116    /// with hardware state.
5117    /// DEPRECATED: Please use CreateContext2.
5118    /// TODO(https://fxbug.dev/413030654): Fully deprecate this API.
5119    pub fn r#create_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5120        PrimaryProxyInterface::r#create_context(self, context_id)
5121    }
5122
5123    /// Creates context `context_id` for use in command execution.  A context may be associated
5124    /// with hardware state.
5125    pub fn r#create_context2(
5126        &self,
5127        mut context_id: u32,
5128        mut priority: Priority,
5129    ) -> Result<(), fidl::Error> {
5130        PrimaryProxyInterface::r#create_context2(self, context_id, priority)
5131    }
5132
5133    /// Destroys context `context_id`.
5134    pub fn r#destroy_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5135        PrimaryProxyInterface::r#destroy_context(self, context_id)
5136    }
5137
5138    /// Submits command buffers for execution on the hardware, with associated `resources`.
5139    /// `resources` must refer to buffers that have been imported.
5140    /// `wait_semaphores` and `signal_semaphores` must refer to events that have been imported.
5141    /// `wait_semaphores` must all be signaled before execution begins, then are reset.
5142    /// `signal_semaphores` will be signaled after the command buffer is completed.
5143    pub fn r#execute_command(
5144        &self,
5145        mut context_id: u32,
5146        mut resources: &[BufferRange],
5147        mut command_buffers: &[CommandBuffer],
5148        mut wait_semaphores: &[u64],
5149        mut signal_semaphores: &[u64],
5150        mut flags: CommandBufferFlags,
5151    ) -> Result<(), fidl::Error> {
5152        PrimaryProxyInterface::r#execute_command(
5153            self,
5154            context_id,
5155            resources,
5156            command_buffers,
5157            wait_semaphores,
5158            signal_semaphores,
5159            flags,
5160        )
5161    }
5162
5163    /// Submits a series of commands for execution on the hardware without using a command buffer.
5164    /// `semaphores` must refer to events that have been imported, and will be signaled after
5165    /// the commands are completed.
5166    pub fn r#execute_immediate_commands(
5167        &self,
5168        mut context_id: u32,
5169        mut command_data: &[u8],
5170        mut semaphores: &[u64],
5171    ) -> Result<(), fidl::Error> {
5172        PrimaryProxyInterface::r#execute_immediate_commands(
5173            self,
5174            context_id,
5175            command_data,
5176            semaphores,
5177        )
5178    }
5179
5180    /// Submits a series of commands for execution on the hardware without using a command buffer.
5181    /// The number of commands sent should be calculated so that the total message size is less than
5182    /// MAX_INLINE_COMMANDS_DATA_SIZE.
5183    pub fn r#execute_inline_commands(
5184        &self,
5185        mut context_id: u32,
5186        mut commands: &[InlineCommand],
5187    ) -> Result<(), fidl::Error> {
5188        PrimaryProxyInterface::r#execute_inline_commands(self, context_id, commands)
5189    }
5190
5191    /// Incurs a round-trip to the system driver, used to ensure all previous messages have been
5192    /// observed, but not necessarily completed.
5193    pub fn r#flush(
5194        &self,
5195    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5196        PrimaryProxyInterface::r#flush(self)
5197    }
5198
5199    /// Maps a page range onto the hardware in the connection's address space at address `hw_va`.
5200    /// `flags` is a set of flags from MapFlags that specify how the hardware can access the buffer.
5201    pub fn r#map_buffer(&self, mut payload: &PrimaryMapBufferRequest) -> Result<(), fidl::Error> {
5202        PrimaryProxyInterface::r#map_buffer(self, payload)
5203    }
5204
5205    /// Releases the mapping at address `hw_va` from the hardware for the given `buffer_id`.
5206    /// Buffers will also be implicitly unmapped when released.
5207    pub fn r#unmap_buffer(
5208        &self,
5209        mut payload: &PrimaryUnmapBufferRequest,
5210    ) -> Result<(), fidl::Error> {
5211        PrimaryProxyInterface::r#unmap_buffer(self, payload)
5212    }
5213
5214    /// Perform an operation on a range of the buffer.
5215    pub fn r#buffer_range_op2(
5216        &self,
5217        mut op: BufferOp,
5218        mut range: &BufferRange,
5219    ) -> Result<(), fidl::Error> {
5220        PrimaryProxyInterface::r#buffer_range_op2(self, op, range)
5221    }
5222
5223    /// Enables the events OnNotifyMessagesConsumed and OnNotifyMemoryImported.
5224    pub fn r#enable_flow_control(&self) -> Result<(), fidl::Error> {
5225        PrimaryProxyInterface::r#enable_flow_control(self)
5226    }
5227
5228    /// Tries to enable performance counter FIDL messages. To be successful, |access_token| must
5229    /// have been returned by PerformanceCounterAccess.GetPerformanceCountToken() from the matching
5230    /// device.
5231    pub fn r#enable_performance_counter_access(
5232        &self,
5233        mut access_token: fidl::Event,
5234    ) -> Result<(), fidl::Error> {
5235        PrimaryProxyInterface::r#enable_performance_counter_access(self, access_token)
5236    }
5237
5238    /// Returns true if any EnablePerformanceCounterAccess message has succeeded.
5239    pub fn r#is_performance_counter_access_allowed(
5240        &self,
5241    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
5242        PrimaryProxyInterface::r#is_performance_counter_access_allowed(self)
5243    }
5244
5245    /// Enables a set of performance counters.  Disables enabled performance counters that are not
5246    /// in the new set. Performance counters will also be automatically disabled on connection
5247    /// close. Performance counter access must have been enabled using
5248    /// EnablePerformanceCounterAccess before calling this method.
5249    pub fn r#enable_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5250        PrimaryProxyInterface::r#enable_performance_counters(self, counters)
5251    }
5252
5253    /// Creates a pool of buffers that performance counters can be dumped into. Performance counter
5254    /// access must have been enabled using EnablePerformanceCounterAccess before calling this
5255    /// method.
5256    pub fn r#create_performance_counter_buffer_pool(
5257        &self,
5258        mut pool_id: u64,
5259        mut event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
5260    ) -> Result<(), fidl::Error> {
5261        PrimaryProxyInterface::r#create_performance_counter_buffer_pool(
5262            self,
5263            pool_id,
5264            event_channel,
5265        )
5266    }
5267
5268    /// Releases a pool of performance counter buffers. Performance counter access must have been
5269    /// enabled using EnablePerformanceCounterAccess before calling this method.
5270    pub fn r#release_performance_counter_buffer_pool(
5271        &self,
5272        mut pool_id: u64,
5273    ) -> Result<(), fidl::Error> {
5274        PrimaryProxyInterface::r#release_performance_counter_buffer_pool(self, pool_id)
5275    }
5276
5277    /// Adds a set of offsets into buffers to the pool. |offsets[n].buffer_id| is the id of a
5278    /// buffer that was previously imported using ImportBuffer(). The same buffer may be added to
5279    /// multiple pools. The pool will hold on to a reference to the buffer even after ReleaseBuffer
5280    /// is called.  When dumped into this entry, counters will be written starting at
5281    /// |offsets[n].buffer_offset| bytes into the buffer, and up to |offsets[n].buffer_offset| +
5282    /// |offsets[n].buffer_size|. |offsets[n].buffer_size| must be large enough to fit all enabled
5283    /// counters. Performance counter access must have been enabled using
5284    /// EnablePerformanceCounterAccess before calling this method.
5285    pub fn r#add_performance_counter_buffer_offsets_to_pool(
5286        &self,
5287        mut pool_id: u64,
5288        mut offsets: &[BufferRange],
5289    ) -> Result<(), fidl::Error> {
5290        PrimaryProxyInterface::r#add_performance_counter_buffer_offsets_to_pool(
5291            self, pool_id, offsets,
5292        )
5293    }
5294
5295    /// Removes every offset of a buffer from the pool. Once this method is finished being handled
5296    /// on the server, no more dumps will be processed into this buffer. In-flight dumps into this
5297    /// buffer may be lost.  Performance counter access must have been enabled using
5298    /// EnablePerformanceCounterAccess before calling this method.
5299    pub fn r#remove_performance_counter_buffer_from_pool(
5300        &self,
5301        mut pool_id: u64,
5302        mut buffer_id: u64,
5303    ) -> Result<(), fidl::Error> {
5304        PrimaryProxyInterface::r#remove_performance_counter_buffer_from_pool(
5305            self, pool_id, buffer_id,
5306        )
5307    }
5308
5309    /// Triggers dumping of the performance counters into a buffer pool. May fail silently if there
5310    /// are no buffers in the pool. |trigger_id| is an arbitrary ID assigned by the client that can
5311    /// be returned in OnPerformanceCounterReadCompleted. Performance counter access must have been
5312    /// enabled using EnablePerformanceCounterAccess before calling this method.
5313    pub fn r#dump_performance_counters(
5314        &self,
5315        mut pool_id: u64,
5316        mut trigger_id: u32,
5317    ) -> Result<(), fidl::Error> {
5318        PrimaryProxyInterface::r#dump_performance_counters(self, pool_id, trigger_id)
5319    }
5320
5321    /// Sets the values of all listed performance counters to 0. May not be supported by some
5322    /// hardware. Performance counter access must have been enabled using
5323    /// EnablePerformanceCounterAccess before calling this method.
5324    pub fn r#clear_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5325        PrimaryProxyInterface::r#clear_performance_counters(self, counters)
5326    }
5327}
5328
5329impl PrimaryProxyInterface for PrimaryProxy {
5330    fn r#import_object2(
5331        &self,
5332        mut object: fidl::Handle,
5333        mut object_type: ObjectType,
5334        mut object_id: u64,
5335    ) -> Result<(), fidl::Error> {
5336        self.client.send::<PrimaryImportObject2Request>(
5337            (object, object_type, object_id),
5338            0x774ef4bc434f6b40,
5339            fidl::encoding::DynamicFlags::empty(),
5340        )
5341    }
5342
5343    fn r#import_object(&self, mut payload: PrimaryImportObjectRequest) -> Result<(), fidl::Error> {
5344        self.client.send::<PrimaryImportObjectRequest>(
5345            &mut payload,
5346            0x5f5a247abb1d9354,
5347            fidl::encoding::DynamicFlags::empty(),
5348        )
5349    }
5350
5351    fn r#release_object(
5352        &self,
5353        mut object_id: u64,
5354        mut object_type: ObjectType,
5355    ) -> Result<(), fidl::Error> {
5356        self.client.send::<PrimaryReleaseObjectRequest>(
5357            (object_id, object_type),
5358            0x4a65d5885da5e88f,
5359            fidl::encoding::DynamicFlags::empty(),
5360        )
5361    }
5362
5363    fn r#create_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5364        self.client.send::<PrimaryCreateContextRequest>(
5365            (context_id,),
5366            0x5a9a91c8b88b5da4,
5367            fidl::encoding::DynamicFlags::empty(),
5368        )
5369    }
5370
5371    fn r#create_context2(
5372        &self,
5373        mut context_id: u32,
5374        mut priority: Priority,
5375    ) -> Result<(), fidl::Error> {
5376        self.client.send::<PrimaryCreateContext2Request>(
5377            (context_id, priority),
5378            0x5f7e3a5137e758f6,
5379            fidl::encoding::DynamicFlags::empty(),
5380        )
5381    }
5382
5383    fn r#destroy_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5384        self.client.send::<PrimaryDestroyContextRequest>(
5385            (context_id,),
5386            0x26b626e6be162ef0,
5387            fidl::encoding::DynamicFlags::empty(),
5388        )
5389    }
5390
5391    fn r#execute_command(
5392        &self,
5393        mut context_id: u32,
5394        mut resources: &[BufferRange],
5395        mut command_buffers: &[CommandBuffer],
5396        mut wait_semaphores: &[u64],
5397        mut signal_semaphores: &[u64],
5398        mut flags: CommandBufferFlags,
5399    ) -> Result<(), fidl::Error> {
5400        self.client.send::<PrimaryExecuteCommandRequest>(
5401            (context_id, resources, command_buffers, wait_semaphores, signal_semaphores, flags),
5402            0xf2799643aadb0db,
5403            fidl::encoding::DynamicFlags::empty(),
5404        )
5405    }
5406
5407    fn r#execute_immediate_commands(
5408        &self,
5409        mut context_id: u32,
5410        mut command_data: &[u8],
5411        mut semaphores: &[u64],
5412    ) -> Result<(), fidl::Error> {
5413        self.client.send::<PrimaryExecuteImmediateCommandsRequest>(
5414            (context_id, command_data, semaphores),
5415            0x3d7e0dcdbfd4b61f,
5416            fidl::encoding::DynamicFlags::empty(),
5417        )
5418    }
5419
5420    fn r#execute_inline_commands(
5421        &self,
5422        mut context_id: u32,
5423        mut commands: &[InlineCommand],
5424    ) -> Result<(), fidl::Error> {
5425        self.client.send::<PrimaryExecuteInlineCommandsRequest>(
5426            (context_id, commands),
5427            0x766d5c86f35468a6,
5428            fidl::encoding::DynamicFlags::empty(),
5429        )
5430    }
5431
5432    type FlushResponseFut =
5433        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5434    fn r#flush(&self) -> Self::FlushResponseFut {
5435        fn _decode(
5436            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5437        ) -> Result<(), fidl::Error> {
5438            let _response = fidl::client::decode_transaction_body::<
5439                fidl::encoding::EmptyPayload,
5440                fidl::encoding::DefaultFuchsiaResourceDialect,
5441                0x54ccb5572d886039,
5442            >(_buf?)?;
5443            Ok(_response)
5444        }
5445        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5446            (),
5447            0x54ccb5572d886039,
5448            fidl::encoding::DynamicFlags::empty(),
5449            _decode,
5450        )
5451    }
5452
5453    fn r#map_buffer(&self, mut payload: &PrimaryMapBufferRequest) -> Result<(), fidl::Error> {
5454        self.client.send::<PrimaryMapBufferRequest>(
5455            payload,
5456            0x56baa5d2092c8e33,
5457            fidl::encoding::DynamicFlags::empty(),
5458        )
5459    }
5460
5461    fn r#unmap_buffer(&self, mut payload: &PrimaryUnmapBufferRequest) -> Result<(), fidl::Error> {
5462        self.client.send::<PrimaryUnmapBufferRequest>(
5463            payload,
5464            0x305188ebd8bcd95c,
5465            fidl::encoding::DynamicFlags::empty(),
5466        )
5467    }
5468
5469    fn r#buffer_range_op2(
5470        &self,
5471        mut op: BufferOp,
5472        mut range: &BufferRange,
5473    ) -> Result<(), fidl::Error> {
5474        self.client.send::<PrimaryBufferRangeOp2Request>(
5475            (op, range),
5476            0x4175c8dfef355396,
5477            fidl::encoding::DynamicFlags::empty(),
5478        )
5479    }
5480
5481    fn r#enable_flow_control(&self) -> Result<(), fidl::Error> {
5482        self.client.send::<fidl::encoding::EmptyPayload>(
5483            (),
5484            0x8b5e68f3ee0b22e,
5485            fidl::encoding::DynamicFlags::empty(),
5486        )
5487    }
5488
5489    fn r#enable_performance_counter_access(
5490        &self,
5491        mut access_token: fidl::Event,
5492    ) -> Result<(), fidl::Error> {
5493        self.client.send::<PrimaryEnablePerformanceCounterAccessRequest>(
5494            (access_token,),
5495            0x51b369ac16588831,
5496            fidl::encoding::DynamicFlags::empty(),
5497        )
5498    }
5499
5500    type IsPerformanceCounterAccessAllowedResponseFut =
5501        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
5502    fn r#is_performance_counter_access_allowed(
5503        &self,
5504    ) -> Self::IsPerformanceCounterAccessAllowedResponseFut {
5505        fn _decode(
5506            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5507        ) -> Result<bool, fidl::Error> {
5508            let _response = fidl::client::decode_transaction_body::<
5509                PrimaryIsPerformanceCounterAccessAllowedResponse,
5510                fidl::encoding::DefaultFuchsiaResourceDialect,
5511                0x1933b70c06cc5702,
5512            >(_buf?)?;
5513            Ok(_response.enabled)
5514        }
5515        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
5516            (),
5517            0x1933b70c06cc5702,
5518            fidl::encoding::DynamicFlags::empty(),
5519            _decode,
5520        )
5521    }
5522
5523    fn r#enable_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5524        self.client.send::<PrimaryEnablePerformanceCountersRequest>(
5525            (counters,),
5526            0x52c4db74b601aaa7,
5527            fidl::encoding::DynamicFlags::empty(),
5528        )
5529    }
5530
5531    fn r#create_performance_counter_buffer_pool(
5532        &self,
5533        mut pool_id: u64,
5534        mut event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
5535    ) -> Result<(), fidl::Error> {
5536        self.client.send::<PrimaryCreatePerformanceCounterBufferPoolRequest>(
5537            (pool_id, event_channel),
5538            0x48ccf6519bbbc638,
5539            fidl::encoding::DynamicFlags::empty(),
5540        )
5541    }
5542
5543    fn r#release_performance_counter_buffer_pool(
5544        &self,
5545        mut pool_id: u64,
5546    ) -> Result<(), fidl::Error> {
5547        self.client.send::<PrimaryReleasePerformanceCounterBufferPoolRequest>(
5548            (pool_id,),
5549            0x18374c4b3ef0b4da,
5550            fidl::encoding::DynamicFlags::empty(),
5551        )
5552    }
5553
5554    fn r#add_performance_counter_buffer_offsets_to_pool(
5555        &self,
5556        mut pool_id: u64,
5557        mut offsets: &[BufferRange],
5558    ) -> Result<(), fidl::Error> {
5559        self.client.send::<PrimaryAddPerformanceCounterBufferOffsetsToPoolRequest>(
5560            (pool_id, offsets),
5561            0x1f7889571111386b,
5562            fidl::encoding::DynamicFlags::empty(),
5563        )
5564    }
5565
5566    fn r#remove_performance_counter_buffer_from_pool(
5567        &self,
5568        mut pool_id: u64,
5569        mut buffer_id: u64,
5570    ) -> Result<(), fidl::Error> {
5571        self.client.send::<PrimaryRemovePerformanceCounterBufferFromPoolRequest>(
5572            (pool_id, buffer_id),
5573            0xbf1275f5a36258e,
5574            fidl::encoding::DynamicFlags::empty(),
5575        )
5576    }
5577
5578    fn r#dump_performance_counters(
5579        &self,
5580        mut pool_id: u64,
5581        mut trigger_id: u32,
5582    ) -> Result<(), fidl::Error> {
5583        self.client.send::<PrimaryDumpPerformanceCountersRequest>(
5584            (pool_id, trigger_id),
5585            0x250b29340be28807,
5586            fidl::encoding::DynamicFlags::empty(),
5587        )
5588    }
5589
5590    fn r#clear_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5591        self.client.send::<PrimaryClearPerformanceCountersRequest>(
5592            (counters,),
5593            0x236831822eff741a,
5594            fidl::encoding::DynamicFlags::empty(),
5595        )
5596    }
5597}
5598
5599pub struct PrimaryEventStream {
5600    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5601}
5602
5603impl std::marker::Unpin for PrimaryEventStream {}
5604
5605impl futures::stream::FusedStream for PrimaryEventStream {
5606    fn is_terminated(&self) -> bool {
5607        self.event_receiver.is_terminated()
5608    }
5609}
5610
5611impl futures::Stream for PrimaryEventStream {
5612    type Item = Result<PrimaryEvent, fidl::Error>;
5613
5614    fn poll_next(
5615        mut self: std::pin::Pin<&mut Self>,
5616        cx: &mut std::task::Context<'_>,
5617    ) -> std::task::Poll<Option<Self::Item>> {
5618        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5619            &mut self.event_receiver,
5620            cx
5621        )?) {
5622            Some(buf) => std::task::Poll::Ready(Some(PrimaryEvent::decode(buf))),
5623            None => std::task::Poll::Ready(None),
5624        }
5625    }
5626}
5627
5628#[derive(Debug)]
5629pub enum PrimaryEvent {
5630    OnNotifyMessagesConsumed { count: u64 },
5631    OnNotifyMemoryImported { bytes: u64 },
5632}
5633
5634impl PrimaryEvent {
5635    #[allow(irrefutable_let_patterns)]
5636    pub fn into_on_notify_messages_consumed(self) -> Option<u64> {
5637        if let PrimaryEvent::OnNotifyMessagesConsumed { count } = self {
5638            Some((count))
5639        } else {
5640            None
5641        }
5642    }
5643    #[allow(irrefutable_let_patterns)]
5644    pub fn into_on_notify_memory_imported(self) -> Option<u64> {
5645        if let PrimaryEvent::OnNotifyMemoryImported { bytes } = self {
5646            Some((bytes))
5647        } else {
5648            None
5649        }
5650    }
5651
5652    /// Decodes a message buffer as a [`PrimaryEvent`].
5653    fn decode(
5654        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5655    ) -> Result<PrimaryEvent, fidl::Error> {
5656        let (bytes, _handles) = buf.split_mut();
5657        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5658        debug_assert_eq!(tx_header.tx_id, 0);
5659        match tx_header.ordinal {
5660            0x5e8dd0b0b753ac43 => {
5661                let mut out = fidl::new_empty!(
5662                    PrimaryOnNotifyMessagesConsumedRequest,
5663                    fidl::encoding::DefaultFuchsiaResourceDialect
5664                );
5665                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryOnNotifyMessagesConsumedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5666                Ok((PrimaryEvent::OnNotifyMessagesConsumed { count: out.count }))
5667            }
5668            0x50524b7a3503aba6 => {
5669                let mut out = fidl::new_empty!(
5670                    PrimaryOnNotifyMemoryImportedRequest,
5671                    fidl::encoding::DefaultFuchsiaResourceDialect
5672                );
5673                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryOnNotifyMemoryImportedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
5674                Ok((PrimaryEvent::OnNotifyMemoryImported { bytes: out.bytes }))
5675            }
5676            _ => Err(fidl::Error::UnknownOrdinal {
5677                ordinal: tx_header.ordinal,
5678                protocol_name: <PrimaryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5679            }),
5680        }
5681    }
5682}
5683
5684/// A Stream of incoming requests for fuchsia.gpu.magma/Primary.
5685pub struct PrimaryRequestStream {
5686    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5687    is_terminated: bool,
5688}
5689
5690impl std::marker::Unpin for PrimaryRequestStream {}
5691
5692impl futures::stream::FusedStream for PrimaryRequestStream {
5693    fn is_terminated(&self) -> bool {
5694        self.is_terminated
5695    }
5696}
5697
5698impl fidl::endpoints::RequestStream for PrimaryRequestStream {
5699    type Protocol = PrimaryMarker;
5700    type ControlHandle = PrimaryControlHandle;
5701
5702    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5703        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5704    }
5705
5706    fn control_handle(&self) -> Self::ControlHandle {
5707        PrimaryControlHandle { inner: self.inner.clone() }
5708    }
5709
5710    fn into_inner(
5711        self,
5712    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5713    {
5714        (self.inner, self.is_terminated)
5715    }
5716
5717    fn from_inner(
5718        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5719        is_terminated: bool,
5720    ) -> Self {
5721        Self { inner, is_terminated }
5722    }
5723}
5724
5725impl futures::Stream for PrimaryRequestStream {
5726    type Item = Result<PrimaryRequest, fidl::Error>;
5727
5728    fn poll_next(
5729        mut self: std::pin::Pin<&mut Self>,
5730        cx: &mut std::task::Context<'_>,
5731    ) -> std::task::Poll<Option<Self::Item>> {
5732        let this = &mut *self;
5733        if this.inner.check_shutdown(cx) {
5734            this.is_terminated = true;
5735            return std::task::Poll::Ready(None);
5736        }
5737        if this.is_terminated {
5738            panic!("polled PrimaryRequestStream after completion");
5739        }
5740        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5741            |bytes, handles| {
5742                match this.inner.channel().read_etc(cx, bytes, handles) {
5743                    std::task::Poll::Ready(Ok(())) => {}
5744                    std::task::Poll::Pending => return std::task::Poll::Pending,
5745                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5746                        this.is_terminated = true;
5747                        return std::task::Poll::Ready(None);
5748                    }
5749                    std::task::Poll::Ready(Err(e)) => {
5750                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5751                            e.into(),
5752                        ))))
5753                    }
5754                }
5755
5756                // A message has been received from the channel
5757                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5758
5759                std::task::Poll::Ready(Some(match header.ordinal {
5760                    0x774ef4bc434f6b40 => {
5761                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5762                        let mut req = fidl::new_empty!(
5763                            PrimaryImportObject2Request,
5764                            fidl::encoding::DefaultFuchsiaResourceDialect
5765                        );
5766                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryImportObject2Request>(&header, _body_bytes, handles, &mut req)?;
5767                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5768                        Ok(PrimaryRequest::ImportObject2 {
5769                            object: req.object,
5770                            object_type: req.object_type,
5771                            object_id: req.object_id,
5772
5773                            control_handle,
5774                        })
5775                    }
5776                    0x5f5a247abb1d9354 => {
5777                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5778                        let mut req = fidl::new_empty!(
5779                            PrimaryImportObjectRequest,
5780                            fidl::encoding::DefaultFuchsiaResourceDialect
5781                        );
5782                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryImportObjectRequest>(&header, _body_bytes, handles, &mut req)?;
5783                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5784                        Ok(PrimaryRequest::ImportObject { payload: req, control_handle })
5785                    }
5786                    0x4a65d5885da5e88f => {
5787                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5788                        let mut req = fidl::new_empty!(
5789                            PrimaryReleaseObjectRequest,
5790                            fidl::encoding::DefaultFuchsiaResourceDialect
5791                        );
5792                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryReleaseObjectRequest>(&header, _body_bytes, handles, &mut req)?;
5793                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5794                        Ok(PrimaryRequest::ReleaseObject {
5795                            object_id: req.object_id,
5796                            object_type: req.object_type,
5797
5798                            control_handle,
5799                        })
5800                    }
5801                    0x5a9a91c8b88b5da4 => {
5802                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5803                        let mut req = fidl::new_empty!(
5804                            PrimaryCreateContextRequest,
5805                            fidl::encoding::DefaultFuchsiaResourceDialect
5806                        );
5807                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryCreateContextRequest>(&header, _body_bytes, handles, &mut req)?;
5808                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5809                        Ok(PrimaryRequest::CreateContext {
5810                            context_id: req.context_id,
5811
5812                            control_handle,
5813                        })
5814                    }
5815                    0x5f7e3a5137e758f6 => {
5816                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5817                        let mut req = fidl::new_empty!(
5818                            PrimaryCreateContext2Request,
5819                            fidl::encoding::DefaultFuchsiaResourceDialect
5820                        );
5821                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryCreateContext2Request>(&header, _body_bytes, handles, &mut req)?;
5822                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5823                        Ok(PrimaryRequest::CreateContext2 {
5824                            context_id: req.context_id,
5825                            priority: req.priority,
5826
5827                            control_handle,
5828                        })
5829                    }
5830                    0x26b626e6be162ef0 => {
5831                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5832                        let mut req = fidl::new_empty!(
5833                            PrimaryDestroyContextRequest,
5834                            fidl::encoding::DefaultFuchsiaResourceDialect
5835                        );
5836                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryDestroyContextRequest>(&header, _body_bytes, handles, &mut req)?;
5837                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5838                        Ok(PrimaryRequest::DestroyContext {
5839                            context_id: req.context_id,
5840
5841                            control_handle,
5842                        })
5843                    }
5844                    0xf2799643aadb0db => {
5845                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5846                        let mut req = fidl::new_empty!(
5847                            PrimaryExecuteCommandRequest,
5848                            fidl::encoding::DefaultFuchsiaResourceDialect
5849                        );
5850                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryExecuteCommandRequest>(&header, _body_bytes, handles, &mut req)?;
5851                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5852                        Ok(PrimaryRequest::ExecuteCommand {
5853                            context_id: req.context_id,
5854                            resources: req.resources,
5855                            command_buffers: req.command_buffers,
5856                            wait_semaphores: req.wait_semaphores,
5857                            signal_semaphores: req.signal_semaphores,
5858                            flags: req.flags,
5859
5860                            control_handle,
5861                        })
5862                    }
5863                    0x3d7e0dcdbfd4b61f => {
5864                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5865                        let mut req = fidl::new_empty!(
5866                            PrimaryExecuteImmediateCommandsRequest,
5867                            fidl::encoding::DefaultFuchsiaResourceDialect
5868                        );
5869                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryExecuteImmediateCommandsRequest>(&header, _body_bytes, handles, &mut req)?;
5870                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5871                        Ok(PrimaryRequest::ExecuteImmediateCommands {
5872                            context_id: req.context_id,
5873                            command_data: req.command_data,
5874                            semaphores: req.semaphores,
5875
5876                            control_handle,
5877                        })
5878                    }
5879                    0x766d5c86f35468a6 => {
5880                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5881                        let mut req = fidl::new_empty!(
5882                            PrimaryExecuteInlineCommandsRequest,
5883                            fidl::encoding::DefaultFuchsiaResourceDialect
5884                        );
5885                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryExecuteInlineCommandsRequest>(&header, _body_bytes, handles, &mut req)?;
5886                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5887                        Ok(PrimaryRequest::ExecuteInlineCommands {
5888                            context_id: req.context_id,
5889                            commands: req.commands,
5890
5891                            control_handle,
5892                        })
5893                    }
5894                    0x54ccb5572d886039 => {
5895                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5896                        let mut req = fidl::new_empty!(
5897                            fidl::encoding::EmptyPayload,
5898                            fidl::encoding::DefaultFuchsiaResourceDialect
5899                        );
5900                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5901                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5902                        Ok(PrimaryRequest::Flush {
5903                            responder: PrimaryFlushResponder {
5904                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5905                                tx_id: header.tx_id,
5906                            },
5907                        })
5908                    }
5909                    0x56baa5d2092c8e33 => {
5910                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5911                        let mut req = fidl::new_empty!(
5912                            PrimaryMapBufferRequest,
5913                            fidl::encoding::DefaultFuchsiaResourceDialect
5914                        );
5915                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryMapBufferRequest>(&header, _body_bytes, handles, &mut req)?;
5916                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5917                        Ok(PrimaryRequest::MapBuffer { payload: req, control_handle })
5918                    }
5919                    0x305188ebd8bcd95c => {
5920                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5921                        let mut req = fidl::new_empty!(
5922                            PrimaryUnmapBufferRequest,
5923                            fidl::encoding::DefaultFuchsiaResourceDialect
5924                        );
5925                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryUnmapBufferRequest>(&header, _body_bytes, handles, &mut req)?;
5926                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5927                        Ok(PrimaryRequest::UnmapBuffer { payload: req, control_handle })
5928                    }
5929                    0x4175c8dfef355396 => {
5930                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5931                        let mut req = fidl::new_empty!(
5932                            PrimaryBufferRangeOp2Request,
5933                            fidl::encoding::DefaultFuchsiaResourceDialect
5934                        );
5935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryBufferRangeOp2Request>(&header, _body_bytes, handles, &mut req)?;
5936                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5937                        Ok(PrimaryRequest::BufferRangeOp2 {
5938                            op: req.op,
5939                            range: req.range,
5940
5941                            control_handle,
5942                        })
5943                    }
5944                    0x8b5e68f3ee0b22e => {
5945                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5946                        let mut req = fidl::new_empty!(
5947                            fidl::encoding::EmptyPayload,
5948                            fidl::encoding::DefaultFuchsiaResourceDialect
5949                        );
5950                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5951                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5952                        Ok(PrimaryRequest::EnableFlowControl { control_handle })
5953                    }
5954                    0x51b369ac16588831 => {
5955                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5956                        let mut req = fidl::new_empty!(
5957                            PrimaryEnablePerformanceCounterAccessRequest,
5958                            fidl::encoding::DefaultFuchsiaResourceDialect
5959                        );
5960                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryEnablePerformanceCounterAccessRequest>(&header, _body_bytes, handles, &mut req)?;
5961                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5962                        Ok(PrimaryRequest::EnablePerformanceCounterAccess {
5963                            access_token: req.access_token,
5964
5965                            control_handle,
5966                        })
5967                    }
5968                    0x1933b70c06cc5702 => {
5969                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5970                        let mut req = fidl::new_empty!(
5971                            fidl::encoding::EmptyPayload,
5972                            fidl::encoding::DefaultFuchsiaResourceDialect
5973                        );
5974                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5975                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5976                        Ok(PrimaryRequest::IsPerformanceCounterAccessAllowed {
5977                            responder: PrimaryIsPerformanceCounterAccessAllowedResponder {
5978                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5979                                tx_id: header.tx_id,
5980                            },
5981                        })
5982                    }
5983                    0x52c4db74b601aaa7 => {
5984                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5985                        let mut req = fidl::new_empty!(
5986                            PrimaryEnablePerformanceCountersRequest,
5987                            fidl::encoding::DefaultFuchsiaResourceDialect
5988                        );
5989                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryEnablePerformanceCountersRequest>(&header, _body_bytes, handles, &mut req)?;
5990                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
5991                        Ok(PrimaryRequest::EnablePerformanceCounters {
5992                            counters: req.counters,
5993
5994                            control_handle,
5995                        })
5996                    }
5997                    0x48ccf6519bbbc638 => {
5998                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5999                        let mut req = fidl::new_empty!(
6000                            PrimaryCreatePerformanceCounterBufferPoolRequest,
6001                            fidl::encoding::DefaultFuchsiaResourceDialect
6002                        );
6003                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryCreatePerformanceCounterBufferPoolRequest>(&header, _body_bytes, handles, &mut req)?;
6004                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6005                        Ok(PrimaryRequest::CreatePerformanceCounterBufferPool {
6006                            pool_id: req.pool_id,
6007                            event_channel: req.event_channel,
6008
6009                            control_handle,
6010                        })
6011                    }
6012                    0x18374c4b3ef0b4da => {
6013                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6014                        let mut req = fidl::new_empty!(
6015                            PrimaryReleasePerformanceCounterBufferPoolRequest,
6016                            fidl::encoding::DefaultFuchsiaResourceDialect
6017                        );
6018                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryReleasePerformanceCounterBufferPoolRequest>(&header, _body_bytes, handles, &mut req)?;
6019                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6020                        Ok(PrimaryRequest::ReleasePerformanceCounterBufferPool {
6021                            pool_id: req.pool_id,
6022
6023                            control_handle,
6024                        })
6025                    }
6026                    0x1f7889571111386b => {
6027                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6028                        let mut req = fidl::new_empty!(
6029                            PrimaryAddPerformanceCounterBufferOffsetsToPoolRequest,
6030                            fidl::encoding::DefaultFuchsiaResourceDialect
6031                        );
6032                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryAddPerformanceCounterBufferOffsetsToPoolRequest>(&header, _body_bytes, handles, &mut req)?;
6033                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6034                        Ok(PrimaryRequest::AddPerformanceCounterBufferOffsetsToPool {
6035                            pool_id: req.pool_id,
6036                            offsets: req.offsets,
6037
6038                            control_handle,
6039                        })
6040                    }
6041                    0xbf1275f5a36258e => {
6042                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6043                        let mut req = fidl::new_empty!(
6044                            PrimaryRemovePerformanceCounterBufferFromPoolRequest,
6045                            fidl::encoding::DefaultFuchsiaResourceDialect
6046                        );
6047                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryRemovePerformanceCounterBufferFromPoolRequest>(&header, _body_bytes, handles, &mut req)?;
6048                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6049                        Ok(PrimaryRequest::RemovePerformanceCounterBufferFromPool {
6050                            pool_id: req.pool_id,
6051                            buffer_id: req.buffer_id,
6052
6053                            control_handle,
6054                        })
6055                    }
6056                    0x250b29340be28807 => {
6057                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6058                        let mut req = fidl::new_empty!(
6059                            PrimaryDumpPerformanceCountersRequest,
6060                            fidl::encoding::DefaultFuchsiaResourceDialect
6061                        );
6062                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryDumpPerformanceCountersRequest>(&header, _body_bytes, handles, &mut req)?;
6063                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6064                        Ok(PrimaryRequest::DumpPerformanceCounters {
6065                            pool_id: req.pool_id,
6066                            trigger_id: req.trigger_id,
6067
6068                            control_handle,
6069                        })
6070                    }
6071                    0x236831822eff741a => {
6072                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6073                        let mut req = fidl::new_empty!(
6074                            PrimaryClearPerformanceCountersRequest,
6075                            fidl::encoding::DefaultFuchsiaResourceDialect
6076                        );
6077                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryClearPerformanceCountersRequest>(&header, _body_bytes, handles, &mut req)?;
6078                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6079                        Ok(PrimaryRequest::ClearPerformanceCounters {
6080                            counters: req.counters,
6081
6082                            control_handle,
6083                        })
6084                    }
6085                    _ => Err(fidl::Error::UnknownOrdinal {
6086                        ordinal: header.ordinal,
6087                        protocol_name:
6088                            <PrimaryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6089                    }),
6090                }))
6091            },
6092        )
6093    }
6094}
6095
6096/// If a system driver error occurs, or if the client sends a message that the client should have
6097/// known is invalid, the connection will be closed and a zx.Status sent via epitaph.
6098#[derive(Debug)]
6099pub enum PrimaryRequest {
6100    ImportObject2 {
6101        object: fidl::Handle,
6102        object_type: ObjectType,
6103        object_id: u64,
6104        control_handle: PrimaryControlHandle,
6105    },
6106    /// Imports an object for use in the system driver.
6107    ImportObject { payload: PrimaryImportObjectRequest, control_handle: PrimaryControlHandle },
6108    /// Destroys the object with `object_id` within this connection.
6109    ReleaseObject { object_id: u64, object_type: ObjectType, control_handle: PrimaryControlHandle },
6110    /// Creates context `context_id` for use in command execution.  A context may be associated
6111    /// with hardware state.
6112    /// DEPRECATED: Please use CreateContext2.
6113    /// TODO(https://fxbug.dev/413030654): Fully deprecate this API.
6114    CreateContext { context_id: u32, control_handle: PrimaryControlHandle },
6115    /// Creates context `context_id` for use in command execution.  A context may be associated
6116    /// with hardware state.
6117    CreateContext2 { context_id: u32, priority: Priority, control_handle: PrimaryControlHandle },
6118    /// Destroys context `context_id`.
6119    DestroyContext { context_id: u32, control_handle: PrimaryControlHandle },
6120    /// Submits command buffers for execution on the hardware, with associated `resources`.
6121    /// `resources` must refer to buffers that have been imported.
6122    /// `wait_semaphores` and `signal_semaphores` must refer to events that have been imported.
6123    /// `wait_semaphores` must all be signaled before execution begins, then are reset.
6124    /// `signal_semaphores` will be signaled after the command buffer is completed.
6125    ExecuteCommand {
6126        context_id: u32,
6127        resources: Vec<BufferRange>,
6128        command_buffers: Vec<CommandBuffer>,
6129        wait_semaphores: Vec<u64>,
6130        signal_semaphores: Vec<u64>,
6131        flags: CommandBufferFlags,
6132        control_handle: PrimaryControlHandle,
6133    },
6134    /// Submits a series of commands for execution on the hardware without using a command buffer.
6135    /// `semaphores` must refer to events that have been imported, and will be signaled after
6136    /// the commands are completed.
6137    ExecuteImmediateCommands {
6138        context_id: u32,
6139        command_data: Vec<u8>,
6140        semaphores: Vec<u64>,
6141        control_handle: PrimaryControlHandle,
6142    },
6143    /// Submits a series of commands for execution on the hardware without using a command buffer.
6144    /// The number of commands sent should be calculated so that the total message size is less than
6145    /// MAX_INLINE_COMMANDS_DATA_SIZE.
6146    ExecuteInlineCommands {
6147        context_id: u32,
6148        commands: Vec<InlineCommand>,
6149        control_handle: PrimaryControlHandle,
6150    },
6151    /// Incurs a round-trip to the system driver, used to ensure all previous messages have been
6152    /// observed, but not necessarily completed.
6153    Flush { responder: PrimaryFlushResponder },
6154    /// Maps a page range onto the hardware in the connection's address space at address `hw_va`.
6155    /// `flags` is a set of flags from MapFlags that specify how the hardware can access the buffer.
6156    MapBuffer { payload: PrimaryMapBufferRequest, control_handle: PrimaryControlHandle },
6157    /// Releases the mapping at address `hw_va` from the hardware for the given `buffer_id`.
6158    /// Buffers will also be implicitly unmapped when released.
6159    UnmapBuffer { payload: PrimaryUnmapBufferRequest, control_handle: PrimaryControlHandle },
6160    /// Perform an operation on a range of the buffer.
6161    BufferRangeOp2 { op: BufferOp, range: BufferRange, control_handle: PrimaryControlHandle },
6162    /// Enables the events OnNotifyMessagesConsumed and OnNotifyMemoryImported.
6163    EnableFlowControl { control_handle: PrimaryControlHandle },
6164    /// Tries to enable performance counter FIDL messages. To be successful, |access_token| must
6165    /// have been returned by PerformanceCounterAccess.GetPerformanceCountToken() from the matching
6166    /// device.
6167    EnablePerformanceCounterAccess {
6168        access_token: fidl::Event,
6169        control_handle: PrimaryControlHandle,
6170    },
6171    /// Returns true if any EnablePerformanceCounterAccess message has succeeded.
6172    IsPerformanceCounterAccessAllowed {
6173        responder: PrimaryIsPerformanceCounterAccessAllowedResponder,
6174    },
6175    /// Enables a set of performance counters.  Disables enabled performance counters that are not
6176    /// in the new set. Performance counters will also be automatically disabled on connection
6177    /// close. Performance counter access must have been enabled using
6178    /// EnablePerformanceCounterAccess before calling this method.
6179    EnablePerformanceCounters { counters: Vec<u64>, control_handle: PrimaryControlHandle },
6180    /// Creates a pool of buffers that performance counters can be dumped into. Performance counter
6181    /// access must have been enabled using EnablePerformanceCounterAccess before calling this
6182    /// method.
6183    CreatePerformanceCounterBufferPool {
6184        pool_id: u64,
6185        event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
6186        control_handle: PrimaryControlHandle,
6187    },
6188    /// Releases a pool of performance counter buffers. Performance counter access must have been
6189    /// enabled using EnablePerformanceCounterAccess before calling this method.
6190    ReleasePerformanceCounterBufferPool { pool_id: u64, control_handle: PrimaryControlHandle },
6191    /// Adds a set of offsets into buffers to the pool. |offsets[n].buffer_id| is the id of a
6192    /// buffer that was previously imported using ImportBuffer(). The same buffer may be added to
6193    /// multiple pools. The pool will hold on to a reference to the buffer even after ReleaseBuffer
6194    /// is called.  When dumped into this entry, counters will be written starting at
6195    /// |offsets[n].buffer_offset| bytes into the buffer, and up to |offsets[n].buffer_offset| +
6196    /// |offsets[n].buffer_size|. |offsets[n].buffer_size| must be large enough to fit all enabled
6197    /// counters. Performance counter access must have been enabled using
6198    /// EnablePerformanceCounterAccess before calling this method.
6199    AddPerformanceCounterBufferOffsetsToPool {
6200        pool_id: u64,
6201        offsets: Vec<BufferRange>,
6202        control_handle: PrimaryControlHandle,
6203    },
6204    /// Removes every offset of a buffer from the pool. Once this method is finished being handled
6205    /// on the server, no more dumps will be processed into this buffer. In-flight dumps into this
6206    /// buffer may be lost.  Performance counter access must have been enabled using
6207    /// EnablePerformanceCounterAccess before calling this method.
6208    RemovePerformanceCounterBufferFromPool {
6209        pool_id: u64,
6210        buffer_id: u64,
6211        control_handle: PrimaryControlHandle,
6212    },
6213    /// Triggers dumping of the performance counters into a buffer pool. May fail silently if there
6214    /// are no buffers in the pool. |trigger_id| is an arbitrary ID assigned by the client that can
6215    /// be returned in OnPerformanceCounterReadCompleted. Performance counter access must have been
6216    /// enabled using EnablePerformanceCounterAccess before calling this method.
6217    DumpPerformanceCounters { pool_id: u64, trigger_id: u32, control_handle: PrimaryControlHandle },
6218    /// Sets the values of all listed performance counters to 0. May not be supported by some
6219    /// hardware. Performance counter access must have been enabled using
6220    /// EnablePerformanceCounterAccess before calling this method.
6221    ClearPerformanceCounters { counters: Vec<u64>, control_handle: PrimaryControlHandle },
6222}
6223
6224impl PrimaryRequest {
6225    #[allow(irrefutable_let_patterns)]
6226    pub fn into_import_object2(
6227        self,
6228    ) -> Option<(fidl::Handle, ObjectType, u64, PrimaryControlHandle)> {
6229        if let PrimaryRequest::ImportObject2 { object, object_type, object_id, control_handle } =
6230            self
6231        {
6232            Some((object, object_type, object_id, control_handle))
6233        } else {
6234            None
6235        }
6236    }
6237
6238    #[allow(irrefutable_let_patterns)]
6239    pub fn into_import_object(self) -> Option<(PrimaryImportObjectRequest, PrimaryControlHandle)> {
6240        if let PrimaryRequest::ImportObject { payload, control_handle } = self {
6241            Some((payload, control_handle))
6242        } else {
6243            None
6244        }
6245    }
6246
6247    #[allow(irrefutable_let_patterns)]
6248    pub fn into_release_object(self) -> Option<(u64, ObjectType, PrimaryControlHandle)> {
6249        if let PrimaryRequest::ReleaseObject { object_id, object_type, control_handle } = self {
6250            Some((object_id, object_type, control_handle))
6251        } else {
6252            None
6253        }
6254    }
6255
6256    #[allow(irrefutable_let_patterns)]
6257    pub fn into_create_context(self) -> Option<(u32, PrimaryControlHandle)> {
6258        if let PrimaryRequest::CreateContext { context_id, control_handle } = self {
6259            Some((context_id, control_handle))
6260        } else {
6261            None
6262        }
6263    }
6264
6265    #[allow(irrefutable_let_patterns)]
6266    pub fn into_create_context2(self) -> Option<(u32, Priority, PrimaryControlHandle)> {
6267        if let PrimaryRequest::CreateContext2 { context_id, priority, control_handle } = self {
6268            Some((context_id, priority, control_handle))
6269        } else {
6270            None
6271        }
6272    }
6273
6274    #[allow(irrefutable_let_patterns)]
6275    pub fn into_destroy_context(self) -> Option<(u32, PrimaryControlHandle)> {
6276        if let PrimaryRequest::DestroyContext { context_id, control_handle } = self {
6277            Some((context_id, control_handle))
6278        } else {
6279            None
6280        }
6281    }
6282
6283    #[allow(irrefutable_let_patterns)]
6284    pub fn into_execute_command(
6285        self,
6286    ) -> Option<(
6287        u32,
6288        Vec<BufferRange>,
6289        Vec<CommandBuffer>,
6290        Vec<u64>,
6291        Vec<u64>,
6292        CommandBufferFlags,
6293        PrimaryControlHandle,
6294    )> {
6295        if let PrimaryRequest::ExecuteCommand {
6296            context_id,
6297            resources,
6298            command_buffers,
6299            wait_semaphores,
6300            signal_semaphores,
6301            flags,
6302            control_handle,
6303        } = self
6304        {
6305            Some((
6306                context_id,
6307                resources,
6308                command_buffers,
6309                wait_semaphores,
6310                signal_semaphores,
6311                flags,
6312                control_handle,
6313            ))
6314        } else {
6315            None
6316        }
6317    }
6318
6319    #[allow(irrefutable_let_patterns)]
6320    pub fn into_execute_immediate_commands(
6321        self,
6322    ) -> Option<(u32, Vec<u8>, Vec<u64>, PrimaryControlHandle)> {
6323        if let PrimaryRequest::ExecuteImmediateCommands {
6324            context_id,
6325            command_data,
6326            semaphores,
6327            control_handle,
6328        } = self
6329        {
6330            Some((context_id, command_data, semaphores, control_handle))
6331        } else {
6332            None
6333        }
6334    }
6335
6336    #[allow(irrefutable_let_patterns)]
6337    pub fn into_execute_inline_commands(
6338        self,
6339    ) -> Option<(u32, Vec<InlineCommand>, PrimaryControlHandle)> {
6340        if let PrimaryRequest::ExecuteInlineCommands { context_id, commands, control_handle } = self
6341        {
6342            Some((context_id, commands, control_handle))
6343        } else {
6344            None
6345        }
6346    }
6347
6348    #[allow(irrefutable_let_patterns)]
6349    pub fn into_flush(self) -> Option<(PrimaryFlushResponder)> {
6350        if let PrimaryRequest::Flush { responder } = self {
6351            Some((responder))
6352        } else {
6353            None
6354        }
6355    }
6356
6357    #[allow(irrefutable_let_patterns)]
6358    pub fn into_map_buffer(self) -> Option<(PrimaryMapBufferRequest, PrimaryControlHandle)> {
6359        if let PrimaryRequest::MapBuffer { payload, control_handle } = self {
6360            Some((payload, control_handle))
6361        } else {
6362            None
6363        }
6364    }
6365
6366    #[allow(irrefutable_let_patterns)]
6367    pub fn into_unmap_buffer(self) -> Option<(PrimaryUnmapBufferRequest, PrimaryControlHandle)> {
6368        if let PrimaryRequest::UnmapBuffer { payload, control_handle } = self {
6369            Some((payload, control_handle))
6370        } else {
6371            None
6372        }
6373    }
6374
6375    #[allow(irrefutable_let_patterns)]
6376    pub fn into_buffer_range_op2(self) -> Option<(BufferOp, BufferRange, PrimaryControlHandle)> {
6377        if let PrimaryRequest::BufferRangeOp2 { op, range, control_handle } = self {
6378            Some((op, range, control_handle))
6379        } else {
6380            None
6381        }
6382    }
6383
6384    #[allow(irrefutable_let_patterns)]
6385    pub fn into_enable_flow_control(self) -> Option<(PrimaryControlHandle)> {
6386        if let PrimaryRequest::EnableFlowControl { control_handle } = self {
6387            Some((control_handle))
6388        } else {
6389            None
6390        }
6391    }
6392
6393    #[allow(irrefutable_let_patterns)]
6394    pub fn into_enable_performance_counter_access(
6395        self,
6396    ) -> Option<(fidl::Event, PrimaryControlHandle)> {
6397        if let PrimaryRequest::EnablePerformanceCounterAccess { access_token, control_handle } =
6398            self
6399        {
6400            Some((access_token, control_handle))
6401        } else {
6402            None
6403        }
6404    }
6405
6406    #[allow(irrefutable_let_patterns)]
6407    pub fn into_is_performance_counter_access_allowed(
6408        self,
6409    ) -> Option<(PrimaryIsPerformanceCounterAccessAllowedResponder)> {
6410        if let PrimaryRequest::IsPerformanceCounterAccessAllowed { responder } = self {
6411            Some((responder))
6412        } else {
6413            None
6414        }
6415    }
6416
6417    #[allow(irrefutable_let_patterns)]
6418    pub fn into_enable_performance_counters(self) -> Option<(Vec<u64>, PrimaryControlHandle)> {
6419        if let PrimaryRequest::EnablePerformanceCounters { counters, control_handle } = self {
6420            Some((counters, control_handle))
6421        } else {
6422            None
6423        }
6424    }
6425
6426    #[allow(irrefutable_let_patterns)]
6427    pub fn into_create_performance_counter_buffer_pool(
6428        self,
6429    ) -> Option<(
6430        u64,
6431        fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
6432        PrimaryControlHandle,
6433    )> {
6434        if let PrimaryRequest::CreatePerformanceCounterBufferPool {
6435            pool_id,
6436            event_channel,
6437            control_handle,
6438        } = self
6439        {
6440            Some((pool_id, event_channel, control_handle))
6441        } else {
6442            None
6443        }
6444    }
6445
6446    #[allow(irrefutable_let_patterns)]
6447    pub fn into_release_performance_counter_buffer_pool(
6448        self,
6449    ) -> Option<(u64, PrimaryControlHandle)> {
6450        if let PrimaryRequest::ReleasePerformanceCounterBufferPool { pool_id, control_handle } =
6451            self
6452        {
6453            Some((pool_id, control_handle))
6454        } else {
6455            None
6456        }
6457    }
6458
6459    #[allow(irrefutable_let_patterns)]
6460    pub fn into_add_performance_counter_buffer_offsets_to_pool(
6461        self,
6462    ) -> Option<(u64, Vec<BufferRange>, PrimaryControlHandle)> {
6463        if let PrimaryRequest::AddPerformanceCounterBufferOffsetsToPool {
6464            pool_id,
6465            offsets,
6466            control_handle,
6467        } = self
6468        {
6469            Some((pool_id, offsets, control_handle))
6470        } else {
6471            None
6472        }
6473    }
6474
6475    #[allow(irrefutable_let_patterns)]
6476    pub fn into_remove_performance_counter_buffer_from_pool(
6477        self,
6478    ) -> Option<(u64, u64, PrimaryControlHandle)> {
6479        if let PrimaryRequest::RemovePerformanceCounterBufferFromPool {
6480            pool_id,
6481            buffer_id,
6482            control_handle,
6483        } = self
6484        {
6485            Some((pool_id, buffer_id, control_handle))
6486        } else {
6487            None
6488        }
6489    }
6490
6491    #[allow(irrefutable_let_patterns)]
6492    pub fn into_dump_performance_counters(self) -> Option<(u64, u32, PrimaryControlHandle)> {
6493        if let PrimaryRequest::DumpPerformanceCounters { pool_id, trigger_id, control_handle } =
6494            self
6495        {
6496            Some((pool_id, trigger_id, control_handle))
6497        } else {
6498            None
6499        }
6500    }
6501
6502    #[allow(irrefutable_let_patterns)]
6503    pub fn into_clear_performance_counters(self) -> Option<(Vec<u64>, PrimaryControlHandle)> {
6504        if let PrimaryRequest::ClearPerformanceCounters { counters, control_handle } = self {
6505            Some((counters, control_handle))
6506        } else {
6507            None
6508        }
6509    }
6510
6511    /// Name of the method defined in FIDL
6512    pub fn method_name(&self) -> &'static str {
6513        match *self {
6514            PrimaryRequest::ImportObject2 { .. } => "import_object2",
6515            PrimaryRequest::ImportObject { .. } => "import_object",
6516            PrimaryRequest::ReleaseObject { .. } => "release_object",
6517            PrimaryRequest::CreateContext { .. } => "create_context",
6518            PrimaryRequest::CreateContext2 { .. } => "create_context2",
6519            PrimaryRequest::DestroyContext { .. } => "destroy_context",
6520            PrimaryRequest::ExecuteCommand { .. } => "execute_command",
6521            PrimaryRequest::ExecuteImmediateCommands { .. } => "execute_immediate_commands",
6522            PrimaryRequest::ExecuteInlineCommands { .. } => "execute_inline_commands",
6523            PrimaryRequest::Flush { .. } => "flush",
6524            PrimaryRequest::MapBuffer { .. } => "map_buffer",
6525            PrimaryRequest::UnmapBuffer { .. } => "unmap_buffer",
6526            PrimaryRequest::BufferRangeOp2 { .. } => "buffer_range_op2",
6527            PrimaryRequest::EnableFlowControl { .. } => "enable_flow_control",
6528            PrimaryRequest::EnablePerformanceCounterAccess { .. } => {
6529                "enable_performance_counter_access"
6530            }
6531            PrimaryRequest::IsPerformanceCounterAccessAllowed { .. } => {
6532                "is_performance_counter_access_allowed"
6533            }
6534            PrimaryRequest::EnablePerformanceCounters { .. } => "enable_performance_counters",
6535            PrimaryRequest::CreatePerformanceCounterBufferPool { .. } => {
6536                "create_performance_counter_buffer_pool"
6537            }
6538            PrimaryRequest::ReleasePerformanceCounterBufferPool { .. } => {
6539                "release_performance_counter_buffer_pool"
6540            }
6541            PrimaryRequest::AddPerformanceCounterBufferOffsetsToPool { .. } => {
6542                "add_performance_counter_buffer_offsets_to_pool"
6543            }
6544            PrimaryRequest::RemovePerformanceCounterBufferFromPool { .. } => {
6545                "remove_performance_counter_buffer_from_pool"
6546            }
6547            PrimaryRequest::DumpPerformanceCounters { .. } => "dump_performance_counters",
6548            PrimaryRequest::ClearPerformanceCounters { .. } => "clear_performance_counters",
6549        }
6550    }
6551}
6552
6553#[derive(Debug, Clone)]
6554pub struct PrimaryControlHandle {
6555    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6556}
6557
6558impl fidl::endpoints::ControlHandle for PrimaryControlHandle {
6559    fn shutdown(&self) {
6560        self.inner.shutdown()
6561    }
6562    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6563        self.inner.shutdown_with_epitaph(status)
6564    }
6565
6566    fn is_closed(&self) -> bool {
6567        self.inner.channel().is_closed()
6568    }
6569    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6570        self.inner.channel().on_closed()
6571    }
6572
6573    #[cfg(target_os = "fuchsia")]
6574    fn signal_peer(
6575        &self,
6576        clear_mask: zx::Signals,
6577        set_mask: zx::Signals,
6578    ) -> Result<(), zx_status::Status> {
6579        use fidl::Peered;
6580        self.inner.channel().signal_peer(clear_mask, set_mask)
6581    }
6582}
6583
6584impl PrimaryControlHandle {
6585    pub fn send_on_notify_messages_consumed(&self, mut count: u64) -> Result<(), fidl::Error> {
6586        self.inner.send::<PrimaryOnNotifyMessagesConsumedRequest>(
6587            (count,),
6588            0,
6589            0x5e8dd0b0b753ac43,
6590            fidl::encoding::DynamicFlags::empty(),
6591        )
6592    }
6593
6594    pub fn send_on_notify_memory_imported(&self, mut bytes: u64) -> Result<(), fidl::Error> {
6595        self.inner.send::<PrimaryOnNotifyMemoryImportedRequest>(
6596            (bytes,),
6597            0,
6598            0x50524b7a3503aba6,
6599            fidl::encoding::DynamicFlags::empty(),
6600        )
6601    }
6602}
6603
6604#[must_use = "FIDL methods require a response to be sent"]
6605#[derive(Debug)]
6606pub struct PrimaryFlushResponder {
6607    control_handle: std::mem::ManuallyDrop<PrimaryControlHandle>,
6608    tx_id: u32,
6609}
6610
6611/// Set the the channel to be shutdown (see [`PrimaryControlHandle::shutdown`])
6612/// if the responder is dropped without sending a response, so that the client
6613/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6614impl std::ops::Drop for PrimaryFlushResponder {
6615    fn drop(&mut self) {
6616        self.control_handle.shutdown();
6617        // Safety: drops once, never accessed again
6618        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6619    }
6620}
6621
6622impl fidl::endpoints::Responder for PrimaryFlushResponder {
6623    type ControlHandle = PrimaryControlHandle;
6624
6625    fn control_handle(&self) -> &PrimaryControlHandle {
6626        &self.control_handle
6627    }
6628
6629    fn drop_without_shutdown(mut self) {
6630        // Safety: drops once, never accessed again due to mem::forget
6631        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6632        // Prevent Drop from running (which would shut down the channel)
6633        std::mem::forget(self);
6634    }
6635}
6636
6637impl PrimaryFlushResponder {
6638    /// Sends a response to the FIDL transaction.
6639    ///
6640    /// Sets the channel to shutdown if an error occurs.
6641    pub fn send(self) -> Result<(), fidl::Error> {
6642        let _result = self.send_raw();
6643        if _result.is_err() {
6644            self.control_handle.shutdown();
6645        }
6646        self.drop_without_shutdown();
6647        _result
6648    }
6649
6650    /// Similar to "send" but does not shutdown the channel if an error occurs.
6651    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6652        let _result = self.send_raw();
6653        self.drop_without_shutdown();
6654        _result
6655    }
6656
6657    fn send_raw(&self) -> Result<(), fidl::Error> {
6658        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6659            (),
6660            self.tx_id,
6661            0x54ccb5572d886039,
6662            fidl::encoding::DynamicFlags::empty(),
6663        )
6664    }
6665}
6666
6667#[must_use = "FIDL methods require a response to be sent"]
6668#[derive(Debug)]
6669pub struct PrimaryIsPerformanceCounterAccessAllowedResponder {
6670    control_handle: std::mem::ManuallyDrop<PrimaryControlHandle>,
6671    tx_id: u32,
6672}
6673
6674/// Set the the channel to be shutdown (see [`PrimaryControlHandle::shutdown`])
6675/// if the responder is dropped without sending a response, so that the client
6676/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6677impl std::ops::Drop for PrimaryIsPerformanceCounterAccessAllowedResponder {
6678    fn drop(&mut self) {
6679        self.control_handle.shutdown();
6680        // Safety: drops once, never accessed again
6681        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6682    }
6683}
6684
6685impl fidl::endpoints::Responder for PrimaryIsPerformanceCounterAccessAllowedResponder {
6686    type ControlHandle = PrimaryControlHandle;
6687
6688    fn control_handle(&self) -> &PrimaryControlHandle {
6689        &self.control_handle
6690    }
6691
6692    fn drop_without_shutdown(mut self) {
6693        // Safety: drops once, never accessed again due to mem::forget
6694        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6695        // Prevent Drop from running (which would shut down the channel)
6696        std::mem::forget(self);
6697    }
6698}
6699
6700impl PrimaryIsPerformanceCounterAccessAllowedResponder {
6701    /// Sends a response to the FIDL transaction.
6702    ///
6703    /// Sets the channel to shutdown if an error occurs.
6704    pub fn send(self, mut enabled: bool) -> Result<(), fidl::Error> {
6705        let _result = self.send_raw(enabled);
6706        if _result.is_err() {
6707            self.control_handle.shutdown();
6708        }
6709        self.drop_without_shutdown();
6710        _result
6711    }
6712
6713    /// Similar to "send" but does not shutdown the channel if an error occurs.
6714    pub fn send_no_shutdown_on_err(self, mut enabled: bool) -> Result<(), fidl::Error> {
6715        let _result = self.send_raw(enabled);
6716        self.drop_without_shutdown();
6717        _result
6718    }
6719
6720    fn send_raw(&self, mut enabled: bool) -> Result<(), fidl::Error> {
6721        self.control_handle.inner.send::<PrimaryIsPerformanceCounterAccessAllowedResponse>(
6722            (enabled,),
6723            self.tx_id,
6724            0x1933b70c06cc5702,
6725            fidl::encoding::DynamicFlags::empty(),
6726        )
6727    }
6728}
6729
6730#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6731pub struct TestDeviceMarker;
6732
6733impl fidl::endpoints::ProtocolMarker for TestDeviceMarker {
6734    type Proxy = TestDeviceProxy;
6735    type RequestStream = TestDeviceRequestStream;
6736    #[cfg(target_os = "fuchsia")]
6737    type SynchronousProxy = TestDeviceSynchronousProxy;
6738
6739    const DEBUG_NAME: &'static str = "(anonymous) TestDevice";
6740}
6741
6742pub trait TestDeviceProxyInterface: Send + Sync {
6743    type QueryResponseFut: std::future::Future<Output = Result<DeviceQueryResult, fidl::Error>>
6744        + Send;
6745    fn r#query(&self, query_id: QueryId) -> Self::QueryResponseFut;
6746    fn r#connect2(
6747        &self,
6748        client_id: u64,
6749        primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
6750        notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
6751    ) -> Result<(), fidl::Error>;
6752    fn r#dump_state(&self, dump_type: u32) -> Result<(), fidl::Error>;
6753    type GetIcdListResponseFut: std::future::Future<Output = Result<Vec<IcdInfo>, fidl::Error>>
6754        + Send;
6755    fn r#get_icd_list(&self) -> Self::GetIcdListResponseFut;
6756    type GetUnitTestStatusResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
6757    fn r#get_unit_test_status(&self) -> Self::GetUnitTestStatusResponseFut;
6758}
6759#[derive(Debug)]
6760#[cfg(target_os = "fuchsia")]
6761pub struct TestDeviceSynchronousProxy {
6762    client: fidl::client::sync::Client,
6763}
6764
6765#[cfg(target_os = "fuchsia")]
6766impl fidl::endpoints::SynchronousProxy for TestDeviceSynchronousProxy {
6767    type Proxy = TestDeviceProxy;
6768    type Protocol = TestDeviceMarker;
6769
6770    fn from_channel(inner: fidl::Channel) -> Self {
6771        Self::new(inner)
6772    }
6773
6774    fn into_channel(self) -> fidl::Channel {
6775        self.client.into_channel()
6776    }
6777
6778    fn as_channel(&self) -> &fidl::Channel {
6779        self.client.as_channel()
6780    }
6781}
6782
6783#[cfg(target_os = "fuchsia")]
6784impl TestDeviceSynchronousProxy {
6785    pub fn new(channel: fidl::Channel) -> Self {
6786        let protocol_name = <TestDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6787        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6788    }
6789
6790    pub fn into_channel(self) -> fidl::Channel {
6791        self.client.into_channel()
6792    }
6793
6794    /// Waits until an event arrives and returns it. It is safe for other
6795    /// threads to make concurrent requests while waiting for an event.
6796    pub fn wait_for_event(
6797        &self,
6798        deadline: zx::MonotonicInstant,
6799    ) -> Result<TestDeviceEvent, fidl::Error> {
6800        TestDeviceEvent::decode(self.client.wait_for_event(deadline)?)
6801    }
6802
6803    /// On success, returns a result either in a buffer or a simple value.
6804    pub fn r#query(
6805        &self,
6806        mut query_id: QueryId,
6807        ___deadline: zx::MonotonicInstant,
6808    ) -> Result<DeviceQueryResult, fidl::Error> {
6809        let _response = self
6810            .client
6811            .send_query::<DeviceQueryRequest, fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
6812                (query_id,),
6813                0x627d4c6093b078e7,
6814                fidl::encoding::DynamicFlags::empty(),
6815                ___deadline,
6816            )?;
6817        Ok(_response.map(|x| x))
6818    }
6819
6820    /// Creates a connection to the device comprised of two IPC channels.
6821    /// The primary channel is for the Primary protocol (see below).  The notification channel is
6822    /// used for vendor-specific messages which are sent only in the reverse (server-client)
6823    /// direction, typically in response to client command completion.
6824    pub fn r#connect2(
6825        &self,
6826        mut client_id: u64,
6827        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
6828        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
6829    ) -> Result<(), fidl::Error> {
6830        self.client.send::<DeviceConnect2Request>(
6831            (client_id, primary_channel, notification_channel),
6832            0x3a5b134714c67914,
6833            fidl::encoding::DynamicFlags::empty(),
6834        )
6835    }
6836
6837    /// Dumps driver and hardware state to the log.
6838    pub fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
6839        self.client.send::<DiagnosticDeviceDumpStateRequest>(
6840            (dump_type,),
6841            0x5420df493d4fa915,
6842            fidl::encoding::DynamicFlags::empty(),
6843        )
6844    }
6845
6846    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
6847    /// descending order of preference.
6848    pub fn r#get_icd_list(
6849        &self,
6850        ___deadline: zx::MonotonicInstant,
6851    ) -> Result<Vec<IcdInfo>, fidl::Error> {
6852        let _response = self
6853            .client
6854            .send_query::<fidl::encoding::EmptyPayload, IcdLoaderDeviceGetIcdListResponse>(
6855                (),
6856                0x7673e76395008257,
6857                fidl::encoding::DynamicFlags::empty(),
6858                ___deadline,
6859            )?;
6860        Ok(_response.icd_list)
6861    }
6862
6863    pub fn r#get_unit_test_status(
6864        &self,
6865        ___deadline: zx::MonotonicInstant,
6866    ) -> Result<i32, fidl::Error> {
6867        let _response = self
6868            .client
6869            .send_query::<fidl::encoding::EmptyPayload, TestDeviceGetUnitTestStatusResponse>(
6870                (),
6871                0x3ebcd9c409c248f1,
6872                fidl::encoding::DynamicFlags::empty(),
6873                ___deadline,
6874            )?;
6875        Ok(_response.status)
6876    }
6877}
6878
6879#[cfg(target_os = "fuchsia")]
6880impl From<TestDeviceSynchronousProxy> for zx::Handle {
6881    fn from(value: TestDeviceSynchronousProxy) -> Self {
6882        value.into_channel().into()
6883    }
6884}
6885
6886#[cfg(target_os = "fuchsia")]
6887impl From<fidl::Channel> for TestDeviceSynchronousProxy {
6888    fn from(value: fidl::Channel) -> Self {
6889        Self::new(value)
6890    }
6891}
6892
6893#[derive(Debug, Clone)]
6894pub struct TestDeviceProxy {
6895    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6896}
6897
6898impl fidl::endpoints::Proxy for TestDeviceProxy {
6899    type Protocol = TestDeviceMarker;
6900
6901    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6902        Self::new(inner)
6903    }
6904
6905    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6906        self.client.into_channel().map_err(|client| Self { client })
6907    }
6908
6909    fn as_channel(&self) -> &::fidl::AsyncChannel {
6910        self.client.as_channel()
6911    }
6912}
6913
6914impl TestDeviceProxy {
6915    /// Create a new Proxy for fuchsia.gpu.magma/TestDevice.
6916    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6917        let protocol_name = <TestDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6918        Self { client: fidl::client::Client::new(channel, protocol_name) }
6919    }
6920
6921    /// Get a Stream of events from the remote end of the protocol.
6922    ///
6923    /// # Panics
6924    ///
6925    /// Panics if the event stream was already taken.
6926    pub fn take_event_stream(&self) -> TestDeviceEventStream {
6927        TestDeviceEventStream { event_receiver: self.client.take_event_receiver() }
6928    }
6929
6930    /// On success, returns a result either in a buffer or a simple value.
6931    pub fn r#query(
6932        &self,
6933        mut query_id: QueryId,
6934    ) -> fidl::client::QueryResponseFut<
6935        DeviceQueryResult,
6936        fidl::encoding::DefaultFuchsiaResourceDialect,
6937    > {
6938        TestDeviceProxyInterface::r#query(self, query_id)
6939    }
6940
6941    /// Creates a connection to the device comprised of two IPC channels.
6942    /// The primary channel is for the Primary protocol (see below).  The notification channel is
6943    /// used for vendor-specific messages which are sent only in the reverse (server-client)
6944    /// direction, typically in response to client command completion.
6945    pub fn r#connect2(
6946        &self,
6947        mut client_id: u64,
6948        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
6949        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
6950    ) -> Result<(), fidl::Error> {
6951        TestDeviceProxyInterface::r#connect2(self, client_id, primary_channel, notification_channel)
6952    }
6953
6954    /// Dumps driver and hardware state to the log.
6955    pub fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
6956        TestDeviceProxyInterface::r#dump_state(self, dump_type)
6957    }
6958
6959    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
6960    /// descending order of preference.
6961    pub fn r#get_icd_list(
6962        &self,
6963    ) -> fidl::client::QueryResponseFut<Vec<IcdInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>
6964    {
6965        TestDeviceProxyInterface::r#get_icd_list(self)
6966    }
6967
6968    pub fn r#get_unit_test_status(
6969        &self,
6970    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
6971        TestDeviceProxyInterface::r#get_unit_test_status(self)
6972    }
6973}
6974
6975impl TestDeviceProxyInterface for TestDeviceProxy {
6976    type QueryResponseFut = fidl::client::QueryResponseFut<
6977        DeviceQueryResult,
6978        fidl::encoding::DefaultFuchsiaResourceDialect,
6979    >;
6980    fn r#query(&self, mut query_id: QueryId) -> Self::QueryResponseFut {
6981        fn _decode(
6982            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6983        ) -> Result<DeviceQueryResult, fidl::Error> {
6984            let _response = fidl::client::decode_transaction_body::<
6985                fidl::encoding::ResultType<DeviceQueryResponse, i32>,
6986                fidl::encoding::DefaultFuchsiaResourceDialect,
6987                0x627d4c6093b078e7,
6988            >(_buf?)?;
6989            Ok(_response.map(|x| x))
6990        }
6991        self.client.send_query_and_decode::<DeviceQueryRequest, DeviceQueryResult>(
6992            (query_id,),
6993            0x627d4c6093b078e7,
6994            fidl::encoding::DynamicFlags::empty(),
6995            _decode,
6996        )
6997    }
6998
6999    fn r#connect2(
7000        &self,
7001        mut client_id: u64,
7002        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
7003        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
7004    ) -> Result<(), fidl::Error> {
7005        self.client.send::<DeviceConnect2Request>(
7006            (client_id, primary_channel, notification_channel),
7007            0x3a5b134714c67914,
7008            fidl::encoding::DynamicFlags::empty(),
7009        )
7010    }
7011
7012    fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
7013        self.client.send::<DiagnosticDeviceDumpStateRequest>(
7014            (dump_type,),
7015            0x5420df493d4fa915,
7016            fidl::encoding::DynamicFlags::empty(),
7017        )
7018    }
7019
7020    type GetIcdListResponseFut =
7021        fidl::client::QueryResponseFut<Vec<IcdInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>;
7022    fn r#get_icd_list(&self) -> Self::GetIcdListResponseFut {
7023        fn _decode(
7024            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7025        ) -> Result<Vec<IcdInfo>, fidl::Error> {
7026            let _response = fidl::client::decode_transaction_body::<
7027                IcdLoaderDeviceGetIcdListResponse,
7028                fidl::encoding::DefaultFuchsiaResourceDialect,
7029                0x7673e76395008257,
7030            >(_buf?)?;
7031            Ok(_response.icd_list)
7032        }
7033        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<IcdInfo>>(
7034            (),
7035            0x7673e76395008257,
7036            fidl::encoding::DynamicFlags::empty(),
7037            _decode,
7038        )
7039    }
7040
7041    type GetUnitTestStatusResponseFut =
7042        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
7043    fn r#get_unit_test_status(&self) -> Self::GetUnitTestStatusResponseFut {
7044        fn _decode(
7045            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7046        ) -> Result<i32, fidl::Error> {
7047            let _response = fidl::client::decode_transaction_body::<
7048                TestDeviceGetUnitTestStatusResponse,
7049                fidl::encoding::DefaultFuchsiaResourceDialect,
7050                0x3ebcd9c409c248f1,
7051            >(_buf?)?;
7052            Ok(_response.status)
7053        }
7054        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
7055            (),
7056            0x3ebcd9c409c248f1,
7057            fidl::encoding::DynamicFlags::empty(),
7058            _decode,
7059        )
7060    }
7061}
7062
7063pub struct TestDeviceEventStream {
7064    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7065}
7066
7067impl std::marker::Unpin for TestDeviceEventStream {}
7068
7069impl futures::stream::FusedStream for TestDeviceEventStream {
7070    fn is_terminated(&self) -> bool {
7071        self.event_receiver.is_terminated()
7072    }
7073}
7074
7075impl futures::Stream for TestDeviceEventStream {
7076    type Item = Result<TestDeviceEvent, fidl::Error>;
7077
7078    fn poll_next(
7079        mut self: std::pin::Pin<&mut Self>,
7080        cx: &mut std::task::Context<'_>,
7081    ) -> std::task::Poll<Option<Self::Item>> {
7082        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7083            &mut self.event_receiver,
7084            cx
7085        )?) {
7086            Some(buf) => std::task::Poll::Ready(Some(TestDeviceEvent::decode(buf))),
7087            None => std::task::Poll::Ready(None),
7088        }
7089    }
7090}
7091
7092#[derive(Debug)]
7093pub enum TestDeviceEvent {}
7094
7095impl TestDeviceEvent {
7096    /// Decodes a message buffer as a [`TestDeviceEvent`].
7097    fn decode(
7098        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7099    ) -> Result<TestDeviceEvent, fidl::Error> {
7100        let (bytes, _handles) = buf.split_mut();
7101        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7102        debug_assert_eq!(tx_header.tx_id, 0);
7103        match tx_header.ordinal {
7104            _ => Err(fidl::Error::UnknownOrdinal {
7105                ordinal: tx_header.ordinal,
7106                protocol_name: <TestDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7107            }),
7108        }
7109    }
7110}
7111
7112/// A Stream of incoming requests for fuchsia.gpu.magma/TestDevice.
7113pub struct TestDeviceRequestStream {
7114    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7115    is_terminated: bool,
7116}
7117
7118impl std::marker::Unpin for TestDeviceRequestStream {}
7119
7120impl futures::stream::FusedStream for TestDeviceRequestStream {
7121    fn is_terminated(&self) -> bool {
7122        self.is_terminated
7123    }
7124}
7125
7126impl fidl::endpoints::RequestStream for TestDeviceRequestStream {
7127    type Protocol = TestDeviceMarker;
7128    type ControlHandle = TestDeviceControlHandle;
7129
7130    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7131        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7132    }
7133
7134    fn control_handle(&self) -> Self::ControlHandle {
7135        TestDeviceControlHandle { inner: self.inner.clone() }
7136    }
7137
7138    fn into_inner(
7139        self,
7140    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7141    {
7142        (self.inner, self.is_terminated)
7143    }
7144
7145    fn from_inner(
7146        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7147        is_terminated: bool,
7148    ) -> Self {
7149        Self { inner, is_terminated }
7150    }
7151}
7152
7153impl futures::Stream for TestDeviceRequestStream {
7154    type Item = Result<TestDeviceRequest, fidl::Error>;
7155
7156    fn poll_next(
7157        mut self: std::pin::Pin<&mut Self>,
7158        cx: &mut std::task::Context<'_>,
7159    ) -> std::task::Poll<Option<Self::Item>> {
7160        let this = &mut *self;
7161        if this.inner.check_shutdown(cx) {
7162            this.is_terminated = true;
7163            return std::task::Poll::Ready(None);
7164        }
7165        if this.is_terminated {
7166            panic!("polled TestDeviceRequestStream after completion");
7167        }
7168        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7169            |bytes, handles| {
7170                match this.inner.channel().read_etc(cx, bytes, handles) {
7171                    std::task::Poll::Ready(Ok(())) => {}
7172                    std::task::Poll::Pending => return std::task::Poll::Pending,
7173                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7174                        this.is_terminated = true;
7175                        return std::task::Poll::Ready(None);
7176                    }
7177                    std::task::Poll::Ready(Err(e)) => {
7178                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7179                            e.into(),
7180                        ))))
7181                    }
7182                }
7183
7184                // A message has been received from the channel
7185                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7186
7187                std::task::Poll::Ready(Some(match header.ordinal {
7188                    0x627d4c6093b078e7 => {
7189                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7190                        let mut req = fidl::new_empty!(
7191                            DeviceQueryRequest,
7192                            fidl::encoding::DefaultFuchsiaResourceDialect
7193                        );
7194                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceQueryRequest>(&header, _body_bytes, handles, &mut req)?;
7195                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7196                        Ok(TestDeviceRequest::Query {
7197                            query_id: req.query_id,
7198
7199                            responder: TestDeviceQueryResponder {
7200                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7201                                tx_id: header.tx_id,
7202                            },
7203                        })
7204                    }
7205                    0x3a5b134714c67914 => {
7206                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7207                        let mut req = fidl::new_empty!(
7208                            DeviceConnect2Request,
7209                            fidl::encoding::DefaultFuchsiaResourceDialect
7210                        );
7211                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceConnect2Request>(&header, _body_bytes, handles, &mut req)?;
7212                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7213                        Ok(TestDeviceRequest::Connect2 {
7214                            client_id: req.client_id,
7215                            primary_channel: req.primary_channel,
7216                            notification_channel: req.notification_channel,
7217
7218                            control_handle,
7219                        })
7220                    }
7221                    0x5420df493d4fa915 => {
7222                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7223                        let mut req = fidl::new_empty!(
7224                            DiagnosticDeviceDumpStateRequest,
7225                            fidl::encoding::DefaultFuchsiaResourceDialect
7226                        );
7227                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DiagnosticDeviceDumpStateRequest>(&header, _body_bytes, handles, &mut req)?;
7228                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7229                        Ok(TestDeviceRequest::DumpState {
7230                            dump_type: req.dump_type,
7231
7232                            control_handle,
7233                        })
7234                    }
7235                    0x7673e76395008257 => {
7236                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7237                        let mut req = fidl::new_empty!(
7238                            fidl::encoding::EmptyPayload,
7239                            fidl::encoding::DefaultFuchsiaResourceDialect
7240                        );
7241                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7242                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7243                        Ok(TestDeviceRequest::GetIcdList {
7244                            responder: TestDeviceGetIcdListResponder {
7245                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7246                                tx_id: header.tx_id,
7247                            },
7248                        })
7249                    }
7250                    0x3ebcd9c409c248f1 => {
7251                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7252                        let mut req = fidl::new_empty!(
7253                            fidl::encoding::EmptyPayload,
7254                            fidl::encoding::DefaultFuchsiaResourceDialect
7255                        );
7256                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7257                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7258                        Ok(TestDeviceRequest::GetUnitTestStatus {
7259                            responder: TestDeviceGetUnitTestStatusResponder {
7260                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7261                                tx_id: header.tx_id,
7262                            },
7263                        })
7264                    }
7265                    _ => Err(fidl::Error::UnknownOrdinal {
7266                        ordinal: header.ordinal,
7267                        protocol_name:
7268                            <TestDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7269                    }),
7270                }))
7271            },
7272        )
7273    }
7274}
7275
7276/// Additional device methods for the purposes of testing the MSD and should not be used by ICDs.
7277/// DEPRECATED: Please use TestDevice2.
7278#[derive(Debug)]
7279pub enum TestDeviceRequest {
7280    /// On success, returns a result either in a buffer or a simple value.
7281    Query {
7282        query_id: QueryId,
7283        responder: TestDeviceQueryResponder,
7284    },
7285    /// Creates a connection to the device comprised of two IPC channels.
7286    /// The primary channel is for the Primary protocol (see below).  The notification channel is
7287    /// used for vendor-specific messages which are sent only in the reverse (server-client)
7288    /// direction, typically in response to client command completion.
7289    Connect2 {
7290        client_id: u64,
7291        primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
7292        notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
7293        control_handle: TestDeviceControlHandle,
7294    },
7295    /// Dumps driver and hardware state to the log.
7296    DumpState {
7297        dump_type: u32,
7298        control_handle: TestDeviceControlHandle,
7299    },
7300    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
7301    /// descending order of preference.
7302    GetIcdList {
7303        responder: TestDeviceGetIcdListResponder,
7304    },
7305    GetUnitTestStatus {
7306        responder: TestDeviceGetUnitTestStatusResponder,
7307    },
7308}
7309
7310impl TestDeviceRequest {
7311    #[allow(irrefutable_let_patterns)]
7312    pub fn into_query(self) -> Option<(QueryId, TestDeviceQueryResponder)> {
7313        if let TestDeviceRequest::Query { query_id, responder } = self {
7314            Some((query_id, responder))
7315        } else {
7316            None
7317        }
7318    }
7319
7320    #[allow(irrefutable_let_patterns)]
7321    pub fn into_connect2(
7322        self,
7323    ) -> Option<(
7324        u64,
7325        fidl::endpoints::ServerEnd<PrimaryMarker>,
7326        fidl::endpoints::ServerEnd<NotificationMarker>,
7327        TestDeviceControlHandle,
7328    )> {
7329        if let TestDeviceRequest::Connect2 {
7330            client_id,
7331            primary_channel,
7332            notification_channel,
7333            control_handle,
7334        } = self
7335        {
7336            Some((client_id, primary_channel, notification_channel, control_handle))
7337        } else {
7338            None
7339        }
7340    }
7341
7342    #[allow(irrefutable_let_patterns)]
7343    pub fn into_dump_state(self) -> Option<(u32, TestDeviceControlHandle)> {
7344        if let TestDeviceRequest::DumpState { dump_type, control_handle } = self {
7345            Some((dump_type, control_handle))
7346        } else {
7347            None
7348        }
7349    }
7350
7351    #[allow(irrefutable_let_patterns)]
7352    pub fn into_get_icd_list(self) -> Option<(TestDeviceGetIcdListResponder)> {
7353        if let TestDeviceRequest::GetIcdList { responder } = self {
7354            Some((responder))
7355        } else {
7356            None
7357        }
7358    }
7359
7360    #[allow(irrefutable_let_patterns)]
7361    pub fn into_get_unit_test_status(self) -> Option<(TestDeviceGetUnitTestStatusResponder)> {
7362        if let TestDeviceRequest::GetUnitTestStatus { responder } = self {
7363            Some((responder))
7364        } else {
7365            None
7366        }
7367    }
7368
7369    /// Name of the method defined in FIDL
7370    pub fn method_name(&self) -> &'static str {
7371        match *self {
7372            TestDeviceRequest::Query { .. } => "query",
7373            TestDeviceRequest::Connect2 { .. } => "connect2",
7374            TestDeviceRequest::DumpState { .. } => "dump_state",
7375            TestDeviceRequest::GetIcdList { .. } => "get_icd_list",
7376            TestDeviceRequest::GetUnitTestStatus { .. } => "get_unit_test_status",
7377        }
7378    }
7379}
7380
7381#[derive(Debug, Clone)]
7382pub struct TestDeviceControlHandle {
7383    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7384}
7385
7386impl fidl::endpoints::ControlHandle for TestDeviceControlHandle {
7387    fn shutdown(&self) {
7388        self.inner.shutdown()
7389    }
7390    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7391        self.inner.shutdown_with_epitaph(status)
7392    }
7393
7394    fn is_closed(&self) -> bool {
7395        self.inner.channel().is_closed()
7396    }
7397    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7398        self.inner.channel().on_closed()
7399    }
7400
7401    #[cfg(target_os = "fuchsia")]
7402    fn signal_peer(
7403        &self,
7404        clear_mask: zx::Signals,
7405        set_mask: zx::Signals,
7406    ) -> Result<(), zx_status::Status> {
7407        use fidl::Peered;
7408        self.inner.channel().signal_peer(clear_mask, set_mask)
7409    }
7410}
7411
7412impl TestDeviceControlHandle {}
7413
7414#[must_use = "FIDL methods require a response to be sent"]
7415#[derive(Debug)]
7416pub struct TestDeviceQueryResponder {
7417    control_handle: std::mem::ManuallyDrop<TestDeviceControlHandle>,
7418    tx_id: u32,
7419}
7420
7421/// Set the the channel to be shutdown (see [`TestDeviceControlHandle::shutdown`])
7422/// if the responder is dropped without sending a response, so that the client
7423/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7424impl std::ops::Drop for TestDeviceQueryResponder {
7425    fn drop(&mut self) {
7426        self.control_handle.shutdown();
7427        // Safety: drops once, never accessed again
7428        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7429    }
7430}
7431
7432impl fidl::endpoints::Responder for TestDeviceQueryResponder {
7433    type ControlHandle = TestDeviceControlHandle;
7434
7435    fn control_handle(&self) -> &TestDeviceControlHandle {
7436        &self.control_handle
7437    }
7438
7439    fn drop_without_shutdown(mut self) {
7440        // Safety: drops once, never accessed again due to mem::forget
7441        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7442        // Prevent Drop from running (which would shut down the channel)
7443        std::mem::forget(self);
7444    }
7445}
7446
7447impl TestDeviceQueryResponder {
7448    /// Sends a response to the FIDL transaction.
7449    ///
7450    /// Sets the channel to shutdown if an error occurs.
7451    pub fn send(self, mut result: Result<DeviceQueryResponse, i32>) -> Result<(), fidl::Error> {
7452        let _result = self.send_raw(result);
7453        if _result.is_err() {
7454            self.control_handle.shutdown();
7455        }
7456        self.drop_without_shutdown();
7457        _result
7458    }
7459
7460    /// Similar to "send" but does not shutdown the channel if an error occurs.
7461    pub fn send_no_shutdown_on_err(
7462        self,
7463        mut result: Result<DeviceQueryResponse, i32>,
7464    ) -> Result<(), fidl::Error> {
7465        let _result = self.send_raw(result);
7466        self.drop_without_shutdown();
7467        _result
7468    }
7469
7470    fn send_raw(&self, mut result: Result<DeviceQueryResponse, i32>) -> Result<(), fidl::Error> {
7471        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
7472            result.as_mut().map_err(|e| *e),
7473            self.tx_id,
7474            0x627d4c6093b078e7,
7475            fidl::encoding::DynamicFlags::empty(),
7476        )
7477    }
7478}
7479
7480#[must_use = "FIDL methods require a response to be sent"]
7481#[derive(Debug)]
7482pub struct TestDeviceGetIcdListResponder {
7483    control_handle: std::mem::ManuallyDrop<TestDeviceControlHandle>,
7484    tx_id: u32,
7485}
7486
7487/// Set the the channel to be shutdown (see [`TestDeviceControlHandle::shutdown`])
7488/// if the responder is dropped without sending a response, so that the client
7489/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7490impl std::ops::Drop for TestDeviceGetIcdListResponder {
7491    fn drop(&mut self) {
7492        self.control_handle.shutdown();
7493        // Safety: drops once, never accessed again
7494        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7495    }
7496}
7497
7498impl fidl::endpoints::Responder for TestDeviceGetIcdListResponder {
7499    type ControlHandle = TestDeviceControlHandle;
7500
7501    fn control_handle(&self) -> &TestDeviceControlHandle {
7502        &self.control_handle
7503    }
7504
7505    fn drop_without_shutdown(mut self) {
7506        // Safety: drops once, never accessed again due to mem::forget
7507        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7508        // Prevent Drop from running (which would shut down the channel)
7509        std::mem::forget(self);
7510    }
7511}
7512
7513impl TestDeviceGetIcdListResponder {
7514    /// Sends a response to the FIDL transaction.
7515    ///
7516    /// Sets the channel to shutdown if an error occurs.
7517    pub fn send(self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
7518        let _result = self.send_raw(icd_list);
7519        if _result.is_err() {
7520            self.control_handle.shutdown();
7521        }
7522        self.drop_without_shutdown();
7523        _result
7524    }
7525
7526    /// Similar to "send" but does not shutdown the channel if an error occurs.
7527    pub fn send_no_shutdown_on_err(self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
7528        let _result = self.send_raw(icd_list);
7529        self.drop_without_shutdown();
7530        _result
7531    }
7532
7533    fn send_raw(&self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
7534        self.control_handle.inner.send::<IcdLoaderDeviceGetIcdListResponse>(
7535            (icd_list,),
7536            self.tx_id,
7537            0x7673e76395008257,
7538            fidl::encoding::DynamicFlags::empty(),
7539        )
7540    }
7541}
7542
7543#[must_use = "FIDL methods require a response to be sent"]
7544#[derive(Debug)]
7545pub struct TestDeviceGetUnitTestStatusResponder {
7546    control_handle: std::mem::ManuallyDrop<TestDeviceControlHandle>,
7547    tx_id: u32,
7548}
7549
7550/// Set the the channel to be shutdown (see [`TestDeviceControlHandle::shutdown`])
7551/// if the responder is dropped without sending a response, so that the client
7552/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7553impl std::ops::Drop for TestDeviceGetUnitTestStatusResponder {
7554    fn drop(&mut self) {
7555        self.control_handle.shutdown();
7556        // Safety: drops once, never accessed again
7557        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7558    }
7559}
7560
7561impl fidl::endpoints::Responder for TestDeviceGetUnitTestStatusResponder {
7562    type ControlHandle = TestDeviceControlHandle;
7563
7564    fn control_handle(&self) -> &TestDeviceControlHandle {
7565        &self.control_handle
7566    }
7567
7568    fn drop_without_shutdown(mut self) {
7569        // Safety: drops once, never accessed again due to mem::forget
7570        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7571        // Prevent Drop from running (which would shut down the channel)
7572        std::mem::forget(self);
7573    }
7574}
7575
7576impl TestDeviceGetUnitTestStatusResponder {
7577    /// Sends a response to the FIDL transaction.
7578    ///
7579    /// Sets the channel to shutdown if an error occurs.
7580    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
7581        let _result = self.send_raw(status);
7582        if _result.is_err() {
7583            self.control_handle.shutdown();
7584        }
7585        self.drop_without_shutdown();
7586        _result
7587    }
7588
7589    /// Similar to "send" but does not shutdown the channel if an error occurs.
7590    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
7591        let _result = self.send_raw(status);
7592        self.drop_without_shutdown();
7593        _result
7594    }
7595
7596    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
7597        self.control_handle.inner.send::<TestDeviceGetUnitTestStatusResponse>(
7598            (status,),
7599            self.tx_id,
7600            0x3ebcd9c409c248f1,
7601            fidl::encoding::DynamicFlags::empty(),
7602        )
7603    }
7604}
7605
7606#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7607pub struct TestDevice2Marker;
7608
7609impl fidl::endpoints::ProtocolMarker for TestDevice2Marker {
7610    type Proxy = TestDevice2Proxy;
7611    type RequestStream = TestDevice2RequestStream;
7612    #[cfg(target_os = "fuchsia")]
7613    type SynchronousProxy = TestDevice2SynchronousProxy;
7614
7615    const DEBUG_NAME: &'static str = "(anonymous) TestDevice2";
7616}
7617
7618pub trait TestDevice2ProxyInterface: Send + Sync {
7619    type GetUnitTestStatusResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
7620    fn r#get_unit_test_status(&self) -> Self::GetUnitTestStatusResponseFut;
7621}
7622#[derive(Debug)]
7623#[cfg(target_os = "fuchsia")]
7624pub struct TestDevice2SynchronousProxy {
7625    client: fidl::client::sync::Client,
7626}
7627
7628#[cfg(target_os = "fuchsia")]
7629impl fidl::endpoints::SynchronousProxy for TestDevice2SynchronousProxy {
7630    type Proxy = TestDevice2Proxy;
7631    type Protocol = TestDevice2Marker;
7632
7633    fn from_channel(inner: fidl::Channel) -> Self {
7634        Self::new(inner)
7635    }
7636
7637    fn into_channel(self) -> fidl::Channel {
7638        self.client.into_channel()
7639    }
7640
7641    fn as_channel(&self) -> &fidl::Channel {
7642        self.client.as_channel()
7643    }
7644}
7645
7646#[cfg(target_os = "fuchsia")]
7647impl TestDevice2SynchronousProxy {
7648    pub fn new(channel: fidl::Channel) -> Self {
7649        let protocol_name = <TestDevice2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7650        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7651    }
7652
7653    pub fn into_channel(self) -> fidl::Channel {
7654        self.client.into_channel()
7655    }
7656
7657    /// Waits until an event arrives and returns it. It is safe for other
7658    /// threads to make concurrent requests while waiting for an event.
7659    pub fn wait_for_event(
7660        &self,
7661        deadline: zx::MonotonicInstant,
7662    ) -> Result<TestDevice2Event, fidl::Error> {
7663        TestDevice2Event::decode(self.client.wait_for_event(deadline)?)
7664    }
7665
7666    pub fn r#get_unit_test_status(
7667        &self,
7668        ___deadline: zx::MonotonicInstant,
7669    ) -> Result<i32, fidl::Error> {
7670        let _response = self
7671            .client
7672            .send_query::<fidl::encoding::EmptyPayload, TestDevice2GetUnitTestStatusResponse>(
7673                (),
7674                0x5be45b0f097813b2,
7675                fidl::encoding::DynamicFlags::empty(),
7676                ___deadline,
7677            )?;
7678        Ok(_response.status)
7679    }
7680}
7681
7682#[cfg(target_os = "fuchsia")]
7683impl From<TestDevice2SynchronousProxy> for zx::Handle {
7684    fn from(value: TestDevice2SynchronousProxy) -> Self {
7685        value.into_channel().into()
7686    }
7687}
7688
7689#[cfg(target_os = "fuchsia")]
7690impl From<fidl::Channel> for TestDevice2SynchronousProxy {
7691    fn from(value: fidl::Channel) -> Self {
7692        Self::new(value)
7693    }
7694}
7695
7696#[derive(Debug, Clone)]
7697pub struct TestDevice2Proxy {
7698    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7699}
7700
7701impl fidl::endpoints::Proxy for TestDevice2Proxy {
7702    type Protocol = TestDevice2Marker;
7703
7704    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7705        Self::new(inner)
7706    }
7707
7708    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7709        self.client.into_channel().map_err(|client| Self { client })
7710    }
7711
7712    fn as_channel(&self) -> &::fidl::AsyncChannel {
7713        self.client.as_channel()
7714    }
7715}
7716
7717impl TestDevice2Proxy {
7718    /// Create a new Proxy for fuchsia.gpu.magma/TestDevice2.
7719    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7720        let protocol_name = <TestDevice2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7721        Self { client: fidl::client::Client::new(channel, protocol_name) }
7722    }
7723
7724    /// Get a Stream of events from the remote end of the protocol.
7725    ///
7726    /// # Panics
7727    ///
7728    /// Panics if the event stream was already taken.
7729    pub fn take_event_stream(&self) -> TestDevice2EventStream {
7730        TestDevice2EventStream { event_receiver: self.client.take_event_receiver() }
7731    }
7732
7733    pub fn r#get_unit_test_status(
7734        &self,
7735    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
7736        TestDevice2ProxyInterface::r#get_unit_test_status(self)
7737    }
7738}
7739
7740impl TestDevice2ProxyInterface for TestDevice2Proxy {
7741    type GetUnitTestStatusResponseFut =
7742        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
7743    fn r#get_unit_test_status(&self) -> Self::GetUnitTestStatusResponseFut {
7744        fn _decode(
7745            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7746        ) -> Result<i32, fidl::Error> {
7747            let _response = fidl::client::decode_transaction_body::<
7748                TestDevice2GetUnitTestStatusResponse,
7749                fidl::encoding::DefaultFuchsiaResourceDialect,
7750                0x5be45b0f097813b2,
7751            >(_buf?)?;
7752            Ok(_response.status)
7753        }
7754        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
7755            (),
7756            0x5be45b0f097813b2,
7757            fidl::encoding::DynamicFlags::empty(),
7758            _decode,
7759        )
7760    }
7761}
7762
7763pub struct TestDevice2EventStream {
7764    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7765}
7766
7767impl std::marker::Unpin for TestDevice2EventStream {}
7768
7769impl futures::stream::FusedStream for TestDevice2EventStream {
7770    fn is_terminated(&self) -> bool {
7771        self.event_receiver.is_terminated()
7772    }
7773}
7774
7775impl futures::Stream for TestDevice2EventStream {
7776    type Item = Result<TestDevice2Event, fidl::Error>;
7777
7778    fn poll_next(
7779        mut self: std::pin::Pin<&mut Self>,
7780        cx: &mut std::task::Context<'_>,
7781    ) -> std::task::Poll<Option<Self::Item>> {
7782        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7783            &mut self.event_receiver,
7784            cx
7785        )?) {
7786            Some(buf) => std::task::Poll::Ready(Some(TestDevice2Event::decode(buf))),
7787            None => std::task::Poll::Ready(None),
7788        }
7789    }
7790}
7791
7792#[derive(Debug)]
7793pub enum TestDevice2Event {}
7794
7795impl TestDevice2Event {
7796    /// Decodes a message buffer as a [`TestDevice2Event`].
7797    fn decode(
7798        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7799    ) -> Result<TestDevice2Event, fidl::Error> {
7800        let (bytes, _handles) = buf.split_mut();
7801        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7802        debug_assert_eq!(tx_header.tx_id, 0);
7803        match tx_header.ordinal {
7804            _ => Err(fidl::Error::UnknownOrdinal {
7805                ordinal: tx_header.ordinal,
7806                protocol_name: <TestDevice2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7807            }),
7808        }
7809    }
7810}
7811
7812/// A Stream of incoming requests for fuchsia.gpu.magma/TestDevice2.
7813pub struct TestDevice2RequestStream {
7814    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7815    is_terminated: bool,
7816}
7817
7818impl std::marker::Unpin for TestDevice2RequestStream {}
7819
7820impl futures::stream::FusedStream for TestDevice2RequestStream {
7821    fn is_terminated(&self) -> bool {
7822        self.is_terminated
7823    }
7824}
7825
7826impl fidl::endpoints::RequestStream for TestDevice2RequestStream {
7827    type Protocol = TestDevice2Marker;
7828    type ControlHandle = TestDevice2ControlHandle;
7829
7830    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7831        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7832    }
7833
7834    fn control_handle(&self) -> Self::ControlHandle {
7835        TestDevice2ControlHandle { inner: self.inner.clone() }
7836    }
7837
7838    fn into_inner(
7839        self,
7840    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7841    {
7842        (self.inner, self.is_terminated)
7843    }
7844
7845    fn from_inner(
7846        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7847        is_terminated: bool,
7848    ) -> Self {
7849        Self { inner, is_terminated }
7850    }
7851}
7852
7853impl futures::Stream for TestDevice2RequestStream {
7854    type Item = Result<TestDevice2Request, fidl::Error>;
7855
7856    fn poll_next(
7857        mut self: std::pin::Pin<&mut Self>,
7858        cx: &mut std::task::Context<'_>,
7859    ) -> std::task::Poll<Option<Self::Item>> {
7860        let this = &mut *self;
7861        if this.inner.check_shutdown(cx) {
7862            this.is_terminated = true;
7863            return std::task::Poll::Ready(None);
7864        }
7865        if this.is_terminated {
7866            panic!("polled TestDevice2RequestStream after completion");
7867        }
7868        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7869            |bytes, handles| {
7870                match this.inner.channel().read_etc(cx, bytes, handles) {
7871                    std::task::Poll::Ready(Ok(())) => {}
7872                    std::task::Poll::Pending => return std::task::Poll::Pending,
7873                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7874                        this.is_terminated = true;
7875                        return std::task::Poll::Ready(None);
7876                    }
7877                    std::task::Poll::Ready(Err(e)) => {
7878                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7879                            e.into(),
7880                        ))))
7881                    }
7882                }
7883
7884                // A message has been received from the channel
7885                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7886
7887                std::task::Poll::Ready(Some(match header.ordinal {
7888                    0x5be45b0f097813b2 => {
7889                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7890                        let mut req = fidl::new_empty!(
7891                            fidl::encoding::EmptyPayload,
7892                            fidl::encoding::DefaultFuchsiaResourceDialect
7893                        );
7894                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7895                        let control_handle = TestDevice2ControlHandle { inner: this.inner.clone() };
7896                        Ok(TestDevice2Request::GetUnitTestStatus {
7897                            responder: TestDevice2GetUnitTestStatusResponder {
7898                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7899                                tx_id: header.tx_id,
7900                            },
7901                        })
7902                    }
7903                    _ => Err(fidl::Error::UnknownOrdinal {
7904                        ordinal: header.ordinal,
7905                        protocol_name:
7906                            <TestDevice2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7907                    }),
7908                }))
7909            },
7910        )
7911    }
7912}
7913
7914/// Additional methods for reporting tests run in the MSD.
7915#[derive(Debug)]
7916pub enum TestDevice2Request {
7917    GetUnitTestStatus { responder: TestDevice2GetUnitTestStatusResponder },
7918}
7919
7920impl TestDevice2Request {
7921    #[allow(irrefutable_let_patterns)]
7922    pub fn into_get_unit_test_status(self) -> Option<(TestDevice2GetUnitTestStatusResponder)> {
7923        if let TestDevice2Request::GetUnitTestStatus { responder } = self {
7924            Some((responder))
7925        } else {
7926            None
7927        }
7928    }
7929
7930    /// Name of the method defined in FIDL
7931    pub fn method_name(&self) -> &'static str {
7932        match *self {
7933            TestDevice2Request::GetUnitTestStatus { .. } => "get_unit_test_status",
7934        }
7935    }
7936}
7937
7938#[derive(Debug, Clone)]
7939pub struct TestDevice2ControlHandle {
7940    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7941}
7942
7943impl fidl::endpoints::ControlHandle for TestDevice2ControlHandle {
7944    fn shutdown(&self) {
7945        self.inner.shutdown()
7946    }
7947    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7948        self.inner.shutdown_with_epitaph(status)
7949    }
7950
7951    fn is_closed(&self) -> bool {
7952        self.inner.channel().is_closed()
7953    }
7954    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7955        self.inner.channel().on_closed()
7956    }
7957
7958    #[cfg(target_os = "fuchsia")]
7959    fn signal_peer(
7960        &self,
7961        clear_mask: zx::Signals,
7962        set_mask: zx::Signals,
7963    ) -> Result<(), zx_status::Status> {
7964        use fidl::Peered;
7965        self.inner.channel().signal_peer(clear_mask, set_mask)
7966    }
7967}
7968
7969impl TestDevice2ControlHandle {}
7970
7971#[must_use = "FIDL methods require a response to be sent"]
7972#[derive(Debug)]
7973pub struct TestDevice2GetUnitTestStatusResponder {
7974    control_handle: std::mem::ManuallyDrop<TestDevice2ControlHandle>,
7975    tx_id: u32,
7976}
7977
7978/// Set the the channel to be shutdown (see [`TestDevice2ControlHandle::shutdown`])
7979/// if the responder is dropped without sending a response, so that the client
7980/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7981impl std::ops::Drop for TestDevice2GetUnitTestStatusResponder {
7982    fn drop(&mut self) {
7983        self.control_handle.shutdown();
7984        // Safety: drops once, never accessed again
7985        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7986    }
7987}
7988
7989impl fidl::endpoints::Responder for TestDevice2GetUnitTestStatusResponder {
7990    type ControlHandle = TestDevice2ControlHandle;
7991
7992    fn control_handle(&self) -> &TestDevice2ControlHandle {
7993        &self.control_handle
7994    }
7995
7996    fn drop_without_shutdown(mut self) {
7997        // Safety: drops once, never accessed again due to mem::forget
7998        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7999        // Prevent Drop from running (which would shut down the channel)
8000        std::mem::forget(self);
8001    }
8002}
8003
8004impl TestDevice2GetUnitTestStatusResponder {
8005    /// Sends a response to the FIDL transaction.
8006    ///
8007    /// Sets the channel to shutdown if an error occurs.
8008    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
8009        let _result = self.send_raw(status);
8010        if _result.is_err() {
8011            self.control_handle.shutdown();
8012        }
8013        self.drop_without_shutdown();
8014        _result
8015    }
8016
8017    /// Similar to "send" but does not shutdown the channel if an error occurs.
8018    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
8019        let _result = self.send_raw(status);
8020        self.drop_without_shutdown();
8021        _result
8022    }
8023
8024    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
8025        self.control_handle.inner.send::<TestDevice2GetUnitTestStatusResponse>(
8026            (status,),
8027            self.tx_id,
8028            0x5be45b0f097813b2,
8029            fidl::encoding::DynamicFlags::empty(),
8030        )
8031    }
8032}
8033
8034#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8035pub struct DependencyInjectionServiceMarker;
8036
8037#[cfg(target_os = "fuchsia")]
8038impl fidl::endpoints::ServiceMarker for DependencyInjectionServiceMarker {
8039    type Proxy = DependencyInjectionServiceProxy;
8040    type Request = DependencyInjectionServiceRequest;
8041    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.DependencyInjectionService";
8042}
8043
8044/// A request for one of the member protocols of DependencyInjectionService.
8045///
8046#[cfg(target_os = "fuchsia")]
8047pub enum DependencyInjectionServiceRequest {
8048    Device(DependencyInjectionRequestStream),
8049}
8050
8051#[cfg(target_os = "fuchsia")]
8052impl fidl::endpoints::ServiceRequest for DependencyInjectionServiceRequest {
8053    type Service = DependencyInjectionServiceMarker;
8054
8055    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8056        match name {
8057            "device" => Self::Device(
8058                <DependencyInjectionRequestStream as fidl::endpoints::RequestStream>::from_channel(
8059                    _channel,
8060                ),
8061            ),
8062            _ => panic!("no such member protocol name for service DependencyInjectionService"),
8063        }
8064    }
8065
8066    fn member_names() -> &'static [&'static str] {
8067        &["device"]
8068    }
8069}
8070#[cfg(target_os = "fuchsia")]
8071pub struct DependencyInjectionServiceProxy(
8072    #[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>,
8073);
8074
8075#[cfg(target_os = "fuchsia")]
8076impl fidl::endpoints::ServiceProxy for DependencyInjectionServiceProxy {
8077    type Service = DependencyInjectionServiceMarker;
8078
8079    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8080        Self(opener)
8081    }
8082}
8083
8084#[cfg(target_os = "fuchsia")]
8085impl DependencyInjectionServiceProxy {
8086    pub fn connect_to_device(&self) -> Result<DependencyInjectionProxy, fidl::Error> {
8087        let (proxy, server_end) = fidl::endpoints::create_proxy::<DependencyInjectionMarker>();
8088        self.connect_channel_to_device(server_end)?;
8089        Ok(proxy)
8090    }
8091
8092    /// Like `connect_to_device`, but returns a sync proxy.
8093    /// See [`Self::connect_to_device`] for more details.
8094    pub fn connect_to_device_sync(
8095        &self,
8096    ) -> Result<DependencyInjectionSynchronousProxy, fidl::Error> {
8097        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DependencyInjectionMarker>();
8098        self.connect_channel_to_device(server_end)?;
8099        Ok(proxy)
8100    }
8101
8102    /// Like `connect_to_device`, but accepts a server end.
8103    /// See [`Self::connect_to_device`] for more details.
8104    pub fn connect_channel_to_device(
8105        &self,
8106        server_end: fidl::endpoints::ServerEnd<DependencyInjectionMarker>,
8107    ) -> Result<(), fidl::Error> {
8108        self.0.open_member("device", server_end.into_channel())
8109    }
8110
8111    pub fn instance_name(&self) -> &str {
8112        self.0.instance_name()
8113    }
8114}
8115
8116#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8117pub struct PerformanceCounterServiceMarker;
8118
8119#[cfg(target_os = "fuchsia")]
8120impl fidl::endpoints::ServiceMarker for PerformanceCounterServiceMarker {
8121    type Proxy = PerformanceCounterServiceProxy;
8122    type Request = PerformanceCounterServiceRequest;
8123    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.PerformanceCounterService";
8124}
8125
8126/// A request for one of the member protocols of PerformanceCounterService.
8127///
8128#[cfg(target_os = "fuchsia")]
8129pub enum PerformanceCounterServiceRequest {
8130    Access(PerformanceCounterAccessRequestStream),
8131}
8132
8133#[cfg(target_os = "fuchsia")]
8134impl fidl::endpoints::ServiceRequest for PerformanceCounterServiceRequest {
8135    type Service = PerformanceCounterServiceMarker;
8136
8137    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8138        match name {
8139            "access" => Self::Access(
8140                <PerformanceCounterAccessRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
8141            ),
8142            _ => panic!("no such member protocol name for service PerformanceCounterService"),
8143        }
8144    }
8145
8146    fn member_names() -> &'static [&'static str] {
8147        &["access"]
8148    }
8149}
8150#[cfg(target_os = "fuchsia")]
8151pub struct PerformanceCounterServiceProxy(
8152    #[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>,
8153);
8154
8155#[cfg(target_os = "fuchsia")]
8156impl fidl::endpoints::ServiceProxy for PerformanceCounterServiceProxy {
8157    type Service = PerformanceCounterServiceMarker;
8158
8159    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8160        Self(opener)
8161    }
8162}
8163
8164#[cfg(target_os = "fuchsia")]
8165impl PerformanceCounterServiceProxy {
8166    pub fn connect_to_access(&self) -> Result<PerformanceCounterAccessProxy, fidl::Error> {
8167        let (proxy, server_end) = fidl::endpoints::create_proxy::<PerformanceCounterAccessMarker>();
8168        self.connect_channel_to_access(server_end)?;
8169        Ok(proxy)
8170    }
8171
8172    /// Like `connect_to_access`, but returns a sync proxy.
8173    /// See [`Self::connect_to_access`] for more details.
8174    pub fn connect_to_access_sync(
8175        &self,
8176    ) -> Result<PerformanceCounterAccessSynchronousProxy, fidl::Error> {
8177        let (proxy, server_end) =
8178            fidl::endpoints::create_sync_proxy::<PerformanceCounterAccessMarker>();
8179        self.connect_channel_to_access(server_end)?;
8180        Ok(proxy)
8181    }
8182
8183    /// Like `connect_to_access`, but accepts a server end.
8184    /// See [`Self::connect_to_access`] for more details.
8185    pub fn connect_channel_to_access(
8186        &self,
8187        server_end: fidl::endpoints::ServerEnd<PerformanceCounterAccessMarker>,
8188    ) -> Result<(), fidl::Error> {
8189        self.0.open_member("access", server_end.into_channel())
8190    }
8191
8192    pub fn instance_name(&self) -> &str {
8193        self.0.instance_name()
8194    }
8195}
8196
8197#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8198pub struct ServiceMarker;
8199
8200#[cfg(target_os = "fuchsia")]
8201impl fidl::endpoints::ServiceMarker for ServiceMarker {
8202    type Proxy = ServiceProxy;
8203    type Request = ServiceRequest;
8204    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.Service";
8205}
8206
8207/// A request for one of the member protocols of Service.
8208///
8209#[cfg(target_os = "fuchsia")]
8210pub enum ServiceRequest {
8211    Device(CombinedDeviceRequestStream),
8212    PowerElementProvider(PowerElementProviderRequestStream),
8213}
8214
8215#[cfg(target_os = "fuchsia")]
8216impl fidl::endpoints::ServiceRequest for ServiceRequest {
8217    type Service = ServiceMarker;
8218
8219    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8220        match name {
8221            "device" => Self::Device(
8222                <CombinedDeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(
8223                    _channel,
8224                ),
8225            ),
8226            "power_element_provider" => Self::PowerElementProvider(
8227                <PowerElementProviderRequestStream as fidl::endpoints::RequestStream>::from_channel(
8228                    _channel,
8229                ),
8230            ),
8231            _ => panic!("no such member protocol name for service Service"),
8232        }
8233    }
8234
8235    fn member_names() -> &'static [&'static str] {
8236        &["device", "power_element_provider"]
8237    }
8238}
8239#[cfg(target_os = "fuchsia")]
8240pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8241
8242#[cfg(target_os = "fuchsia")]
8243impl fidl::endpoints::ServiceProxy for ServiceProxy {
8244    type Service = ServiceMarker;
8245
8246    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8247        Self(opener)
8248    }
8249}
8250
8251#[cfg(target_os = "fuchsia")]
8252impl ServiceProxy {
8253    pub fn connect_to_device(&self) -> Result<CombinedDeviceProxy, fidl::Error> {
8254        let (proxy, server_end) = fidl::endpoints::create_proxy::<CombinedDeviceMarker>();
8255        self.connect_channel_to_device(server_end)?;
8256        Ok(proxy)
8257    }
8258
8259    /// Like `connect_to_device`, but returns a sync proxy.
8260    /// See [`Self::connect_to_device`] for more details.
8261    pub fn connect_to_device_sync(&self) -> Result<CombinedDeviceSynchronousProxy, fidl::Error> {
8262        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<CombinedDeviceMarker>();
8263        self.connect_channel_to_device(server_end)?;
8264        Ok(proxy)
8265    }
8266
8267    /// Like `connect_to_device`, but accepts a server end.
8268    /// See [`Self::connect_to_device`] for more details.
8269    pub fn connect_channel_to_device(
8270        &self,
8271        server_end: fidl::endpoints::ServerEnd<CombinedDeviceMarker>,
8272    ) -> Result<(), fidl::Error> {
8273        self.0.open_member("device", server_end.into_channel())
8274    }
8275    pub fn connect_to_power_element_provider(
8276        &self,
8277    ) -> Result<PowerElementProviderProxy, fidl::Error> {
8278        let (proxy, server_end) = fidl::endpoints::create_proxy::<PowerElementProviderMarker>();
8279        self.connect_channel_to_power_element_provider(server_end)?;
8280        Ok(proxy)
8281    }
8282
8283    /// Like `connect_to_power_element_provider`, but returns a sync proxy.
8284    /// See [`Self::connect_to_power_element_provider`] for more details.
8285    pub fn connect_to_power_element_provider_sync(
8286        &self,
8287    ) -> Result<PowerElementProviderSynchronousProxy, fidl::Error> {
8288        let (proxy, server_end) =
8289            fidl::endpoints::create_sync_proxy::<PowerElementProviderMarker>();
8290        self.connect_channel_to_power_element_provider(server_end)?;
8291        Ok(proxy)
8292    }
8293
8294    /// Like `connect_to_power_element_provider`, but accepts a server end.
8295    /// See [`Self::connect_to_power_element_provider`] for more details.
8296    pub fn connect_channel_to_power_element_provider(
8297        &self,
8298        server_end: fidl::endpoints::ServerEnd<PowerElementProviderMarker>,
8299    ) -> Result<(), fidl::Error> {
8300        self.0.open_member("power_element_provider", server_end.into_channel())
8301    }
8302
8303    pub fn instance_name(&self) -> &str {
8304        self.0.instance_name()
8305    }
8306}
8307
8308#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8309pub struct TestServiceMarker;
8310
8311#[cfg(target_os = "fuchsia")]
8312impl fidl::endpoints::ServiceMarker for TestServiceMarker {
8313    type Proxy = TestServiceProxy;
8314    type Request = TestServiceRequest;
8315    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.TestService";
8316}
8317
8318/// A request for one of the member protocols of TestService.
8319///
8320/// This service is only exposed by test MSDs. This should not be used by an ICD.
8321#[cfg(target_os = "fuchsia")]
8322pub enum TestServiceRequest {
8323    Device(CombinedDeviceRequestStream),
8324    PowerElementProvider(PowerElementProviderRequestStream),
8325    TestDevice(TestDevice2RequestStream),
8326}
8327
8328#[cfg(target_os = "fuchsia")]
8329impl fidl::endpoints::ServiceRequest for TestServiceRequest {
8330    type Service = TestServiceMarker;
8331
8332    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8333        match name {
8334            "device" => Self::Device(
8335                <CombinedDeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(
8336                    _channel,
8337                ),
8338            ),
8339            "power_element_provider" => Self::PowerElementProvider(
8340                <PowerElementProviderRequestStream as fidl::endpoints::RequestStream>::from_channel(
8341                    _channel,
8342                ),
8343            ),
8344            "test_device" => Self::TestDevice(
8345                <TestDevice2RequestStream as fidl::endpoints::RequestStream>::from_channel(
8346                    _channel,
8347                ),
8348            ),
8349            _ => panic!("no such member protocol name for service TestService"),
8350        }
8351    }
8352
8353    fn member_names() -> &'static [&'static str] {
8354        &["device", "power_element_provider", "test_device"]
8355    }
8356}
8357/// This service is only exposed by test MSDs. This should not be used by an ICD.
8358#[cfg(target_os = "fuchsia")]
8359pub struct TestServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8360
8361#[cfg(target_os = "fuchsia")]
8362impl fidl::endpoints::ServiceProxy for TestServiceProxy {
8363    type Service = TestServiceMarker;
8364
8365    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8366        Self(opener)
8367    }
8368}
8369
8370#[cfg(target_os = "fuchsia")]
8371impl TestServiceProxy {
8372    pub fn connect_to_device(&self) -> Result<CombinedDeviceProxy, fidl::Error> {
8373        let (proxy, server_end) = fidl::endpoints::create_proxy::<CombinedDeviceMarker>();
8374        self.connect_channel_to_device(server_end)?;
8375        Ok(proxy)
8376    }
8377
8378    /// Like `connect_to_device`, but returns a sync proxy.
8379    /// See [`Self::connect_to_device`] for more details.
8380    pub fn connect_to_device_sync(&self) -> Result<CombinedDeviceSynchronousProxy, fidl::Error> {
8381        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<CombinedDeviceMarker>();
8382        self.connect_channel_to_device(server_end)?;
8383        Ok(proxy)
8384    }
8385
8386    /// Like `connect_to_device`, but accepts a server end.
8387    /// See [`Self::connect_to_device`] for more details.
8388    pub fn connect_channel_to_device(
8389        &self,
8390        server_end: fidl::endpoints::ServerEnd<CombinedDeviceMarker>,
8391    ) -> Result<(), fidl::Error> {
8392        self.0.open_member("device", server_end.into_channel())
8393    }
8394    pub fn connect_to_power_element_provider(
8395        &self,
8396    ) -> Result<PowerElementProviderProxy, fidl::Error> {
8397        let (proxy, server_end) = fidl::endpoints::create_proxy::<PowerElementProviderMarker>();
8398        self.connect_channel_to_power_element_provider(server_end)?;
8399        Ok(proxy)
8400    }
8401
8402    /// Like `connect_to_power_element_provider`, but returns a sync proxy.
8403    /// See [`Self::connect_to_power_element_provider`] for more details.
8404    pub fn connect_to_power_element_provider_sync(
8405        &self,
8406    ) -> Result<PowerElementProviderSynchronousProxy, fidl::Error> {
8407        let (proxy, server_end) =
8408            fidl::endpoints::create_sync_proxy::<PowerElementProviderMarker>();
8409        self.connect_channel_to_power_element_provider(server_end)?;
8410        Ok(proxy)
8411    }
8412
8413    /// Like `connect_to_power_element_provider`, but accepts a server end.
8414    /// See [`Self::connect_to_power_element_provider`] for more details.
8415    pub fn connect_channel_to_power_element_provider(
8416        &self,
8417        server_end: fidl::endpoints::ServerEnd<PowerElementProviderMarker>,
8418    ) -> Result<(), fidl::Error> {
8419        self.0.open_member("power_element_provider", server_end.into_channel())
8420    }
8421    pub fn connect_to_test_device(&self) -> Result<TestDevice2Proxy, fidl::Error> {
8422        let (proxy, server_end) = fidl::endpoints::create_proxy::<TestDevice2Marker>();
8423        self.connect_channel_to_test_device(server_end)?;
8424        Ok(proxy)
8425    }
8426
8427    /// Like `connect_to_test_device`, but returns a sync proxy.
8428    /// See [`Self::connect_to_test_device`] for more details.
8429    pub fn connect_to_test_device_sync(&self) -> Result<TestDevice2SynchronousProxy, fidl::Error> {
8430        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<TestDevice2Marker>();
8431        self.connect_channel_to_test_device(server_end)?;
8432        Ok(proxy)
8433    }
8434
8435    /// Like `connect_to_test_device`, but accepts a server end.
8436    /// See [`Self::connect_to_test_device`] for more details.
8437    pub fn connect_channel_to_test_device(
8438        &self,
8439        server_end: fidl::endpoints::ServerEnd<TestDevice2Marker>,
8440    ) -> Result<(), fidl::Error> {
8441        self.0.open_member("test_device", server_end.into_channel())
8442    }
8443
8444    pub fn instance_name(&self) -> &str {
8445        self.0.instance_name()
8446    }
8447}
8448
8449mod internal {
8450    use super::*;
8451
8452    impl fidl::encoding::ResourceTypeMarker for DependencyInjectionSetMemoryPressureProviderRequest {
8453        type Borrowed<'a> = &'a mut Self;
8454        fn take_or_borrow<'a>(
8455            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8456        ) -> Self::Borrowed<'a> {
8457            value
8458        }
8459    }
8460
8461    unsafe impl fidl::encoding::TypeMarker for DependencyInjectionSetMemoryPressureProviderRequest {
8462        type Owned = Self;
8463
8464        #[inline(always)]
8465        fn inline_align(_context: fidl::encoding::Context) -> usize {
8466            4
8467        }
8468
8469        #[inline(always)]
8470        fn inline_size(_context: fidl::encoding::Context) -> usize {
8471            4
8472        }
8473    }
8474
8475    unsafe impl
8476        fidl::encoding::Encode<
8477            DependencyInjectionSetMemoryPressureProviderRequest,
8478            fidl::encoding::DefaultFuchsiaResourceDialect,
8479        > for &mut DependencyInjectionSetMemoryPressureProviderRequest
8480    {
8481        #[inline]
8482        unsafe fn encode(
8483            self,
8484            encoder: &mut fidl::encoding::Encoder<
8485                '_,
8486                fidl::encoding::DefaultFuchsiaResourceDialect,
8487            >,
8488            offset: usize,
8489            _depth: fidl::encoding::Depth,
8490        ) -> fidl::Result<()> {
8491            encoder
8492                .debug_check_bounds::<DependencyInjectionSetMemoryPressureProviderRequest>(offset);
8493            // Delegate to tuple encoding.
8494            fidl::encoding::Encode::<
8495                DependencyInjectionSetMemoryPressureProviderRequest,
8496                fidl::encoding::DefaultFuchsiaResourceDialect,
8497            >::encode(
8498                (<fidl::encoding::Endpoint<
8499                    fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
8500                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8501                    &mut self.provider
8502                ),),
8503                encoder,
8504                offset,
8505                _depth,
8506            )
8507        }
8508    }
8509    unsafe impl<
8510            T0: fidl::encoding::Encode<
8511                fidl::encoding::Endpoint<
8512                    fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
8513                >,
8514                fidl::encoding::DefaultFuchsiaResourceDialect,
8515            >,
8516        >
8517        fidl::encoding::Encode<
8518            DependencyInjectionSetMemoryPressureProviderRequest,
8519            fidl::encoding::DefaultFuchsiaResourceDialect,
8520        > for (T0,)
8521    {
8522        #[inline]
8523        unsafe fn encode(
8524            self,
8525            encoder: &mut fidl::encoding::Encoder<
8526                '_,
8527                fidl::encoding::DefaultFuchsiaResourceDialect,
8528            >,
8529            offset: usize,
8530            depth: fidl::encoding::Depth,
8531        ) -> fidl::Result<()> {
8532            encoder
8533                .debug_check_bounds::<DependencyInjectionSetMemoryPressureProviderRequest>(offset);
8534            // Zero out padding regions. There's no need to apply masks
8535            // because the unmasked parts will be overwritten by fields.
8536            // Write the fields.
8537            self.0.encode(encoder, offset + 0, depth)?;
8538            Ok(())
8539        }
8540    }
8541
8542    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8543        for DependencyInjectionSetMemoryPressureProviderRequest
8544    {
8545        #[inline(always)]
8546        fn new_empty() -> Self {
8547            Self {
8548                provider: fidl::new_empty!(
8549                    fidl::encoding::Endpoint<
8550                        fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
8551                    >,
8552                    fidl::encoding::DefaultFuchsiaResourceDialect
8553                ),
8554            }
8555        }
8556
8557        #[inline]
8558        unsafe fn decode(
8559            &mut self,
8560            decoder: &mut fidl::encoding::Decoder<
8561                '_,
8562                fidl::encoding::DefaultFuchsiaResourceDialect,
8563            >,
8564            offset: usize,
8565            _depth: fidl::encoding::Depth,
8566        ) -> fidl::Result<()> {
8567            decoder.debug_check_bounds::<Self>(offset);
8568            // Verify that padding bytes are zero.
8569            fidl::decode!(
8570                fidl::encoding::Endpoint<
8571                    fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
8572                >,
8573                fidl::encoding::DefaultFuchsiaResourceDialect,
8574                &mut self.provider,
8575                decoder,
8576                offset + 0,
8577                _depth
8578            )?;
8579            Ok(())
8580        }
8581    }
8582
8583    impl fidl::encoding::ResourceTypeMarker for DeviceConnect2Request {
8584        type Borrowed<'a> = &'a mut Self;
8585        fn take_or_borrow<'a>(
8586            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8587        ) -> Self::Borrowed<'a> {
8588            value
8589        }
8590    }
8591
8592    unsafe impl fidl::encoding::TypeMarker for DeviceConnect2Request {
8593        type Owned = Self;
8594
8595        #[inline(always)]
8596        fn inline_align(_context: fidl::encoding::Context) -> usize {
8597            8
8598        }
8599
8600        #[inline(always)]
8601        fn inline_size(_context: fidl::encoding::Context) -> usize {
8602            16
8603        }
8604    }
8605
8606    unsafe impl
8607        fidl::encoding::Encode<DeviceConnect2Request, fidl::encoding::DefaultFuchsiaResourceDialect>
8608        for &mut DeviceConnect2Request
8609    {
8610        #[inline]
8611        unsafe fn encode(
8612            self,
8613            encoder: &mut fidl::encoding::Encoder<
8614                '_,
8615                fidl::encoding::DefaultFuchsiaResourceDialect,
8616            >,
8617            offset: usize,
8618            _depth: fidl::encoding::Depth,
8619        ) -> fidl::Result<()> {
8620            encoder.debug_check_bounds::<DeviceConnect2Request>(offset);
8621            // Delegate to tuple encoding.
8622            fidl::encoding::Encode::<DeviceConnect2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8623                (
8624                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.client_id),
8625                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrimaryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.primary_channel),
8626                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NotificationMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.notification_channel),
8627                ),
8628                encoder, offset, _depth
8629            )
8630        }
8631    }
8632    unsafe impl<
8633            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
8634            T1: fidl::encoding::Encode<
8635                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrimaryMarker>>,
8636                fidl::encoding::DefaultFuchsiaResourceDialect,
8637            >,
8638            T2: fidl::encoding::Encode<
8639                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NotificationMarker>>,
8640                fidl::encoding::DefaultFuchsiaResourceDialect,
8641            >,
8642        >
8643        fidl::encoding::Encode<DeviceConnect2Request, fidl::encoding::DefaultFuchsiaResourceDialect>
8644        for (T0, T1, T2)
8645    {
8646        #[inline]
8647        unsafe fn encode(
8648            self,
8649            encoder: &mut fidl::encoding::Encoder<
8650                '_,
8651                fidl::encoding::DefaultFuchsiaResourceDialect,
8652            >,
8653            offset: usize,
8654            depth: fidl::encoding::Depth,
8655        ) -> fidl::Result<()> {
8656            encoder.debug_check_bounds::<DeviceConnect2Request>(offset);
8657            // Zero out padding regions. There's no need to apply masks
8658            // because the unmasked parts will be overwritten by fields.
8659            // Write the fields.
8660            self.0.encode(encoder, offset + 0, depth)?;
8661            self.1.encode(encoder, offset + 8, depth)?;
8662            self.2.encode(encoder, offset + 12, depth)?;
8663            Ok(())
8664        }
8665    }
8666
8667    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8668        for DeviceConnect2Request
8669    {
8670        #[inline(always)]
8671        fn new_empty() -> Self {
8672            Self {
8673                client_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
8674                primary_channel: fidl::new_empty!(
8675                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrimaryMarker>>,
8676                    fidl::encoding::DefaultFuchsiaResourceDialect
8677                ),
8678                notification_channel: fidl::new_empty!(
8679                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NotificationMarker>>,
8680                    fidl::encoding::DefaultFuchsiaResourceDialect
8681                ),
8682            }
8683        }
8684
8685        #[inline]
8686        unsafe fn decode(
8687            &mut self,
8688            decoder: &mut fidl::encoding::Decoder<
8689                '_,
8690                fidl::encoding::DefaultFuchsiaResourceDialect,
8691            >,
8692            offset: usize,
8693            _depth: fidl::encoding::Depth,
8694        ) -> fidl::Result<()> {
8695            decoder.debug_check_bounds::<Self>(offset);
8696            // Verify that padding bytes are zero.
8697            fidl::decode!(
8698                u64,
8699                fidl::encoding::DefaultFuchsiaResourceDialect,
8700                &mut self.client_id,
8701                decoder,
8702                offset + 0,
8703                _depth
8704            )?;
8705            fidl::decode!(
8706                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrimaryMarker>>,
8707                fidl::encoding::DefaultFuchsiaResourceDialect,
8708                &mut self.primary_channel,
8709                decoder,
8710                offset + 8,
8711                _depth
8712            )?;
8713            fidl::decode!(
8714                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NotificationMarker>>,
8715                fidl::encoding::DefaultFuchsiaResourceDialect,
8716                &mut self.notification_channel,
8717                decoder,
8718                offset + 12,
8719                _depth
8720            )?;
8721            Ok(())
8722        }
8723    }
8724
8725    impl fidl::encoding::ResourceTypeMarker
8726        for PerformanceCounterAccessGetPerformanceCountTokenResponse
8727    {
8728        type Borrowed<'a> = &'a mut Self;
8729        fn take_or_borrow<'a>(
8730            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8731        ) -> Self::Borrowed<'a> {
8732            value
8733        }
8734    }
8735
8736    unsafe impl fidl::encoding::TypeMarker
8737        for PerformanceCounterAccessGetPerformanceCountTokenResponse
8738    {
8739        type Owned = Self;
8740
8741        #[inline(always)]
8742        fn inline_align(_context: fidl::encoding::Context) -> usize {
8743            4
8744        }
8745
8746        #[inline(always)]
8747        fn inline_size(_context: fidl::encoding::Context) -> usize {
8748            4
8749        }
8750    }
8751
8752    unsafe impl
8753        fidl::encoding::Encode<
8754            PerformanceCounterAccessGetPerformanceCountTokenResponse,
8755            fidl::encoding::DefaultFuchsiaResourceDialect,
8756        > for &mut PerformanceCounterAccessGetPerformanceCountTokenResponse
8757    {
8758        #[inline]
8759        unsafe fn encode(
8760            self,
8761            encoder: &mut fidl::encoding::Encoder<
8762                '_,
8763                fidl::encoding::DefaultFuchsiaResourceDialect,
8764            >,
8765            offset: usize,
8766            _depth: fidl::encoding::Depth,
8767        ) -> fidl::Result<()> {
8768            encoder.debug_check_bounds::<PerformanceCounterAccessGetPerformanceCountTokenResponse>(
8769                offset,
8770            );
8771            // Delegate to tuple encoding.
8772            fidl::encoding::Encode::<
8773                PerformanceCounterAccessGetPerformanceCountTokenResponse,
8774                fidl::encoding::DefaultFuchsiaResourceDialect,
8775            >::encode(
8776                (<fidl::encoding::HandleType<
8777                    fidl::Event,
8778                    { fidl::ObjectType::EVENT.into_raw() },
8779                    2147483648,
8780                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8781                    &mut self.access_token
8782                ),),
8783                encoder,
8784                offset,
8785                _depth,
8786            )
8787        }
8788    }
8789    unsafe impl<
8790            T0: fidl::encoding::Encode<
8791                fidl::encoding::HandleType<
8792                    fidl::Event,
8793                    { fidl::ObjectType::EVENT.into_raw() },
8794                    2147483648,
8795                >,
8796                fidl::encoding::DefaultFuchsiaResourceDialect,
8797            >,
8798        >
8799        fidl::encoding::Encode<
8800            PerformanceCounterAccessGetPerformanceCountTokenResponse,
8801            fidl::encoding::DefaultFuchsiaResourceDialect,
8802        > for (T0,)
8803    {
8804        #[inline]
8805        unsafe fn encode(
8806            self,
8807            encoder: &mut fidl::encoding::Encoder<
8808                '_,
8809                fidl::encoding::DefaultFuchsiaResourceDialect,
8810            >,
8811            offset: usize,
8812            depth: fidl::encoding::Depth,
8813        ) -> fidl::Result<()> {
8814            encoder.debug_check_bounds::<PerformanceCounterAccessGetPerformanceCountTokenResponse>(
8815                offset,
8816            );
8817            // Zero out padding regions. There's no need to apply masks
8818            // because the unmasked parts will be overwritten by fields.
8819            // Write the fields.
8820            self.0.encode(encoder, offset + 0, depth)?;
8821            Ok(())
8822        }
8823    }
8824
8825    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8826        for PerformanceCounterAccessGetPerformanceCountTokenResponse
8827    {
8828        #[inline(always)]
8829        fn new_empty() -> Self {
8830            Self {
8831                access_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8832            }
8833        }
8834
8835        #[inline]
8836        unsafe fn decode(
8837            &mut self,
8838            decoder: &mut fidl::encoding::Decoder<
8839                '_,
8840                fidl::encoding::DefaultFuchsiaResourceDialect,
8841            >,
8842            offset: usize,
8843            _depth: fidl::encoding::Depth,
8844        ) -> fidl::Result<()> {
8845            decoder.debug_check_bounds::<Self>(offset);
8846            // Verify that padding bytes are zero.
8847            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.access_token, decoder, offset + 0, _depth)?;
8848            Ok(())
8849        }
8850    }
8851
8852    impl fidl::encoding::ResourceTypeMarker for PowerElementProviderGetPowerGoalsResponse {
8853        type Borrowed<'a> = &'a mut Self;
8854        fn take_or_borrow<'a>(
8855            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8856        ) -> Self::Borrowed<'a> {
8857            value
8858        }
8859    }
8860
8861    unsafe impl fidl::encoding::TypeMarker for PowerElementProviderGetPowerGoalsResponse {
8862        type Owned = Self;
8863
8864        #[inline(always)]
8865        fn inline_align(_context: fidl::encoding::Context) -> usize {
8866            8
8867        }
8868
8869        #[inline(always)]
8870        fn inline_size(_context: fidl::encoding::Context) -> usize {
8871            16
8872        }
8873    }
8874
8875    unsafe impl
8876        fidl::encoding::Encode<
8877            PowerElementProviderGetPowerGoalsResponse,
8878            fidl::encoding::DefaultFuchsiaResourceDialect,
8879        > for &mut PowerElementProviderGetPowerGoalsResponse
8880    {
8881        #[inline]
8882        unsafe fn encode(
8883            self,
8884            encoder: &mut fidl::encoding::Encoder<
8885                '_,
8886                fidl::encoding::DefaultFuchsiaResourceDialect,
8887            >,
8888            offset: usize,
8889            _depth: fidl::encoding::Depth,
8890        ) -> fidl::Result<()> {
8891            encoder.debug_check_bounds::<PowerElementProviderGetPowerGoalsResponse>(offset);
8892            // Delegate to tuple encoding.
8893            fidl::encoding::Encode::<PowerElementProviderGetPowerGoalsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8894                (
8895                    <fidl::encoding::UnboundedVector<PowerGoal> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.goals),
8896                ),
8897                encoder, offset, _depth
8898            )
8899        }
8900    }
8901    unsafe impl<
8902            T0: fidl::encoding::Encode<
8903                fidl::encoding::UnboundedVector<PowerGoal>,
8904                fidl::encoding::DefaultFuchsiaResourceDialect,
8905            >,
8906        >
8907        fidl::encoding::Encode<
8908            PowerElementProviderGetPowerGoalsResponse,
8909            fidl::encoding::DefaultFuchsiaResourceDialect,
8910        > for (T0,)
8911    {
8912        #[inline]
8913        unsafe fn encode(
8914            self,
8915            encoder: &mut fidl::encoding::Encoder<
8916                '_,
8917                fidl::encoding::DefaultFuchsiaResourceDialect,
8918            >,
8919            offset: usize,
8920            depth: fidl::encoding::Depth,
8921        ) -> fidl::Result<()> {
8922            encoder.debug_check_bounds::<PowerElementProviderGetPowerGoalsResponse>(offset);
8923            // Zero out padding regions. There's no need to apply masks
8924            // because the unmasked parts will be overwritten by fields.
8925            // Write the fields.
8926            self.0.encode(encoder, offset + 0, depth)?;
8927            Ok(())
8928        }
8929    }
8930
8931    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8932        for PowerElementProviderGetPowerGoalsResponse
8933    {
8934        #[inline(always)]
8935        fn new_empty() -> Self {
8936            Self {
8937                goals: fidl::new_empty!(
8938                    fidl::encoding::UnboundedVector<PowerGoal>,
8939                    fidl::encoding::DefaultFuchsiaResourceDialect
8940                ),
8941            }
8942        }
8943
8944        #[inline]
8945        unsafe fn decode(
8946            &mut self,
8947            decoder: &mut fidl::encoding::Decoder<
8948                '_,
8949                fidl::encoding::DefaultFuchsiaResourceDialect,
8950            >,
8951            offset: usize,
8952            _depth: fidl::encoding::Depth,
8953        ) -> fidl::Result<()> {
8954            decoder.debug_check_bounds::<Self>(offset);
8955            // Verify that padding bytes are zero.
8956            fidl::decode!(
8957                fidl::encoding::UnboundedVector<PowerGoal>,
8958                fidl::encoding::DefaultFuchsiaResourceDialect,
8959                &mut self.goals,
8960                decoder,
8961                offset + 0,
8962                _depth
8963            )?;
8964            Ok(())
8965        }
8966    }
8967
8968    impl fidl::encoding::ResourceTypeMarker for PrimaryCreatePerformanceCounterBufferPoolRequest {
8969        type Borrowed<'a> = &'a mut Self;
8970        fn take_or_borrow<'a>(
8971            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8972        ) -> Self::Borrowed<'a> {
8973            value
8974        }
8975    }
8976
8977    unsafe impl fidl::encoding::TypeMarker for PrimaryCreatePerformanceCounterBufferPoolRequest {
8978        type Owned = Self;
8979
8980        #[inline(always)]
8981        fn inline_align(_context: fidl::encoding::Context) -> usize {
8982            8
8983        }
8984
8985        #[inline(always)]
8986        fn inline_size(_context: fidl::encoding::Context) -> usize {
8987            16
8988        }
8989    }
8990
8991    unsafe impl
8992        fidl::encoding::Encode<
8993            PrimaryCreatePerformanceCounterBufferPoolRequest,
8994            fidl::encoding::DefaultFuchsiaResourceDialect,
8995        > for &mut PrimaryCreatePerformanceCounterBufferPoolRequest
8996    {
8997        #[inline]
8998        unsafe fn encode(
8999            self,
9000            encoder: &mut fidl::encoding::Encoder<
9001                '_,
9002                fidl::encoding::DefaultFuchsiaResourceDialect,
9003            >,
9004            offset: usize,
9005            _depth: fidl::encoding::Depth,
9006        ) -> fidl::Result<()> {
9007            encoder.debug_check_bounds::<PrimaryCreatePerformanceCounterBufferPoolRequest>(offset);
9008            // Delegate to tuple encoding.
9009            fidl::encoding::Encode::<
9010                PrimaryCreatePerformanceCounterBufferPoolRequest,
9011                fidl::encoding::DefaultFuchsiaResourceDialect,
9012            >::encode(
9013                (
9014                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pool_id),
9015                    <fidl::encoding::Endpoint<
9016                        fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
9017                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9018                        &mut self.event_channel,
9019                    ),
9020                ),
9021                encoder,
9022                offset,
9023                _depth,
9024            )
9025        }
9026    }
9027    unsafe impl<
9028            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
9029            T1: fidl::encoding::Encode<
9030                fidl::encoding::Endpoint<
9031                    fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
9032                >,
9033                fidl::encoding::DefaultFuchsiaResourceDialect,
9034            >,
9035        >
9036        fidl::encoding::Encode<
9037            PrimaryCreatePerformanceCounterBufferPoolRequest,
9038            fidl::encoding::DefaultFuchsiaResourceDialect,
9039        > for (T0, T1)
9040    {
9041        #[inline]
9042        unsafe fn encode(
9043            self,
9044            encoder: &mut fidl::encoding::Encoder<
9045                '_,
9046                fidl::encoding::DefaultFuchsiaResourceDialect,
9047            >,
9048            offset: usize,
9049            depth: fidl::encoding::Depth,
9050        ) -> fidl::Result<()> {
9051            encoder.debug_check_bounds::<PrimaryCreatePerformanceCounterBufferPoolRequest>(offset);
9052            // Zero out padding regions. There's no need to apply masks
9053            // because the unmasked parts will be overwritten by fields.
9054            unsafe {
9055                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
9056                (ptr as *mut u64).write_unaligned(0);
9057            }
9058            // Write the fields.
9059            self.0.encode(encoder, offset + 0, depth)?;
9060            self.1.encode(encoder, offset + 8, depth)?;
9061            Ok(())
9062        }
9063    }
9064
9065    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9066        for PrimaryCreatePerformanceCounterBufferPoolRequest
9067    {
9068        #[inline(always)]
9069        fn new_empty() -> Self {
9070            Self {
9071                pool_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
9072                event_channel: fidl::new_empty!(
9073                    fidl::encoding::Endpoint<
9074                        fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
9075                    >,
9076                    fidl::encoding::DefaultFuchsiaResourceDialect
9077                ),
9078            }
9079        }
9080
9081        #[inline]
9082        unsafe fn decode(
9083            &mut self,
9084            decoder: &mut fidl::encoding::Decoder<
9085                '_,
9086                fidl::encoding::DefaultFuchsiaResourceDialect,
9087            >,
9088            offset: usize,
9089            _depth: fidl::encoding::Depth,
9090        ) -> fidl::Result<()> {
9091            decoder.debug_check_bounds::<Self>(offset);
9092            // Verify that padding bytes are zero.
9093            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
9094            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9095            let mask = 0xffffffff00000000u64;
9096            let maskedval = padval & mask;
9097            if maskedval != 0 {
9098                return Err(fidl::Error::NonZeroPadding {
9099                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
9100                });
9101            }
9102            fidl::decode!(
9103                u64,
9104                fidl::encoding::DefaultFuchsiaResourceDialect,
9105                &mut self.pool_id,
9106                decoder,
9107                offset + 0,
9108                _depth
9109            )?;
9110            fidl::decode!(
9111                fidl::encoding::Endpoint<
9112                    fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
9113                >,
9114                fidl::encoding::DefaultFuchsiaResourceDialect,
9115                &mut self.event_channel,
9116                decoder,
9117                offset + 8,
9118                _depth
9119            )?;
9120            Ok(())
9121        }
9122    }
9123
9124    impl fidl::encoding::ResourceTypeMarker for PrimaryEnablePerformanceCounterAccessRequest {
9125        type Borrowed<'a> = &'a mut Self;
9126        fn take_or_borrow<'a>(
9127            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9128        ) -> Self::Borrowed<'a> {
9129            value
9130        }
9131    }
9132
9133    unsafe impl fidl::encoding::TypeMarker for PrimaryEnablePerformanceCounterAccessRequest {
9134        type Owned = Self;
9135
9136        #[inline(always)]
9137        fn inline_align(_context: fidl::encoding::Context) -> usize {
9138            4
9139        }
9140
9141        #[inline(always)]
9142        fn inline_size(_context: fidl::encoding::Context) -> usize {
9143            4
9144        }
9145    }
9146
9147    unsafe impl
9148        fidl::encoding::Encode<
9149            PrimaryEnablePerformanceCounterAccessRequest,
9150            fidl::encoding::DefaultFuchsiaResourceDialect,
9151        > for &mut PrimaryEnablePerformanceCounterAccessRequest
9152    {
9153        #[inline]
9154        unsafe fn encode(
9155            self,
9156            encoder: &mut fidl::encoding::Encoder<
9157                '_,
9158                fidl::encoding::DefaultFuchsiaResourceDialect,
9159            >,
9160            offset: usize,
9161            _depth: fidl::encoding::Depth,
9162        ) -> fidl::Result<()> {
9163            encoder.debug_check_bounds::<PrimaryEnablePerformanceCounterAccessRequest>(offset);
9164            // Delegate to tuple encoding.
9165            fidl::encoding::Encode::<
9166                PrimaryEnablePerformanceCounterAccessRequest,
9167                fidl::encoding::DefaultFuchsiaResourceDialect,
9168            >::encode(
9169                (<fidl::encoding::HandleType<
9170                    fidl::Event,
9171                    { fidl::ObjectType::EVENT.into_raw() },
9172                    2147483648,
9173                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9174                    &mut self.access_token
9175                ),),
9176                encoder,
9177                offset,
9178                _depth,
9179            )
9180        }
9181    }
9182    unsafe impl<
9183            T0: fidl::encoding::Encode<
9184                fidl::encoding::HandleType<
9185                    fidl::Event,
9186                    { fidl::ObjectType::EVENT.into_raw() },
9187                    2147483648,
9188                >,
9189                fidl::encoding::DefaultFuchsiaResourceDialect,
9190            >,
9191        >
9192        fidl::encoding::Encode<
9193            PrimaryEnablePerformanceCounterAccessRequest,
9194            fidl::encoding::DefaultFuchsiaResourceDialect,
9195        > for (T0,)
9196    {
9197        #[inline]
9198        unsafe fn encode(
9199            self,
9200            encoder: &mut fidl::encoding::Encoder<
9201                '_,
9202                fidl::encoding::DefaultFuchsiaResourceDialect,
9203            >,
9204            offset: usize,
9205            depth: fidl::encoding::Depth,
9206        ) -> fidl::Result<()> {
9207            encoder.debug_check_bounds::<PrimaryEnablePerformanceCounterAccessRequest>(offset);
9208            // Zero out padding regions. There's no need to apply masks
9209            // because the unmasked parts will be overwritten by fields.
9210            // Write the fields.
9211            self.0.encode(encoder, offset + 0, depth)?;
9212            Ok(())
9213        }
9214    }
9215
9216    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9217        for PrimaryEnablePerformanceCounterAccessRequest
9218    {
9219        #[inline(always)]
9220        fn new_empty() -> Self {
9221            Self {
9222                access_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9223            }
9224        }
9225
9226        #[inline]
9227        unsafe fn decode(
9228            &mut self,
9229            decoder: &mut fidl::encoding::Decoder<
9230                '_,
9231                fidl::encoding::DefaultFuchsiaResourceDialect,
9232            >,
9233            offset: usize,
9234            _depth: fidl::encoding::Depth,
9235        ) -> fidl::Result<()> {
9236            decoder.debug_check_bounds::<Self>(offset);
9237            // Verify that padding bytes are zero.
9238            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.access_token, decoder, offset + 0, _depth)?;
9239            Ok(())
9240        }
9241    }
9242
9243    impl fidl::encoding::ResourceTypeMarker for PrimaryImportObject2Request {
9244        type Borrowed<'a> = &'a mut Self;
9245        fn take_or_borrow<'a>(
9246            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9247        ) -> Self::Borrowed<'a> {
9248            value
9249        }
9250    }
9251
9252    unsafe impl fidl::encoding::TypeMarker for PrimaryImportObject2Request {
9253        type Owned = Self;
9254
9255        #[inline(always)]
9256        fn inline_align(_context: fidl::encoding::Context) -> usize {
9257            8
9258        }
9259
9260        #[inline(always)]
9261        fn inline_size(_context: fidl::encoding::Context) -> usize {
9262            16
9263        }
9264    }
9265
9266    unsafe impl
9267        fidl::encoding::Encode<
9268            PrimaryImportObject2Request,
9269            fidl::encoding::DefaultFuchsiaResourceDialect,
9270        > for &mut PrimaryImportObject2Request
9271    {
9272        #[inline]
9273        unsafe fn encode(
9274            self,
9275            encoder: &mut fidl::encoding::Encoder<
9276                '_,
9277                fidl::encoding::DefaultFuchsiaResourceDialect,
9278            >,
9279            offset: usize,
9280            _depth: fidl::encoding::Depth,
9281        ) -> fidl::Result<()> {
9282            encoder.debug_check_bounds::<PrimaryImportObject2Request>(offset);
9283            // Delegate to tuple encoding.
9284            fidl::encoding::Encode::<
9285                PrimaryImportObject2Request,
9286                fidl::encoding::DefaultFuchsiaResourceDialect,
9287            >::encode(
9288                (
9289                    <fidl::encoding::HandleType<
9290                        fidl::Handle,
9291                        { fidl::ObjectType::NONE.into_raw() },
9292                        2147483648,
9293                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9294                        &mut self.object
9295                    ),
9296                    <ObjectType as fidl::encoding::ValueTypeMarker>::borrow(&self.object_type),
9297                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.object_id),
9298                ),
9299                encoder,
9300                offset,
9301                _depth,
9302            )
9303        }
9304    }
9305    unsafe impl<
9306            T0: fidl::encoding::Encode<
9307                fidl::encoding::HandleType<
9308                    fidl::Handle,
9309                    { fidl::ObjectType::NONE.into_raw() },
9310                    2147483648,
9311                >,
9312                fidl::encoding::DefaultFuchsiaResourceDialect,
9313            >,
9314            T1: fidl::encoding::Encode<ObjectType, fidl::encoding::DefaultFuchsiaResourceDialect>,
9315            T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
9316        >
9317        fidl::encoding::Encode<
9318            PrimaryImportObject2Request,
9319            fidl::encoding::DefaultFuchsiaResourceDialect,
9320        > for (T0, T1, T2)
9321    {
9322        #[inline]
9323        unsafe fn encode(
9324            self,
9325            encoder: &mut fidl::encoding::Encoder<
9326                '_,
9327                fidl::encoding::DefaultFuchsiaResourceDialect,
9328            >,
9329            offset: usize,
9330            depth: fidl::encoding::Depth,
9331        ) -> fidl::Result<()> {
9332            encoder.debug_check_bounds::<PrimaryImportObject2Request>(offset);
9333            // Zero out padding regions. There's no need to apply masks
9334            // because the unmasked parts will be overwritten by fields.
9335            // Write the fields.
9336            self.0.encode(encoder, offset + 0, depth)?;
9337            self.1.encode(encoder, offset + 4, depth)?;
9338            self.2.encode(encoder, offset + 8, depth)?;
9339            Ok(())
9340        }
9341    }
9342
9343    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9344        for PrimaryImportObject2Request
9345    {
9346        #[inline(always)]
9347        fn new_empty() -> Self {
9348            Self {
9349                object: fidl::new_empty!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9350                object_type: fidl::new_empty!(
9351                    ObjectType,
9352                    fidl::encoding::DefaultFuchsiaResourceDialect
9353                ),
9354                object_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
9355            }
9356        }
9357
9358        #[inline]
9359        unsafe fn decode(
9360            &mut self,
9361            decoder: &mut fidl::encoding::Decoder<
9362                '_,
9363                fidl::encoding::DefaultFuchsiaResourceDialect,
9364            >,
9365            offset: usize,
9366            _depth: fidl::encoding::Depth,
9367        ) -> fidl::Result<()> {
9368            decoder.debug_check_bounds::<Self>(offset);
9369            // Verify that padding bytes are zero.
9370            fidl::decode!(fidl::encoding::HandleType<fidl::Handle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.object, decoder, offset + 0, _depth)?;
9371            fidl::decode!(
9372                ObjectType,
9373                fidl::encoding::DefaultFuchsiaResourceDialect,
9374                &mut self.object_type,
9375                decoder,
9376                offset + 4,
9377                _depth
9378            )?;
9379            fidl::decode!(
9380                u64,
9381                fidl::encoding::DefaultFuchsiaResourceDialect,
9382                &mut self.object_id,
9383                decoder,
9384                offset + 8,
9385                _depth
9386            )?;
9387            Ok(())
9388        }
9389    }
9390
9391    impl PowerElementProviderGetClockSpeedLevelResponse {
9392        #[inline(always)]
9393        fn max_ordinal_present(&self) -> u64 {
9394            if let Some(_) = self.actual_hz {
9395                return 3;
9396            }
9397            if let Some(_) = self.level {
9398                return 2;
9399            }
9400            if let Some(_) = self.token {
9401                return 1;
9402            }
9403            0
9404        }
9405    }
9406
9407    impl fidl::encoding::ResourceTypeMarker for PowerElementProviderGetClockSpeedLevelResponse {
9408        type Borrowed<'a> = &'a mut Self;
9409        fn take_or_borrow<'a>(
9410            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9411        ) -> Self::Borrowed<'a> {
9412            value
9413        }
9414    }
9415
9416    unsafe impl fidl::encoding::TypeMarker for PowerElementProviderGetClockSpeedLevelResponse {
9417        type Owned = Self;
9418
9419        #[inline(always)]
9420        fn inline_align(_context: fidl::encoding::Context) -> usize {
9421            8
9422        }
9423
9424        #[inline(always)]
9425        fn inline_size(_context: fidl::encoding::Context) -> usize {
9426            16
9427        }
9428    }
9429
9430    unsafe impl
9431        fidl::encoding::Encode<
9432            PowerElementProviderGetClockSpeedLevelResponse,
9433            fidl::encoding::DefaultFuchsiaResourceDialect,
9434        > for &mut PowerElementProviderGetClockSpeedLevelResponse
9435    {
9436        unsafe fn encode(
9437            self,
9438            encoder: &mut fidl::encoding::Encoder<
9439                '_,
9440                fidl::encoding::DefaultFuchsiaResourceDialect,
9441            >,
9442            offset: usize,
9443            mut depth: fidl::encoding::Depth,
9444        ) -> fidl::Result<()> {
9445            encoder.debug_check_bounds::<PowerElementProviderGetClockSpeedLevelResponse>(offset);
9446            // Vector header
9447            let max_ordinal: u64 = self.max_ordinal_present();
9448            encoder.write_num(max_ordinal, offset);
9449            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9450            // Calling encoder.out_of_line_offset(0) is not allowed.
9451            if max_ordinal == 0 {
9452                return Ok(());
9453            }
9454            depth.increment()?;
9455            let envelope_size = 8;
9456            let bytes_len = max_ordinal as usize * envelope_size;
9457            #[allow(unused_variables)]
9458            let offset = encoder.out_of_line_offset(bytes_len);
9459            let mut _prev_end_offset: usize = 0;
9460            if 1 > max_ordinal {
9461                return Ok(());
9462            }
9463
9464            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9465            // are envelope_size bytes.
9466            let cur_offset: usize = (1 - 1) * envelope_size;
9467
9468            // Zero reserved fields.
9469            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9470
9471            // Safety:
9472            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9473            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9474            //   envelope_size bytes, there is always sufficient room.
9475            fidl::encoding::encode_in_envelope_optional::<
9476                fidl::encoding::HandleType<
9477                    fidl::Event,
9478                    { fidl::ObjectType::EVENT.into_raw() },
9479                    2147483648,
9480                >,
9481                fidl::encoding::DefaultFuchsiaResourceDialect,
9482            >(
9483                self.token.as_mut().map(
9484                    <fidl::encoding::HandleType<
9485                        fidl::Event,
9486                        { fidl::ObjectType::EVENT.into_raw() },
9487                        2147483648,
9488                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9489                ),
9490                encoder,
9491                offset + cur_offset,
9492                depth,
9493            )?;
9494
9495            _prev_end_offset = cur_offset + envelope_size;
9496            if 2 > max_ordinal {
9497                return Ok(());
9498            }
9499
9500            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9501            // are envelope_size bytes.
9502            let cur_offset: usize = (2 - 1) * envelope_size;
9503
9504            // Zero reserved fields.
9505            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9506
9507            // Safety:
9508            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9509            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9510            //   envelope_size bytes, there is always sufficient room.
9511            fidl::encoding::encode_in_envelope_optional::<
9512                u8,
9513                fidl::encoding::DefaultFuchsiaResourceDialect,
9514            >(
9515                self.level.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
9516                encoder,
9517                offset + cur_offset,
9518                depth,
9519            )?;
9520
9521            _prev_end_offset = cur_offset + envelope_size;
9522            if 3 > max_ordinal {
9523                return Ok(());
9524            }
9525
9526            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9527            // are envelope_size bytes.
9528            let cur_offset: usize = (3 - 1) * envelope_size;
9529
9530            // Zero reserved fields.
9531            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9532
9533            // Safety:
9534            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9535            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9536            //   envelope_size bytes, there is always sufficient room.
9537            fidl::encoding::encode_in_envelope_optional::<
9538                u64,
9539                fidl::encoding::DefaultFuchsiaResourceDialect,
9540            >(
9541                self.actual_hz.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9542                encoder,
9543                offset + cur_offset,
9544                depth,
9545            )?;
9546
9547            _prev_end_offset = cur_offset + envelope_size;
9548
9549            Ok(())
9550        }
9551    }
9552
9553    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9554        for PowerElementProviderGetClockSpeedLevelResponse
9555    {
9556        #[inline(always)]
9557        fn new_empty() -> Self {
9558            Self::default()
9559        }
9560
9561        unsafe fn decode(
9562            &mut self,
9563            decoder: &mut fidl::encoding::Decoder<
9564                '_,
9565                fidl::encoding::DefaultFuchsiaResourceDialect,
9566            >,
9567            offset: usize,
9568            mut depth: fidl::encoding::Depth,
9569        ) -> fidl::Result<()> {
9570            decoder.debug_check_bounds::<Self>(offset);
9571            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9572                None => return Err(fidl::Error::NotNullable),
9573                Some(len) => len,
9574            };
9575            // Calling decoder.out_of_line_offset(0) is not allowed.
9576            if len == 0 {
9577                return Ok(());
9578            };
9579            depth.increment()?;
9580            let envelope_size = 8;
9581            let bytes_len = len * envelope_size;
9582            let offset = decoder.out_of_line_offset(bytes_len)?;
9583            // Decode the envelope for each type.
9584            let mut _next_ordinal_to_read = 0;
9585            let mut next_offset = offset;
9586            let end_offset = offset + bytes_len;
9587            _next_ordinal_to_read += 1;
9588            if next_offset >= end_offset {
9589                return Ok(());
9590            }
9591
9592            // Decode unknown envelopes for gaps in ordinals.
9593            while _next_ordinal_to_read < 1 {
9594                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9595                _next_ordinal_to_read += 1;
9596                next_offset += envelope_size;
9597            }
9598
9599            let next_out_of_line = decoder.next_out_of_line();
9600            let handles_before = decoder.remaining_handles();
9601            if let Some((inlined, num_bytes, num_handles)) =
9602                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9603            {
9604                let member_inline_size = <fidl::encoding::HandleType<
9605                    fidl::Event,
9606                    { fidl::ObjectType::EVENT.into_raw() },
9607                    2147483648,
9608                > as fidl::encoding::TypeMarker>::inline_size(
9609                    decoder.context
9610                );
9611                if inlined != (member_inline_size <= 4) {
9612                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9613                }
9614                let inner_offset;
9615                let mut inner_depth = depth.clone();
9616                if inlined {
9617                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9618                    inner_offset = next_offset;
9619                } else {
9620                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9621                    inner_depth.increment()?;
9622                }
9623                let val_ref =
9624                self.token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
9625                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9626                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9627                {
9628                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9629                }
9630                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9631                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9632                }
9633            }
9634
9635            next_offset += envelope_size;
9636            _next_ordinal_to_read += 1;
9637            if next_offset >= end_offset {
9638                return Ok(());
9639            }
9640
9641            // Decode unknown envelopes for gaps in ordinals.
9642            while _next_ordinal_to_read < 2 {
9643                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9644                _next_ordinal_to_read += 1;
9645                next_offset += envelope_size;
9646            }
9647
9648            let next_out_of_line = decoder.next_out_of_line();
9649            let handles_before = decoder.remaining_handles();
9650            if let Some((inlined, num_bytes, num_handles)) =
9651                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9652            {
9653                let member_inline_size =
9654                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9655                if inlined != (member_inline_size <= 4) {
9656                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9657                }
9658                let inner_offset;
9659                let mut inner_depth = depth.clone();
9660                if inlined {
9661                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9662                    inner_offset = next_offset;
9663                } else {
9664                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9665                    inner_depth.increment()?;
9666                }
9667                let val_ref = self.level.get_or_insert_with(|| {
9668                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
9669                });
9670                fidl::decode!(
9671                    u8,
9672                    fidl::encoding::DefaultFuchsiaResourceDialect,
9673                    val_ref,
9674                    decoder,
9675                    inner_offset,
9676                    inner_depth
9677                )?;
9678                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9679                {
9680                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9681                }
9682                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9683                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9684                }
9685            }
9686
9687            next_offset += envelope_size;
9688            _next_ordinal_to_read += 1;
9689            if next_offset >= end_offset {
9690                return Ok(());
9691            }
9692
9693            // Decode unknown envelopes for gaps in ordinals.
9694            while _next_ordinal_to_read < 3 {
9695                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9696                _next_ordinal_to_read += 1;
9697                next_offset += envelope_size;
9698            }
9699
9700            let next_out_of_line = decoder.next_out_of_line();
9701            let handles_before = decoder.remaining_handles();
9702            if let Some((inlined, num_bytes, num_handles)) =
9703                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9704            {
9705                let member_inline_size =
9706                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9707                if inlined != (member_inline_size <= 4) {
9708                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9709                }
9710                let inner_offset;
9711                let mut inner_depth = depth.clone();
9712                if inlined {
9713                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9714                    inner_offset = next_offset;
9715                } else {
9716                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9717                    inner_depth.increment()?;
9718                }
9719                let val_ref = self.actual_hz.get_or_insert_with(|| {
9720                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
9721                });
9722                fidl::decode!(
9723                    u64,
9724                    fidl::encoding::DefaultFuchsiaResourceDialect,
9725                    val_ref,
9726                    decoder,
9727                    inner_offset,
9728                    inner_depth
9729                )?;
9730                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9731                {
9732                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9733                }
9734                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9735                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9736                }
9737            }
9738
9739            next_offset += envelope_size;
9740
9741            // Decode the remaining unknown envelopes.
9742            while next_offset < end_offset {
9743                _next_ordinal_to_read += 1;
9744                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9745                next_offset += envelope_size;
9746            }
9747
9748            Ok(())
9749        }
9750    }
9751
9752    impl PowerElementProviderSetClockLimitResponse {
9753        #[inline(always)]
9754        fn max_ordinal_present(&self) -> u64 {
9755            if let Some(_) = self.actual_hz {
9756                return 2;
9757            }
9758            if let Some(_) = self.handle {
9759                return 1;
9760            }
9761            0
9762        }
9763    }
9764
9765    impl fidl::encoding::ResourceTypeMarker for PowerElementProviderSetClockLimitResponse {
9766        type Borrowed<'a> = &'a mut Self;
9767        fn take_or_borrow<'a>(
9768            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9769        ) -> Self::Borrowed<'a> {
9770            value
9771        }
9772    }
9773
9774    unsafe impl fidl::encoding::TypeMarker for PowerElementProviderSetClockLimitResponse {
9775        type Owned = Self;
9776
9777        #[inline(always)]
9778        fn inline_align(_context: fidl::encoding::Context) -> usize {
9779            8
9780        }
9781
9782        #[inline(always)]
9783        fn inline_size(_context: fidl::encoding::Context) -> usize {
9784            16
9785        }
9786    }
9787
9788    unsafe impl
9789        fidl::encoding::Encode<
9790            PowerElementProviderSetClockLimitResponse,
9791            fidl::encoding::DefaultFuchsiaResourceDialect,
9792        > for &mut PowerElementProviderSetClockLimitResponse
9793    {
9794        unsafe fn encode(
9795            self,
9796            encoder: &mut fidl::encoding::Encoder<
9797                '_,
9798                fidl::encoding::DefaultFuchsiaResourceDialect,
9799            >,
9800            offset: usize,
9801            mut depth: fidl::encoding::Depth,
9802        ) -> fidl::Result<()> {
9803            encoder.debug_check_bounds::<PowerElementProviderSetClockLimitResponse>(offset);
9804            // Vector header
9805            let max_ordinal: u64 = self.max_ordinal_present();
9806            encoder.write_num(max_ordinal, offset);
9807            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9808            // Calling encoder.out_of_line_offset(0) is not allowed.
9809            if max_ordinal == 0 {
9810                return Ok(());
9811            }
9812            depth.increment()?;
9813            let envelope_size = 8;
9814            let bytes_len = max_ordinal as usize * envelope_size;
9815            #[allow(unused_variables)]
9816            let offset = encoder.out_of_line_offset(bytes_len);
9817            let mut _prev_end_offset: usize = 0;
9818            if 1 > max_ordinal {
9819                return Ok(());
9820            }
9821
9822            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9823            // are envelope_size bytes.
9824            let cur_offset: usize = (1 - 1) * envelope_size;
9825
9826            // Zero reserved fields.
9827            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9828
9829            // Safety:
9830            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9831            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9832            //   envelope_size bytes, there is always sufficient room.
9833            fidl::encoding::encode_in_envelope_optional::<
9834                fidl::encoding::HandleType<
9835                    fidl::EventPair,
9836                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9837                    2147483648,
9838                >,
9839                fidl::encoding::DefaultFuchsiaResourceDialect,
9840            >(
9841                self.handle.as_mut().map(
9842                    <fidl::encoding::HandleType<
9843                        fidl::EventPair,
9844                        { fidl::ObjectType::EVENTPAIR.into_raw() },
9845                        2147483648,
9846                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9847                ),
9848                encoder,
9849                offset + cur_offset,
9850                depth,
9851            )?;
9852
9853            _prev_end_offset = cur_offset + envelope_size;
9854            if 2 > max_ordinal {
9855                return Ok(());
9856            }
9857
9858            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9859            // are envelope_size bytes.
9860            let cur_offset: usize = (2 - 1) * envelope_size;
9861
9862            // Zero reserved fields.
9863            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9864
9865            // Safety:
9866            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9867            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9868            //   envelope_size bytes, there is always sufficient room.
9869            fidl::encoding::encode_in_envelope_optional::<
9870                u64,
9871                fidl::encoding::DefaultFuchsiaResourceDialect,
9872            >(
9873                self.actual_hz.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9874                encoder,
9875                offset + cur_offset,
9876                depth,
9877            )?;
9878
9879            _prev_end_offset = cur_offset + envelope_size;
9880
9881            Ok(())
9882        }
9883    }
9884
9885    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9886        for PowerElementProviderSetClockLimitResponse
9887    {
9888        #[inline(always)]
9889        fn new_empty() -> Self {
9890            Self::default()
9891        }
9892
9893        unsafe fn decode(
9894            &mut self,
9895            decoder: &mut fidl::encoding::Decoder<
9896                '_,
9897                fidl::encoding::DefaultFuchsiaResourceDialect,
9898            >,
9899            offset: usize,
9900            mut depth: fidl::encoding::Depth,
9901        ) -> fidl::Result<()> {
9902            decoder.debug_check_bounds::<Self>(offset);
9903            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9904                None => return Err(fidl::Error::NotNullable),
9905                Some(len) => len,
9906            };
9907            // Calling decoder.out_of_line_offset(0) is not allowed.
9908            if len == 0 {
9909                return Ok(());
9910            };
9911            depth.increment()?;
9912            let envelope_size = 8;
9913            let bytes_len = len * envelope_size;
9914            let offset = decoder.out_of_line_offset(bytes_len)?;
9915            // Decode the envelope for each type.
9916            let mut _next_ordinal_to_read = 0;
9917            let mut next_offset = offset;
9918            let end_offset = offset + bytes_len;
9919            _next_ordinal_to_read += 1;
9920            if next_offset >= end_offset {
9921                return Ok(());
9922            }
9923
9924            // Decode unknown envelopes for gaps in ordinals.
9925            while _next_ordinal_to_read < 1 {
9926                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9927                _next_ordinal_to_read += 1;
9928                next_offset += envelope_size;
9929            }
9930
9931            let next_out_of_line = decoder.next_out_of_line();
9932            let handles_before = decoder.remaining_handles();
9933            if let Some((inlined, num_bytes, num_handles)) =
9934                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9935            {
9936                let member_inline_size = <fidl::encoding::HandleType<
9937                    fidl::EventPair,
9938                    { fidl::ObjectType::EVENTPAIR.into_raw() },
9939                    2147483648,
9940                > as fidl::encoding::TypeMarker>::inline_size(
9941                    decoder.context
9942                );
9943                if inlined != (member_inline_size <= 4) {
9944                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9945                }
9946                let inner_offset;
9947                let mut inner_depth = depth.clone();
9948                if inlined {
9949                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9950                    inner_offset = next_offset;
9951                } else {
9952                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9953                    inner_depth.increment()?;
9954                }
9955                let val_ref =
9956                self.handle.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
9957                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9958                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9959                {
9960                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9961                }
9962                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9963                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9964                }
9965            }
9966
9967            next_offset += envelope_size;
9968            _next_ordinal_to_read += 1;
9969            if next_offset >= end_offset {
9970                return Ok(());
9971            }
9972
9973            // Decode unknown envelopes for gaps in ordinals.
9974            while _next_ordinal_to_read < 2 {
9975                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9976                _next_ordinal_to_read += 1;
9977                next_offset += envelope_size;
9978            }
9979
9980            let next_out_of_line = decoder.next_out_of_line();
9981            let handles_before = decoder.remaining_handles();
9982            if let Some((inlined, num_bytes, num_handles)) =
9983                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9984            {
9985                let member_inline_size =
9986                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9987                if inlined != (member_inline_size <= 4) {
9988                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9989                }
9990                let inner_offset;
9991                let mut inner_depth = depth.clone();
9992                if inlined {
9993                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9994                    inner_offset = next_offset;
9995                } else {
9996                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9997                    inner_depth.increment()?;
9998                }
9999                let val_ref = self.actual_hz.get_or_insert_with(|| {
10000                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
10001                });
10002                fidl::decode!(
10003                    u64,
10004                    fidl::encoding::DefaultFuchsiaResourceDialect,
10005                    val_ref,
10006                    decoder,
10007                    inner_offset,
10008                    inner_depth
10009                )?;
10010                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10011                {
10012                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10013                }
10014                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10015                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10016                }
10017            }
10018
10019            next_offset += envelope_size;
10020
10021            // Decode the remaining unknown envelopes.
10022            while next_offset < end_offset {
10023                _next_ordinal_to_read += 1;
10024                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10025                next_offset += envelope_size;
10026            }
10027
10028            Ok(())
10029        }
10030    }
10031
10032    impl PowerGoal {
10033        #[inline(always)]
10034        fn max_ordinal_present(&self) -> u64 {
10035            if let Some(_) = self.token {
10036                return 2;
10037            }
10038            if let Some(_) = self.type_ {
10039                return 1;
10040            }
10041            0
10042        }
10043    }
10044
10045    impl fidl::encoding::ResourceTypeMarker for PowerGoal {
10046        type Borrowed<'a> = &'a mut Self;
10047        fn take_or_borrow<'a>(
10048            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10049        ) -> Self::Borrowed<'a> {
10050            value
10051        }
10052    }
10053
10054    unsafe impl fidl::encoding::TypeMarker for PowerGoal {
10055        type Owned = Self;
10056
10057        #[inline(always)]
10058        fn inline_align(_context: fidl::encoding::Context) -> usize {
10059            8
10060        }
10061
10062        #[inline(always)]
10063        fn inline_size(_context: fidl::encoding::Context) -> usize {
10064            16
10065        }
10066    }
10067
10068    unsafe impl fidl::encoding::Encode<PowerGoal, fidl::encoding::DefaultFuchsiaResourceDialect>
10069        for &mut PowerGoal
10070    {
10071        unsafe fn encode(
10072            self,
10073            encoder: &mut fidl::encoding::Encoder<
10074                '_,
10075                fidl::encoding::DefaultFuchsiaResourceDialect,
10076            >,
10077            offset: usize,
10078            mut depth: fidl::encoding::Depth,
10079        ) -> fidl::Result<()> {
10080            encoder.debug_check_bounds::<PowerGoal>(offset);
10081            // Vector header
10082            let max_ordinal: u64 = self.max_ordinal_present();
10083            encoder.write_num(max_ordinal, offset);
10084            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10085            // Calling encoder.out_of_line_offset(0) is not allowed.
10086            if max_ordinal == 0 {
10087                return Ok(());
10088            }
10089            depth.increment()?;
10090            let envelope_size = 8;
10091            let bytes_len = max_ordinal as usize * envelope_size;
10092            #[allow(unused_variables)]
10093            let offset = encoder.out_of_line_offset(bytes_len);
10094            let mut _prev_end_offset: usize = 0;
10095            if 1 > max_ordinal {
10096                return Ok(());
10097            }
10098
10099            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10100            // are envelope_size bytes.
10101            let cur_offset: usize = (1 - 1) * envelope_size;
10102
10103            // Zero reserved fields.
10104            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10105
10106            // Safety:
10107            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10108            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10109            //   envelope_size bytes, there is always sufficient room.
10110            fidl::encoding::encode_in_envelope_optional::<
10111                PowerGoalType,
10112                fidl::encoding::DefaultFuchsiaResourceDialect,
10113            >(
10114                self.type_.as_ref().map(<PowerGoalType as fidl::encoding::ValueTypeMarker>::borrow),
10115                encoder,
10116                offset + cur_offset,
10117                depth,
10118            )?;
10119
10120            _prev_end_offset = cur_offset + envelope_size;
10121            if 2 > max_ordinal {
10122                return Ok(());
10123            }
10124
10125            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10126            // are envelope_size bytes.
10127            let cur_offset: usize = (2 - 1) * envelope_size;
10128
10129            // Zero reserved fields.
10130            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10131
10132            // Safety:
10133            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10134            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10135            //   envelope_size bytes, there is always sufficient room.
10136            fidl::encoding::encode_in_envelope_optional::<
10137                fidl::encoding::HandleType<
10138                    fidl::Event,
10139                    { fidl::ObjectType::EVENT.into_raw() },
10140                    2147483648,
10141                >,
10142                fidl::encoding::DefaultFuchsiaResourceDialect,
10143            >(
10144                self.token.as_mut().map(
10145                    <fidl::encoding::HandleType<
10146                        fidl::Event,
10147                        { fidl::ObjectType::EVENT.into_raw() },
10148                        2147483648,
10149                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10150                ),
10151                encoder,
10152                offset + cur_offset,
10153                depth,
10154            )?;
10155
10156            _prev_end_offset = cur_offset + envelope_size;
10157
10158            Ok(())
10159        }
10160    }
10161
10162    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PowerGoal {
10163        #[inline(always)]
10164        fn new_empty() -> Self {
10165            Self::default()
10166        }
10167
10168        unsafe fn decode(
10169            &mut self,
10170            decoder: &mut fidl::encoding::Decoder<
10171                '_,
10172                fidl::encoding::DefaultFuchsiaResourceDialect,
10173            >,
10174            offset: usize,
10175            mut depth: fidl::encoding::Depth,
10176        ) -> fidl::Result<()> {
10177            decoder.debug_check_bounds::<Self>(offset);
10178            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10179                None => return Err(fidl::Error::NotNullable),
10180                Some(len) => len,
10181            };
10182            // Calling decoder.out_of_line_offset(0) is not allowed.
10183            if len == 0 {
10184                return Ok(());
10185            };
10186            depth.increment()?;
10187            let envelope_size = 8;
10188            let bytes_len = len * envelope_size;
10189            let offset = decoder.out_of_line_offset(bytes_len)?;
10190            // Decode the envelope for each type.
10191            let mut _next_ordinal_to_read = 0;
10192            let mut next_offset = offset;
10193            let end_offset = offset + bytes_len;
10194            _next_ordinal_to_read += 1;
10195            if next_offset >= end_offset {
10196                return Ok(());
10197            }
10198
10199            // Decode unknown envelopes for gaps in ordinals.
10200            while _next_ordinal_to_read < 1 {
10201                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10202                _next_ordinal_to_read += 1;
10203                next_offset += envelope_size;
10204            }
10205
10206            let next_out_of_line = decoder.next_out_of_line();
10207            let handles_before = decoder.remaining_handles();
10208            if let Some((inlined, num_bytes, num_handles)) =
10209                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10210            {
10211                let member_inline_size =
10212                    <PowerGoalType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10213                if inlined != (member_inline_size <= 4) {
10214                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10215                }
10216                let inner_offset;
10217                let mut inner_depth = depth.clone();
10218                if inlined {
10219                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10220                    inner_offset = next_offset;
10221                } else {
10222                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10223                    inner_depth.increment()?;
10224                }
10225                let val_ref = self.type_.get_or_insert_with(|| {
10226                    fidl::new_empty!(PowerGoalType, fidl::encoding::DefaultFuchsiaResourceDialect)
10227                });
10228                fidl::decode!(
10229                    PowerGoalType,
10230                    fidl::encoding::DefaultFuchsiaResourceDialect,
10231                    val_ref,
10232                    decoder,
10233                    inner_offset,
10234                    inner_depth
10235                )?;
10236                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10237                {
10238                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10239                }
10240                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10241                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10242                }
10243            }
10244
10245            next_offset += envelope_size;
10246            _next_ordinal_to_read += 1;
10247            if next_offset >= end_offset {
10248                return Ok(());
10249            }
10250
10251            // Decode unknown envelopes for gaps in ordinals.
10252            while _next_ordinal_to_read < 2 {
10253                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10254                _next_ordinal_to_read += 1;
10255                next_offset += envelope_size;
10256            }
10257
10258            let next_out_of_line = decoder.next_out_of_line();
10259            let handles_before = decoder.remaining_handles();
10260            if let Some((inlined, num_bytes, num_handles)) =
10261                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10262            {
10263                let member_inline_size = <fidl::encoding::HandleType<
10264                    fidl::Event,
10265                    { fidl::ObjectType::EVENT.into_raw() },
10266                    2147483648,
10267                > as fidl::encoding::TypeMarker>::inline_size(
10268                    decoder.context
10269                );
10270                if inlined != (member_inline_size <= 4) {
10271                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10272                }
10273                let inner_offset;
10274                let mut inner_depth = depth.clone();
10275                if inlined {
10276                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10277                    inner_offset = next_offset;
10278                } else {
10279                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10280                    inner_depth.increment()?;
10281                }
10282                let val_ref =
10283                self.token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
10284                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10285                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10286                {
10287                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10288                }
10289                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10290                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10291                }
10292            }
10293
10294            next_offset += envelope_size;
10295
10296            // Decode the remaining unknown envelopes.
10297            while next_offset < end_offset {
10298                _next_ordinal_to_read += 1;
10299                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10300                next_offset += envelope_size;
10301            }
10302
10303            Ok(())
10304        }
10305    }
10306
10307    impl PrimaryImportObjectRequest {
10308        #[inline(always)]
10309        fn max_ordinal_present(&self) -> u64 {
10310            if let Some(_) = self.flags {
10311                return 4;
10312            }
10313            if let Some(_) = self.object_id {
10314                return 3;
10315            }
10316            if let Some(_) = self.object_type {
10317                return 2;
10318            }
10319            if let Some(_) = self.object {
10320                return 1;
10321            }
10322            0
10323        }
10324    }
10325
10326    impl fidl::encoding::ResourceTypeMarker for PrimaryImportObjectRequest {
10327        type Borrowed<'a> = &'a mut Self;
10328        fn take_or_borrow<'a>(
10329            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10330        ) -> Self::Borrowed<'a> {
10331            value
10332        }
10333    }
10334
10335    unsafe impl fidl::encoding::TypeMarker for PrimaryImportObjectRequest {
10336        type Owned = Self;
10337
10338        #[inline(always)]
10339        fn inline_align(_context: fidl::encoding::Context) -> usize {
10340            8
10341        }
10342
10343        #[inline(always)]
10344        fn inline_size(_context: fidl::encoding::Context) -> usize {
10345            16
10346        }
10347    }
10348
10349    unsafe impl
10350        fidl::encoding::Encode<
10351            PrimaryImportObjectRequest,
10352            fidl::encoding::DefaultFuchsiaResourceDialect,
10353        > for &mut PrimaryImportObjectRequest
10354    {
10355        unsafe fn encode(
10356            self,
10357            encoder: &mut fidl::encoding::Encoder<
10358                '_,
10359                fidl::encoding::DefaultFuchsiaResourceDialect,
10360            >,
10361            offset: usize,
10362            mut depth: fidl::encoding::Depth,
10363        ) -> fidl::Result<()> {
10364            encoder.debug_check_bounds::<PrimaryImportObjectRequest>(offset);
10365            // Vector header
10366            let max_ordinal: u64 = self.max_ordinal_present();
10367            encoder.write_num(max_ordinal, offset);
10368            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10369            // Calling encoder.out_of_line_offset(0) is not allowed.
10370            if max_ordinal == 0 {
10371                return Ok(());
10372            }
10373            depth.increment()?;
10374            let envelope_size = 8;
10375            let bytes_len = max_ordinal as usize * envelope_size;
10376            #[allow(unused_variables)]
10377            let offset = encoder.out_of_line_offset(bytes_len);
10378            let mut _prev_end_offset: usize = 0;
10379            if 1 > max_ordinal {
10380                return Ok(());
10381            }
10382
10383            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10384            // are envelope_size bytes.
10385            let cur_offset: usize = (1 - 1) * envelope_size;
10386
10387            // Zero reserved fields.
10388            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10389
10390            // Safety:
10391            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10392            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10393            //   envelope_size bytes, there is always sufficient room.
10394            fidl::encoding::encode_in_envelope_optional::<
10395                Object,
10396                fidl::encoding::DefaultFuchsiaResourceDialect,
10397            >(
10398                self.object
10399                    .as_mut()
10400                    .map(<Object as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10401                encoder,
10402                offset + cur_offset,
10403                depth,
10404            )?;
10405
10406            _prev_end_offset = cur_offset + envelope_size;
10407            if 2 > max_ordinal {
10408                return Ok(());
10409            }
10410
10411            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10412            // are envelope_size bytes.
10413            let cur_offset: usize = (2 - 1) * envelope_size;
10414
10415            // Zero reserved fields.
10416            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10417
10418            // Safety:
10419            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10420            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10421            //   envelope_size bytes, there is always sufficient room.
10422            fidl::encoding::encode_in_envelope_optional::<
10423                ObjectType,
10424                fidl::encoding::DefaultFuchsiaResourceDialect,
10425            >(
10426                self.object_type
10427                    .as_ref()
10428                    .map(<ObjectType as fidl::encoding::ValueTypeMarker>::borrow),
10429                encoder,
10430                offset + cur_offset,
10431                depth,
10432            )?;
10433
10434            _prev_end_offset = cur_offset + envelope_size;
10435            if 3 > max_ordinal {
10436                return Ok(());
10437            }
10438
10439            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10440            // are envelope_size bytes.
10441            let cur_offset: usize = (3 - 1) * envelope_size;
10442
10443            // Zero reserved fields.
10444            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10445
10446            // Safety:
10447            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10448            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10449            //   envelope_size bytes, there is always sufficient room.
10450            fidl::encoding::encode_in_envelope_optional::<
10451                u64,
10452                fidl::encoding::DefaultFuchsiaResourceDialect,
10453            >(
10454                self.object_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10455                encoder,
10456                offset + cur_offset,
10457                depth,
10458            )?;
10459
10460            _prev_end_offset = cur_offset + envelope_size;
10461            if 4 > max_ordinal {
10462                return Ok(());
10463            }
10464
10465            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10466            // are envelope_size bytes.
10467            let cur_offset: usize = (4 - 1) * envelope_size;
10468
10469            // Zero reserved fields.
10470            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10471
10472            // Safety:
10473            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10474            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10475            //   envelope_size bytes, there is always sufficient room.
10476            fidl::encoding::encode_in_envelope_optional::<
10477                ImportFlags,
10478                fidl::encoding::DefaultFuchsiaResourceDialect,
10479            >(
10480                self.flags.as_ref().map(<ImportFlags as fidl::encoding::ValueTypeMarker>::borrow),
10481                encoder,
10482                offset + cur_offset,
10483                depth,
10484            )?;
10485
10486            _prev_end_offset = cur_offset + envelope_size;
10487
10488            Ok(())
10489        }
10490    }
10491
10492    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10493        for PrimaryImportObjectRequest
10494    {
10495        #[inline(always)]
10496        fn new_empty() -> Self {
10497            Self::default()
10498        }
10499
10500        unsafe fn decode(
10501            &mut self,
10502            decoder: &mut fidl::encoding::Decoder<
10503                '_,
10504                fidl::encoding::DefaultFuchsiaResourceDialect,
10505            >,
10506            offset: usize,
10507            mut depth: fidl::encoding::Depth,
10508        ) -> fidl::Result<()> {
10509            decoder.debug_check_bounds::<Self>(offset);
10510            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10511                None => return Err(fidl::Error::NotNullable),
10512                Some(len) => len,
10513            };
10514            // Calling decoder.out_of_line_offset(0) is not allowed.
10515            if len == 0 {
10516                return Ok(());
10517            };
10518            depth.increment()?;
10519            let envelope_size = 8;
10520            let bytes_len = len * envelope_size;
10521            let offset = decoder.out_of_line_offset(bytes_len)?;
10522            // Decode the envelope for each type.
10523            let mut _next_ordinal_to_read = 0;
10524            let mut next_offset = offset;
10525            let end_offset = offset + bytes_len;
10526            _next_ordinal_to_read += 1;
10527            if next_offset >= end_offset {
10528                return Ok(());
10529            }
10530
10531            // Decode unknown envelopes for gaps in ordinals.
10532            while _next_ordinal_to_read < 1 {
10533                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10534                _next_ordinal_to_read += 1;
10535                next_offset += envelope_size;
10536            }
10537
10538            let next_out_of_line = decoder.next_out_of_line();
10539            let handles_before = decoder.remaining_handles();
10540            if let Some((inlined, num_bytes, num_handles)) =
10541                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10542            {
10543                let member_inline_size =
10544                    <Object as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10545                if inlined != (member_inline_size <= 4) {
10546                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10547                }
10548                let inner_offset;
10549                let mut inner_depth = depth.clone();
10550                if inlined {
10551                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10552                    inner_offset = next_offset;
10553                } else {
10554                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10555                    inner_depth.increment()?;
10556                }
10557                let val_ref = self.object.get_or_insert_with(|| {
10558                    fidl::new_empty!(Object, fidl::encoding::DefaultFuchsiaResourceDialect)
10559                });
10560                fidl::decode!(
10561                    Object,
10562                    fidl::encoding::DefaultFuchsiaResourceDialect,
10563                    val_ref,
10564                    decoder,
10565                    inner_offset,
10566                    inner_depth
10567                )?;
10568                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10569                {
10570                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10571                }
10572                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10573                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10574                }
10575            }
10576
10577            next_offset += envelope_size;
10578            _next_ordinal_to_read += 1;
10579            if next_offset >= end_offset {
10580                return Ok(());
10581            }
10582
10583            // Decode unknown envelopes for gaps in ordinals.
10584            while _next_ordinal_to_read < 2 {
10585                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10586                _next_ordinal_to_read += 1;
10587                next_offset += envelope_size;
10588            }
10589
10590            let next_out_of_line = decoder.next_out_of_line();
10591            let handles_before = decoder.remaining_handles();
10592            if let Some((inlined, num_bytes, num_handles)) =
10593                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10594            {
10595                let member_inline_size =
10596                    <ObjectType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10597                if inlined != (member_inline_size <= 4) {
10598                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10599                }
10600                let inner_offset;
10601                let mut inner_depth = depth.clone();
10602                if inlined {
10603                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10604                    inner_offset = next_offset;
10605                } else {
10606                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10607                    inner_depth.increment()?;
10608                }
10609                let val_ref = self.object_type.get_or_insert_with(|| {
10610                    fidl::new_empty!(ObjectType, fidl::encoding::DefaultFuchsiaResourceDialect)
10611                });
10612                fidl::decode!(
10613                    ObjectType,
10614                    fidl::encoding::DefaultFuchsiaResourceDialect,
10615                    val_ref,
10616                    decoder,
10617                    inner_offset,
10618                    inner_depth
10619                )?;
10620                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10621                {
10622                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10623                }
10624                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10625                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10626                }
10627            }
10628
10629            next_offset += envelope_size;
10630            _next_ordinal_to_read += 1;
10631            if next_offset >= end_offset {
10632                return Ok(());
10633            }
10634
10635            // Decode unknown envelopes for gaps in ordinals.
10636            while _next_ordinal_to_read < 3 {
10637                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10638                _next_ordinal_to_read += 1;
10639                next_offset += envelope_size;
10640            }
10641
10642            let next_out_of_line = decoder.next_out_of_line();
10643            let handles_before = decoder.remaining_handles();
10644            if let Some((inlined, num_bytes, num_handles)) =
10645                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10646            {
10647                let member_inline_size =
10648                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10649                if inlined != (member_inline_size <= 4) {
10650                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10651                }
10652                let inner_offset;
10653                let mut inner_depth = depth.clone();
10654                if inlined {
10655                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10656                    inner_offset = next_offset;
10657                } else {
10658                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10659                    inner_depth.increment()?;
10660                }
10661                let val_ref = self.object_id.get_or_insert_with(|| {
10662                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
10663                });
10664                fidl::decode!(
10665                    u64,
10666                    fidl::encoding::DefaultFuchsiaResourceDialect,
10667                    val_ref,
10668                    decoder,
10669                    inner_offset,
10670                    inner_depth
10671                )?;
10672                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10673                {
10674                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10675                }
10676                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10677                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10678                }
10679            }
10680
10681            next_offset += envelope_size;
10682            _next_ordinal_to_read += 1;
10683            if next_offset >= end_offset {
10684                return Ok(());
10685            }
10686
10687            // Decode unknown envelopes for gaps in ordinals.
10688            while _next_ordinal_to_read < 4 {
10689                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10690                _next_ordinal_to_read += 1;
10691                next_offset += envelope_size;
10692            }
10693
10694            let next_out_of_line = decoder.next_out_of_line();
10695            let handles_before = decoder.remaining_handles();
10696            if let Some((inlined, num_bytes, num_handles)) =
10697                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10698            {
10699                let member_inline_size =
10700                    <ImportFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10701                if inlined != (member_inline_size <= 4) {
10702                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10703                }
10704                let inner_offset;
10705                let mut inner_depth = depth.clone();
10706                if inlined {
10707                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10708                    inner_offset = next_offset;
10709                } else {
10710                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10711                    inner_depth.increment()?;
10712                }
10713                let val_ref = self.flags.get_or_insert_with(|| {
10714                    fidl::new_empty!(ImportFlags, fidl::encoding::DefaultFuchsiaResourceDialect)
10715                });
10716                fidl::decode!(
10717                    ImportFlags,
10718                    fidl::encoding::DefaultFuchsiaResourceDialect,
10719                    val_ref,
10720                    decoder,
10721                    inner_offset,
10722                    inner_depth
10723                )?;
10724                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10725                {
10726                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10727                }
10728                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10729                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10730                }
10731            }
10732
10733            next_offset += envelope_size;
10734
10735            // Decode the remaining unknown envelopes.
10736            while next_offset < end_offset {
10737                _next_ordinal_to_read += 1;
10738                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10739                next_offset += envelope_size;
10740            }
10741
10742            Ok(())
10743        }
10744    }
10745
10746    impl fidl::encoding::ResourceTypeMarker for DeviceQueryResponse {
10747        type Borrowed<'a> = &'a mut Self;
10748        fn take_or_borrow<'a>(
10749            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10750        ) -> Self::Borrowed<'a> {
10751            value
10752        }
10753    }
10754
10755    unsafe impl fidl::encoding::TypeMarker for DeviceQueryResponse {
10756        type Owned = Self;
10757
10758        #[inline(always)]
10759        fn inline_align(_context: fidl::encoding::Context) -> usize {
10760            8
10761        }
10762
10763        #[inline(always)]
10764        fn inline_size(_context: fidl::encoding::Context) -> usize {
10765            16
10766        }
10767    }
10768
10769    unsafe impl
10770        fidl::encoding::Encode<DeviceQueryResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
10771        for &mut DeviceQueryResponse
10772    {
10773        #[inline]
10774        unsafe fn encode(
10775            self,
10776            encoder: &mut fidl::encoding::Encoder<
10777                '_,
10778                fidl::encoding::DefaultFuchsiaResourceDialect,
10779            >,
10780            offset: usize,
10781            _depth: fidl::encoding::Depth,
10782        ) -> fidl::Result<()> {
10783            encoder.debug_check_bounds::<DeviceQueryResponse>(offset);
10784            encoder.write_num::<u64>(self.ordinal(), offset);
10785            match self {
10786                DeviceQueryResponse::SimpleResult(ref val) => fidl::encoding::encode_in_envelope::<
10787                    u64,
10788                    fidl::encoding::DefaultFuchsiaResourceDialect,
10789                >(
10790                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
10791                    encoder,
10792                    offset + 8,
10793                    _depth,
10794                ),
10795                DeviceQueryResponse::BufferResult(ref mut val) => {
10796                    fidl::encoding::encode_in_envelope::<
10797                        fidl::encoding::HandleType<
10798                            fidl::Vmo,
10799                            { fidl::ObjectType::VMO.into_raw() },
10800                            2147483648,
10801                        >,
10802                        fidl::encoding::DefaultFuchsiaResourceDialect,
10803                    >(
10804                        <fidl::encoding::HandleType<
10805                            fidl::Vmo,
10806                            { fidl::ObjectType::VMO.into_raw() },
10807                            2147483648,
10808                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10809                            val
10810                        ),
10811                        encoder,
10812                        offset + 8,
10813                        _depth,
10814                    )
10815                }
10816            }
10817        }
10818    }
10819
10820    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10821        for DeviceQueryResponse
10822    {
10823        #[inline(always)]
10824        fn new_empty() -> Self {
10825            Self::SimpleResult(fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect))
10826        }
10827
10828        #[inline]
10829        unsafe fn decode(
10830            &mut self,
10831            decoder: &mut fidl::encoding::Decoder<
10832                '_,
10833                fidl::encoding::DefaultFuchsiaResourceDialect,
10834            >,
10835            offset: usize,
10836            mut depth: fidl::encoding::Depth,
10837        ) -> fidl::Result<()> {
10838            decoder.debug_check_bounds::<Self>(offset);
10839            #[allow(unused_variables)]
10840            let next_out_of_line = decoder.next_out_of_line();
10841            let handles_before = decoder.remaining_handles();
10842            let (ordinal, inlined, num_bytes, num_handles) =
10843                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
10844
10845            let member_inline_size = match ordinal {
10846                1 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
10847                2 => <fidl::encoding::HandleType<
10848                    fidl::Vmo,
10849                    { fidl::ObjectType::VMO.into_raw() },
10850                    2147483648,
10851                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
10852                _ => return Err(fidl::Error::UnknownUnionTag),
10853            };
10854
10855            if inlined != (member_inline_size <= 4) {
10856                return Err(fidl::Error::InvalidInlineBitInEnvelope);
10857            }
10858            let _inner_offset;
10859            if inlined {
10860                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
10861                _inner_offset = offset + 8;
10862            } else {
10863                depth.increment()?;
10864                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10865            }
10866            match ordinal {
10867                1 => {
10868                    #[allow(irrefutable_let_patterns)]
10869                    if let DeviceQueryResponse::SimpleResult(_) = self {
10870                        // Do nothing, read the value into the object
10871                    } else {
10872                        // Initialize `self` to the right variant
10873                        *self = DeviceQueryResponse::SimpleResult(fidl::new_empty!(
10874                            u64,
10875                            fidl::encoding::DefaultFuchsiaResourceDialect
10876                        ));
10877                    }
10878                    #[allow(irrefutable_let_patterns)]
10879                    if let DeviceQueryResponse::SimpleResult(ref mut val) = self {
10880                        fidl::decode!(
10881                            u64,
10882                            fidl::encoding::DefaultFuchsiaResourceDialect,
10883                            val,
10884                            decoder,
10885                            _inner_offset,
10886                            depth
10887                        )?;
10888                    } else {
10889                        unreachable!()
10890                    }
10891                }
10892                2 => {
10893                    #[allow(irrefutable_let_patterns)]
10894                    if let DeviceQueryResponse::BufferResult(_) = self {
10895                        // Do nothing, read the value into the object
10896                    } else {
10897                        // Initialize `self` to the right variant
10898                        *self = DeviceQueryResponse::BufferResult(
10899                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
10900                        );
10901                    }
10902                    #[allow(irrefutable_let_patterns)]
10903                    if let DeviceQueryResponse::BufferResult(ref mut val) = self {
10904                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
10905                    } else {
10906                        unreachable!()
10907                    }
10908                }
10909                ordinal => panic!("unexpected ordinal {:?}", ordinal),
10910            }
10911            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
10912                return Err(fidl::Error::InvalidNumBytesInEnvelope);
10913            }
10914            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10915                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10916            }
10917            Ok(())
10918        }
10919    }
10920
10921    impl fidl::encoding::ResourceTypeMarker for Object {
10922        type Borrowed<'a> = &'a mut Self;
10923        fn take_or_borrow<'a>(
10924            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10925        ) -> Self::Borrowed<'a> {
10926            value
10927        }
10928    }
10929
10930    unsafe impl fidl::encoding::TypeMarker for Object {
10931        type Owned = Self;
10932
10933        #[inline(always)]
10934        fn inline_align(_context: fidl::encoding::Context) -> usize {
10935            8
10936        }
10937
10938        #[inline(always)]
10939        fn inline_size(_context: fidl::encoding::Context) -> usize {
10940            16
10941        }
10942    }
10943
10944    unsafe impl fidl::encoding::Encode<Object, fidl::encoding::DefaultFuchsiaResourceDialect>
10945        for &mut Object
10946    {
10947        #[inline]
10948        unsafe fn encode(
10949            self,
10950            encoder: &mut fidl::encoding::Encoder<
10951                '_,
10952                fidl::encoding::DefaultFuchsiaResourceDialect,
10953            >,
10954            offset: usize,
10955            _depth: fidl::encoding::Depth,
10956        ) -> fidl::Result<()> {
10957            encoder.debug_check_bounds::<Object>(offset);
10958            encoder.write_num::<u64>(self.ordinal(), offset);
10959            match self {
10960                Object::Semaphore(ref mut val) => fidl::encoding::encode_in_envelope::<
10961                    fidl::encoding::HandleType<
10962                        fidl::Event,
10963                        { fidl::ObjectType::EVENT.into_raw() },
10964                        2147483648,
10965                    >,
10966                    fidl::encoding::DefaultFuchsiaResourceDialect,
10967                >(
10968                    <fidl::encoding::HandleType<
10969                        fidl::Event,
10970                        { fidl::ObjectType::EVENT.into_raw() },
10971                        2147483648,
10972                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10973                        val
10974                    ),
10975                    encoder,
10976                    offset + 8,
10977                    _depth,
10978                ),
10979                Object::Buffer(ref mut val) => fidl::encoding::encode_in_envelope::<
10980                    fidl::encoding::HandleType<
10981                        fidl::Vmo,
10982                        { fidl::ObjectType::VMO.into_raw() },
10983                        2147483648,
10984                    >,
10985                    fidl::encoding::DefaultFuchsiaResourceDialect,
10986                >(
10987                    <fidl::encoding::HandleType<
10988                        fidl::Vmo,
10989                        { fidl::ObjectType::VMO.into_raw() },
10990                        2147483648,
10991                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10992                        val
10993                    ),
10994                    encoder,
10995                    offset + 8,
10996                    _depth,
10997                ),
10998                Object::VmoSemaphore(ref mut val) => fidl::encoding::encode_in_envelope::<
10999                    fidl::encoding::HandleType<
11000                        fidl::Vmo,
11001                        { fidl::ObjectType::VMO.into_raw() },
11002                        2147483648,
11003                    >,
11004                    fidl::encoding::DefaultFuchsiaResourceDialect,
11005                >(
11006                    <fidl::encoding::HandleType<
11007                        fidl::Vmo,
11008                        { fidl::ObjectType::VMO.into_raw() },
11009                        2147483648,
11010                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11011                        val
11012                    ),
11013                    encoder,
11014                    offset + 8,
11015                    _depth,
11016                ),
11017                Object::CounterSemaphore(ref mut val) => fidl::encoding::encode_in_envelope::<
11018                    fidl::encoding::HandleType<
11019                        fidl::Counter,
11020                        { fidl::ObjectType::COUNTER.into_raw() },
11021                        2147483648,
11022                    >,
11023                    fidl::encoding::DefaultFuchsiaResourceDialect,
11024                >(
11025                    <fidl::encoding::HandleType<
11026                        fidl::Counter,
11027                        { fidl::ObjectType::COUNTER.into_raw() },
11028                        2147483648,
11029                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11030                        val
11031                    ),
11032                    encoder,
11033                    offset + 8,
11034                    _depth,
11035                ),
11036                Object::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
11037            }
11038        }
11039    }
11040
11041    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Object {
11042        #[inline(always)]
11043        fn new_empty() -> Self {
11044            Self::__SourceBreaking { unknown_ordinal: 0 }
11045        }
11046
11047        #[inline]
11048        unsafe fn decode(
11049            &mut self,
11050            decoder: &mut fidl::encoding::Decoder<
11051                '_,
11052                fidl::encoding::DefaultFuchsiaResourceDialect,
11053            >,
11054            offset: usize,
11055            mut depth: fidl::encoding::Depth,
11056        ) -> fidl::Result<()> {
11057            decoder.debug_check_bounds::<Self>(offset);
11058            #[allow(unused_variables)]
11059            let next_out_of_line = decoder.next_out_of_line();
11060            let handles_before = decoder.remaining_handles();
11061            let (ordinal, inlined, num_bytes, num_handles) =
11062                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
11063
11064            let member_inline_size = match ordinal {
11065                1 => <fidl::encoding::HandleType<
11066                    fidl::Event,
11067                    { fidl::ObjectType::EVENT.into_raw() },
11068                    2147483648,
11069                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11070                2 => <fidl::encoding::HandleType<
11071                    fidl::Vmo,
11072                    { fidl::ObjectType::VMO.into_raw() },
11073                    2147483648,
11074                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11075                3 => <fidl::encoding::HandleType<
11076                    fidl::Vmo,
11077                    { fidl::ObjectType::VMO.into_raw() },
11078                    2147483648,
11079                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11080                4 => <fidl::encoding::HandleType<
11081                    fidl::Counter,
11082                    { fidl::ObjectType::COUNTER.into_raw() },
11083                    2147483648,
11084                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11085                0 => return Err(fidl::Error::UnknownUnionTag),
11086                _ => num_bytes as usize,
11087            };
11088
11089            if inlined != (member_inline_size <= 4) {
11090                return Err(fidl::Error::InvalidInlineBitInEnvelope);
11091            }
11092            let _inner_offset;
11093            if inlined {
11094                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
11095                _inner_offset = offset + 8;
11096            } else {
11097                depth.increment()?;
11098                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11099            }
11100            match ordinal {
11101                1 => {
11102                    #[allow(irrefutable_let_patterns)]
11103                    if let Object::Semaphore(_) = self {
11104                        // Do nothing, read the value into the object
11105                    } else {
11106                        // Initialize `self` to the right variant
11107                        *self = Object::Semaphore(
11108                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11109                        );
11110                    }
11111                    #[allow(irrefutable_let_patterns)]
11112                    if let Object::Semaphore(ref mut val) = self {
11113                        fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11114                    } else {
11115                        unreachable!()
11116                    }
11117                }
11118                2 => {
11119                    #[allow(irrefutable_let_patterns)]
11120                    if let Object::Buffer(_) = self {
11121                        // Do nothing, read the value into the object
11122                    } else {
11123                        // Initialize `self` to the right variant
11124                        *self = Object::Buffer(
11125                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11126                        );
11127                    }
11128                    #[allow(irrefutable_let_patterns)]
11129                    if let Object::Buffer(ref mut val) = self {
11130                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11131                    } else {
11132                        unreachable!()
11133                    }
11134                }
11135                3 => {
11136                    #[allow(irrefutable_let_patterns)]
11137                    if let Object::VmoSemaphore(_) = self {
11138                        // Do nothing, read the value into the object
11139                    } else {
11140                        // Initialize `self` to the right variant
11141                        *self = Object::VmoSemaphore(
11142                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11143                        );
11144                    }
11145                    #[allow(irrefutable_let_patterns)]
11146                    if let Object::VmoSemaphore(ref mut val) = self {
11147                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11148                    } else {
11149                        unreachable!()
11150                    }
11151                }
11152                4 => {
11153                    #[allow(irrefutable_let_patterns)]
11154                    if let Object::CounterSemaphore(_) = self {
11155                        // Do nothing, read the value into the object
11156                    } else {
11157                        // Initialize `self` to the right variant
11158                        *self = Object::CounterSemaphore(
11159                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Counter, { fidl::ObjectType::COUNTER.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11160                        );
11161                    }
11162                    #[allow(irrefutable_let_patterns)]
11163                    if let Object::CounterSemaphore(ref mut val) = self {
11164                        fidl::decode!(fidl::encoding::HandleType<fidl::Counter, { fidl::ObjectType::COUNTER.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11165                    } else {
11166                        unreachable!()
11167                    }
11168                }
11169                #[allow(deprecated)]
11170                ordinal => {
11171                    for _ in 0..num_handles {
11172                        decoder.drop_next_handle()?;
11173                    }
11174                    *self = Object::__SourceBreaking { unknown_ordinal: ordinal };
11175                }
11176            }
11177            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
11178                return Err(fidl::Error::InvalidNumBytesInEnvelope);
11179            }
11180            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11181                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11182            }
11183            Ok(())
11184        }
11185    }
11186}