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