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