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_inline_commands(
5158        &self,
5159        context_id: u32,
5160        commands: &[InlineCommand],
5161    ) -> Result<(), fidl::Error>;
5162    type FlushResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5163    fn r#flush(&self) -> Self::FlushResponseFut;
5164    fn r#map_buffer(&self, payload: &PrimaryMapBufferRequest) -> Result<(), fidl::Error>;
5165    fn r#unmap_buffer(&self, payload: &PrimaryUnmapBufferRequest) -> Result<(), fidl::Error>;
5166    fn r#buffer_range_op2(&self, op: BufferOp, range: &BufferRange) -> Result<(), fidl::Error>;
5167    fn r#enable_flow_control(&self) -> Result<(), fidl::Error>;
5168    fn r#enable_performance_counter_access(
5169        &self,
5170        access_token: fidl::Event,
5171    ) -> Result<(), fidl::Error>;
5172    type IsPerformanceCounterAccessAllowedResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
5173        + Send;
5174    fn r#is_performance_counter_access_allowed(
5175        &self,
5176    ) -> Self::IsPerformanceCounterAccessAllowedResponseFut;
5177    fn r#enable_performance_counters(&self, counters: &[u64]) -> Result<(), fidl::Error>;
5178    fn r#create_performance_counter_buffer_pool(
5179        &self,
5180        pool_id: u64,
5181        event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
5182    ) -> Result<(), fidl::Error>;
5183    fn r#release_performance_counter_buffer_pool(&self, pool_id: u64) -> Result<(), fidl::Error>;
5184    fn r#add_performance_counter_buffer_offsets_to_pool(
5185        &self,
5186        pool_id: u64,
5187        offsets: &[BufferRange],
5188    ) -> Result<(), fidl::Error>;
5189    fn r#remove_performance_counter_buffer_from_pool(
5190        &self,
5191        pool_id: u64,
5192        buffer_id: u64,
5193    ) -> Result<(), fidl::Error>;
5194    fn r#dump_performance_counters(&self, pool_id: u64, trigger_id: u32)
5195    -> Result<(), fidl::Error>;
5196    fn r#clear_performance_counters(&self, counters: &[u64]) -> Result<(), fidl::Error>;
5197}
5198#[derive(Debug)]
5199#[cfg(target_os = "fuchsia")]
5200pub struct PrimarySynchronousProxy {
5201    client: fidl::client::sync::Client,
5202}
5203
5204#[cfg(target_os = "fuchsia")]
5205impl fidl::endpoints::SynchronousProxy for PrimarySynchronousProxy {
5206    type Proxy = PrimaryProxy;
5207    type Protocol = PrimaryMarker;
5208
5209    fn from_channel(inner: fidl::Channel) -> Self {
5210        Self::new(inner)
5211    }
5212
5213    fn into_channel(self) -> fidl::Channel {
5214        self.client.into_channel()
5215    }
5216
5217    fn as_channel(&self) -> &fidl::Channel {
5218        self.client.as_channel()
5219    }
5220}
5221
5222#[cfg(target_os = "fuchsia")]
5223impl PrimarySynchronousProxy {
5224    pub fn new(channel: fidl::Channel) -> Self {
5225        let protocol_name = <PrimaryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5226        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5227    }
5228
5229    pub fn into_channel(self) -> fidl::Channel {
5230        self.client.into_channel()
5231    }
5232
5233    /// Waits until an event arrives and returns it. It is safe for other
5234    /// threads to make concurrent requests while waiting for an event.
5235    pub fn wait_for_event(
5236        &self,
5237        deadline: zx::MonotonicInstant,
5238    ) -> Result<PrimaryEvent, fidl::Error> {
5239        PrimaryEvent::decode(self.client.wait_for_event(deadline)?)
5240    }
5241
5242    /// Imports an object for use in the system driver.
5243    pub fn r#import_object(
5244        &self,
5245        mut payload: PrimaryImportObjectRequest,
5246    ) -> Result<(), fidl::Error> {
5247        self.client.send::<PrimaryImportObjectRequest>(
5248            &mut payload,
5249            0x5f5a247abb1d9354,
5250            fidl::encoding::DynamicFlags::empty(),
5251        )
5252    }
5253
5254    /// Destroys the object with `object_id` within this connection.
5255    pub fn r#release_object(
5256        &self,
5257        mut object_id: u64,
5258        mut object_type: ObjectType,
5259    ) -> Result<(), fidl::Error> {
5260        self.client.send::<PrimaryReleaseObjectRequest>(
5261            (object_id, object_type),
5262            0x4a65d5885da5e88f,
5263            fidl::encoding::DynamicFlags::empty(),
5264        )
5265    }
5266
5267    /// Creates context `context_id` for use in command execution.  A context may be associated
5268    /// with hardware state.
5269    /// DEPRECATED: Please use CreateContext2.
5270    /// TODO(https://fxbug.dev/413030654): Fully deprecate this API.
5271    pub fn r#create_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5272        self.client.send::<PrimaryCreateContextRequest>(
5273            (context_id,),
5274            0x5a9a91c8b88b5da4,
5275            fidl::encoding::DynamicFlags::empty(),
5276        )
5277    }
5278
5279    /// Creates context `context_id` for use in command execution.  A context may be associated
5280    /// with hardware state.
5281    pub fn r#create_context2(
5282        &self,
5283        mut context_id: u32,
5284        mut priority: Priority,
5285    ) -> Result<(), fidl::Error> {
5286        self.client.send::<PrimaryCreateContext2Request>(
5287            (context_id, priority),
5288            0x5f7e3a5137e758f6,
5289            fidl::encoding::DynamicFlags::empty(),
5290        )
5291    }
5292
5293    /// Destroys context `context_id`.
5294    pub fn r#destroy_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5295        self.client.send::<PrimaryDestroyContextRequest>(
5296            (context_id,),
5297            0x26b626e6be162ef0,
5298            fidl::encoding::DynamicFlags::empty(),
5299        )
5300    }
5301
5302    /// Submits command buffers for execution on the hardware, with associated `resources`.
5303    /// `resources` must refer to buffers that have been imported.
5304    /// `wait_semaphores` and `signal_semaphores` must refer to events that have been imported.
5305    /// `wait_semaphores` must all be signaled before execution begins, then are reset.
5306    /// `signal_semaphores` will be signaled after the command buffer is completed.
5307    pub fn r#execute_command(
5308        &self,
5309        mut context_id: u32,
5310        mut resources: &[BufferRange],
5311        mut command_buffers: &[CommandBuffer],
5312        mut wait_semaphores: &[u64],
5313        mut signal_semaphores: &[u64],
5314        mut flags: CommandBufferFlags,
5315    ) -> Result<(), fidl::Error> {
5316        self.client.send::<PrimaryExecuteCommandRequest>(
5317            (context_id, resources, command_buffers, wait_semaphores, signal_semaphores, flags),
5318            0xf2799643aadb0db,
5319            fidl::encoding::DynamicFlags::empty(),
5320        )
5321    }
5322
5323    /// Submits a series of commands for execution on the hardware without using a command buffer.
5324    /// The number of commands sent should be calculated so that the total message size is less than
5325    /// MAX_INLINE_COMMANDS_DATA_SIZE.
5326    pub fn r#execute_inline_commands(
5327        &self,
5328        mut context_id: u32,
5329        mut commands: &[InlineCommand],
5330    ) -> Result<(), fidl::Error> {
5331        self.client.send::<PrimaryExecuteInlineCommandsRequest>(
5332            (context_id, commands),
5333            0x766d5c86f35468a6,
5334            fidl::encoding::DynamicFlags::empty(),
5335        )
5336    }
5337
5338    /// Incurs a round-trip to the system driver, used to ensure all previous messages have been
5339    /// observed, but not necessarily completed.
5340    pub fn r#flush(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
5341        let _response =
5342            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
5343                (),
5344                0x54ccb5572d886039,
5345                fidl::encoding::DynamicFlags::empty(),
5346                ___deadline,
5347            )?;
5348        Ok(_response)
5349    }
5350
5351    /// Maps a page range onto the hardware in the connection's address space at address `hw_va`.
5352    /// `flags` is a set of flags from MapFlags that specify how the hardware can access the buffer.
5353    pub fn r#map_buffer(&self, mut payload: &PrimaryMapBufferRequest) -> Result<(), fidl::Error> {
5354        self.client.send::<PrimaryMapBufferRequest>(
5355            payload,
5356            0x56baa5d2092c8e33,
5357            fidl::encoding::DynamicFlags::empty(),
5358        )
5359    }
5360
5361    /// Releases the mapping at address `hw_va` from the hardware for the given `buffer_id`.
5362    /// Buffers will also be implicitly unmapped when released.
5363    pub fn r#unmap_buffer(
5364        &self,
5365        mut payload: &PrimaryUnmapBufferRequest,
5366    ) -> Result<(), fidl::Error> {
5367        self.client.send::<PrimaryUnmapBufferRequest>(
5368            payload,
5369            0x305188ebd8bcd95c,
5370            fidl::encoding::DynamicFlags::empty(),
5371        )
5372    }
5373
5374    /// Perform an operation on a range of the buffer.
5375    pub fn r#buffer_range_op2(
5376        &self,
5377        mut op: BufferOp,
5378        mut range: &BufferRange,
5379    ) -> Result<(), fidl::Error> {
5380        self.client.send::<PrimaryBufferRangeOp2Request>(
5381            (op, range),
5382            0x4175c8dfef355396,
5383            fidl::encoding::DynamicFlags::empty(),
5384        )
5385    }
5386
5387    /// Enables the events OnNotifyMessagesConsumed and OnNotifyMemoryImported.
5388    pub fn r#enable_flow_control(&self) -> Result<(), fidl::Error> {
5389        self.client.send::<fidl::encoding::EmptyPayload>(
5390            (),
5391            0x8b5e68f3ee0b22e,
5392            fidl::encoding::DynamicFlags::empty(),
5393        )
5394    }
5395
5396    /// Tries to enable performance counter FIDL messages. To be successful, |access_token| must
5397    /// have been returned by PerformanceCounterAccess.GetPerformanceCountToken() from the matching
5398    /// device.
5399    pub fn r#enable_performance_counter_access(
5400        &self,
5401        mut access_token: fidl::Event,
5402    ) -> Result<(), fidl::Error> {
5403        self.client.send::<PrimaryEnablePerformanceCounterAccessRequest>(
5404            (access_token,),
5405            0x51b369ac16588831,
5406            fidl::encoding::DynamicFlags::empty(),
5407        )
5408    }
5409
5410    /// Returns true if any EnablePerformanceCounterAccess message has succeeded.
5411    pub fn r#is_performance_counter_access_allowed(
5412        &self,
5413        ___deadline: zx::MonotonicInstant,
5414    ) -> Result<bool, fidl::Error> {
5415        let _response = self.client.send_query::<
5416            fidl::encoding::EmptyPayload,
5417            PrimaryIsPerformanceCounterAccessAllowedResponse,
5418        >(
5419            (),
5420            0x1933b70c06cc5702,
5421            fidl::encoding::DynamicFlags::empty(),
5422            ___deadline,
5423        )?;
5424        Ok(_response.enabled)
5425    }
5426
5427    /// Enables a set of performance counters.  Disables enabled performance counters that are not
5428    /// in the new set. Performance counters will also be automatically disabled on connection
5429    /// close. Performance counter access must have been enabled using
5430    /// EnablePerformanceCounterAccess before calling this method.
5431    pub fn r#enable_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5432        self.client.send::<PrimaryEnablePerformanceCountersRequest>(
5433            (counters,),
5434            0x52c4db74b601aaa7,
5435            fidl::encoding::DynamicFlags::empty(),
5436        )
5437    }
5438
5439    /// Creates a pool of buffers that performance counters can be dumped into. Performance counter
5440    /// access must have been enabled using EnablePerformanceCounterAccess before calling this
5441    /// method.
5442    pub fn r#create_performance_counter_buffer_pool(
5443        &self,
5444        mut pool_id: u64,
5445        mut event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
5446    ) -> Result<(), fidl::Error> {
5447        self.client.send::<PrimaryCreatePerformanceCounterBufferPoolRequest>(
5448            (pool_id, event_channel),
5449            0x48ccf6519bbbc638,
5450            fidl::encoding::DynamicFlags::empty(),
5451        )
5452    }
5453
5454    /// Releases a pool of performance counter buffers. Performance counter access must have been
5455    /// enabled using EnablePerformanceCounterAccess before calling this method.
5456    pub fn r#release_performance_counter_buffer_pool(
5457        &self,
5458        mut pool_id: u64,
5459    ) -> Result<(), fidl::Error> {
5460        self.client.send::<PrimaryReleasePerformanceCounterBufferPoolRequest>(
5461            (pool_id,),
5462            0x18374c4b3ef0b4da,
5463            fidl::encoding::DynamicFlags::empty(),
5464        )
5465    }
5466
5467    /// Adds a set of offsets into buffers to the pool. |offsets[n].buffer_id| is the id of a
5468    /// buffer that was previously imported using ImportBuffer(). The same buffer may be added to
5469    /// multiple pools. The pool will hold on to a reference to the buffer even after ReleaseBuffer
5470    /// is called.  When dumped into this entry, counters will be written starting at
5471    /// |offsets[n].buffer_offset| bytes into the buffer, and up to |offsets[n].buffer_offset| +
5472    /// |offsets[n].buffer_size|. |offsets[n].buffer_size| must be large enough to fit all enabled
5473    /// counters. Performance counter access must have been enabled using
5474    /// EnablePerformanceCounterAccess before calling this method.
5475    pub fn r#add_performance_counter_buffer_offsets_to_pool(
5476        &self,
5477        mut pool_id: u64,
5478        mut offsets: &[BufferRange],
5479    ) -> Result<(), fidl::Error> {
5480        self.client.send::<PrimaryAddPerformanceCounterBufferOffsetsToPoolRequest>(
5481            (pool_id, offsets),
5482            0x1f7889571111386b,
5483            fidl::encoding::DynamicFlags::empty(),
5484        )
5485    }
5486
5487    /// Removes every offset of a buffer from the pool. Once this method is finished being handled
5488    /// on the server, no more dumps will be processed into this buffer. In-flight dumps into this
5489    /// buffer may be lost.  Performance counter access must have been enabled using
5490    /// EnablePerformanceCounterAccess before calling this method.
5491    pub fn r#remove_performance_counter_buffer_from_pool(
5492        &self,
5493        mut pool_id: u64,
5494        mut buffer_id: u64,
5495    ) -> Result<(), fidl::Error> {
5496        self.client.send::<PrimaryRemovePerformanceCounterBufferFromPoolRequest>(
5497            (pool_id, buffer_id),
5498            0xbf1275f5a36258e,
5499            fidl::encoding::DynamicFlags::empty(),
5500        )
5501    }
5502
5503    /// Triggers dumping of the performance counters into a buffer pool. May fail silently if there
5504    /// are no buffers in the pool. |trigger_id| is an arbitrary ID assigned by the client that can
5505    /// be returned in OnPerformanceCounterReadCompleted. Performance counter access must have been
5506    /// enabled using EnablePerformanceCounterAccess before calling this method.
5507    pub fn r#dump_performance_counters(
5508        &self,
5509        mut pool_id: u64,
5510        mut trigger_id: u32,
5511    ) -> Result<(), fidl::Error> {
5512        self.client.send::<PrimaryDumpPerformanceCountersRequest>(
5513            (pool_id, trigger_id),
5514            0x250b29340be28807,
5515            fidl::encoding::DynamicFlags::empty(),
5516        )
5517    }
5518
5519    /// Sets the values of all listed performance counters to 0. May not be supported by some
5520    /// hardware. Performance counter access must have been enabled using
5521    /// EnablePerformanceCounterAccess before calling this method.
5522    pub fn r#clear_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5523        self.client.send::<PrimaryClearPerformanceCountersRequest>(
5524            (counters,),
5525            0x236831822eff741a,
5526            fidl::encoding::DynamicFlags::empty(),
5527        )
5528    }
5529}
5530
5531#[cfg(target_os = "fuchsia")]
5532impl From<PrimarySynchronousProxy> for zx::NullableHandle {
5533    fn from(value: PrimarySynchronousProxy) -> Self {
5534        value.into_channel().into()
5535    }
5536}
5537
5538#[cfg(target_os = "fuchsia")]
5539impl From<fidl::Channel> for PrimarySynchronousProxy {
5540    fn from(value: fidl::Channel) -> Self {
5541        Self::new(value)
5542    }
5543}
5544
5545#[cfg(target_os = "fuchsia")]
5546impl fidl::endpoints::FromClient for PrimarySynchronousProxy {
5547    type Protocol = PrimaryMarker;
5548
5549    fn from_client(value: fidl::endpoints::ClientEnd<PrimaryMarker>) -> Self {
5550        Self::new(value.into_channel())
5551    }
5552}
5553
5554#[derive(Debug, Clone)]
5555pub struct PrimaryProxy {
5556    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5557}
5558
5559impl fidl::endpoints::Proxy for PrimaryProxy {
5560    type Protocol = PrimaryMarker;
5561
5562    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5563        Self::new(inner)
5564    }
5565
5566    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5567        self.client.into_channel().map_err(|client| Self { client })
5568    }
5569
5570    fn as_channel(&self) -> &::fidl::AsyncChannel {
5571        self.client.as_channel()
5572    }
5573}
5574
5575impl PrimaryProxy {
5576    /// Create a new Proxy for fuchsia.gpu.magma/Primary.
5577    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5578        let protocol_name = <PrimaryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5579        Self { client: fidl::client::Client::new(channel, protocol_name) }
5580    }
5581
5582    /// Get a Stream of events from the remote end of the protocol.
5583    ///
5584    /// # Panics
5585    ///
5586    /// Panics if the event stream was already taken.
5587    pub fn take_event_stream(&self) -> PrimaryEventStream {
5588        PrimaryEventStream { event_receiver: self.client.take_event_receiver() }
5589    }
5590
5591    /// Imports an object for use in the system driver.
5592    pub fn r#import_object(
5593        &self,
5594        mut payload: PrimaryImportObjectRequest,
5595    ) -> Result<(), fidl::Error> {
5596        PrimaryProxyInterface::r#import_object(self, payload)
5597    }
5598
5599    /// Destroys the object with `object_id` within this connection.
5600    pub fn r#release_object(
5601        &self,
5602        mut object_id: u64,
5603        mut object_type: ObjectType,
5604    ) -> Result<(), fidl::Error> {
5605        PrimaryProxyInterface::r#release_object(self, object_id, object_type)
5606    }
5607
5608    /// Creates context `context_id` for use in command execution.  A context may be associated
5609    /// with hardware state.
5610    /// DEPRECATED: Please use CreateContext2.
5611    /// TODO(https://fxbug.dev/413030654): Fully deprecate this API.
5612    pub fn r#create_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5613        PrimaryProxyInterface::r#create_context(self, context_id)
5614    }
5615
5616    /// Creates context `context_id` for use in command execution.  A context may be associated
5617    /// with hardware state.
5618    pub fn r#create_context2(
5619        &self,
5620        mut context_id: u32,
5621        mut priority: Priority,
5622    ) -> Result<(), fidl::Error> {
5623        PrimaryProxyInterface::r#create_context2(self, context_id, priority)
5624    }
5625
5626    /// Destroys context `context_id`.
5627    pub fn r#destroy_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5628        PrimaryProxyInterface::r#destroy_context(self, context_id)
5629    }
5630
5631    /// Submits command buffers for execution on the hardware, with associated `resources`.
5632    /// `resources` must refer to buffers that have been imported.
5633    /// `wait_semaphores` and `signal_semaphores` must refer to events that have been imported.
5634    /// `wait_semaphores` must all be signaled before execution begins, then are reset.
5635    /// `signal_semaphores` will be signaled after the command buffer is completed.
5636    pub fn r#execute_command(
5637        &self,
5638        mut context_id: u32,
5639        mut resources: &[BufferRange],
5640        mut command_buffers: &[CommandBuffer],
5641        mut wait_semaphores: &[u64],
5642        mut signal_semaphores: &[u64],
5643        mut flags: CommandBufferFlags,
5644    ) -> Result<(), fidl::Error> {
5645        PrimaryProxyInterface::r#execute_command(
5646            self,
5647            context_id,
5648            resources,
5649            command_buffers,
5650            wait_semaphores,
5651            signal_semaphores,
5652            flags,
5653        )
5654    }
5655
5656    /// Submits a series of commands for execution on the hardware without using a command buffer.
5657    /// The number of commands sent should be calculated so that the total message size is less than
5658    /// MAX_INLINE_COMMANDS_DATA_SIZE.
5659    pub fn r#execute_inline_commands(
5660        &self,
5661        mut context_id: u32,
5662        mut commands: &[InlineCommand],
5663    ) -> Result<(), fidl::Error> {
5664        PrimaryProxyInterface::r#execute_inline_commands(self, context_id, commands)
5665    }
5666
5667    /// Incurs a round-trip to the system driver, used to ensure all previous messages have been
5668    /// observed, but not necessarily completed.
5669    pub fn r#flush(
5670        &self,
5671    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
5672        PrimaryProxyInterface::r#flush(self)
5673    }
5674
5675    /// Maps a page range onto the hardware in the connection's address space at address `hw_va`.
5676    /// `flags` is a set of flags from MapFlags that specify how the hardware can access the buffer.
5677    pub fn r#map_buffer(&self, mut payload: &PrimaryMapBufferRequest) -> Result<(), fidl::Error> {
5678        PrimaryProxyInterface::r#map_buffer(self, payload)
5679    }
5680
5681    /// Releases the mapping at address `hw_va` from the hardware for the given `buffer_id`.
5682    /// Buffers will also be implicitly unmapped when released.
5683    pub fn r#unmap_buffer(
5684        &self,
5685        mut payload: &PrimaryUnmapBufferRequest,
5686    ) -> Result<(), fidl::Error> {
5687        PrimaryProxyInterface::r#unmap_buffer(self, payload)
5688    }
5689
5690    /// Perform an operation on a range of the buffer.
5691    pub fn r#buffer_range_op2(
5692        &self,
5693        mut op: BufferOp,
5694        mut range: &BufferRange,
5695    ) -> Result<(), fidl::Error> {
5696        PrimaryProxyInterface::r#buffer_range_op2(self, op, range)
5697    }
5698
5699    /// Enables the events OnNotifyMessagesConsumed and OnNotifyMemoryImported.
5700    pub fn r#enable_flow_control(&self) -> Result<(), fidl::Error> {
5701        PrimaryProxyInterface::r#enable_flow_control(self)
5702    }
5703
5704    /// Tries to enable performance counter FIDL messages. To be successful, |access_token| must
5705    /// have been returned by PerformanceCounterAccess.GetPerformanceCountToken() from the matching
5706    /// device.
5707    pub fn r#enable_performance_counter_access(
5708        &self,
5709        mut access_token: fidl::Event,
5710    ) -> Result<(), fidl::Error> {
5711        PrimaryProxyInterface::r#enable_performance_counter_access(self, access_token)
5712    }
5713
5714    /// Returns true if any EnablePerformanceCounterAccess message has succeeded.
5715    pub fn r#is_performance_counter_access_allowed(
5716        &self,
5717    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
5718        PrimaryProxyInterface::r#is_performance_counter_access_allowed(self)
5719    }
5720
5721    /// Enables a set of performance counters.  Disables enabled performance counters that are not
5722    /// in the new set. Performance counters will also be automatically disabled on connection
5723    /// close. Performance counter access must have been enabled using
5724    /// EnablePerformanceCounterAccess before calling this method.
5725    pub fn r#enable_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5726        PrimaryProxyInterface::r#enable_performance_counters(self, counters)
5727    }
5728
5729    /// Creates a pool of buffers that performance counters can be dumped into. Performance counter
5730    /// access must have been enabled using EnablePerformanceCounterAccess before calling this
5731    /// method.
5732    pub fn r#create_performance_counter_buffer_pool(
5733        &self,
5734        mut pool_id: u64,
5735        mut event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
5736    ) -> Result<(), fidl::Error> {
5737        PrimaryProxyInterface::r#create_performance_counter_buffer_pool(
5738            self,
5739            pool_id,
5740            event_channel,
5741        )
5742    }
5743
5744    /// Releases a pool of performance counter buffers. Performance counter access must have been
5745    /// enabled using EnablePerformanceCounterAccess before calling this method.
5746    pub fn r#release_performance_counter_buffer_pool(
5747        &self,
5748        mut pool_id: u64,
5749    ) -> Result<(), fidl::Error> {
5750        PrimaryProxyInterface::r#release_performance_counter_buffer_pool(self, pool_id)
5751    }
5752
5753    /// Adds a set of offsets into buffers to the pool. |offsets[n].buffer_id| is the id of a
5754    /// buffer that was previously imported using ImportBuffer(). The same buffer may be added to
5755    /// multiple pools. The pool will hold on to a reference to the buffer even after ReleaseBuffer
5756    /// is called.  When dumped into this entry, counters will be written starting at
5757    /// |offsets[n].buffer_offset| bytes into the buffer, and up to |offsets[n].buffer_offset| +
5758    /// |offsets[n].buffer_size|. |offsets[n].buffer_size| must be large enough to fit all enabled
5759    /// counters. Performance counter access must have been enabled using
5760    /// EnablePerformanceCounterAccess before calling this method.
5761    pub fn r#add_performance_counter_buffer_offsets_to_pool(
5762        &self,
5763        mut pool_id: u64,
5764        mut offsets: &[BufferRange],
5765    ) -> Result<(), fidl::Error> {
5766        PrimaryProxyInterface::r#add_performance_counter_buffer_offsets_to_pool(
5767            self, pool_id, offsets,
5768        )
5769    }
5770
5771    /// Removes every offset of a buffer from the pool. Once this method is finished being handled
5772    /// on the server, no more dumps will be processed into this buffer. In-flight dumps into this
5773    /// buffer may be lost.  Performance counter access must have been enabled using
5774    /// EnablePerformanceCounterAccess before calling this method.
5775    pub fn r#remove_performance_counter_buffer_from_pool(
5776        &self,
5777        mut pool_id: u64,
5778        mut buffer_id: u64,
5779    ) -> Result<(), fidl::Error> {
5780        PrimaryProxyInterface::r#remove_performance_counter_buffer_from_pool(
5781            self, pool_id, buffer_id,
5782        )
5783    }
5784
5785    /// Triggers dumping of the performance counters into a buffer pool. May fail silently if there
5786    /// are no buffers in the pool. |trigger_id| is an arbitrary ID assigned by the client that can
5787    /// be returned in OnPerformanceCounterReadCompleted. Performance counter access must have been
5788    /// enabled using EnablePerformanceCounterAccess before calling this method.
5789    pub fn r#dump_performance_counters(
5790        &self,
5791        mut pool_id: u64,
5792        mut trigger_id: u32,
5793    ) -> Result<(), fidl::Error> {
5794        PrimaryProxyInterface::r#dump_performance_counters(self, pool_id, trigger_id)
5795    }
5796
5797    /// Sets the values of all listed performance counters to 0. May not be supported by some
5798    /// hardware. Performance counter access must have been enabled using
5799    /// EnablePerformanceCounterAccess before calling this method.
5800    pub fn r#clear_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5801        PrimaryProxyInterface::r#clear_performance_counters(self, counters)
5802    }
5803}
5804
5805impl PrimaryProxyInterface for PrimaryProxy {
5806    fn r#import_object(&self, mut payload: PrimaryImportObjectRequest) -> Result<(), fidl::Error> {
5807        self.client.send::<PrimaryImportObjectRequest>(
5808            &mut payload,
5809            0x5f5a247abb1d9354,
5810            fidl::encoding::DynamicFlags::empty(),
5811        )
5812    }
5813
5814    fn r#release_object(
5815        &self,
5816        mut object_id: u64,
5817        mut object_type: ObjectType,
5818    ) -> Result<(), fidl::Error> {
5819        self.client.send::<PrimaryReleaseObjectRequest>(
5820            (object_id, object_type),
5821            0x4a65d5885da5e88f,
5822            fidl::encoding::DynamicFlags::empty(),
5823        )
5824    }
5825
5826    fn r#create_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5827        self.client.send::<PrimaryCreateContextRequest>(
5828            (context_id,),
5829            0x5a9a91c8b88b5da4,
5830            fidl::encoding::DynamicFlags::empty(),
5831        )
5832    }
5833
5834    fn r#create_context2(
5835        &self,
5836        mut context_id: u32,
5837        mut priority: Priority,
5838    ) -> Result<(), fidl::Error> {
5839        self.client.send::<PrimaryCreateContext2Request>(
5840            (context_id, priority),
5841            0x5f7e3a5137e758f6,
5842            fidl::encoding::DynamicFlags::empty(),
5843        )
5844    }
5845
5846    fn r#destroy_context(&self, mut context_id: u32) -> Result<(), fidl::Error> {
5847        self.client.send::<PrimaryDestroyContextRequest>(
5848            (context_id,),
5849            0x26b626e6be162ef0,
5850            fidl::encoding::DynamicFlags::empty(),
5851        )
5852    }
5853
5854    fn r#execute_command(
5855        &self,
5856        mut context_id: u32,
5857        mut resources: &[BufferRange],
5858        mut command_buffers: &[CommandBuffer],
5859        mut wait_semaphores: &[u64],
5860        mut signal_semaphores: &[u64],
5861        mut flags: CommandBufferFlags,
5862    ) -> Result<(), fidl::Error> {
5863        self.client.send::<PrimaryExecuteCommandRequest>(
5864            (context_id, resources, command_buffers, wait_semaphores, signal_semaphores, flags),
5865            0xf2799643aadb0db,
5866            fidl::encoding::DynamicFlags::empty(),
5867        )
5868    }
5869
5870    fn r#execute_inline_commands(
5871        &self,
5872        mut context_id: u32,
5873        mut commands: &[InlineCommand],
5874    ) -> Result<(), fidl::Error> {
5875        self.client.send::<PrimaryExecuteInlineCommandsRequest>(
5876            (context_id, commands),
5877            0x766d5c86f35468a6,
5878            fidl::encoding::DynamicFlags::empty(),
5879        )
5880    }
5881
5882    type FlushResponseFut =
5883        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
5884    fn r#flush(&self) -> Self::FlushResponseFut {
5885        fn _decode(
5886            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5887        ) -> Result<(), fidl::Error> {
5888            let _response = fidl::client::decode_transaction_body::<
5889                fidl::encoding::EmptyPayload,
5890                fidl::encoding::DefaultFuchsiaResourceDialect,
5891                0x54ccb5572d886039,
5892            >(_buf?)?;
5893            Ok(_response)
5894        }
5895        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5896            (),
5897            0x54ccb5572d886039,
5898            fidl::encoding::DynamicFlags::empty(),
5899            _decode,
5900        )
5901    }
5902
5903    fn r#map_buffer(&self, mut payload: &PrimaryMapBufferRequest) -> Result<(), fidl::Error> {
5904        self.client.send::<PrimaryMapBufferRequest>(
5905            payload,
5906            0x56baa5d2092c8e33,
5907            fidl::encoding::DynamicFlags::empty(),
5908        )
5909    }
5910
5911    fn r#unmap_buffer(&self, mut payload: &PrimaryUnmapBufferRequest) -> Result<(), fidl::Error> {
5912        self.client.send::<PrimaryUnmapBufferRequest>(
5913            payload,
5914            0x305188ebd8bcd95c,
5915            fidl::encoding::DynamicFlags::empty(),
5916        )
5917    }
5918
5919    fn r#buffer_range_op2(
5920        &self,
5921        mut op: BufferOp,
5922        mut range: &BufferRange,
5923    ) -> Result<(), fidl::Error> {
5924        self.client.send::<PrimaryBufferRangeOp2Request>(
5925            (op, range),
5926            0x4175c8dfef355396,
5927            fidl::encoding::DynamicFlags::empty(),
5928        )
5929    }
5930
5931    fn r#enable_flow_control(&self) -> Result<(), fidl::Error> {
5932        self.client.send::<fidl::encoding::EmptyPayload>(
5933            (),
5934            0x8b5e68f3ee0b22e,
5935            fidl::encoding::DynamicFlags::empty(),
5936        )
5937    }
5938
5939    fn r#enable_performance_counter_access(
5940        &self,
5941        mut access_token: fidl::Event,
5942    ) -> Result<(), fidl::Error> {
5943        self.client.send::<PrimaryEnablePerformanceCounterAccessRequest>(
5944            (access_token,),
5945            0x51b369ac16588831,
5946            fidl::encoding::DynamicFlags::empty(),
5947        )
5948    }
5949
5950    type IsPerformanceCounterAccessAllowedResponseFut =
5951        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
5952    fn r#is_performance_counter_access_allowed(
5953        &self,
5954    ) -> Self::IsPerformanceCounterAccessAllowedResponseFut {
5955        fn _decode(
5956            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5957        ) -> Result<bool, fidl::Error> {
5958            let _response = fidl::client::decode_transaction_body::<
5959                PrimaryIsPerformanceCounterAccessAllowedResponse,
5960                fidl::encoding::DefaultFuchsiaResourceDialect,
5961                0x1933b70c06cc5702,
5962            >(_buf?)?;
5963            Ok(_response.enabled)
5964        }
5965        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
5966            (),
5967            0x1933b70c06cc5702,
5968            fidl::encoding::DynamicFlags::empty(),
5969            _decode,
5970        )
5971    }
5972
5973    fn r#enable_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
5974        self.client.send::<PrimaryEnablePerformanceCountersRequest>(
5975            (counters,),
5976            0x52c4db74b601aaa7,
5977            fidl::encoding::DynamicFlags::empty(),
5978        )
5979    }
5980
5981    fn r#create_performance_counter_buffer_pool(
5982        &self,
5983        mut pool_id: u64,
5984        mut event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
5985    ) -> Result<(), fidl::Error> {
5986        self.client.send::<PrimaryCreatePerformanceCounterBufferPoolRequest>(
5987            (pool_id, event_channel),
5988            0x48ccf6519bbbc638,
5989            fidl::encoding::DynamicFlags::empty(),
5990        )
5991    }
5992
5993    fn r#release_performance_counter_buffer_pool(
5994        &self,
5995        mut pool_id: u64,
5996    ) -> Result<(), fidl::Error> {
5997        self.client.send::<PrimaryReleasePerformanceCounterBufferPoolRequest>(
5998            (pool_id,),
5999            0x18374c4b3ef0b4da,
6000            fidl::encoding::DynamicFlags::empty(),
6001        )
6002    }
6003
6004    fn r#add_performance_counter_buffer_offsets_to_pool(
6005        &self,
6006        mut pool_id: u64,
6007        mut offsets: &[BufferRange],
6008    ) -> Result<(), fidl::Error> {
6009        self.client.send::<PrimaryAddPerformanceCounterBufferOffsetsToPoolRequest>(
6010            (pool_id, offsets),
6011            0x1f7889571111386b,
6012            fidl::encoding::DynamicFlags::empty(),
6013        )
6014    }
6015
6016    fn r#remove_performance_counter_buffer_from_pool(
6017        &self,
6018        mut pool_id: u64,
6019        mut buffer_id: u64,
6020    ) -> Result<(), fidl::Error> {
6021        self.client.send::<PrimaryRemovePerformanceCounterBufferFromPoolRequest>(
6022            (pool_id, buffer_id),
6023            0xbf1275f5a36258e,
6024            fidl::encoding::DynamicFlags::empty(),
6025        )
6026    }
6027
6028    fn r#dump_performance_counters(
6029        &self,
6030        mut pool_id: u64,
6031        mut trigger_id: u32,
6032    ) -> Result<(), fidl::Error> {
6033        self.client.send::<PrimaryDumpPerformanceCountersRequest>(
6034            (pool_id, trigger_id),
6035            0x250b29340be28807,
6036            fidl::encoding::DynamicFlags::empty(),
6037        )
6038    }
6039
6040    fn r#clear_performance_counters(&self, mut counters: &[u64]) -> Result<(), fidl::Error> {
6041        self.client.send::<PrimaryClearPerformanceCountersRequest>(
6042            (counters,),
6043            0x236831822eff741a,
6044            fidl::encoding::DynamicFlags::empty(),
6045        )
6046    }
6047}
6048
6049pub struct PrimaryEventStream {
6050    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6051}
6052
6053impl std::marker::Unpin for PrimaryEventStream {}
6054
6055impl futures::stream::FusedStream for PrimaryEventStream {
6056    fn is_terminated(&self) -> bool {
6057        self.event_receiver.is_terminated()
6058    }
6059}
6060
6061impl futures::Stream for PrimaryEventStream {
6062    type Item = Result<PrimaryEvent, fidl::Error>;
6063
6064    fn poll_next(
6065        mut self: std::pin::Pin<&mut Self>,
6066        cx: &mut std::task::Context<'_>,
6067    ) -> std::task::Poll<Option<Self::Item>> {
6068        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6069            &mut self.event_receiver,
6070            cx
6071        )?) {
6072            Some(buf) => std::task::Poll::Ready(Some(PrimaryEvent::decode(buf))),
6073            None => std::task::Poll::Ready(None),
6074        }
6075    }
6076}
6077
6078#[derive(Debug)]
6079pub enum PrimaryEvent {
6080    OnNotifyMessagesConsumed { count: u64 },
6081    OnNotifyMemoryImported { bytes: u64 },
6082}
6083
6084impl PrimaryEvent {
6085    #[allow(irrefutable_let_patterns)]
6086    pub fn into_on_notify_messages_consumed(self) -> Option<u64> {
6087        if let PrimaryEvent::OnNotifyMessagesConsumed { count } = self {
6088            Some((count))
6089        } else {
6090            None
6091        }
6092    }
6093    #[allow(irrefutable_let_patterns)]
6094    pub fn into_on_notify_memory_imported(self) -> Option<u64> {
6095        if let PrimaryEvent::OnNotifyMemoryImported { bytes } = self { Some((bytes)) } else { None }
6096    }
6097
6098    /// Decodes a message buffer as a [`PrimaryEvent`].
6099    fn decode(
6100        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6101    ) -> Result<PrimaryEvent, fidl::Error> {
6102        let (bytes, _handles) = buf.split_mut();
6103        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6104        debug_assert_eq!(tx_header.tx_id, 0);
6105        match tx_header.ordinal {
6106            0x5e8dd0b0b753ac43 => {
6107                let mut out = fidl::new_empty!(
6108                    PrimaryOnNotifyMessagesConsumedRequest,
6109                    fidl::encoding::DefaultFuchsiaResourceDialect
6110                );
6111                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryOnNotifyMessagesConsumedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6112                Ok((PrimaryEvent::OnNotifyMessagesConsumed { count: out.count }))
6113            }
6114            0x50524b7a3503aba6 => {
6115                let mut out = fidl::new_empty!(
6116                    PrimaryOnNotifyMemoryImportedRequest,
6117                    fidl::encoding::DefaultFuchsiaResourceDialect
6118                );
6119                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryOnNotifyMemoryImportedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6120                Ok((PrimaryEvent::OnNotifyMemoryImported { bytes: out.bytes }))
6121            }
6122            _ => Err(fidl::Error::UnknownOrdinal {
6123                ordinal: tx_header.ordinal,
6124                protocol_name: <PrimaryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6125            }),
6126        }
6127    }
6128}
6129
6130/// A Stream of incoming requests for fuchsia.gpu.magma/Primary.
6131pub struct PrimaryRequestStream {
6132    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6133    is_terminated: bool,
6134}
6135
6136impl std::marker::Unpin for PrimaryRequestStream {}
6137
6138impl futures::stream::FusedStream for PrimaryRequestStream {
6139    fn is_terminated(&self) -> bool {
6140        self.is_terminated
6141    }
6142}
6143
6144impl fidl::endpoints::RequestStream for PrimaryRequestStream {
6145    type Protocol = PrimaryMarker;
6146    type ControlHandle = PrimaryControlHandle;
6147
6148    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6149        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6150    }
6151
6152    fn control_handle(&self) -> Self::ControlHandle {
6153        PrimaryControlHandle { inner: self.inner.clone() }
6154    }
6155
6156    fn into_inner(
6157        self,
6158    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6159    {
6160        (self.inner, self.is_terminated)
6161    }
6162
6163    fn from_inner(
6164        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6165        is_terminated: bool,
6166    ) -> Self {
6167        Self { inner, is_terminated }
6168    }
6169}
6170
6171impl futures::Stream for PrimaryRequestStream {
6172    type Item = Result<PrimaryRequest, fidl::Error>;
6173
6174    fn poll_next(
6175        mut self: std::pin::Pin<&mut Self>,
6176        cx: &mut std::task::Context<'_>,
6177    ) -> std::task::Poll<Option<Self::Item>> {
6178        let this = &mut *self;
6179        if this.inner.check_shutdown(cx) {
6180            this.is_terminated = true;
6181            return std::task::Poll::Ready(None);
6182        }
6183        if this.is_terminated {
6184            panic!("polled PrimaryRequestStream after completion");
6185        }
6186        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6187            |bytes, handles| {
6188                match this.inner.channel().read_etc(cx, bytes, handles) {
6189                    std::task::Poll::Ready(Ok(())) => {}
6190                    std::task::Poll::Pending => return std::task::Poll::Pending,
6191                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6192                        this.is_terminated = true;
6193                        return std::task::Poll::Ready(None);
6194                    }
6195                    std::task::Poll::Ready(Err(e)) => {
6196                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6197                            e.into(),
6198                        ))));
6199                    }
6200                }
6201
6202                // A message has been received from the channel
6203                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6204
6205                std::task::Poll::Ready(Some(match header.ordinal {
6206                    0x5f5a247abb1d9354 => {
6207                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6208                        let mut req = fidl::new_empty!(
6209                            PrimaryImportObjectRequest,
6210                            fidl::encoding::DefaultFuchsiaResourceDialect
6211                        );
6212                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryImportObjectRequest>(&header, _body_bytes, handles, &mut req)?;
6213                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6214                        Ok(PrimaryRequest::ImportObject { payload: req, control_handle })
6215                    }
6216                    0x4a65d5885da5e88f => {
6217                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6218                        let mut req = fidl::new_empty!(
6219                            PrimaryReleaseObjectRequest,
6220                            fidl::encoding::DefaultFuchsiaResourceDialect
6221                        );
6222                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryReleaseObjectRequest>(&header, _body_bytes, handles, &mut req)?;
6223                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6224                        Ok(PrimaryRequest::ReleaseObject {
6225                            object_id: req.object_id,
6226                            object_type: req.object_type,
6227
6228                            control_handle,
6229                        })
6230                    }
6231                    0x5a9a91c8b88b5da4 => {
6232                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6233                        let mut req = fidl::new_empty!(
6234                            PrimaryCreateContextRequest,
6235                            fidl::encoding::DefaultFuchsiaResourceDialect
6236                        );
6237                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryCreateContextRequest>(&header, _body_bytes, handles, &mut req)?;
6238                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6239                        Ok(PrimaryRequest::CreateContext {
6240                            context_id: req.context_id,
6241
6242                            control_handle,
6243                        })
6244                    }
6245                    0x5f7e3a5137e758f6 => {
6246                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6247                        let mut req = fidl::new_empty!(
6248                            PrimaryCreateContext2Request,
6249                            fidl::encoding::DefaultFuchsiaResourceDialect
6250                        );
6251                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryCreateContext2Request>(&header, _body_bytes, handles, &mut req)?;
6252                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6253                        Ok(PrimaryRequest::CreateContext2 {
6254                            context_id: req.context_id,
6255                            priority: req.priority,
6256
6257                            control_handle,
6258                        })
6259                    }
6260                    0x26b626e6be162ef0 => {
6261                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6262                        let mut req = fidl::new_empty!(
6263                            PrimaryDestroyContextRequest,
6264                            fidl::encoding::DefaultFuchsiaResourceDialect
6265                        );
6266                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryDestroyContextRequest>(&header, _body_bytes, handles, &mut req)?;
6267                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6268                        Ok(PrimaryRequest::DestroyContext {
6269                            context_id: req.context_id,
6270
6271                            control_handle,
6272                        })
6273                    }
6274                    0xf2799643aadb0db => {
6275                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6276                        let mut req = fidl::new_empty!(
6277                            PrimaryExecuteCommandRequest,
6278                            fidl::encoding::DefaultFuchsiaResourceDialect
6279                        );
6280                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryExecuteCommandRequest>(&header, _body_bytes, handles, &mut req)?;
6281                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6282                        Ok(PrimaryRequest::ExecuteCommand {
6283                            context_id: req.context_id,
6284                            resources: req.resources,
6285                            command_buffers: req.command_buffers,
6286                            wait_semaphores: req.wait_semaphores,
6287                            signal_semaphores: req.signal_semaphores,
6288                            flags: req.flags,
6289
6290                            control_handle,
6291                        })
6292                    }
6293                    0x766d5c86f35468a6 => {
6294                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6295                        let mut req = fidl::new_empty!(
6296                            PrimaryExecuteInlineCommandsRequest,
6297                            fidl::encoding::DefaultFuchsiaResourceDialect
6298                        );
6299                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryExecuteInlineCommandsRequest>(&header, _body_bytes, handles, &mut req)?;
6300                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6301                        Ok(PrimaryRequest::ExecuteInlineCommands {
6302                            context_id: req.context_id,
6303                            commands: req.commands,
6304
6305                            control_handle,
6306                        })
6307                    }
6308                    0x54ccb5572d886039 => {
6309                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6310                        let mut req = fidl::new_empty!(
6311                            fidl::encoding::EmptyPayload,
6312                            fidl::encoding::DefaultFuchsiaResourceDialect
6313                        );
6314                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6315                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6316                        Ok(PrimaryRequest::Flush {
6317                            responder: PrimaryFlushResponder {
6318                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6319                                tx_id: header.tx_id,
6320                            },
6321                        })
6322                    }
6323                    0x56baa5d2092c8e33 => {
6324                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6325                        let mut req = fidl::new_empty!(
6326                            PrimaryMapBufferRequest,
6327                            fidl::encoding::DefaultFuchsiaResourceDialect
6328                        );
6329                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryMapBufferRequest>(&header, _body_bytes, handles, &mut req)?;
6330                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6331                        Ok(PrimaryRequest::MapBuffer { payload: req, control_handle })
6332                    }
6333                    0x305188ebd8bcd95c => {
6334                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6335                        let mut req = fidl::new_empty!(
6336                            PrimaryUnmapBufferRequest,
6337                            fidl::encoding::DefaultFuchsiaResourceDialect
6338                        );
6339                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryUnmapBufferRequest>(&header, _body_bytes, handles, &mut req)?;
6340                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6341                        Ok(PrimaryRequest::UnmapBuffer { payload: req, control_handle })
6342                    }
6343                    0x4175c8dfef355396 => {
6344                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6345                        let mut req = fidl::new_empty!(
6346                            PrimaryBufferRangeOp2Request,
6347                            fidl::encoding::DefaultFuchsiaResourceDialect
6348                        );
6349                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryBufferRangeOp2Request>(&header, _body_bytes, handles, &mut req)?;
6350                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6351                        Ok(PrimaryRequest::BufferRangeOp2 {
6352                            op: req.op,
6353                            range: req.range,
6354
6355                            control_handle,
6356                        })
6357                    }
6358                    0x8b5e68f3ee0b22e => {
6359                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6360                        let mut req = fidl::new_empty!(
6361                            fidl::encoding::EmptyPayload,
6362                            fidl::encoding::DefaultFuchsiaResourceDialect
6363                        );
6364                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6365                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6366                        Ok(PrimaryRequest::EnableFlowControl { control_handle })
6367                    }
6368                    0x51b369ac16588831 => {
6369                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6370                        let mut req = fidl::new_empty!(
6371                            PrimaryEnablePerformanceCounterAccessRequest,
6372                            fidl::encoding::DefaultFuchsiaResourceDialect
6373                        );
6374                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryEnablePerformanceCounterAccessRequest>(&header, _body_bytes, handles, &mut req)?;
6375                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6376                        Ok(PrimaryRequest::EnablePerformanceCounterAccess {
6377                            access_token: req.access_token,
6378
6379                            control_handle,
6380                        })
6381                    }
6382                    0x1933b70c06cc5702 => {
6383                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6384                        let mut req = fidl::new_empty!(
6385                            fidl::encoding::EmptyPayload,
6386                            fidl::encoding::DefaultFuchsiaResourceDialect
6387                        );
6388                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6389                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6390                        Ok(PrimaryRequest::IsPerformanceCounterAccessAllowed {
6391                            responder: PrimaryIsPerformanceCounterAccessAllowedResponder {
6392                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6393                                tx_id: header.tx_id,
6394                            },
6395                        })
6396                    }
6397                    0x52c4db74b601aaa7 => {
6398                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6399                        let mut req = fidl::new_empty!(
6400                            PrimaryEnablePerformanceCountersRequest,
6401                            fidl::encoding::DefaultFuchsiaResourceDialect
6402                        );
6403                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryEnablePerformanceCountersRequest>(&header, _body_bytes, handles, &mut req)?;
6404                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6405                        Ok(PrimaryRequest::EnablePerformanceCounters {
6406                            counters: req.counters,
6407
6408                            control_handle,
6409                        })
6410                    }
6411                    0x48ccf6519bbbc638 => {
6412                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6413                        let mut req = fidl::new_empty!(
6414                            PrimaryCreatePerformanceCounterBufferPoolRequest,
6415                            fidl::encoding::DefaultFuchsiaResourceDialect
6416                        );
6417                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryCreatePerformanceCounterBufferPoolRequest>(&header, _body_bytes, handles, &mut req)?;
6418                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6419                        Ok(PrimaryRequest::CreatePerformanceCounterBufferPool {
6420                            pool_id: req.pool_id,
6421                            event_channel: req.event_channel,
6422
6423                            control_handle,
6424                        })
6425                    }
6426                    0x18374c4b3ef0b4da => {
6427                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6428                        let mut req = fidl::new_empty!(
6429                            PrimaryReleasePerformanceCounterBufferPoolRequest,
6430                            fidl::encoding::DefaultFuchsiaResourceDialect
6431                        );
6432                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryReleasePerformanceCounterBufferPoolRequest>(&header, _body_bytes, handles, &mut req)?;
6433                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6434                        Ok(PrimaryRequest::ReleasePerformanceCounterBufferPool {
6435                            pool_id: req.pool_id,
6436
6437                            control_handle,
6438                        })
6439                    }
6440                    0x1f7889571111386b => {
6441                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6442                        let mut req = fidl::new_empty!(
6443                            PrimaryAddPerformanceCounterBufferOffsetsToPoolRequest,
6444                            fidl::encoding::DefaultFuchsiaResourceDialect
6445                        );
6446                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryAddPerformanceCounterBufferOffsetsToPoolRequest>(&header, _body_bytes, handles, &mut req)?;
6447                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6448                        Ok(PrimaryRequest::AddPerformanceCounterBufferOffsetsToPool {
6449                            pool_id: req.pool_id,
6450                            offsets: req.offsets,
6451
6452                            control_handle,
6453                        })
6454                    }
6455                    0xbf1275f5a36258e => {
6456                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6457                        let mut req = fidl::new_empty!(
6458                            PrimaryRemovePerformanceCounterBufferFromPoolRequest,
6459                            fidl::encoding::DefaultFuchsiaResourceDialect
6460                        );
6461                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryRemovePerformanceCounterBufferFromPoolRequest>(&header, _body_bytes, handles, &mut req)?;
6462                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6463                        Ok(PrimaryRequest::RemovePerformanceCounterBufferFromPool {
6464                            pool_id: req.pool_id,
6465                            buffer_id: req.buffer_id,
6466
6467                            control_handle,
6468                        })
6469                    }
6470                    0x250b29340be28807 => {
6471                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6472                        let mut req = fidl::new_empty!(
6473                            PrimaryDumpPerformanceCountersRequest,
6474                            fidl::encoding::DefaultFuchsiaResourceDialect
6475                        );
6476                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryDumpPerformanceCountersRequest>(&header, _body_bytes, handles, &mut req)?;
6477                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6478                        Ok(PrimaryRequest::DumpPerformanceCounters {
6479                            pool_id: req.pool_id,
6480                            trigger_id: req.trigger_id,
6481
6482                            control_handle,
6483                        })
6484                    }
6485                    0x236831822eff741a => {
6486                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6487                        let mut req = fidl::new_empty!(
6488                            PrimaryClearPerformanceCountersRequest,
6489                            fidl::encoding::DefaultFuchsiaResourceDialect
6490                        );
6491                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PrimaryClearPerformanceCountersRequest>(&header, _body_bytes, handles, &mut req)?;
6492                        let control_handle = PrimaryControlHandle { inner: this.inner.clone() };
6493                        Ok(PrimaryRequest::ClearPerformanceCounters {
6494                            counters: req.counters,
6495
6496                            control_handle,
6497                        })
6498                    }
6499                    _ => Err(fidl::Error::UnknownOrdinal {
6500                        ordinal: header.ordinal,
6501                        protocol_name:
6502                            <PrimaryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6503                    }),
6504                }))
6505            },
6506        )
6507    }
6508}
6509
6510/// If a system driver error occurs, or if the client sends a message that the client should have
6511/// known is invalid, the connection will be closed and a zx.Status sent via epitaph.
6512#[derive(Debug)]
6513pub enum PrimaryRequest {
6514    /// Imports an object for use in the system driver.
6515    ImportObject { payload: PrimaryImportObjectRequest, control_handle: PrimaryControlHandle },
6516    /// Destroys the object with `object_id` within this connection.
6517    ReleaseObject { object_id: u64, object_type: ObjectType, control_handle: PrimaryControlHandle },
6518    /// Creates context `context_id` for use in command execution.  A context may be associated
6519    /// with hardware state.
6520    /// DEPRECATED: Please use CreateContext2.
6521    /// TODO(https://fxbug.dev/413030654): Fully deprecate this API.
6522    CreateContext { context_id: u32, control_handle: PrimaryControlHandle },
6523    /// Creates context `context_id` for use in command execution.  A context may be associated
6524    /// with hardware state.
6525    CreateContext2 { context_id: u32, priority: Priority, control_handle: PrimaryControlHandle },
6526    /// Destroys context `context_id`.
6527    DestroyContext { context_id: u32, control_handle: PrimaryControlHandle },
6528    /// Submits command buffers for execution on the hardware, with associated `resources`.
6529    /// `resources` must refer to buffers that have been imported.
6530    /// `wait_semaphores` and `signal_semaphores` must refer to events that have been imported.
6531    /// `wait_semaphores` must all be signaled before execution begins, then are reset.
6532    /// `signal_semaphores` will be signaled after the command buffer is completed.
6533    ExecuteCommand {
6534        context_id: u32,
6535        resources: Vec<BufferRange>,
6536        command_buffers: Vec<CommandBuffer>,
6537        wait_semaphores: Vec<u64>,
6538        signal_semaphores: Vec<u64>,
6539        flags: CommandBufferFlags,
6540        control_handle: PrimaryControlHandle,
6541    },
6542    /// Submits a series of commands for execution on the hardware without using a command buffer.
6543    /// The number of commands sent should be calculated so that the total message size is less than
6544    /// MAX_INLINE_COMMANDS_DATA_SIZE.
6545    ExecuteInlineCommands {
6546        context_id: u32,
6547        commands: Vec<InlineCommand>,
6548        control_handle: PrimaryControlHandle,
6549    },
6550    /// Incurs a round-trip to the system driver, used to ensure all previous messages have been
6551    /// observed, but not necessarily completed.
6552    Flush { responder: PrimaryFlushResponder },
6553    /// Maps a page range onto the hardware in the connection's address space at address `hw_va`.
6554    /// `flags` is a set of flags from MapFlags that specify how the hardware can access the buffer.
6555    MapBuffer { payload: PrimaryMapBufferRequest, control_handle: PrimaryControlHandle },
6556    /// Releases the mapping at address `hw_va` from the hardware for the given `buffer_id`.
6557    /// Buffers will also be implicitly unmapped when released.
6558    UnmapBuffer { payload: PrimaryUnmapBufferRequest, control_handle: PrimaryControlHandle },
6559    /// Perform an operation on a range of the buffer.
6560    BufferRangeOp2 { op: BufferOp, range: BufferRange, control_handle: PrimaryControlHandle },
6561    /// Enables the events OnNotifyMessagesConsumed and OnNotifyMemoryImported.
6562    EnableFlowControl { control_handle: PrimaryControlHandle },
6563    /// Tries to enable performance counter FIDL messages. To be successful, |access_token| must
6564    /// have been returned by PerformanceCounterAccess.GetPerformanceCountToken() from the matching
6565    /// device.
6566    EnablePerformanceCounterAccess {
6567        access_token: fidl::Event,
6568        control_handle: PrimaryControlHandle,
6569    },
6570    /// Returns true if any EnablePerformanceCounterAccess message has succeeded.
6571    IsPerformanceCounterAccessAllowed {
6572        responder: PrimaryIsPerformanceCounterAccessAllowedResponder,
6573    },
6574    /// Enables a set of performance counters.  Disables enabled performance counters that are not
6575    /// in the new set. Performance counters will also be automatically disabled on connection
6576    /// close. Performance counter access must have been enabled using
6577    /// EnablePerformanceCounterAccess before calling this method.
6578    EnablePerformanceCounters { counters: Vec<u64>, control_handle: PrimaryControlHandle },
6579    /// Creates a pool of buffers that performance counters can be dumped into. Performance counter
6580    /// access must have been enabled using EnablePerformanceCounterAccess before calling this
6581    /// method.
6582    CreatePerformanceCounterBufferPool {
6583        pool_id: u64,
6584        event_channel: fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
6585        control_handle: PrimaryControlHandle,
6586    },
6587    /// Releases a pool of performance counter buffers. Performance counter access must have been
6588    /// enabled using EnablePerformanceCounterAccess before calling this method.
6589    ReleasePerformanceCounterBufferPool { pool_id: u64, control_handle: PrimaryControlHandle },
6590    /// Adds a set of offsets into buffers to the pool. |offsets[n].buffer_id| is the id of a
6591    /// buffer that was previously imported using ImportBuffer(). The same buffer may be added to
6592    /// multiple pools. The pool will hold on to a reference to the buffer even after ReleaseBuffer
6593    /// is called.  When dumped into this entry, counters will be written starting at
6594    /// |offsets[n].buffer_offset| bytes into the buffer, and up to |offsets[n].buffer_offset| +
6595    /// |offsets[n].buffer_size|. |offsets[n].buffer_size| must be large enough to fit all enabled
6596    /// counters. Performance counter access must have been enabled using
6597    /// EnablePerformanceCounterAccess before calling this method.
6598    AddPerformanceCounterBufferOffsetsToPool {
6599        pool_id: u64,
6600        offsets: Vec<BufferRange>,
6601        control_handle: PrimaryControlHandle,
6602    },
6603    /// Removes every offset of a buffer from the pool. Once this method is finished being handled
6604    /// on the server, no more dumps will be processed into this buffer. In-flight dumps into this
6605    /// buffer may be lost.  Performance counter access must have been enabled using
6606    /// EnablePerformanceCounterAccess before calling this method.
6607    RemovePerformanceCounterBufferFromPool {
6608        pool_id: u64,
6609        buffer_id: u64,
6610        control_handle: PrimaryControlHandle,
6611    },
6612    /// Triggers dumping of the performance counters into a buffer pool. May fail silently if there
6613    /// are no buffers in the pool. |trigger_id| is an arbitrary ID assigned by the client that can
6614    /// be returned in OnPerformanceCounterReadCompleted. Performance counter access must have been
6615    /// enabled using EnablePerformanceCounterAccess before calling this method.
6616    DumpPerformanceCounters { pool_id: u64, trigger_id: u32, control_handle: PrimaryControlHandle },
6617    /// Sets the values of all listed performance counters to 0. May not be supported by some
6618    /// hardware. Performance counter access must have been enabled using
6619    /// EnablePerformanceCounterAccess before calling this method.
6620    ClearPerformanceCounters { counters: Vec<u64>, control_handle: PrimaryControlHandle },
6621}
6622
6623impl PrimaryRequest {
6624    #[allow(irrefutable_let_patterns)]
6625    pub fn into_import_object(self) -> Option<(PrimaryImportObjectRequest, PrimaryControlHandle)> {
6626        if let PrimaryRequest::ImportObject { payload, control_handle } = self {
6627            Some((payload, control_handle))
6628        } else {
6629            None
6630        }
6631    }
6632
6633    #[allow(irrefutable_let_patterns)]
6634    pub fn into_release_object(self) -> Option<(u64, ObjectType, PrimaryControlHandle)> {
6635        if let PrimaryRequest::ReleaseObject { object_id, object_type, control_handle } = self {
6636            Some((object_id, object_type, control_handle))
6637        } else {
6638            None
6639        }
6640    }
6641
6642    #[allow(irrefutable_let_patterns)]
6643    pub fn into_create_context(self) -> Option<(u32, PrimaryControlHandle)> {
6644        if let PrimaryRequest::CreateContext { context_id, control_handle } = self {
6645            Some((context_id, control_handle))
6646        } else {
6647            None
6648        }
6649    }
6650
6651    #[allow(irrefutable_let_patterns)]
6652    pub fn into_create_context2(self) -> Option<(u32, Priority, PrimaryControlHandle)> {
6653        if let PrimaryRequest::CreateContext2 { context_id, priority, control_handle } = self {
6654            Some((context_id, priority, control_handle))
6655        } else {
6656            None
6657        }
6658    }
6659
6660    #[allow(irrefutable_let_patterns)]
6661    pub fn into_destroy_context(self) -> Option<(u32, PrimaryControlHandle)> {
6662        if let PrimaryRequest::DestroyContext { context_id, control_handle } = self {
6663            Some((context_id, control_handle))
6664        } else {
6665            None
6666        }
6667    }
6668
6669    #[allow(irrefutable_let_patterns)]
6670    pub fn into_execute_command(
6671        self,
6672    ) -> Option<(
6673        u32,
6674        Vec<BufferRange>,
6675        Vec<CommandBuffer>,
6676        Vec<u64>,
6677        Vec<u64>,
6678        CommandBufferFlags,
6679        PrimaryControlHandle,
6680    )> {
6681        if let PrimaryRequest::ExecuteCommand {
6682            context_id,
6683            resources,
6684            command_buffers,
6685            wait_semaphores,
6686            signal_semaphores,
6687            flags,
6688            control_handle,
6689        } = self
6690        {
6691            Some((
6692                context_id,
6693                resources,
6694                command_buffers,
6695                wait_semaphores,
6696                signal_semaphores,
6697                flags,
6698                control_handle,
6699            ))
6700        } else {
6701            None
6702        }
6703    }
6704
6705    #[allow(irrefutable_let_patterns)]
6706    pub fn into_execute_inline_commands(
6707        self,
6708    ) -> Option<(u32, Vec<InlineCommand>, PrimaryControlHandle)> {
6709        if let PrimaryRequest::ExecuteInlineCommands { context_id, commands, control_handle } = self
6710        {
6711            Some((context_id, commands, control_handle))
6712        } else {
6713            None
6714        }
6715    }
6716
6717    #[allow(irrefutable_let_patterns)]
6718    pub fn into_flush(self) -> Option<(PrimaryFlushResponder)> {
6719        if let PrimaryRequest::Flush { responder } = self { Some((responder)) } else { None }
6720    }
6721
6722    #[allow(irrefutable_let_patterns)]
6723    pub fn into_map_buffer(self) -> Option<(PrimaryMapBufferRequest, PrimaryControlHandle)> {
6724        if let PrimaryRequest::MapBuffer { payload, control_handle } = self {
6725            Some((payload, control_handle))
6726        } else {
6727            None
6728        }
6729    }
6730
6731    #[allow(irrefutable_let_patterns)]
6732    pub fn into_unmap_buffer(self) -> Option<(PrimaryUnmapBufferRequest, PrimaryControlHandle)> {
6733        if let PrimaryRequest::UnmapBuffer { payload, control_handle } = self {
6734            Some((payload, control_handle))
6735        } else {
6736            None
6737        }
6738    }
6739
6740    #[allow(irrefutable_let_patterns)]
6741    pub fn into_buffer_range_op2(self) -> Option<(BufferOp, BufferRange, PrimaryControlHandle)> {
6742        if let PrimaryRequest::BufferRangeOp2 { op, range, control_handle } = self {
6743            Some((op, range, control_handle))
6744        } else {
6745            None
6746        }
6747    }
6748
6749    #[allow(irrefutable_let_patterns)]
6750    pub fn into_enable_flow_control(self) -> Option<(PrimaryControlHandle)> {
6751        if let PrimaryRequest::EnableFlowControl { control_handle } = self {
6752            Some((control_handle))
6753        } else {
6754            None
6755        }
6756    }
6757
6758    #[allow(irrefutable_let_patterns)]
6759    pub fn into_enable_performance_counter_access(
6760        self,
6761    ) -> Option<(fidl::Event, PrimaryControlHandle)> {
6762        if let PrimaryRequest::EnablePerformanceCounterAccess { access_token, control_handle } =
6763            self
6764        {
6765            Some((access_token, control_handle))
6766        } else {
6767            None
6768        }
6769    }
6770
6771    #[allow(irrefutable_let_patterns)]
6772    pub fn into_is_performance_counter_access_allowed(
6773        self,
6774    ) -> Option<(PrimaryIsPerformanceCounterAccessAllowedResponder)> {
6775        if let PrimaryRequest::IsPerformanceCounterAccessAllowed { responder } = self {
6776            Some((responder))
6777        } else {
6778            None
6779        }
6780    }
6781
6782    #[allow(irrefutable_let_patterns)]
6783    pub fn into_enable_performance_counters(self) -> Option<(Vec<u64>, PrimaryControlHandle)> {
6784        if let PrimaryRequest::EnablePerformanceCounters { counters, control_handle } = self {
6785            Some((counters, control_handle))
6786        } else {
6787            None
6788        }
6789    }
6790
6791    #[allow(irrefutable_let_patterns)]
6792    pub fn into_create_performance_counter_buffer_pool(
6793        self,
6794    ) -> Option<(
6795        u64,
6796        fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
6797        PrimaryControlHandle,
6798    )> {
6799        if let PrimaryRequest::CreatePerformanceCounterBufferPool {
6800            pool_id,
6801            event_channel,
6802            control_handle,
6803        } = self
6804        {
6805            Some((pool_id, event_channel, control_handle))
6806        } else {
6807            None
6808        }
6809    }
6810
6811    #[allow(irrefutable_let_patterns)]
6812    pub fn into_release_performance_counter_buffer_pool(
6813        self,
6814    ) -> Option<(u64, PrimaryControlHandle)> {
6815        if let PrimaryRequest::ReleasePerformanceCounterBufferPool { pool_id, control_handle } =
6816            self
6817        {
6818            Some((pool_id, control_handle))
6819        } else {
6820            None
6821        }
6822    }
6823
6824    #[allow(irrefutable_let_patterns)]
6825    pub fn into_add_performance_counter_buffer_offsets_to_pool(
6826        self,
6827    ) -> Option<(u64, Vec<BufferRange>, PrimaryControlHandle)> {
6828        if let PrimaryRequest::AddPerformanceCounterBufferOffsetsToPool {
6829            pool_id,
6830            offsets,
6831            control_handle,
6832        } = self
6833        {
6834            Some((pool_id, offsets, control_handle))
6835        } else {
6836            None
6837        }
6838    }
6839
6840    #[allow(irrefutable_let_patterns)]
6841    pub fn into_remove_performance_counter_buffer_from_pool(
6842        self,
6843    ) -> Option<(u64, u64, PrimaryControlHandle)> {
6844        if let PrimaryRequest::RemovePerformanceCounterBufferFromPool {
6845            pool_id,
6846            buffer_id,
6847            control_handle,
6848        } = self
6849        {
6850            Some((pool_id, buffer_id, control_handle))
6851        } else {
6852            None
6853        }
6854    }
6855
6856    #[allow(irrefutable_let_patterns)]
6857    pub fn into_dump_performance_counters(self) -> Option<(u64, u32, PrimaryControlHandle)> {
6858        if let PrimaryRequest::DumpPerformanceCounters { pool_id, trigger_id, control_handle } =
6859            self
6860        {
6861            Some((pool_id, trigger_id, control_handle))
6862        } else {
6863            None
6864        }
6865    }
6866
6867    #[allow(irrefutable_let_patterns)]
6868    pub fn into_clear_performance_counters(self) -> Option<(Vec<u64>, PrimaryControlHandle)> {
6869        if let PrimaryRequest::ClearPerformanceCounters { counters, control_handle } = self {
6870            Some((counters, control_handle))
6871        } else {
6872            None
6873        }
6874    }
6875
6876    /// Name of the method defined in FIDL
6877    pub fn method_name(&self) -> &'static str {
6878        match *self {
6879            PrimaryRequest::ImportObject { .. } => "import_object",
6880            PrimaryRequest::ReleaseObject { .. } => "release_object",
6881            PrimaryRequest::CreateContext { .. } => "create_context",
6882            PrimaryRequest::CreateContext2 { .. } => "create_context2",
6883            PrimaryRequest::DestroyContext { .. } => "destroy_context",
6884            PrimaryRequest::ExecuteCommand { .. } => "execute_command",
6885            PrimaryRequest::ExecuteInlineCommands { .. } => "execute_inline_commands",
6886            PrimaryRequest::Flush { .. } => "flush",
6887            PrimaryRequest::MapBuffer { .. } => "map_buffer",
6888            PrimaryRequest::UnmapBuffer { .. } => "unmap_buffer",
6889            PrimaryRequest::BufferRangeOp2 { .. } => "buffer_range_op2",
6890            PrimaryRequest::EnableFlowControl { .. } => "enable_flow_control",
6891            PrimaryRequest::EnablePerformanceCounterAccess { .. } => {
6892                "enable_performance_counter_access"
6893            }
6894            PrimaryRequest::IsPerformanceCounterAccessAllowed { .. } => {
6895                "is_performance_counter_access_allowed"
6896            }
6897            PrimaryRequest::EnablePerformanceCounters { .. } => "enable_performance_counters",
6898            PrimaryRequest::CreatePerformanceCounterBufferPool { .. } => {
6899                "create_performance_counter_buffer_pool"
6900            }
6901            PrimaryRequest::ReleasePerformanceCounterBufferPool { .. } => {
6902                "release_performance_counter_buffer_pool"
6903            }
6904            PrimaryRequest::AddPerformanceCounterBufferOffsetsToPool { .. } => {
6905                "add_performance_counter_buffer_offsets_to_pool"
6906            }
6907            PrimaryRequest::RemovePerformanceCounterBufferFromPool { .. } => {
6908                "remove_performance_counter_buffer_from_pool"
6909            }
6910            PrimaryRequest::DumpPerformanceCounters { .. } => "dump_performance_counters",
6911            PrimaryRequest::ClearPerformanceCounters { .. } => "clear_performance_counters",
6912        }
6913    }
6914}
6915
6916#[derive(Debug, Clone)]
6917pub struct PrimaryControlHandle {
6918    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6919}
6920
6921impl fidl::endpoints::ControlHandle for PrimaryControlHandle {
6922    fn shutdown(&self) {
6923        self.inner.shutdown()
6924    }
6925
6926    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6927        self.inner.shutdown_with_epitaph(status)
6928    }
6929
6930    fn is_closed(&self) -> bool {
6931        self.inner.channel().is_closed()
6932    }
6933    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6934        self.inner.channel().on_closed()
6935    }
6936
6937    #[cfg(target_os = "fuchsia")]
6938    fn signal_peer(
6939        &self,
6940        clear_mask: zx::Signals,
6941        set_mask: zx::Signals,
6942    ) -> Result<(), zx_status::Status> {
6943        use fidl::Peered;
6944        self.inner.channel().signal_peer(clear_mask, set_mask)
6945    }
6946}
6947
6948impl PrimaryControlHandle {
6949    pub fn send_on_notify_messages_consumed(&self, mut count: u64) -> Result<(), fidl::Error> {
6950        self.inner.send::<PrimaryOnNotifyMessagesConsumedRequest>(
6951            (count,),
6952            0,
6953            0x5e8dd0b0b753ac43,
6954            fidl::encoding::DynamicFlags::empty(),
6955        )
6956    }
6957
6958    pub fn send_on_notify_memory_imported(&self, mut bytes: u64) -> Result<(), fidl::Error> {
6959        self.inner.send::<PrimaryOnNotifyMemoryImportedRequest>(
6960            (bytes,),
6961            0,
6962            0x50524b7a3503aba6,
6963            fidl::encoding::DynamicFlags::empty(),
6964        )
6965    }
6966}
6967
6968#[must_use = "FIDL methods require a response to be sent"]
6969#[derive(Debug)]
6970pub struct PrimaryFlushResponder {
6971    control_handle: std::mem::ManuallyDrop<PrimaryControlHandle>,
6972    tx_id: u32,
6973}
6974
6975/// Set the the channel to be shutdown (see [`PrimaryControlHandle::shutdown`])
6976/// if the responder is dropped without sending a response, so that the client
6977/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6978impl std::ops::Drop for PrimaryFlushResponder {
6979    fn drop(&mut self) {
6980        self.control_handle.shutdown();
6981        // Safety: drops once, never accessed again
6982        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6983    }
6984}
6985
6986impl fidl::endpoints::Responder for PrimaryFlushResponder {
6987    type ControlHandle = PrimaryControlHandle;
6988
6989    fn control_handle(&self) -> &PrimaryControlHandle {
6990        &self.control_handle
6991    }
6992
6993    fn drop_without_shutdown(mut self) {
6994        // Safety: drops once, never accessed again due to mem::forget
6995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6996        // Prevent Drop from running (which would shut down the channel)
6997        std::mem::forget(self);
6998    }
6999}
7000
7001impl PrimaryFlushResponder {
7002    /// Sends a response to the FIDL transaction.
7003    ///
7004    /// Sets the channel to shutdown if an error occurs.
7005    pub fn send(self) -> Result<(), fidl::Error> {
7006        let _result = self.send_raw();
7007        if _result.is_err() {
7008            self.control_handle.shutdown();
7009        }
7010        self.drop_without_shutdown();
7011        _result
7012    }
7013
7014    /// Similar to "send" but does not shutdown the channel if an error occurs.
7015    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7016        let _result = self.send_raw();
7017        self.drop_without_shutdown();
7018        _result
7019    }
7020
7021    fn send_raw(&self) -> Result<(), fidl::Error> {
7022        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7023            (),
7024            self.tx_id,
7025            0x54ccb5572d886039,
7026            fidl::encoding::DynamicFlags::empty(),
7027        )
7028    }
7029}
7030
7031#[must_use = "FIDL methods require a response to be sent"]
7032#[derive(Debug)]
7033pub struct PrimaryIsPerformanceCounterAccessAllowedResponder {
7034    control_handle: std::mem::ManuallyDrop<PrimaryControlHandle>,
7035    tx_id: u32,
7036}
7037
7038/// Set the the channel to be shutdown (see [`PrimaryControlHandle::shutdown`])
7039/// if the responder is dropped without sending a response, so that the client
7040/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7041impl std::ops::Drop for PrimaryIsPerformanceCounterAccessAllowedResponder {
7042    fn drop(&mut self) {
7043        self.control_handle.shutdown();
7044        // Safety: drops once, never accessed again
7045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7046    }
7047}
7048
7049impl fidl::endpoints::Responder for PrimaryIsPerformanceCounterAccessAllowedResponder {
7050    type ControlHandle = PrimaryControlHandle;
7051
7052    fn control_handle(&self) -> &PrimaryControlHandle {
7053        &self.control_handle
7054    }
7055
7056    fn drop_without_shutdown(mut self) {
7057        // Safety: drops once, never accessed again due to mem::forget
7058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7059        // Prevent Drop from running (which would shut down the channel)
7060        std::mem::forget(self);
7061    }
7062}
7063
7064impl PrimaryIsPerformanceCounterAccessAllowedResponder {
7065    /// Sends a response to the FIDL transaction.
7066    ///
7067    /// Sets the channel to shutdown if an error occurs.
7068    pub fn send(self, mut enabled: bool) -> Result<(), fidl::Error> {
7069        let _result = self.send_raw(enabled);
7070        if _result.is_err() {
7071            self.control_handle.shutdown();
7072        }
7073        self.drop_without_shutdown();
7074        _result
7075    }
7076
7077    /// Similar to "send" but does not shutdown the channel if an error occurs.
7078    pub fn send_no_shutdown_on_err(self, mut enabled: bool) -> Result<(), fidl::Error> {
7079        let _result = self.send_raw(enabled);
7080        self.drop_without_shutdown();
7081        _result
7082    }
7083
7084    fn send_raw(&self, mut enabled: bool) -> Result<(), fidl::Error> {
7085        self.control_handle.inner.send::<PrimaryIsPerformanceCounterAccessAllowedResponse>(
7086            (enabled,),
7087            self.tx_id,
7088            0x1933b70c06cc5702,
7089            fidl::encoding::DynamicFlags::empty(),
7090        )
7091    }
7092}
7093
7094#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7095pub struct TestDeviceMarker;
7096
7097impl fidl::endpoints::ProtocolMarker for TestDeviceMarker {
7098    type Proxy = TestDeviceProxy;
7099    type RequestStream = TestDeviceRequestStream;
7100    #[cfg(target_os = "fuchsia")]
7101    type SynchronousProxy = TestDeviceSynchronousProxy;
7102
7103    const DEBUG_NAME: &'static str = "(anonymous) TestDevice";
7104}
7105
7106pub trait TestDeviceProxyInterface: Send + Sync {
7107    type QueryResponseFut: std::future::Future<Output = Result<DeviceQueryResult, fidl::Error>>
7108        + Send;
7109    fn r#query(&self, query_id: QueryId) -> Self::QueryResponseFut;
7110    fn r#connect2(
7111        &self,
7112        client_id: u64,
7113        primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
7114        notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
7115    ) -> Result<(), fidl::Error>;
7116    fn r#dump_state(&self, dump_type: u32) -> Result<(), fidl::Error>;
7117    type GetIcdListResponseFut: std::future::Future<Output = Result<Vec<IcdInfo>, fidl::Error>>
7118        + Send;
7119    fn r#get_icd_list(&self) -> Self::GetIcdListResponseFut;
7120    type GetUnitTestStatusResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
7121    fn r#get_unit_test_status(&self) -> Self::GetUnitTestStatusResponseFut;
7122}
7123#[derive(Debug)]
7124#[cfg(target_os = "fuchsia")]
7125pub struct TestDeviceSynchronousProxy {
7126    client: fidl::client::sync::Client,
7127}
7128
7129#[cfg(target_os = "fuchsia")]
7130impl fidl::endpoints::SynchronousProxy for TestDeviceSynchronousProxy {
7131    type Proxy = TestDeviceProxy;
7132    type Protocol = TestDeviceMarker;
7133
7134    fn from_channel(inner: fidl::Channel) -> Self {
7135        Self::new(inner)
7136    }
7137
7138    fn into_channel(self) -> fidl::Channel {
7139        self.client.into_channel()
7140    }
7141
7142    fn as_channel(&self) -> &fidl::Channel {
7143        self.client.as_channel()
7144    }
7145}
7146
7147#[cfg(target_os = "fuchsia")]
7148impl TestDeviceSynchronousProxy {
7149    pub fn new(channel: fidl::Channel) -> Self {
7150        let protocol_name = <TestDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7151        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7152    }
7153
7154    pub fn into_channel(self) -> fidl::Channel {
7155        self.client.into_channel()
7156    }
7157
7158    /// Waits until an event arrives and returns it. It is safe for other
7159    /// threads to make concurrent requests while waiting for an event.
7160    pub fn wait_for_event(
7161        &self,
7162        deadline: zx::MonotonicInstant,
7163    ) -> Result<TestDeviceEvent, fidl::Error> {
7164        TestDeviceEvent::decode(self.client.wait_for_event(deadline)?)
7165    }
7166
7167    /// On success, returns a result either in a buffer or a simple value.
7168    pub fn r#query(
7169        &self,
7170        mut query_id: QueryId,
7171        ___deadline: zx::MonotonicInstant,
7172    ) -> Result<DeviceQueryResult, fidl::Error> {
7173        let _response = self
7174            .client
7175            .send_query::<DeviceQueryRequest, fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
7176                (query_id,),
7177                0x627d4c6093b078e7,
7178                fidl::encoding::DynamicFlags::empty(),
7179                ___deadline,
7180            )?;
7181        Ok(_response.map(|x| x))
7182    }
7183
7184    /// Creates a connection to the device comprised of two IPC channels.
7185    /// The primary channel is for the Primary protocol (see below).  The notification channel is
7186    /// used for vendor-specific messages which are sent only in the reverse (server-client)
7187    /// direction, typically in response to client command completion.
7188    pub fn r#connect2(
7189        &self,
7190        mut client_id: u64,
7191        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
7192        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
7193    ) -> Result<(), fidl::Error> {
7194        self.client.send::<DeviceConnect2Request>(
7195            (client_id, primary_channel, notification_channel),
7196            0x3a5b134714c67914,
7197            fidl::encoding::DynamicFlags::empty(),
7198        )
7199    }
7200
7201    /// Dumps driver and hardware state to the log.
7202    pub fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
7203        self.client.send::<DiagnosticDeviceDumpStateRequest>(
7204            (dump_type,),
7205            0x5420df493d4fa915,
7206            fidl::encoding::DynamicFlags::empty(),
7207        )
7208    }
7209
7210    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
7211    /// descending order of preference.
7212    pub fn r#get_icd_list(
7213        &self,
7214        ___deadline: zx::MonotonicInstant,
7215    ) -> Result<Vec<IcdInfo>, fidl::Error> {
7216        let _response = self
7217            .client
7218            .send_query::<fidl::encoding::EmptyPayload, IcdLoaderDeviceGetIcdListResponse>(
7219                (),
7220                0x7673e76395008257,
7221                fidl::encoding::DynamicFlags::empty(),
7222                ___deadline,
7223            )?;
7224        Ok(_response.icd_list)
7225    }
7226
7227    pub fn r#get_unit_test_status(
7228        &self,
7229        ___deadline: zx::MonotonicInstant,
7230    ) -> Result<i32, fidl::Error> {
7231        let _response = self
7232            .client
7233            .send_query::<fidl::encoding::EmptyPayload, TestDeviceGetUnitTestStatusResponse>(
7234                (),
7235                0x3ebcd9c409c248f1,
7236                fidl::encoding::DynamicFlags::empty(),
7237                ___deadline,
7238            )?;
7239        Ok(_response.status)
7240    }
7241}
7242
7243#[cfg(target_os = "fuchsia")]
7244impl From<TestDeviceSynchronousProxy> for zx::NullableHandle {
7245    fn from(value: TestDeviceSynchronousProxy) -> Self {
7246        value.into_channel().into()
7247    }
7248}
7249
7250#[cfg(target_os = "fuchsia")]
7251impl From<fidl::Channel> for TestDeviceSynchronousProxy {
7252    fn from(value: fidl::Channel) -> Self {
7253        Self::new(value)
7254    }
7255}
7256
7257#[cfg(target_os = "fuchsia")]
7258impl fidl::endpoints::FromClient for TestDeviceSynchronousProxy {
7259    type Protocol = TestDeviceMarker;
7260
7261    fn from_client(value: fidl::endpoints::ClientEnd<TestDeviceMarker>) -> Self {
7262        Self::new(value.into_channel())
7263    }
7264}
7265
7266#[derive(Debug, Clone)]
7267pub struct TestDeviceProxy {
7268    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7269}
7270
7271impl fidl::endpoints::Proxy for TestDeviceProxy {
7272    type Protocol = TestDeviceMarker;
7273
7274    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7275        Self::new(inner)
7276    }
7277
7278    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7279        self.client.into_channel().map_err(|client| Self { client })
7280    }
7281
7282    fn as_channel(&self) -> &::fidl::AsyncChannel {
7283        self.client.as_channel()
7284    }
7285}
7286
7287impl TestDeviceProxy {
7288    /// Create a new Proxy for fuchsia.gpu.magma/TestDevice.
7289    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7290        let protocol_name = <TestDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7291        Self { client: fidl::client::Client::new(channel, protocol_name) }
7292    }
7293
7294    /// Get a Stream of events from the remote end of the protocol.
7295    ///
7296    /// # Panics
7297    ///
7298    /// Panics if the event stream was already taken.
7299    pub fn take_event_stream(&self) -> TestDeviceEventStream {
7300        TestDeviceEventStream { event_receiver: self.client.take_event_receiver() }
7301    }
7302
7303    /// On success, returns a result either in a buffer or a simple value.
7304    pub fn r#query(
7305        &self,
7306        mut query_id: QueryId,
7307    ) -> fidl::client::QueryResponseFut<
7308        DeviceQueryResult,
7309        fidl::encoding::DefaultFuchsiaResourceDialect,
7310    > {
7311        TestDeviceProxyInterface::r#query(self, query_id)
7312    }
7313
7314    /// Creates a connection to the device comprised of two IPC channels.
7315    /// The primary channel is for the Primary protocol (see below).  The notification channel is
7316    /// used for vendor-specific messages which are sent only in the reverse (server-client)
7317    /// direction, typically in response to client command completion.
7318    pub fn r#connect2(
7319        &self,
7320        mut client_id: u64,
7321        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
7322        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
7323    ) -> Result<(), fidl::Error> {
7324        TestDeviceProxyInterface::r#connect2(self, client_id, primary_channel, notification_channel)
7325    }
7326
7327    /// Dumps driver and hardware state to the log.
7328    pub fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
7329        TestDeviceProxyInterface::r#dump_state(self, dump_type)
7330    }
7331
7332    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
7333    /// descending order of preference.
7334    pub fn r#get_icd_list(
7335        &self,
7336    ) -> fidl::client::QueryResponseFut<Vec<IcdInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>
7337    {
7338        TestDeviceProxyInterface::r#get_icd_list(self)
7339    }
7340
7341    pub fn r#get_unit_test_status(
7342        &self,
7343    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
7344        TestDeviceProxyInterface::r#get_unit_test_status(self)
7345    }
7346}
7347
7348impl TestDeviceProxyInterface for TestDeviceProxy {
7349    type QueryResponseFut = fidl::client::QueryResponseFut<
7350        DeviceQueryResult,
7351        fidl::encoding::DefaultFuchsiaResourceDialect,
7352    >;
7353    fn r#query(&self, mut query_id: QueryId) -> Self::QueryResponseFut {
7354        fn _decode(
7355            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7356        ) -> Result<DeviceQueryResult, fidl::Error> {
7357            let _response = fidl::client::decode_transaction_body::<
7358                fidl::encoding::ResultType<DeviceQueryResponse, i32>,
7359                fidl::encoding::DefaultFuchsiaResourceDialect,
7360                0x627d4c6093b078e7,
7361            >(_buf?)?;
7362            Ok(_response.map(|x| x))
7363        }
7364        self.client.send_query_and_decode::<DeviceQueryRequest, DeviceQueryResult>(
7365            (query_id,),
7366            0x627d4c6093b078e7,
7367            fidl::encoding::DynamicFlags::empty(),
7368            _decode,
7369        )
7370    }
7371
7372    fn r#connect2(
7373        &self,
7374        mut client_id: u64,
7375        mut primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
7376        mut notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
7377    ) -> Result<(), fidl::Error> {
7378        self.client.send::<DeviceConnect2Request>(
7379            (client_id, primary_channel, notification_channel),
7380            0x3a5b134714c67914,
7381            fidl::encoding::DynamicFlags::empty(),
7382        )
7383    }
7384
7385    fn r#dump_state(&self, mut dump_type: u32) -> Result<(), fidl::Error> {
7386        self.client.send::<DiagnosticDeviceDumpStateRequest>(
7387            (dump_type,),
7388            0x5420df493d4fa915,
7389            fidl::encoding::DynamicFlags::empty(),
7390        )
7391    }
7392
7393    type GetIcdListResponseFut =
7394        fidl::client::QueryResponseFut<Vec<IcdInfo>, fidl::encoding::DefaultFuchsiaResourceDialect>;
7395    fn r#get_icd_list(&self) -> Self::GetIcdListResponseFut {
7396        fn _decode(
7397            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7398        ) -> Result<Vec<IcdInfo>, fidl::Error> {
7399            let _response = fidl::client::decode_transaction_body::<
7400                IcdLoaderDeviceGetIcdListResponse,
7401                fidl::encoding::DefaultFuchsiaResourceDialect,
7402                0x7673e76395008257,
7403            >(_buf?)?;
7404            Ok(_response.icd_list)
7405        }
7406        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<IcdInfo>>(
7407            (),
7408            0x7673e76395008257,
7409            fidl::encoding::DynamicFlags::empty(),
7410            _decode,
7411        )
7412    }
7413
7414    type GetUnitTestStatusResponseFut =
7415        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
7416    fn r#get_unit_test_status(&self) -> Self::GetUnitTestStatusResponseFut {
7417        fn _decode(
7418            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7419        ) -> Result<i32, fidl::Error> {
7420            let _response = fidl::client::decode_transaction_body::<
7421                TestDeviceGetUnitTestStatusResponse,
7422                fidl::encoding::DefaultFuchsiaResourceDialect,
7423                0x3ebcd9c409c248f1,
7424            >(_buf?)?;
7425            Ok(_response.status)
7426        }
7427        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
7428            (),
7429            0x3ebcd9c409c248f1,
7430            fidl::encoding::DynamicFlags::empty(),
7431            _decode,
7432        )
7433    }
7434}
7435
7436pub struct TestDeviceEventStream {
7437    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7438}
7439
7440impl std::marker::Unpin for TestDeviceEventStream {}
7441
7442impl futures::stream::FusedStream for TestDeviceEventStream {
7443    fn is_terminated(&self) -> bool {
7444        self.event_receiver.is_terminated()
7445    }
7446}
7447
7448impl futures::Stream for TestDeviceEventStream {
7449    type Item = Result<TestDeviceEvent, fidl::Error>;
7450
7451    fn poll_next(
7452        mut self: std::pin::Pin<&mut Self>,
7453        cx: &mut std::task::Context<'_>,
7454    ) -> std::task::Poll<Option<Self::Item>> {
7455        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7456            &mut self.event_receiver,
7457            cx
7458        )?) {
7459            Some(buf) => std::task::Poll::Ready(Some(TestDeviceEvent::decode(buf))),
7460            None => std::task::Poll::Ready(None),
7461        }
7462    }
7463}
7464
7465#[derive(Debug)]
7466pub enum TestDeviceEvent {}
7467
7468impl TestDeviceEvent {
7469    /// Decodes a message buffer as a [`TestDeviceEvent`].
7470    fn decode(
7471        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7472    ) -> Result<TestDeviceEvent, fidl::Error> {
7473        let (bytes, _handles) = buf.split_mut();
7474        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7475        debug_assert_eq!(tx_header.tx_id, 0);
7476        match tx_header.ordinal {
7477            _ => Err(fidl::Error::UnknownOrdinal {
7478                ordinal: tx_header.ordinal,
7479                protocol_name: <TestDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7480            }),
7481        }
7482    }
7483}
7484
7485/// A Stream of incoming requests for fuchsia.gpu.magma/TestDevice.
7486pub struct TestDeviceRequestStream {
7487    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7488    is_terminated: bool,
7489}
7490
7491impl std::marker::Unpin for TestDeviceRequestStream {}
7492
7493impl futures::stream::FusedStream for TestDeviceRequestStream {
7494    fn is_terminated(&self) -> bool {
7495        self.is_terminated
7496    }
7497}
7498
7499impl fidl::endpoints::RequestStream for TestDeviceRequestStream {
7500    type Protocol = TestDeviceMarker;
7501    type ControlHandle = TestDeviceControlHandle;
7502
7503    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7504        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7505    }
7506
7507    fn control_handle(&self) -> Self::ControlHandle {
7508        TestDeviceControlHandle { inner: self.inner.clone() }
7509    }
7510
7511    fn into_inner(
7512        self,
7513    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7514    {
7515        (self.inner, self.is_terminated)
7516    }
7517
7518    fn from_inner(
7519        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7520        is_terminated: bool,
7521    ) -> Self {
7522        Self { inner, is_terminated }
7523    }
7524}
7525
7526impl futures::Stream for TestDeviceRequestStream {
7527    type Item = Result<TestDeviceRequest, fidl::Error>;
7528
7529    fn poll_next(
7530        mut self: std::pin::Pin<&mut Self>,
7531        cx: &mut std::task::Context<'_>,
7532    ) -> std::task::Poll<Option<Self::Item>> {
7533        let this = &mut *self;
7534        if this.inner.check_shutdown(cx) {
7535            this.is_terminated = true;
7536            return std::task::Poll::Ready(None);
7537        }
7538        if this.is_terminated {
7539            panic!("polled TestDeviceRequestStream after completion");
7540        }
7541        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7542            |bytes, handles| {
7543                match this.inner.channel().read_etc(cx, bytes, handles) {
7544                    std::task::Poll::Ready(Ok(())) => {}
7545                    std::task::Poll::Pending => return std::task::Poll::Pending,
7546                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7547                        this.is_terminated = true;
7548                        return std::task::Poll::Ready(None);
7549                    }
7550                    std::task::Poll::Ready(Err(e)) => {
7551                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7552                            e.into(),
7553                        ))));
7554                    }
7555                }
7556
7557                // A message has been received from the channel
7558                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7559
7560                std::task::Poll::Ready(Some(match header.ordinal {
7561                    0x627d4c6093b078e7 => {
7562                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7563                        let mut req = fidl::new_empty!(
7564                            DeviceQueryRequest,
7565                            fidl::encoding::DefaultFuchsiaResourceDialect
7566                        );
7567                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceQueryRequest>(&header, _body_bytes, handles, &mut req)?;
7568                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7569                        Ok(TestDeviceRequest::Query {
7570                            query_id: req.query_id,
7571
7572                            responder: TestDeviceQueryResponder {
7573                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7574                                tx_id: header.tx_id,
7575                            },
7576                        })
7577                    }
7578                    0x3a5b134714c67914 => {
7579                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7580                        let mut req = fidl::new_empty!(
7581                            DeviceConnect2Request,
7582                            fidl::encoding::DefaultFuchsiaResourceDialect
7583                        );
7584                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceConnect2Request>(&header, _body_bytes, handles, &mut req)?;
7585                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7586                        Ok(TestDeviceRequest::Connect2 {
7587                            client_id: req.client_id,
7588                            primary_channel: req.primary_channel,
7589                            notification_channel: req.notification_channel,
7590
7591                            control_handle,
7592                        })
7593                    }
7594                    0x5420df493d4fa915 => {
7595                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7596                        let mut req = fidl::new_empty!(
7597                            DiagnosticDeviceDumpStateRequest,
7598                            fidl::encoding::DefaultFuchsiaResourceDialect
7599                        );
7600                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DiagnosticDeviceDumpStateRequest>(&header, _body_bytes, handles, &mut req)?;
7601                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7602                        Ok(TestDeviceRequest::DumpState {
7603                            dump_type: req.dump_type,
7604
7605                            control_handle,
7606                        })
7607                    }
7608                    0x7673e76395008257 => {
7609                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7610                        let mut req = fidl::new_empty!(
7611                            fidl::encoding::EmptyPayload,
7612                            fidl::encoding::DefaultFuchsiaResourceDialect
7613                        );
7614                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7615                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7616                        Ok(TestDeviceRequest::GetIcdList {
7617                            responder: TestDeviceGetIcdListResponder {
7618                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7619                                tx_id: header.tx_id,
7620                            },
7621                        })
7622                    }
7623                    0x3ebcd9c409c248f1 => {
7624                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7625                        let mut req = fidl::new_empty!(
7626                            fidl::encoding::EmptyPayload,
7627                            fidl::encoding::DefaultFuchsiaResourceDialect
7628                        );
7629                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7630                        let control_handle = TestDeviceControlHandle { inner: this.inner.clone() };
7631                        Ok(TestDeviceRequest::GetUnitTestStatus {
7632                            responder: TestDeviceGetUnitTestStatusResponder {
7633                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7634                                tx_id: header.tx_id,
7635                            },
7636                        })
7637                    }
7638                    _ => Err(fidl::Error::UnknownOrdinal {
7639                        ordinal: header.ordinal,
7640                        protocol_name:
7641                            <TestDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7642                    }),
7643                }))
7644            },
7645        )
7646    }
7647}
7648
7649/// Additional device methods for the purposes of testing the MSD and should not be used by ICDs.
7650/// DEPRECATED: Please use TestDevice2.
7651#[derive(Debug)]
7652pub enum TestDeviceRequest {
7653    /// On success, returns a result either in a buffer or a simple value.
7654    Query {
7655        query_id: QueryId,
7656        responder: TestDeviceQueryResponder,
7657    },
7658    /// Creates a connection to the device comprised of two IPC channels.
7659    /// The primary channel is for the Primary protocol (see below).  The notification channel is
7660    /// used for vendor-specific messages which are sent only in the reverse (server-client)
7661    /// direction, typically in response to client command completion.
7662    Connect2 {
7663        client_id: u64,
7664        primary_channel: fidl::endpoints::ServerEnd<PrimaryMarker>,
7665        notification_channel: fidl::endpoints::ServerEnd<NotificationMarker>,
7666        control_handle: TestDeviceControlHandle,
7667    },
7668    /// Dumps driver and hardware state to the log.
7669    DumpState {
7670        dump_type: u32,
7671        control_handle: TestDeviceControlHandle,
7672    },
7673    /// Returns a list of ICDs that can be used with this Magma device. The list is sorted in
7674    /// descending order of preference.
7675    GetIcdList {
7676        responder: TestDeviceGetIcdListResponder,
7677    },
7678    GetUnitTestStatus {
7679        responder: TestDeviceGetUnitTestStatusResponder,
7680    },
7681}
7682
7683impl TestDeviceRequest {
7684    #[allow(irrefutable_let_patterns)]
7685    pub fn into_query(self) -> Option<(QueryId, TestDeviceQueryResponder)> {
7686        if let TestDeviceRequest::Query { query_id, responder } = self {
7687            Some((query_id, responder))
7688        } else {
7689            None
7690        }
7691    }
7692
7693    #[allow(irrefutable_let_patterns)]
7694    pub fn into_connect2(
7695        self,
7696    ) -> Option<(
7697        u64,
7698        fidl::endpoints::ServerEnd<PrimaryMarker>,
7699        fidl::endpoints::ServerEnd<NotificationMarker>,
7700        TestDeviceControlHandle,
7701    )> {
7702        if let TestDeviceRequest::Connect2 {
7703            client_id,
7704            primary_channel,
7705            notification_channel,
7706            control_handle,
7707        } = self
7708        {
7709            Some((client_id, primary_channel, notification_channel, control_handle))
7710        } else {
7711            None
7712        }
7713    }
7714
7715    #[allow(irrefutable_let_patterns)]
7716    pub fn into_dump_state(self) -> Option<(u32, TestDeviceControlHandle)> {
7717        if let TestDeviceRequest::DumpState { dump_type, control_handle } = self {
7718            Some((dump_type, control_handle))
7719        } else {
7720            None
7721        }
7722    }
7723
7724    #[allow(irrefutable_let_patterns)]
7725    pub fn into_get_icd_list(self) -> Option<(TestDeviceGetIcdListResponder)> {
7726        if let TestDeviceRequest::GetIcdList { responder } = self {
7727            Some((responder))
7728        } else {
7729            None
7730        }
7731    }
7732
7733    #[allow(irrefutable_let_patterns)]
7734    pub fn into_get_unit_test_status(self) -> Option<(TestDeviceGetUnitTestStatusResponder)> {
7735        if let TestDeviceRequest::GetUnitTestStatus { responder } = self {
7736            Some((responder))
7737        } else {
7738            None
7739        }
7740    }
7741
7742    /// Name of the method defined in FIDL
7743    pub fn method_name(&self) -> &'static str {
7744        match *self {
7745            TestDeviceRequest::Query { .. } => "query",
7746            TestDeviceRequest::Connect2 { .. } => "connect2",
7747            TestDeviceRequest::DumpState { .. } => "dump_state",
7748            TestDeviceRequest::GetIcdList { .. } => "get_icd_list",
7749            TestDeviceRequest::GetUnitTestStatus { .. } => "get_unit_test_status",
7750        }
7751    }
7752}
7753
7754#[derive(Debug, Clone)]
7755pub struct TestDeviceControlHandle {
7756    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7757}
7758
7759impl fidl::endpoints::ControlHandle for TestDeviceControlHandle {
7760    fn shutdown(&self) {
7761        self.inner.shutdown()
7762    }
7763
7764    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7765        self.inner.shutdown_with_epitaph(status)
7766    }
7767
7768    fn is_closed(&self) -> bool {
7769        self.inner.channel().is_closed()
7770    }
7771    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7772        self.inner.channel().on_closed()
7773    }
7774
7775    #[cfg(target_os = "fuchsia")]
7776    fn signal_peer(
7777        &self,
7778        clear_mask: zx::Signals,
7779        set_mask: zx::Signals,
7780    ) -> Result<(), zx_status::Status> {
7781        use fidl::Peered;
7782        self.inner.channel().signal_peer(clear_mask, set_mask)
7783    }
7784}
7785
7786impl TestDeviceControlHandle {}
7787
7788#[must_use = "FIDL methods require a response to be sent"]
7789#[derive(Debug)]
7790pub struct TestDeviceQueryResponder {
7791    control_handle: std::mem::ManuallyDrop<TestDeviceControlHandle>,
7792    tx_id: u32,
7793}
7794
7795/// Set the the channel to be shutdown (see [`TestDeviceControlHandle::shutdown`])
7796/// if the responder is dropped without sending a response, so that the client
7797/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7798impl std::ops::Drop for TestDeviceQueryResponder {
7799    fn drop(&mut self) {
7800        self.control_handle.shutdown();
7801        // Safety: drops once, never accessed again
7802        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7803    }
7804}
7805
7806impl fidl::endpoints::Responder for TestDeviceQueryResponder {
7807    type ControlHandle = TestDeviceControlHandle;
7808
7809    fn control_handle(&self) -> &TestDeviceControlHandle {
7810        &self.control_handle
7811    }
7812
7813    fn drop_without_shutdown(mut self) {
7814        // Safety: drops once, never accessed again due to mem::forget
7815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7816        // Prevent Drop from running (which would shut down the channel)
7817        std::mem::forget(self);
7818    }
7819}
7820
7821impl TestDeviceQueryResponder {
7822    /// Sends a response to the FIDL transaction.
7823    ///
7824    /// Sets the channel to shutdown if an error occurs.
7825    pub fn send(self, mut result: Result<DeviceQueryResponse, i32>) -> Result<(), fidl::Error> {
7826        let _result = self.send_raw(result);
7827        if _result.is_err() {
7828            self.control_handle.shutdown();
7829        }
7830        self.drop_without_shutdown();
7831        _result
7832    }
7833
7834    /// Similar to "send" but does not shutdown the channel if an error occurs.
7835    pub fn send_no_shutdown_on_err(
7836        self,
7837        mut result: Result<DeviceQueryResponse, i32>,
7838    ) -> Result<(), fidl::Error> {
7839        let _result = self.send_raw(result);
7840        self.drop_without_shutdown();
7841        _result
7842    }
7843
7844    fn send_raw(&self, mut result: Result<DeviceQueryResponse, i32>) -> Result<(), fidl::Error> {
7845        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceQueryResponse, i32>>(
7846            result.as_mut().map_err(|e| *e),
7847            self.tx_id,
7848            0x627d4c6093b078e7,
7849            fidl::encoding::DynamicFlags::empty(),
7850        )
7851    }
7852}
7853
7854#[must_use = "FIDL methods require a response to be sent"]
7855#[derive(Debug)]
7856pub struct TestDeviceGetIcdListResponder {
7857    control_handle: std::mem::ManuallyDrop<TestDeviceControlHandle>,
7858    tx_id: u32,
7859}
7860
7861/// Set the the channel to be shutdown (see [`TestDeviceControlHandle::shutdown`])
7862/// if the responder is dropped without sending a response, so that the client
7863/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7864impl std::ops::Drop for TestDeviceGetIcdListResponder {
7865    fn drop(&mut self) {
7866        self.control_handle.shutdown();
7867        // Safety: drops once, never accessed again
7868        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7869    }
7870}
7871
7872impl fidl::endpoints::Responder for TestDeviceGetIcdListResponder {
7873    type ControlHandle = TestDeviceControlHandle;
7874
7875    fn control_handle(&self) -> &TestDeviceControlHandle {
7876        &self.control_handle
7877    }
7878
7879    fn drop_without_shutdown(mut self) {
7880        // Safety: drops once, never accessed again due to mem::forget
7881        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7882        // Prevent Drop from running (which would shut down the channel)
7883        std::mem::forget(self);
7884    }
7885}
7886
7887impl TestDeviceGetIcdListResponder {
7888    /// Sends a response to the FIDL transaction.
7889    ///
7890    /// Sets the channel to shutdown if an error occurs.
7891    pub fn send(self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
7892        let _result = self.send_raw(icd_list);
7893        if _result.is_err() {
7894            self.control_handle.shutdown();
7895        }
7896        self.drop_without_shutdown();
7897        _result
7898    }
7899
7900    /// Similar to "send" but does not shutdown the channel if an error occurs.
7901    pub fn send_no_shutdown_on_err(self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
7902        let _result = self.send_raw(icd_list);
7903        self.drop_without_shutdown();
7904        _result
7905    }
7906
7907    fn send_raw(&self, mut icd_list: &[IcdInfo]) -> Result<(), fidl::Error> {
7908        self.control_handle.inner.send::<IcdLoaderDeviceGetIcdListResponse>(
7909            (icd_list,),
7910            self.tx_id,
7911            0x7673e76395008257,
7912            fidl::encoding::DynamicFlags::empty(),
7913        )
7914    }
7915}
7916
7917#[must_use = "FIDL methods require a response to be sent"]
7918#[derive(Debug)]
7919pub struct TestDeviceGetUnitTestStatusResponder {
7920    control_handle: std::mem::ManuallyDrop<TestDeviceControlHandle>,
7921    tx_id: u32,
7922}
7923
7924/// Set the the channel to be shutdown (see [`TestDeviceControlHandle::shutdown`])
7925/// if the responder is dropped without sending a response, so that the client
7926/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7927impl std::ops::Drop for TestDeviceGetUnitTestStatusResponder {
7928    fn drop(&mut self) {
7929        self.control_handle.shutdown();
7930        // Safety: drops once, never accessed again
7931        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7932    }
7933}
7934
7935impl fidl::endpoints::Responder for TestDeviceGetUnitTestStatusResponder {
7936    type ControlHandle = TestDeviceControlHandle;
7937
7938    fn control_handle(&self) -> &TestDeviceControlHandle {
7939        &self.control_handle
7940    }
7941
7942    fn drop_without_shutdown(mut self) {
7943        // Safety: drops once, never accessed again due to mem::forget
7944        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7945        // Prevent Drop from running (which would shut down the channel)
7946        std::mem::forget(self);
7947    }
7948}
7949
7950impl TestDeviceGetUnitTestStatusResponder {
7951    /// Sends a response to the FIDL transaction.
7952    ///
7953    /// Sets the channel to shutdown if an error occurs.
7954    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
7955        let _result = self.send_raw(status);
7956        if _result.is_err() {
7957            self.control_handle.shutdown();
7958        }
7959        self.drop_without_shutdown();
7960        _result
7961    }
7962
7963    /// Similar to "send" but does not shutdown the channel if an error occurs.
7964    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
7965        let _result = self.send_raw(status);
7966        self.drop_without_shutdown();
7967        _result
7968    }
7969
7970    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
7971        self.control_handle.inner.send::<TestDeviceGetUnitTestStatusResponse>(
7972            (status,),
7973            self.tx_id,
7974            0x3ebcd9c409c248f1,
7975            fidl::encoding::DynamicFlags::empty(),
7976        )
7977    }
7978}
7979
7980#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7981pub struct TestDevice2Marker;
7982
7983impl fidl::endpoints::ProtocolMarker for TestDevice2Marker {
7984    type Proxy = TestDevice2Proxy;
7985    type RequestStream = TestDevice2RequestStream;
7986    #[cfg(target_os = "fuchsia")]
7987    type SynchronousProxy = TestDevice2SynchronousProxy;
7988
7989    const DEBUG_NAME: &'static str = "(anonymous) TestDevice2";
7990}
7991
7992pub trait TestDevice2ProxyInterface: Send + Sync {
7993    type GetUnitTestStatusResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
7994    fn r#get_unit_test_status(&self) -> Self::GetUnitTestStatusResponseFut;
7995}
7996#[derive(Debug)]
7997#[cfg(target_os = "fuchsia")]
7998pub struct TestDevice2SynchronousProxy {
7999    client: fidl::client::sync::Client,
8000}
8001
8002#[cfg(target_os = "fuchsia")]
8003impl fidl::endpoints::SynchronousProxy for TestDevice2SynchronousProxy {
8004    type Proxy = TestDevice2Proxy;
8005    type Protocol = TestDevice2Marker;
8006
8007    fn from_channel(inner: fidl::Channel) -> Self {
8008        Self::new(inner)
8009    }
8010
8011    fn into_channel(self) -> fidl::Channel {
8012        self.client.into_channel()
8013    }
8014
8015    fn as_channel(&self) -> &fidl::Channel {
8016        self.client.as_channel()
8017    }
8018}
8019
8020#[cfg(target_os = "fuchsia")]
8021impl TestDevice2SynchronousProxy {
8022    pub fn new(channel: fidl::Channel) -> Self {
8023        let protocol_name = <TestDevice2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8024        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
8025    }
8026
8027    pub fn into_channel(self) -> fidl::Channel {
8028        self.client.into_channel()
8029    }
8030
8031    /// Waits until an event arrives and returns it. It is safe for other
8032    /// threads to make concurrent requests while waiting for an event.
8033    pub fn wait_for_event(
8034        &self,
8035        deadline: zx::MonotonicInstant,
8036    ) -> Result<TestDevice2Event, fidl::Error> {
8037        TestDevice2Event::decode(self.client.wait_for_event(deadline)?)
8038    }
8039
8040    pub fn r#get_unit_test_status(
8041        &self,
8042        ___deadline: zx::MonotonicInstant,
8043    ) -> Result<i32, fidl::Error> {
8044        let _response = self
8045            .client
8046            .send_query::<fidl::encoding::EmptyPayload, TestDevice2GetUnitTestStatusResponse>(
8047                (),
8048                0x5be45b0f097813b2,
8049                fidl::encoding::DynamicFlags::empty(),
8050                ___deadline,
8051            )?;
8052        Ok(_response.status)
8053    }
8054}
8055
8056#[cfg(target_os = "fuchsia")]
8057impl From<TestDevice2SynchronousProxy> for zx::NullableHandle {
8058    fn from(value: TestDevice2SynchronousProxy) -> Self {
8059        value.into_channel().into()
8060    }
8061}
8062
8063#[cfg(target_os = "fuchsia")]
8064impl From<fidl::Channel> for TestDevice2SynchronousProxy {
8065    fn from(value: fidl::Channel) -> Self {
8066        Self::new(value)
8067    }
8068}
8069
8070#[cfg(target_os = "fuchsia")]
8071impl fidl::endpoints::FromClient for TestDevice2SynchronousProxy {
8072    type Protocol = TestDevice2Marker;
8073
8074    fn from_client(value: fidl::endpoints::ClientEnd<TestDevice2Marker>) -> Self {
8075        Self::new(value.into_channel())
8076    }
8077}
8078
8079#[derive(Debug, Clone)]
8080pub struct TestDevice2Proxy {
8081    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8082}
8083
8084impl fidl::endpoints::Proxy for TestDevice2Proxy {
8085    type Protocol = TestDevice2Marker;
8086
8087    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8088        Self::new(inner)
8089    }
8090
8091    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8092        self.client.into_channel().map_err(|client| Self { client })
8093    }
8094
8095    fn as_channel(&self) -> &::fidl::AsyncChannel {
8096        self.client.as_channel()
8097    }
8098}
8099
8100impl TestDevice2Proxy {
8101    /// Create a new Proxy for fuchsia.gpu.magma/TestDevice2.
8102    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8103        let protocol_name = <TestDevice2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8104        Self { client: fidl::client::Client::new(channel, protocol_name) }
8105    }
8106
8107    /// Get a Stream of events from the remote end of the protocol.
8108    ///
8109    /// # Panics
8110    ///
8111    /// Panics if the event stream was already taken.
8112    pub fn take_event_stream(&self) -> TestDevice2EventStream {
8113        TestDevice2EventStream { event_receiver: self.client.take_event_receiver() }
8114    }
8115
8116    pub fn r#get_unit_test_status(
8117        &self,
8118    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
8119        TestDevice2ProxyInterface::r#get_unit_test_status(self)
8120    }
8121}
8122
8123impl TestDevice2ProxyInterface for TestDevice2Proxy {
8124    type GetUnitTestStatusResponseFut =
8125        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
8126    fn r#get_unit_test_status(&self) -> Self::GetUnitTestStatusResponseFut {
8127        fn _decode(
8128            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8129        ) -> Result<i32, fidl::Error> {
8130            let _response = fidl::client::decode_transaction_body::<
8131                TestDevice2GetUnitTestStatusResponse,
8132                fidl::encoding::DefaultFuchsiaResourceDialect,
8133                0x5be45b0f097813b2,
8134            >(_buf?)?;
8135            Ok(_response.status)
8136        }
8137        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
8138            (),
8139            0x5be45b0f097813b2,
8140            fidl::encoding::DynamicFlags::empty(),
8141            _decode,
8142        )
8143    }
8144}
8145
8146pub struct TestDevice2EventStream {
8147    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
8148}
8149
8150impl std::marker::Unpin for TestDevice2EventStream {}
8151
8152impl futures::stream::FusedStream for TestDevice2EventStream {
8153    fn is_terminated(&self) -> bool {
8154        self.event_receiver.is_terminated()
8155    }
8156}
8157
8158impl futures::Stream for TestDevice2EventStream {
8159    type Item = Result<TestDevice2Event, fidl::Error>;
8160
8161    fn poll_next(
8162        mut self: std::pin::Pin<&mut Self>,
8163        cx: &mut std::task::Context<'_>,
8164    ) -> std::task::Poll<Option<Self::Item>> {
8165        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8166            &mut self.event_receiver,
8167            cx
8168        )?) {
8169            Some(buf) => std::task::Poll::Ready(Some(TestDevice2Event::decode(buf))),
8170            None => std::task::Poll::Ready(None),
8171        }
8172    }
8173}
8174
8175#[derive(Debug)]
8176pub enum TestDevice2Event {}
8177
8178impl TestDevice2Event {
8179    /// Decodes a message buffer as a [`TestDevice2Event`].
8180    fn decode(
8181        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8182    ) -> Result<TestDevice2Event, fidl::Error> {
8183        let (bytes, _handles) = buf.split_mut();
8184        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8185        debug_assert_eq!(tx_header.tx_id, 0);
8186        match tx_header.ordinal {
8187            _ => Err(fidl::Error::UnknownOrdinal {
8188                ordinal: tx_header.ordinal,
8189                protocol_name: <TestDevice2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8190            }),
8191        }
8192    }
8193}
8194
8195/// A Stream of incoming requests for fuchsia.gpu.magma/TestDevice2.
8196pub struct TestDevice2RequestStream {
8197    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8198    is_terminated: bool,
8199}
8200
8201impl std::marker::Unpin for TestDevice2RequestStream {}
8202
8203impl futures::stream::FusedStream for TestDevice2RequestStream {
8204    fn is_terminated(&self) -> bool {
8205        self.is_terminated
8206    }
8207}
8208
8209impl fidl::endpoints::RequestStream for TestDevice2RequestStream {
8210    type Protocol = TestDevice2Marker;
8211    type ControlHandle = TestDevice2ControlHandle;
8212
8213    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
8214        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8215    }
8216
8217    fn control_handle(&self) -> Self::ControlHandle {
8218        TestDevice2ControlHandle { inner: self.inner.clone() }
8219    }
8220
8221    fn into_inner(
8222        self,
8223    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
8224    {
8225        (self.inner, self.is_terminated)
8226    }
8227
8228    fn from_inner(
8229        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8230        is_terminated: bool,
8231    ) -> Self {
8232        Self { inner, is_terminated }
8233    }
8234}
8235
8236impl futures::Stream for TestDevice2RequestStream {
8237    type Item = Result<TestDevice2Request, fidl::Error>;
8238
8239    fn poll_next(
8240        mut self: std::pin::Pin<&mut Self>,
8241        cx: &mut std::task::Context<'_>,
8242    ) -> std::task::Poll<Option<Self::Item>> {
8243        let this = &mut *self;
8244        if this.inner.check_shutdown(cx) {
8245            this.is_terminated = true;
8246            return std::task::Poll::Ready(None);
8247        }
8248        if this.is_terminated {
8249            panic!("polled TestDevice2RequestStream after completion");
8250        }
8251        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
8252            |bytes, handles| {
8253                match this.inner.channel().read_etc(cx, bytes, handles) {
8254                    std::task::Poll::Ready(Ok(())) => {}
8255                    std::task::Poll::Pending => return std::task::Poll::Pending,
8256                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
8257                        this.is_terminated = true;
8258                        return std::task::Poll::Ready(None);
8259                    }
8260                    std::task::Poll::Ready(Err(e)) => {
8261                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8262                            e.into(),
8263                        ))));
8264                    }
8265                }
8266
8267                // A message has been received from the channel
8268                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8269
8270                std::task::Poll::Ready(Some(match header.ordinal {
8271                    0x5be45b0f097813b2 => {
8272                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8273                        let mut req = fidl::new_empty!(
8274                            fidl::encoding::EmptyPayload,
8275                            fidl::encoding::DefaultFuchsiaResourceDialect
8276                        );
8277                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8278                        let control_handle = TestDevice2ControlHandle { inner: this.inner.clone() };
8279                        Ok(TestDevice2Request::GetUnitTestStatus {
8280                            responder: TestDevice2GetUnitTestStatusResponder {
8281                                control_handle: std::mem::ManuallyDrop::new(control_handle),
8282                                tx_id: header.tx_id,
8283                            },
8284                        })
8285                    }
8286                    _ => Err(fidl::Error::UnknownOrdinal {
8287                        ordinal: header.ordinal,
8288                        protocol_name:
8289                            <TestDevice2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
8290                    }),
8291                }))
8292            },
8293        )
8294    }
8295}
8296
8297/// Additional methods for reporting tests run in the MSD.
8298#[derive(Debug)]
8299pub enum TestDevice2Request {
8300    GetUnitTestStatus { responder: TestDevice2GetUnitTestStatusResponder },
8301}
8302
8303impl TestDevice2Request {
8304    #[allow(irrefutable_let_patterns)]
8305    pub fn into_get_unit_test_status(self) -> Option<(TestDevice2GetUnitTestStatusResponder)> {
8306        if let TestDevice2Request::GetUnitTestStatus { responder } = self {
8307            Some((responder))
8308        } else {
8309            None
8310        }
8311    }
8312
8313    /// Name of the method defined in FIDL
8314    pub fn method_name(&self) -> &'static str {
8315        match *self {
8316            TestDevice2Request::GetUnitTestStatus { .. } => "get_unit_test_status",
8317        }
8318    }
8319}
8320
8321#[derive(Debug, Clone)]
8322pub struct TestDevice2ControlHandle {
8323    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
8324}
8325
8326impl fidl::endpoints::ControlHandle for TestDevice2ControlHandle {
8327    fn shutdown(&self) {
8328        self.inner.shutdown()
8329    }
8330
8331    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8332        self.inner.shutdown_with_epitaph(status)
8333    }
8334
8335    fn is_closed(&self) -> bool {
8336        self.inner.channel().is_closed()
8337    }
8338    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
8339        self.inner.channel().on_closed()
8340    }
8341
8342    #[cfg(target_os = "fuchsia")]
8343    fn signal_peer(
8344        &self,
8345        clear_mask: zx::Signals,
8346        set_mask: zx::Signals,
8347    ) -> Result<(), zx_status::Status> {
8348        use fidl::Peered;
8349        self.inner.channel().signal_peer(clear_mask, set_mask)
8350    }
8351}
8352
8353impl TestDevice2ControlHandle {}
8354
8355#[must_use = "FIDL methods require a response to be sent"]
8356#[derive(Debug)]
8357pub struct TestDevice2GetUnitTestStatusResponder {
8358    control_handle: std::mem::ManuallyDrop<TestDevice2ControlHandle>,
8359    tx_id: u32,
8360}
8361
8362/// Set the the channel to be shutdown (see [`TestDevice2ControlHandle::shutdown`])
8363/// if the responder is dropped without sending a response, so that the client
8364/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8365impl std::ops::Drop for TestDevice2GetUnitTestStatusResponder {
8366    fn drop(&mut self) {
8367        self.control_handle.shutdown();
8368        // Safety: drops once, never accessed again
8369        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8370    }
8371}
8372
8373impl fidl::endpoints::Responder for TestDevice2GetUnitTestStatusResponder {
8374    type ControlHandle = TestDevice2ControlHandle;
8375
8376    fn control_handle(&self) -> &TestDevice2ControlHandle {
8377        &self.control_handle
8378    }
8379
8380    fn drop_without_shutdown(mut self) {
8381        // Safety: drops once, never accessed again due to mem::forget
8382        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8383        // Prevent Drop from running (which would shut down the channel)
8384        std::mem::forget(self);
8385    }
8386}
8387
8388impl TestDevice2GetUnitTestStatusResponder {
8389    /// Sends a response to the FIDL transaction.
8390    ///
8391    /// Sets the channel to shutdown if an error occurs.
8392    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
8393        let _result = self.send_raw(status);
8394        if _result.is_err() {
8395            self.control_handle.shutdown();
8396        }
8397        self.drop_without_shutdown();
8398        _result
8399    }
8400
8401    /// Similar to "send" but does not shutdown the channel if an error occurs.
8402    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
8403        let _result = self.send_raw(status);
8404        self.drop_without_shutdown();
8405        _result
8406    }
8407
8408    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
8409        self.control_handle.inner.send::<TestDevice2GetUnitTestStatusResponse>(
8410            (status,),
8411            self.tx_id,
8412            0x5be45b0f097813b2,
8413            fidl::encoding::DynamicFlags::empty(),
8414        )
8415    }
8416}
8417
8418#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8419pub struct DependencyInjectionServiceMarker;
8420
8421#[cfg(target_os = "fuchsia")]
8422impl fidl::endpoints::ServiceMarker for DependencyInjectionServiceMarker {
8423    type Proxy = DependencyInjectionServiceProxy;
8424    type Request = DependencyInjectionServiceRequest;
8425    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.DependencyInjectionService";
8426}
8427
8428/// A request for one of the member protocols of DependencyInjectionService.
8429///
8430#[cfg(target_os = "fuchsia")]
8431pub enum DependencyInjectionServiceRequest {
8432    Device(DependencyInjectionRequestStream),
8433}
8434
8435#[cfg(target_os = "fuchsia")]
8436impl fidl::endpoints::ServiceRequest for DependencyInjectionServiceRequest {
8437    type Service = DependencyInjectionServiceMarker;
8438
8439    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8440        match name {
8441            "device" => Self::Device(
8442                <DependencyInjectionRequestStream as fidl::endpoints::RequestStream>::from_channel(
8443                    _channel,
8444                ),
8445            ),
8446            _ => panic!("no such member protocol name for service DependencyInjectionService"),
8447        }
8448    }
8449
8450    fn member_names() -> &'static [&'static str] {
8451        &["device"]
8452    }
8453}
8454#[cfg(target_os = "fuchsia")]
8455pub struct DependencyInjectionServiceProxy(
8456    #[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>,
8457);
8458
8459#[cfg(target_os = "fuchsia")]
8460impl fidl::endpoints::ServiceProxy for DependencyInjectionServiceProxy {
8461    type Service = DependencyInjectionServiceMarker;
8462
8463    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8464        Self(opener)
8465    }
8466}
8467
8468#[cfg(target_os = "fuchsia")]
8469impl DependencyInjectionServiceProxy {
8470    pub fn connect_to_device(&self) -> Result<DependencyInjectionProxy, fidl::Error> {
8471        let (proxy, server_end) = fidl::endpoints::create_proxy::<DependencyInjectionMarker>();
8472        self.connect_channel_to_device(server_end)?;
8473        Ok(proxy)
8474    }
8475
8476    /// Like `connect_to_device`, but returns a sync proxy.
8477    /// See [`Self::connect_to_device`] for more details.
8478    pub fn connect_to_device_sync(
8479        &self,
8480    ) -> Result<DependencyInjectionSynchronousProxy, fidl::Error> {
8481        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DependencyInjectionMarker>();
8482        self.connect_channel_to_device(server_end)?;
8483        Ok(proxy)
8484    }
8485
8486    /// Like `connect_to_device`, but accepts a server end.
8487    /// See [`Self::connect_to_device`] for more details.
8488    pub fn connect_channel_to_device(
8489        &self,
8490        server_end: fidl::endpoints::ServerEnd<DependencyInjectionMarker>,
8491    ) -> Result<(), fidl::Error> {
8492        self.0.open_member("device", server_end.into_channel())
8493    }
8494
8495    pub fn instance_name(&self) -> &str {
8496        self.0.instance_name()
8497    }
8498}
8499
8500#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8501pub struct PerformanceCounterServiceMarker;
8502
8503#[cfg(target_os = "fuchsia")]
8504impl fidl::endpoints::ServiceMarker for PerformanceCounterServiceMarker {
8505    type Proxy = PerformanceCounterServiceProxy;
8506    type Request = PerformanceCounterServiceRequest;
8507    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.PerformanceCounterService";
8508}
8509
8510/// A request for one of the member protocols of PerformanceCounterService.
8511///
8512#[cfg(target_os = "fuchsia")]
8513pub enum PerformanceCounterServiceRequest {
8514    Access(PerformanceCounterAccessRequestStream),
8515}
8516
8517#[cfg(target_os = "fuchsia")]
8518impl fidl::endpoints::ServiceRequest for PerformanceCounterServiceRequest {
8519    type Service = PerformanceCounterServiceMarker;
8520
8521    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8522        match name {
8523            "access" => Self::Access(
8524                <PerformanceCounterAccessRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
8525            ),
8526            _ => panic!("no such member protocol name for service PerformanceCounterService"),
8527        }
8528    }
8529
8530    fn member_names() -> &'static [&'static str] {
8531        &["access"]
8532    }
8533}
8534#[cfg(target_os = "fuchsia")]
8535pub struct PerformanceCounterServiceProxy(
8536    #[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>,
8537);
8538
8539#[cfg(target_os = "fuchsia")]
8540impl fidl::endpoints::ServiceProxy for PerformanceCounterServiceProxy {
8541    type Service = PerformanceCounterServiceMarker;
8542
8543    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8544        Self(opener)
8545    }
8546}
8547
8548#[cfg(target_os = "fuchsia")]
8549impl PerformanceCounterServiceProxy {
8550    pub fn connect_to_access(&self) -> Result<PerformanceCounterAccessProxy, fidl::Error> {
8551        let (proxy, server_end) = fidl::endpoints::create_proxy::<PerformanceCounterAccessMarker>();
8552        self.connect_channel_to_access(server_end)?;
8553        Ok(proxy)
8554    }
8555
8556    /// Like `connect_to_access`, but returns a sync proxy.
8557    /// See [`Self::connect_to_access`] for more details.
8558    pub fn connect_to_access_sync(
8559        &self,
8560    ) -> Result<PerformanceCounterAccessSynchronousProxy, fidl::Error> {
8561        let (proxy, server_end) =
8562            fidl::endpoints::create_sync_proxy::<PerformanceCounterAccessMarker>();
8563        self.connect_channel_to_access(server_end)?;
8564        Ok(proxy)
8565    }
8566
8567    /// Like `connect_to_access`, but accepts a server end.
8568    /// See [`Self::connect_to_access`] for more details.
8569    pub fn connect_channel_to_access(
8570        &self,
8571        server_end: fidl::endpoints::ServerEnd<PerformanceCounterAccessMarker>,
8572    ) -> Result<(), fidl::Error> {
8573        self.0.open_member("access", server_end.into_channel())
8574    }
8575
8576    pub fn instance_name(&self) -> &str {
8577        self.0.instance_name()
8578    }
8579}
8580
8581#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8582pub struct ServiceMarker;
8583
8584#[cfg(target_os = "fuchsia")]
8585impl fidl::endpoints::ServiceMarker for ServiceMarker {
8586    type Proxy = ServiceProxy;
8587    type Request = ServiceRequest;
8588    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.Service";
8589}
8590
8591/// A request for one of the member protocols of Service.
8592///
8593#[cfg(target_os = "fuchsia")]
8594pub enum ServiceRequest {
8595    Device(CombinedDeviceRequestStream),
8596    PowerElementProvider(PowerElementProviderRequestStream),
8597}
8598
8599#[cfg(target_os = "fuchsia")]
8600impl fidl::endpoints::ServiceRequest for ServiceRequest {
8601    type Service = ServiceMarker;
8602
8603    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8604        match name {
8605            "device" => Self::Device(
8606                <CombinedDeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(
8607                    _channel,
8608                ),
8609            ),
8610            "power_element_provider" => Self::PowerElementProvider(
8611                <PowerElementProviderRequestStream as fidl::endpoints::RequestStream>::from_channel(
8612                    _channel,
8613                ),
8614            ),
8615            _ => panic!("no such member protocol name for service Service"),
8616        }
8617    }
8618
8619    fn member_names() -> &'static [&'static str] {
8620        &["device", "power_element_provider"]
8621    }
8622}
8623#[cfg(target_os = "fuchsia")]
8624pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8625
8626#[cfg(target_os = "fuchsia")]
8627impl fidl::endpoints::ServiceProxy for ServiceProxy {
8628    type Service = ServiceMarker;
8629
8630    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8631        Self(opener)
8632    }
8633}
8634
8635#[cfg(target_os = "fuchsia")]
8636impl ServiceProxy {
8637    pub fn connect_to_device(&self) -> Result<CombinedDeviceProxy, fidl::Error> {
8638        let (proxy, server_end) = fidl::endpoints::create_proxy::<CombinedDeviceMarker>();
8639        self.connect_channel_to_device(server_end)?;
8640        Ok(proxy)
8641    }
8642
8643    /// Like `connect_to_device`, but returns a sync proxy.
8644    /// See [`Self::connect_to_device`] for more details.
8645    pub fn connect_to_device_sync(&self) -> Result<CombinedDeviceSynchronousProxy, fidl::Error> {
8646        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<CombinedDeviceMarker>();
8647        self.connect_channel_to_device(server_end)?;
8648        Ok(proxy)
8649    }
8650
8651    /// Like `connect_to_device`, but accepts a server end.
8652    /// See [`Self::connect_to_device`] for more details.
8653    pub fn connect_channel_to_device(
8654        &self,
8655        server_end: fidl::endpoints::ServerEnd<CombinedDeviceMarker>,
8656    ) -> Result<(), fidl::Error> {
8657        self.0.open_member("device", server_end.into_channel())
8658    }
8659    pub fn connect_to_power_element_provider(
8660        &self,
8661    ) -> Result<PowerElementProviderProxy, fidl::Error> {
8662        let (proxy, server_end) = fidl::endpoints::create_proxy::<PowerElementProviderMarker>();
8663        self.connect_channel_to_power_element_provider(server_end)?;
8664        Ok(proxy)
8665    }
8666
8667    /// Like `connect_to_power_element_provider`, but returns a sync proxy.
8668    /// See [`Self::connect_to_power_element_provider`] for more details.
8669    pub fn connect_to_power_element_provider_sync(
8670        &self,
8671    ) -> Result<PowerElementProviderSynchronousProxy, fidl::Error> {
8672        let (proxy, server_end) =
8673            fidl::endpoints::create_sync_proxy::<PowerElementProviderMarker>();
8674        self.connect_channel_to_power_element_provider(server_end)?;
8675        Ok(proxy)
8676    }
8677
8678    /// Like `connect_to_power_element_provider`, but accepts a server end.
8679    /// See [`Self::connect_to_power_element_provider`] for more details.
8680    pub fn connect_channel_to_power_element_provider(
8681        &self,
8682        server_end: fidl::endpoints::ServerEnd<PowerElementProviderMarker>,
8683    ) -> Result<(), fidl::Error> {
8684        self.0.open_member("power_element_provider", server_end.into_channel())
8685    }
8686
8687    pub fn instance_name(&self) -> &str {
8688        self.0.instance_name()
8689    }
8690}
8691
8692#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8693pub struct TestServiceMarker;
8694
8695#[cfg(target_os = "fuchsia")]
8696impl fidl::endpoints::ServiceMarker for TestServiceMarker {
8697    type Proxy = TestServiceProxy;
8698    type Request = TestServiceRequest;
8699    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.TestService";
8700}
8701
8702/// A request for one of the member protocols of TestService.
8703///
8704/// This service is only exposed by test MSDs. This should not be used by an ICD.
8705#[cfg(target_os = "fuchsia")]
8706pub enum TestServiceRequest {
8707    Device(CombinedDeviceRequestStream),
8708    PowerElementProvider(PowerElementProviderRequestStream),
8709    TestDevice(TestDevice2RequestStream),
8710}
8711
8712#[cfg(target_os = "fuchsia")]
8713impl fidl::endpoints::ServiceRequest for TestServiceRequest {
8714    type Service = TestServiceMarker;
8715
8716    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8717        match name {
8718            "device" => Self::Device(
8719                <CombinedDeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(
8720                    _channel,
8721                ),
8722            ),
8723            "power_element_provider" => Self::PowerElementProvider(
8724                <PowerElementProviderRequestStream as fidl::endpoints::RequestStream>::from_channel(
8725                    _channel,
8726                ),
8727            ),
8728            "test_device" => Self::TestDevice(
8729                <TestDevice2RequestStream as fidl::endpoints::RequestStream>::from_channel(
8730                    _channel,
8731                ),
8732            ),
8733            _ => panic!("no such member protocol name for service TestService"),
8734        }
8735    }
8736
8737    fn member_names() -> &'static [&'static str] {
8738        &["device", "power_element_provider", "test_device"]
8739    }
8740}
8741/// This service is only exposed by test MSDs. This should not be used by an ICD.
8742#[cfg(target_os = "fuchsia")]
8743pub struct TestServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8744
8745#[cfg(target_os = "fuchsia")]
8746impl fidl::endpoints::ServiceProxy for TestServiceProxy {
8747    type Service = TestServiceMarker;
8748
8749    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8750        Self(opener)
8751    }
8752}
8753
8754#[cfg(target_os = "fuchsia")]
8755impl TestServiceProxy {
8756    pub fn connect_to_device(&self) -> Result<CombinedDeviceProxy, fidl::Error> {
8757        let (proxy, server_end) = fidl::endpoints::create_proxy::<CombinedDeviceMarker>();
8758        self.connect_channel_to_device(server_end)?;
8759        Ok(proxy)
8760    }
8761
8762    /// Like `connect_to_device`, but returns a sync proxy.
8763    /// See [`Self::connect_to_device`] for more details.
8764    pub fn connect_to_device_sync(&self) -> Result<CombinedDeviceSynchronousProxy, fidl::Error> {
8765        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<CombinedDeviceMarker>();
8766        self.connect_channel_to_device(server_end)?;
8767        Ok(proxy)
8768    }
8769
8770    /// Like `connect_to_device`, but accepts a server end.
8771    /// See [`Self::connect_to_device`] for more details.
8772    pub fn connect_channel_to_device(
8773        &self,
8774        server_end: fidl::endpoints::ServerEnd<CombinedDeviceMarker>,
8775    ) -> Result<(), fidl::Error> {
8776        self.0.open_member("device", server_end.into_channel())
8777    }
8778    pub fn connect_to_power_element_provider(
8779        &self,
8780    ) -> Result<PowerElementProviderProxy, fidl::Error> {
8781        let (proxy, server_end) = fidl::endpoints::create_proxy::<PowerElementProviderMarker>();
8782        self.connect_channel_to_power_element_provider(server_end)?;
8783        Ok(proxy)
8784    }
8785
8786    /// Like `connect_to_power_element_provider`, but returns a sync proxy.
8787    /// See [`Self::connect_to_power_element_provider`] for more details.
8788    pub fn connect_to_power_element_provider_sync(
8789        &self,
8790    ) -> Result<PowerElementProviderSynchronousProxy, fidl::Error> {
8791        let (proxy, server_end) =
8792            fidl::endpoints::create_sync_proxy::<PowerElementProviderMarker>();
8793        self.connect_channel_to_power_element_provider(server_end)?;
8794        Ok(proxy)
8795    }
8796
8797    /// Like `connect_to_power_element_provider`, but accepts a server end.
8798    /// See [`Self::connect_to_power_element_provider`] for more details.
8799    pub fn connect_channel_to_power_element_provider(
8800        &self,
8801        server_end: fidl::endpoints::ServerEnd<PowerElementProviderMarker>,
8802    ) -> Result<(), fidl::Error> {
8803        self.0.open_member("power_element_provider", server_end.into_channel())
8804    }
8805    pub fn connect_to_test_device(&self) -> Result<TestDevice2Proxy, fidl::Error> {
8806        let (proxy, server_end) = fidl::endpoints::create_proxy::<TestDevice2Marker>();
8807        self.connect_channel_to_test_device(server_end)?;
8808        Ok(proxy)
8809    }
8810
8811    /// Like `connect_to_test_device`, but returns a sync proxy.
8812    /// See [`Self::connect_to_test_device`] for more details.
8813    pub fn connect_to_test_device_sync(&self) -> Result<TestDevice2SynchronousProxy, fidl::Error> {
8814        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<TestDevice2Marker>();
8815        self.connect_channel_to_test_device(server_end)?;
8816        Ok(proxy)
8817    }
8818
8819    /// Like `connect_to_test_device`, but accepts a server end.
8820    /// See [`Self::connect_to_test_device`] for more details.
8821    pub fn connect_channel_to_test_device(
8822        &self,
8823        server_end: fidl::endpoints::ServerEnd<TestDevice2Marker>,
8824    ) -> Result<(), fidl::Error> {
8825        self.0.open_member("test_device", server_end.into_channel())
8826    }
8827
8828    pub fn instance_name(&self) -> &str {
8829        self.0.instance_name()
8830    }
8831}
8832
8833#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8834pub struct TrustedServiceMarker;
8835
8836#[cfg(target_os = "fuchsia")]
8837impl fidl::endpoints::ServiceMarker for TrustedServiceMarker {
8838    type Proxy = TrustedServiceProxy;
8839    type Request = TrustedServiceRequest;
8840    const SERVICE_NAME: &'static str = "fuchsia.gpu.magma.TrustedService";
8841}
8842
8843/// A request for one of the member protocols of TrustedService.
8844///
8845/// This service has additional abilities above the normal service.
8846#[cfg(target_os = "fuchsia")]
8847pub enum TrustedServiceRequest {
8848    Device(CombinedDeviceRequestStream),
8849    PowerElementProvider(PowerElementProviderRequestStream),
8850    DebugUtils(DebugUtilsRequestStream),
8851}
8852
8853#[cfg(target_os = "fuchsia")]
8854impl fidl::endpoints::ServiceRequest for TrustedServiceRequest {
8855    type Service = TrustedServiceMarker;
8856
8857    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
8858        match name {
8859            "device" => Self::Device(
8860                <CombinedDeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(
8861                    _channel,
8862                ),
8863            ),
8864            "power_element_provider" => Self::PowerElementProvider(
8865                <PowerElementProviderRequestStream as fidl::endpoints::RequestStream>::from_channel(
8866                    _channel,
8867                ),
8868            ),
8869            "debug_utils" => Self::DebugUtils(
8870                <DebugUtilsRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
8871            ),
8872            _ => panic!("no such member protocol name for service TrustedService"),
8873        }
8874    }
8875
8876    fn member_names() -> &'static [&'static str] {
8877        &["device", "power_element_provider", "debug_utils"]
8878    }
8879}
8880/// This service has additional abilities above the normal service.
8881#[cfg(target_os = "fuchsia")]
8882pub struct TrustedServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
8883
8884#[cfg(target_os = "fuchsia")]
8885impl fidl::endpoints::ServiceProxy for TrustedServiceProxy {
8886    type Service = TrustedServiceMarker;
8887
8888    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
8889        Self(opener)
8890    }
8891}
8892
8893#[cfg(target_os = "fuchsia")]
8894impl TrustedServiceProxy {
8895    pub fn connect_to_device(&self) -> Result<CombinedDeviceProxy, fidl::Error> {
8896        let (proxy, server_end) = fidl::endpoints::create_proxy::<CombinedDeviceMarker>();
8897        self.connect_channel_to_device(server_end)?;
8898        Ok(proxy)
8899    }
8900
8901    /// Like `connect_to_device`, but returns a sync proxy.
8902    /// See [`Self::connect_to_device`] for more details.
8903    pub fn connect_to_device_sync(&self) -> Result<CombinedDeviceSynchronousProxy, fidl::Error> {
8904        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<CombinedDeviceMarker>();
8905        self.connect_channel_to_device(server_end)?;
8906        Ok(proxy)
8907    }
8908
8909    /// Like `connect_to_device`, but accepts a server end.
8910    /// See [`Self::connect_to_device`] for more details.
8911    pub fn connect_channel_to_device(
8912        &self,
8913        server_end: fidl::endpoints::ServerEnd<CombinedDeviceMarker>,
8914    ) -> Result<(), fidl::Error> {
8915        self.0.open_member("device", server_end.into_channel())
8916    }
8917    pub fn connect_to_power_element_provider(
8918        &self,
8919    ) -> Result<PowerElementProviderProxy, fidl::Error> {
8920        let (proxy, server_end) = fidl::endpoints::create_proxy::<PowerElementProviderMarker>();
8921        self.connect_channel_to_power_element_provider(server_end)?;
8922        Ok(proxy)
8923    }
8924
8925    /// Like `connect_to_power_element_provider`, but returns a sync proxy.
8926    /// See [`Self::connect_to_power_element_provider`] for more details.
8927    pub fn connect_to_power_element_provider_sync(
8928        &self,
8929    ) -> Result<PowerElementProviderSynchronousProxy, fidl::Error> {
8930        let (proxy, server_end) =
8931            fidl::endpoints::create_sync_proxy::<PowerElementProviderMarker>();
8932        self.connect_channel_to_power_element_provider(server_end)?;
8933        Ok(proxy)
8934    }
8935
8936    /// Like `connect_to_power_element_provider`, but accepts a server end.
8937    /// See [`Self::connect_to_power_element_provider`] for more details.
8938    pub fn connect_channel_to_power_element_provider(
8939        &self,
8940        server_end: fidl::endpoints::ServerEnd<PowerElementProviderMarker>,
8941    ) -> Result<(), fidl::Error> {
8942        self.0.open_member("power_element_provider", server_end.into_channel())
8943    }
8944    pub fn connect_to_debug_utils(&self) -> Result<DebugUtilsProxy, fidl::Error> {
8945        let (proxy, server_end) = fidl::endpoints::create_proxy::<DebugUtilsMarker>();
8946        self.connect_channel_to_debug_utils(server_end)?;
8947        Ok(proxy)
8948    }
8949
8950    /// Like `connect_to_debug_utils`, but returns a sync proxy.
8951    /// See [`Self::connect_to_debug_utils`] for more details.
8952    pub fn connect_to_debug_utils_sync(&self) -> Result<DebugUtilsSynchronousProxy, fidl::Error> {
8953        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DebugUtilsMarker>();
8954        self.connect_channel_to_debug_utils(server_end)?;
8955        Ok(proxy)
8956    }
8957
8958    /// Like `connect_to_debug_utils`, but accepts a server end.
8959    /// See [`Self::connect_to_debug_utils`] for more details.
8960    pub fn connect_channel_to_debug_utils(
8961        &self,
8962        server_end: fidl::endpoints::ServerEnd<DebugUtilsMarker>,
8963    ) -> Result<(), fidl::Error> {
8964        self.0.open_member("debug_utils", server_end.into_channel())
8965    }
8966
8967    pub fn instance_name(&self) -> &str {
8968        self.0.instance_name()
8969    }
8970}
8971
8972mod internal {
8973    use super::*;
8974
8975    impl fidl::encoding::ResourceTypeMarker for DependencyInjectionSetMemoryPressureProviderRequest {
8976        type Borrowed<'a> = &'a mut Self;
8977        fn take_or_borrow<'a>(
8978            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8979        ) -> Self::Borrowed<'a> {
8980            value
8981        }
8982    }
8983
8984    unsafe impl fidl::encoding::TypeMarker for DependencyInjectionSetMemoryPressureProviderRequest {
8985        type Owned = Self;
8986
8987        #[inline(always)]
8988        fn inline_align(_context: fidl::encoding::Context) -> usize {
8989            4
8990        }
8991
8992        #[inline(always)]
8993        fn inline_size(_context: fidl::encoding::Context) -> usize {
8994            4
8995        }
8996    }
8997
8998    unsafe impl
8999        fidl::encoding::Encode<
9000            DependencyInjectionSetMemoryPressureProviderRequest,
9001            fidl::encoding::DefaultFuchsiaResourceDialect,
9002        > for &mut DependencyInjectionSetMemoryPressureProviderRequest
9003    {
9004        #[inline]
9005        unsafe fn encode(
9006            self,
9007            encoder: &mut fidl::encoding::Encoder<
9008                '_,
9009                fidl::encoding::DefaultFuchsiaResourceDialect,
9010            >,
9011            offset: usize,
9012            _depth: fidl::encoding::Depth,
9013        ) -> fidl::Result<()> {
9014            encoder
9015                .debug_check_bounds::<DependencyInjectionSetMemoryPressureProviderRequest>(offset);
9016            // Delegate to tuple encoding.
9017            fidl::encoding::Encode::<
9018                DependencyInjectionSetMemoryPressureProviderRequest,
9019                fidl::encoding::DefaultFuchsiaResourceDialect,
9020            >::encode(
9021                (<fidl::encoding::Endpoint<
9022                    fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
9023                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9024                    &mut self.provider
9025                ),),
9026                encoder,
9027                offset,
9028                _depth,
9029            )
9030        }
9031    }
9032    unsafe impl<
9033        T0: fidl::encoding::Encode<
9034                fidl::encoding::Endpoint<
9035                    fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
9036                >,
9037                fidl::encoding::DefaultFuchsiaResourceDialect,
9038            >,
9039    >
9040        fidl::encoding::Encode<
9041            DependencyInjectionSetMemoryPressureProviderRequest,
9042            fidl::encoding::DefaultFuchsiaResourceDialect,
9043        > for (T0,)
9044    {
9045        #[inline]
9046        unsafe fn encode(
9047            self,
9048            encoder: &mut fidl::encoding::Encoder<
9049                '_,
9050                fidl::encoding::DefaultFuchsiaResourceDialect,
9051            >,
9052            offset: usize,
9053            depth: fidl::encoding::Depth,
9054        ) -> fidl::Result<()> {
9055            encoder
9056                .debug_check_bounds::<DependencyInjectionSetMemoryPressureProviderRequest>(offset);
9057            // Zero out padding regions. There's no need to apply masks
9058            // because the unmasked parts will be overwritten by fields.
9059            // Write the fields.
9060            self.0.encode(encoder, offset + 0, depth)?;
9061            Ok(())
9062        }
9063    }
9064
9065    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9066        for DependencyInjectionSetMemoryPressureProviderRequest
9067    {
9068        #[inline(always)]
9069        fn new_empty() -> Self {
9070            Self {
9071                provider: fidl::new_empty!(
9072                    fidl::encoding::Endpoint<
9073                        fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
9074                    >,
9075                    fidl::encoding::DefaultFuchsiaResourceDialect
9076                ),
9077            }
9078        }
9079
9080        #[inline]
9081        unsafe fn decode(
9082            &mut self,
9083            decoder: &mut fidl::encoding::Decoder<
9084                '_,
9085                fidl::encoding::DefaultFuchsiaResourceDialect,
9086            >,
9087            offset: usize,
9088            _depth: fidl::encoding::Depth,
9089        ) -> fidl::Result<()> {
9090            decoder.debug_check_bounds::<Self>(offset);
9091            // Verify that padding bytes are zero.
9092            fidl::decode!(
9093                fidl::encoding::Endpoint<
9094                    fidl::endpoints::ClientEnd<fidl_fuchsia_memorypressure::ProviderMarker>,
9095                >,
9096                fidl::encoding::DefaultFuchsiaResourceDialect,
9097                &mut self.provider,
9098                decoder,
9099                offset + 0,
9100                _depth
9101            )?;
9102            Ok(())
9103        }
9104    }
9105
9106    impl fidl::encoding::ResourceTypeMarker for DeviceConnect2Request {
9107        type Borrowed<'a> = &'a mut Self;
9108        fn take_or_borrow<'a>(
9109            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9110        ) -> Self::Borrowed<'a> {
9111            value
9112        }
9113    }
9114
9115    unsafe impl fidl::encoding::TypeMarker for DeviceConnect2Request {
9116        type Owned = Self;
9117
9118        #[inline(always)]
9119        fn inline_align(_context: fidl::encoding::Context) -> usize {
9120            8
9121        }
9122
9123        #[inline(always)]
9124        fn inline_size(_context: fidl::encoding::Context) -> usize {
9125            16
9126        }
9127    }
9128
9129    unsafe impl
9130        fidl::encoding::Encode<DeviceConnect2Request, fidl::encoding::DefaultFuchsiaResourceDialect>
9131        for &mut DeviceConnect2Request
9132    {
9133        #[inline]
9134        unsafe fn encode(
9135            self,
9136            encoder: &mut fidl::encoding::Encoder<
9137                '_,
9138                fidl::encoding::DefaultFuchsiaResourceDialect,
9139            >,
9140            offset: usize,
9141            _depth: fidl::encoding::Depth,
9142        ) -> fidl::Result<()> {
9143            encoder.debug_check_bounds::<DeviceConnect2Request>(offset);
9144            // Delegate to tuple encoding.
9145            fidl::encoding::Encode::<DeviceConnect2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9146                (
9147                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.client_id),
9148                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrimaryMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.primary_channel),
9149                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NotificationMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.notification_channel),
9150                ),
9151                encoder, offset, _depth
9152            )
9153        }
9154    }
9155    unsafe impl<
9156        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
9157        T1: fidl::encoding::Encode<
9158                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrimaryMarker>>,
9159                fidl::encoding::DefaultFuchsiaResourceDialect,
9160            >,
9161        T2: fidl::encoding::Encode<
9162                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NotificationMarker>>,
9163                fidl::encoding::DefaultFuchsiaResourceDialect,
9164            >,
9165    >
9166        fidl::encoding::Encode<DeviceConnect2Request, fidl::encoding::DefaultFuchsiaResourceDialect>
9167        for (T0, T1, T2)
9168    {
9169        #[inline]
9170        unsafe fn encode(
9171            self,
9172            encoder: &mut fidl::encoding::Encoder<
9173                '_,
9174                fidl::encoding::DefaultFuchsiaResourceDialect,
9175            >,
9176            offset: usize,
9177            depth: fidl::encoding::Depth,
9178        ) -> fidl::Result<()> {
9179            encoder.debug_check_bounds::<DeviceConnect2Request>(offset);
9180            // Zero out padding regions. There's no need to apply masks
9181            // because the unmasked parts will be overwritten by fields.
9182            // Write the fields.
9183            self.0.encode(encoder, offset + 0, depth)?;
9184            self.1.encode(encoder, offset + 8, depth)?;
9185            self.2.encode(encoder, offset + 12, depth)?;
9186            Ok(())
9187        }
9188    }
9189
9190    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9191        for DeviceConnect2Request
9192    {
9193        #[inline(always)]
9194        fn new_empty() -> Self {
9195            Self {
9196                client_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
9197                primary_channel: fidl::new_empty!(
9198                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrimaryMarker>>,
9199                    fidl::encoding::DefaultFuchsiaResourceDialect
9200                ),
9201                notification_channel: fidl::new_empty!(
9202                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NotificationMarker>>,
9203                    fidl::encoding::DefaultFuchsiaResourceDialect
9204                ),
9205            }
9206        }
9207
9208        #[inline]
9209        unsafe fn decode(
9210            &mut self,
9211            decoder: &mut fidl::encoding::Decoder<
9212                '_,
9213                fidl::encoding::DefaultFuchsiaResourceDialect,
9214            >,
9215            offset: usize,
9216            _depth: fidl::encoding::Depth,
9217        ) -> fidl::Result<()> {
9218            decoder.debug_check_bounds::<Self>(offset);
9219            // Verify that padding bytes are zero.
9220            fidl::decode!(
9221                u64,
9222                fidl::encoding::DefaultFuchsiaResourceDialect,
9223                &mut self.client_id,
9224                decoder,
9225                offset + 0,
9226                _depth
9227            )?;
9228            fidl::decode!(
9229                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PrimaryMarker>>,
9230                fidl::encoding::DefaultFuchsiaResourceDialect,
9231                &mut self.primary_channel,
9232                decoder,
9233                offset + 8,
9234                _depth
9235            )?;
9236            fidl::decode!(
9237                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NotificationMarker>>,
9238                fidl::encoding::DefaultFuchsiaResourceDialect,
9239                &mut self.notification_channel,
9240                decoder,
9241                offset + 12,
9242                _depth
9243            )?;
9244            Ok(())
9245        }
9246    }
9247
9248    impl fidl::encoding::ResourceTypeMarker
9249        for PerformanceCounterAccessGetPerformanceCountTokenResponse
9250    {
9251        type Borrowed<'a> = &'a mut Self;
9252        fn take_or_borrow<'a>(
9253            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9254        ) -> Self::Borrowed<'a> {
9255            value
9256        }
9257    }
9258
9259    unsafe impl fidl::encoding::TypeMarker
9260        for PerformanceCounterAccessGetPerformanceCountTokenResponse
9261    {
9262        type Owned = Self;
9263
9264        #[inline(always)]
9265        fn inline_align(_context: fidl::encoding::Context) -> usize {
9266            4
9267        }
9268
9269        #[inline(always)]
9270        fn inline_size(_context: fidl::encoding::Context) -> usize {
9271            4
9272        }
9273    }
9274
9275    unsafe impl
9276        fidl::encoding::Encode<
9277            PerformanceCounterAccessGetPerformanceCountTokenResponse,
9278            fidl::encoding::DefaultFuchsiaResourceDialect,
9279        > for &mut PerformanceCounterAccessGetPerformanceCountTokenResponse
9280    {
9281        #[inline]
9282        unsafe fn encode(
9283            self,
9284            encoder: &mut fidl::encoding::Encoder<
9285                '_,
9286                fidl::encoding::DefaultFuchsiaResourceDialect,
9287            >,
9288            offset: usize,
9289            _depth: fidl::encoding::Depth,
9290        ) -> fidl::Result<()> {
9291            encoder.debug_check_bounds::<PerformanceCounterAccessGetPerformanceCountTokenResponse>(
9292                offset,
9293            );
9294            // Delegate to tuple encoding.
9295            fidl::encoding::Encode::<
9296                PerformanceCounterAccessGetPerformanceCountTokenResponse,
9297                fidl::encoding::DefaultFuchsiaResourceDialect,
9298            >::encode(
9299                (<fidl::encoding::HandleType<
9300                    fidl::Event,
9301                    { fidl::ObjectType::EVENT.into_raw() },
9302                    2147483648,
9303                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9304                    &mut self.access_token
9305                ),),
9306                encoder,
9307                offset,
9308                _depth,
9309            )
9310        }
9311    }
9312    unsafe impl<
9313        T0: fidl::encoding::Encode<
9314                fidl::encoding::HandleType<
9315                    fidl::Event,
9316                    { fidl::ObjectType::EVENT.into_raw() },
9317                    2147483648,
9318                >,
9319                fidl::encoding::DefaultFuchsiaResourceDialect,
9320            >,
9321    >
9322        fidl::encoding::Encode<
9323            PerformanceCounterAccessGetPerformanceCountTokenResponse,
9324            fidl::encoding::DefaultFuchsiaResourceDialect,
9325        > for (T0,)
9326    {
9327        #[inline]
9328        unsafe fn encode(
9329            self,
9330            encoder: &mut fidl::encoding::Encoder<
9331                '_,
9332                fidl::encoding::DefaultFuchsiaResourceDialect,
9333            >,
9334            offset: usize,
9335            depth: fidl::encoding::Depth,
9336        ) -> fidl::Result<()> {
9337            encoder.debug_check_bounds::<PerformanceCounterAccessGetPerformanceCountTokenResponse>(
9338                offset,
9339            );
9340            // Zero out padding regions. There's no need to apply masks
9341            // because the unmasked parts will be overwritten by fields.
9342            // Write the fields.
9343            self.0.encode(encoder, offset + 0, depth)?;
9344            Ok(())
9345        }
9346    }
9347
9348    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9349        for PerformanceCounterAccessGetPerformanceCountTokenResponse
9350    {
9351        #[inline(always)]
9352        fn new_empty() -> Self {
9353            Self {
9354                access_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9355            }
9356        }
9357
9358        #[inline]
9359        unsafe fn decode(
9360            &mut self,
9361            decoder: &mut fidl::encoding::Decoder<
9362                '_,
9363                fidl::encoding::DefaultFuchsiaResourceDialect,
9364            >,
9365            offset: usize,
9366            _depth: fidl::encoding::Depth,
9367        ) -> fidl::Result<()> {
9368            decoder.debug_check_bounds::<Self>(offset);
9369            // Verify that padding bytes are zero.
9370            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.access_token, decoder, offset + 0, _depth)?;
9371            Ok(())
9372        }
9373    }
9374
9375    impl fidl::encoding::ResourceTypeMarker for PowerElementProviderGetPowerGoalsResponse {
9376        type Borrowed<'a> = &'a mut Self;
9377        fn take_or_borrow<'a>(
9378            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9379        ) -> Self::Borrowed<'a> {
9380            value
9381        }
9382    }
9383
9384    unsafe impl fidl::encoding::TypeMarker for PowerElementProviderGetPowerGoalsResponse {
9385        type Owned = Self;
9386
9387        #[inline(always)]
9388        fn inline_align(_context: fidl::encoding::Context) -> usize {
9389            8
9390        }
9391
9392        #[inline(always)]
9393        fn inline_size(_context: fidl::encoding::Context) -> usize {
9394            16
9395        }
9396    }
9397
9398    unsafe impl
9399        fidl::encoding::Encode<
9400            PowerElementProviderGetPowerGoalsResponse,
9401            fidl::encoding::DefaultFuchsiaResourceDialect,
9402        > for &mut PowerElementProviderGetPowerGoalsResponse
9403    {
9404        #[inline]
9405        unsafe fn encode(
9406            self,
9407            encoder: &mut fidl::encoding::Encoder<
9408                '_,
9409                fidl::encoding::DefaultFuchsiaResourceDialect,
9410            >,
9411            offset: usize,
9412            _depth: fidl::encoding::Depth,
9413        ) -> fidl::Result<()> {
9414            encoder.debug_check_bounds::<PowerElementProviderGetPowerGoalsResponse>(offset);
9415            // Delegate to tuple encoding.
9416            fidl::encoding::Encode::<PowerElementProviderGetPowerGoalsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9417                (
9418                    <fidl::encoding::UnboundedVector<PowerGoal> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.goals),
9419                ),
9420                encoder, offset, _depth
9421            )
9422        }
9423    }
9424    unsafe impl<
9425        T0: fidl::encoding::Encode<
9426                fidl::encoding::UnboundedVector<PowerGoal>,
9427                fidl::encoding::DefaultFuchsiaResourceDialect,
9428            >,
9429    >
9430        fidl::encoding::Encode<
9431            PowerElementProviderGetPowerGoalsResponse,
9432            fidl::encoding::DefaultFuchsiaResourceDialect,
9433        > for (T0,)
9434    {
9435        #[inline]
9436        unsafe fn encode(
9437            self,
9438            encoder: &mut fidl::encoding::Encoder<
9439                '_,
9440                fidl::encoding::DefaultFuchsiaResourceDialect,
9441            >,
9442            offset: usize,
9443            depth: fidl::encoding::Depth,
9444        ) -> fidl::Result<()> {
9445            encoder.debug_check_bounds::<PowerElementProviderGetPowerGoalsResponse>(offset);
9446            // Zero out padding regions. There's no need to apply masks
9447            // because the unmasked parts will be overwritten by fields.
9448            // Write the fields.
9449            self.0.encode(encoder, offset + 0, depth)?;
9450            Ok(())
9451        }
9452    }
9453
9454    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9455        for PowerElementProviderGetPowerGoalsResponse
9456    {
9457        #[inline(always)]
9458        fn new_empty() -> Self {
9459            Self {
9460                goals: fidl::new_empty!(
9461                    fidl::encoding::UnboundedVector<PowerGoal>,
9462                    fidl::encoding::DefaultFuchsiaResourceDialect
9463                ),
9464            }
9465        }
9466
9467        #[inline]
9468        unsafe fn decode(
9469            &mut self,
9470            decoder: &mut fidl::encoding::Decoder<
9471                '_,
9472                fidl::encoding::DefaultFuchsiaResourceDialect,
9473            >,
9474            offset: usize,
9475            _depth: fidl::encoding::Depth,
9476        ) -> fidl::Result<()> {
9477            decoder.debug_check_bounds::<Self>(offset);
9478            // Verify that padding bytes are zero.
9479            fidl::decode!(
9480                fidl::encoding::UnboundedVector<PowerGoal>,
9481                fidl::encoding::DefaultFuchsiaResourceDialect,
9482                &mut self.goals,
9483                decoder,
9484                offset + 0,
9485                _depth
9486            )?;
9487            Ok(())
9488        }
9489    }
9490
9491    impl fidl::encoding::ResourceTypeMarker for PrimaryCreatePerformanceCounterBufferPoolRequest {
9492        type Borrowed<'a> = &'a mut Self;
9493        fn take_or_borrow<'a>(
9494            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9495        ) -> Self::Borrowed<'a> {
9496            value
9497        }
9498    }
9499
9500    unsafe impl fidl::encoding::TypeMarker for PrimaryCreatePerformanceCounterBufferPoolRequest {
9501        type Owned = Self;
9502
9503        #[inline(always)]
9504        fn inline_align(_context: fidl::encoding::Context) -> usize {
9505            8
9506        }
9507
9508        #[inline(always)]
9509        fn inline_size(_context: fidl::encoding::Context) -> usize {
9510            16
9511        }
9512    }
9513
9514    unsafe impl
9515        fidl::encoding::Encode<
9516            PrimaryCreatePerformanceCounterBufferPoolRequest,
9517            fidl::encoding::DefaultFuchsiaResourceDialect,
9518        > for &mut PrimaryCreatePerformanceCounterBufferPoolRequest
9519    {
9520        #[inline]
9521        unsafe fn encode(
9522            self,
9523            encoder: &mut fidl::encoding::Encoder<
9524                '_,
9525                fidl::encoding::DefaultFuchsiaResourceDialect,
9526            >,
9527            offset: usize,
9528            _depth: fidl::encoding::Depth,
9529        ) -> fidl::Result<()> {
9530            encoder.debug_check_bounds::<PrimaryCreatePerformanceCounterBufferPoolRequest>(offset);
9531            // Delegate to tuple encoding.
9532            fidl::encoding::Encode::<
9533                PrimaryCreatePerformanceCounterBufferPoolRequest,
9534                fidl::encoding::DefaultFuchsiaResourceDialect,
9535            >::encode(
9536                (
9537                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pool_id),
9538                    <fidl::encoding::Endpoint<
9539                        fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
9540                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9541                        &mut self.event_channel,
9542                    ),
9543                ),
9544                encoder,
9545                offset,
9546                _depth,
9547            )
9548        }
9549    }
9550    unsafe impl<
9551        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
9552        T1: fidl::encoding::Encode<
9553                fidl::encoding::Endpoint<
9554                    fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
9555                >,
9556                fidl::encoding::DefaultFuchsiaResourceDialect,
9557            >,
9558    >
9559        fidl::encoding::Encode<
9560            PrimaryCreatePerformanceCounterBufferPoolRequest,
9561            fidl::encoding::DefaultFuchsiaResourceDialect,
9562        > for (T0, T1)
9563    {
9564        #[inline]
9565        unsafe fn encode(
9566            self,
9567            encoder: &mut fidl::encoding::Encoder<
9568                '_,
9569                fidl::encoding::DefaultFuchsiaResourceDialect,
9570            >,
9571            offset: usize,
9572            depth: fidl::encoding::Depth,
9573        ) -> fidl::Result<()> {
9574            encoder.debug_check_bounds::<PrimaryCreatePerformanceCounterBufferPoolRequest>(offset);
9575            // Zero out padding regions. There's no need to apply masks
9576            // because the unmasked parts will be overwritten by fields.
9577            unsafe {
9578                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
9579                (ptr as *mut u64).write_unaligned(0);
9580            }
9581            // Write the fields.
9582            self.0.encode(encoder, offset + 0, depth)?;
9583            self.1.encode(encoder, offset + 8, depth)?;
9584            Ok(())
9585        }
9586    }
9587
9588    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9589        for PrimaryCreatePerformanceCounterBufferPoolRequest
9590    {
9591        #[inline(always)]
9592        fn new_empty() -> Self {
9593            Self {
9594                pool_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
9595                event_channel: fidl::new_empty!(
9596                    fidl::encoding::Endpoint<
9597                        fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
9598                    >,
9599                    fidl::encoding::DefaultFuchsiaResourceDialect
9600                ),
9601            }
9602        }
9603
9604        #[inline]
9605        unsafe fn decode(
9606            &mut self,
9607            decoder: &mut fidl::encoding::Decoder<
9608                '_,
9609                fidl::encoding::DefaultFuchsiaResourceDialect,
9610            >,
9611            offset: usize,
9612            _depth: fidl::encoding::Depth,
9613        ) -> fidl::Result<()> {
9614            decoder.debug_check_bounds::<Self>(offset);
9615            // Verify that padding bytes are zero.
9616            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
9617            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9618            let mask = 0xffffffff00000000u64;
9619            let maskedval = padval & mask;
9620            if maskedval != 0 {
9621                return Err(fidl::Error::NonZeroPadding {
9622                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
9623                });
9624            }
9625            fidl::decode!(
9626                u64,
9627                fidl::encoding::DefaultFuchsiaResourceDialect,
9628                &mut self.pool_id,
9629                decoder,
9630                offset + 0,
9631                _depth
9632            )?;
9633            fidl::decode!(
9634                fidl::encoding::Endpoint<
9635                    fidl::endpoints::ServerEnd<PerformanceCounterEventsMarker>,
9636                >,
9637                fidl::encoding::DefaultFuchsiaResourceDialect,
9638                &mut self.event_channel,
9639                decoder,
9640                offset + 8,
9641                _depth
9642            )?;
9643            Ok(())
9644        }
9645    }
9646
9647    impl fidl::encoding::ResourceTypeMarker for PrimaryEnablePerformanceCounterAccessRequest {
9648        type Borrowed<'a> = &'a mut Self;
9649        fn take_or_borrow<'a>(
9650            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9651        ) -> Self::Borrowed<'a> {
9652            value
9653        }
9654    }
9655
9656    unsafe impl fidl::encoding::TypeMarker for PrimaryEnablePerformanceCounterAccessRequest {
9657        type Owned = Self;
9658
9659        #[inline(always)]
9660        fn inline_align(_context: fidl::encoding::Context) -> usize {
9661            4
9662        }
9663
9664        #[inline(always)]
9665        fn inline_size(_context: fidl::encoding::Context) -> usize {
9666            4
9667        }
9668    }
9669
9670    unsafe impl
9671        fidl::encoding::Encode<
9672            PrimaryEnablePerformanceCounterAccessRequest,
9673            fidl::encoding::DefaultFuchsiaResourceDialect,
9674        > for &mut PrimaryEnablePerformanceCounterAccessRequest
9675    {
9676        #[inline]
9677        unsafe fn encode(
9678            self,
9679            encoder: &mut fidl::encoding::Encoder<
9680                '_,
9681                fidl::encoding::DefaultFuchsiaResourceDialect,
9682            >,
9683            offset: usize,
9684            _depth: fidl::encoding::Depth,
9685        ) -> fidl::Result<()> {
9686            encoder.debug_check_bounds::<PrimaryEnablePerformanceCounterAccessRequest>(offset);
9687            // Delegate to tuple encoding.
9688            fidl::encoding::Encode::<
9689                PrimaryEnablePerformanceCounterAccessRequest,
9690                fidl::encoding::DefaultFuchsiaResourceDialect,
9691            >::encode(
9692                (<fidl::encoding::HandleType<
9693                    fidl::Event,
9694                    { fidl::ObjectType::EVENT.into_raw() },
9695                    2147483648,
9696                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9697                    &mut self.access_token
9698                ),),
9699                encoder,
9700                offset,
9701                _depth,
9702            )
9703        }
9704    }
9705    unsafe impl<
9706        T0: fidl::encoding::Encode<
9707                fidl::encoding::HandleType<
9708                    fidl::Event,
9709                    { fidl::ObjectType::EVENT.into_raw() },
9710                    2147483648,
9711                >,
9712                fidl::encoding::DefaultFuchsiaResourceDialect,
9713            >,
9714    >
9715        fidl::encoding::Encode<
9716            PrimaryEnablePerformanceCounterAccessRequest,
9717            fidl::encoding::DefaultFuchsiaResourceDialect,
9718        > for (T0,)
9719    {
9720        #[inline]
9721        unsafe fn encode(
9722            self,
9723            encoder: &mut fidl::encoding::Encoder<
9724                '_,
9725                fidl::encoding::DefaultFuchsiaResourceDialect,
9726            >,
9727            offset: usize,
9728            depth: fidl::encoding::Depth,
9729        ) -> fidl::Result<()> {
9730            encoder.debug_check_bounds::<PrimaryEnablePerformanceCounterAccessRequest>(offset);
9731            // Zero out padding regions. There's no need to apply masks
9732            // because the unmasked parts will be overwritten by fields.
9733            // Write the fields.
9734            self.0.encode(encoder, offset + 0, depth)?;
9735            Ok(())
9736        }
9737    }
9738
9739    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9740        for PrimaryEnablePerformanceCounterAccessRequest
9741    {
9742        #[inline(always)]
9743        fn new_empty() -> Self {
9744            Self {
9745                access_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
9746            }
9747        }
9748
9749        #[inline]
9750        unsafe fn decode(
9751            &mut self,
9752            decoder: &mut fidl::encoding::Decoder<
9753                '_,
9754                fidl::encoding::DefaultFuchsiaResourceDialect,
9755            >,
9756            offset: usize,
9757            _depth: fidl::encoding::Depth,
9758        ) -> fidl::Result<()> {
9759            decoder.debug_check_bounds::<Self>(offset);
9760            // Verify that padding bytes are zero.
9761            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.access_token, decoder, offset + 0, _depth)?;
9762            Ok(())
9763        }
9764    }
9765
9766    impl PowerElementProviderGetClockSpeedLevelResponse {
9767        #[inline(always)]
9768        fn max_ordinal_present(&self) -> u64 {
9769            if let Some(_) = self.actual_hz {
9770                return 3;
9771            }
9772            if let Some(_) = self.level {
9773                return 2;
9774            }
9775            if let Some(_) = self.token {
9776                return 1;
9777            }
9778            0
9779        }
9780    }
9781
9782    impl fidl::encoding::ResourceTypeMarker for PowerElementProviderGetClockSpeedLevelResponse {
9783        type Borrowed<'a> = &'a mut Self;
9784        fn take_or_borrow<'a>(
9785            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9786        ) -> Self::Borrowed<'a> {
9787            value
9788        }
9789    }
9790
9791    unsafe impl fidl::encoding::TypeMarker for PowerElementProviderGetClockSpeedLevelResponse {
9792        type Owned = Self;
9793
9794        #[inline(always)]
9795        fn inline_align(_context: fidl::encoding::Context) -> usize {
9796            8
9797        }
9798
9799        #[inline(always)]
9800        fn inline_size(_context: fidl::encoding::Context) -> usize {
9801            16
9802        }
9803    }
9804
9805    unsafe impl
9806        fidl::encoding::Encode<
9807            PowerElementProviderGetClockSpeedLevelResponse,
9808            fidl::encoding::DefaultFuchsiaResourceDialect,
9809        > for &mut PowerElementProviderGetClockSpeedLevelResponse
9810    {
9811        unsafe fn encode(
9812            self,
9813            encoder: &mut fidl::encoding::Encoder<
9814                '_,
9815                fidl::encoding::DefaultFuchsiaResourceDialect,
9816            >,
9817            offset: usize,
9818            mut depth: fidl::encoding::Depth,
9819        ) -> fidl::Result<()> {
9820            encoder.debug_check_bounds::<PowerElementProviderGetClockSpeedLevelResponse>(offset);
9821            // Vector header
9822            let max_ordinal: u64 = self.max_ordinal_present();
9823            encoder.write_num(max_ordinal, offset);
9824            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9825            // Calling encoder.out_of_line_offset(0) is not allowed.
9826            if max_ordinal == 0 {
9827                return Ok(());
9828            }
9829            depth.increment()?;
9830            let envelope_size = 8;
9831            let bytes_len = max_ordinal as usize * envelope_size;
9832            #[allow(unused_variables)]
9833            let offset = encoder.out_of_line_offset(bytes_len);
9834            let mut _prev_end_offset: usize = 0;
9835            if 1 > max_ordinal {
9836                return Ok(());
9837            }
9838
9839            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9840            // are envelope_size bytes.
9841            let cur_offset: usize = (1 - 1) * envelope_size;
9842
9843            // Zero reserved fields.
9844            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9845
9846            // Safety:
9847            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9848            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9849            //   envelope_size bytes, there is always sufficient room.
9850            fidl::encoding::encode_in_envelope_optional::<
9851                fidl::encoding::HandleType<
9852                    fidl::Event,
9853                    { fidl::ObjectType::EVENT.into_raw() },
9854                    2147483648,
9855                >,
9856                fidl::encoding::DefaultFuchsiaResourceDialect,
9857            >(
9858                self.token.as_mut().map(
9859                    <fidl::encoding::HandleType<
9860                        fidl::Event,
9861                        { fidl::ObjectType::EVENT.into_raw() },
9862                        2147483648,
9863                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9864                ),
9865                encoder,
9866                offset + cur_offset,
9867                depth,
9868            )?;
9869
9870            _prev_end_offset = cur_offset + envelope_size;
9871            if 2 > max_ordinal {
9872                return Ok(());
9873            }
9874
9875            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9876            // are envelope_size bytes.
9877            let cur_offset: usize = (2 - 1) * envelope_size;
9878
9879            // Zero reserved fields.
9880            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9881
9882            // Safety:
9883            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9884            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9885            //   envelope_size bytes, there is always sufficient room.
9886            fidl::encoding::encode_in_envelope_optional::<
9887                u8,
9888                fidl::encoding::DefaultFuchsiaResourceDialect,
9889            >(
9890                self.level.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
9891                encoder,
9892                offset + cur_offset,
9893                depth,
9894            )?;
9895
9896            _prev_end_offset = cur_offset + envelope_size;
9897            if 3 > max_ordinal {
9898                return Ok(());
9899            }
9900
9901            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9902            // are envelope_size bytes.
9903            let cur_offset: usize = (3 - 1) * envelope_size;
9904
9905            // Zero reserved fields.
9906            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9907
9908            // Safety:
9909            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9910            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9911            //   envelope_size bytes, there is always sufficient room.
9912            fidl::encoding::encode_in_envelope_optional::<
9913                u64,
9914                fidl::encoding::DefaultFuchsiaResourceDialect,
9915            >(
9916                self.actual_hz.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
9917                encoder,
9918                offset + cur_offset,
9919                depth,
9920            )?;
9921
9922            _prev_end_offset = cur_offset + envelope_size;
9923
9924            Ok(())
9925        }
9926    }
9927
9928    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9929        for PowerElementProviderGetClockSpeedLevelResponse
9930    {
9931        #[inline(always)]
9932        fn new_empty() -> Self {
9933            Self::default()
9934        }
9935
9936        unsafe fn decode(
9937            &mut self,
9938            decoder: &mut fidl::encoding::Decoder<
9939                '_,
9940                fidl::encoding::DefaultFuchsiaResourceDialect,
9941            >,
9942            offset: usize,
9943            mut depth: fidl::encoding::Depth,
9944        ) -> fidl::Result<()> {
9945            decoder.debug_check_bounds::<Self>(offset);
9946            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9947                None => return Err(fidl::Error::NotNullable),
9948                Some(len) => len,
9949            };
9950            // Calling decoder.out_of_line_offset(0) is not allowed.
9951            if len == 0 {
9952                return Ok(());
9953            };
9954            depth.increment()?;
9955            let envelope_size = 8;
9956            let bytes_len = len * envelope_size;
9957            let offset = decoder.out_of_line_offset(bytes_len)?;
9958            // Decode the envelope for each type.
9959            let mut _next_ordinal_to_read = 0;
9960            let mut next_offset = offset;
9961            let end_offset = offset + bytes_len;
9962            _next_ordinal_to_read += 1;
9963            if next_offset >= end_offset {
9964                return Ok(());
9965            }
9966
9967            // Decode unknown envelopes for gaps in ordinals.
9968            while _next_ordinal_to_read < 1 {
9969                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9970                _next_ordinal_to_read += 1;
9971                next_offset += envelope_size;
9972            }
9973
9974            let next_out_of_line = decoder.next_out_of_line();
9975            let handles_before = decoder.remaining_handles();
9976            if let Some((inlined, num_bytes, num_handles)) =
9977                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9978            {
9979                let member_inline_size = <fidl::encoding::HandleType<
9980                    fidl::Event,
9981                    { fidl::ObjectType::EVENT.into_raw() },
9982                    2147483648,
9983                > as fidl::encoding::TypeMarker>::inline_size(
9984                    decoder.context
9985                );
9986                if inlined != (member_inline_size <= 4) {
9987                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9988                }
9989                let inner_offset;
9990                let mut inner_depth = depth.clone();
9991                if inlined {
9992                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9993                    inner_offset = next_offset;
9994                } else {
9995                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9996                    inner_depth.increment()?;
9997                }
9998                let val_ref =
9999                self.token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
10000                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10001                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10002                {
10003                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10004                }
10005                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10006                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10007                }
10008            }
10009
10010            next_offset += envelope_size;
10011            _next_ordinal_to_read += 1;
10012            if next_offset >= end_offset {
10013                return Ok(());
10014            }
10015
10016            // Decode unknown envelopes for gaps in ordinals.
10017            while _next_ordinal_to_read < 2 {
10018                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10019                _next_ordinal_to_read += 1;
10020                next_offset += envelope_size;
10021            }
10022
10023            let next_out_of_line = decoder.next_out_of_line();
10024            let handles_before = decoder.remaining_handles();
10025            if let Some((inlined, num_bytes, num_handles)) =
10026                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10027            {
10028                let member_inline_size =
10029                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10030                if inlined != (member_inline_size <= 4) {
10031                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10032                }
10033                let inner_offset;
10034                let mut inner_depth = depth.clone();
10035                if inlined {
10036                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10037                    inner_offset = next_offset;
10038                } else {
10039                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10040                    inner_depth.increment()?;
10041                }
10042                let val_ref = self.level.get_or_insert_with(|| {
10043                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
10044                });
10045                fidl::decode!(
10046                    u8,
10047                    fidl::encoding::DefaultFuchsiaResourceDialect,
10048                    val_ref,
10049                    decoder,
10050                    inner_offset,
10051                    inner_depth
10052                )?;
10053                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10054                {
10055                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10056                }
10057                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10058                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10059                }
10060            }
10061
10062            next_offset += envelope_size;
10063            _next_ordinal_to_read += 1;
10064            if next_offset >= end_offset {
10065                return Ok(());
10066            }
10067
10068            // Decode unknown envelopes for gaps in ordinals.
10069            while _next_ordinal_to_read < 3 {
10070                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10071                _next_ordinal_to_read += 1;
10072                next_offset += envelope_size;
10073            }
10074
10075            let next_out_of_line = decoder.next_out_of_line();
10076            let handles_before = decoder.remaining_handles();
10077            if let Some((inlined, num_bytes, num_handles)) =
10078                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10079            {
10080                let member_inline_size =
10081                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10082                if inlined != (member_inline_size <= 4) {
10083                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10084                }
10085                let inner_offset;
10086                let mut inner_depth = depth.clone();
10087                if inlined {
10088                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10089                    inner_offset = next_offset;
10090                } else {
10091                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10092                    inner_depth.increment()?;
10093                }
10094                let val_ref = self.actual_hz.get_or_insert_with(|| {
10095                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
10096                });
10097                fidl::decode!(
10098                    u64,
10099                    fidl::encoding::DefaultFuchsiaResourceDialect,
10100                    val_ref,
10101                    decoder,
10102                    inner_offset,
10103                    inner_depth
10104                )?;
10105                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10106                {
10107                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10108                }
10109                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10110                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10111                }
10112            }
10113
10114            next_offset += envelope_size;
10115
10116            // Decode the remaining unknown envelopes.
10117            while next_offset < end_offset {
10118                _next_ordinal_to_read += 1;
10119                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10120                next_offset += envelope_size;
10121            }
10122
10123            Ok(())
10124        }
10125    }
10126
10127    impl PowerElementProviderSetClockLimitResponse {
10128        #[inline(always)]
10129        fn max_ordinal_present(&self) -> u64 {
10130            if let Some(_) = self.actual_hz {
10131                return 2;
10132            }
10133            if let Some(_) = self.handle {
10134                return 1;
10135            }
10136            0
10137        }
10138    }
10139
10140    impl fidl::encoding::ResourceTypeMarker for PowerElementProviderSetClockLimitResponse {
10141        type Borrowed<'a> = &'a mut Self;
10142        fn take_or_borrow<'a>(
10143            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10144        ) -> Self::Borrowed<'a> {
10145            value
10146        }
10147    }
10148
10149    unsafe impl fidl::encoding::TypeMarker for PowerElementProviderSetClockLimitResponse {
10150        type Owned = Self;
10151
10152        #[inline(always)]
10153        fn inline_align(_context: fidl::encoding::Context) -> usize {
10154            8
10155        }
10156
10157        #[inline(always)]
10158        fn inline_size(_context: fidl::encoding::Context) -> usize {
10159            16
10160        }
10161    }
10162
10163    unsafe impl
10164        fidl::encoding::Encode<
10165            PowerElementProviderSetClockLimitResponse,
10166            fidl::encoding::DefaultFuchsiaResourceDialect,
10167        > for &mut PowerElementProviderSetClockLimitResponse
10168    {
10169        unsafe fn encode(
10170            self,
10171            encoder: &mut fidl::encoding::Encoder<
10172                '_,
10173                fidl::encoding::DefaultFuchsiaResourceDialect,
10174            >,
10175            offset: usize,
10176            mut depth: fidl::encoding::Depth,
10177        ) -> fidl::Result<()> {
10178            encoder.debug_check_bounds::<PowerElementProviderSetClockLimitResponse>(offset);
10179            // Vector header
10180            let max_ordinal: u64 = self.max_ordinal_present();
10181            encoder.write_num(max_ordinal, offset);
10182            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10183            // Calling encoder.out_of_line_offset(0) is not allowed.
10184            if max_ordinal == 0 {
10185                return Ok(());
10186            }
10187            depth.increment()?;
10188            let envelope_size = 8;
10189            let bytes_len = max_ordinal as usize * envelope_size;
10190            #[allow(unused_variables)]
10191            let offset = encoder.out_of_line_offset(bytes_len);
10192            let mut _prev_end_offset: usize = 0;
10193            if 1 > max_ordinal {
10194                return Ok(());
10195            }
10196
10197            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10198            // are envelope_size bytes.
10199            let cur_offset: usize = (1 - 1) * envelope_size;
10200
10201            // Zero reserved fields.
10202            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10203
10204            // Safety:
10205            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10206            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10207            //   envelope_size bytes, there is always sufficient room.
10208            fidl::encoding::encode_in_envelope_optional::<
10209                fidl::encoding::HandleType<
10210                    fidl::EventPair,
10211                    { fidl::ObjectType::EVENTPAIR.into_raw() },
10212                    2147483648,
10213                >,
10214                fidl::encoding::DefaultFuchsiaResourceDialect,
10215            >(
10216                self.handle.as_mut().map(
10217                    <fidl::encoding::HandleType<
10218                        fidl::EventPair,
10219                        { fidl::ObjectType::EVENTPAIR.into_raw() },
10220                        2147483648,
10221                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10222                ),
10223                encoder,
10224                offset + cur_offset,
10225                depth,
10226            )?;
10227
10228            _prev_end_offset = cur_offset + envelope_size;
10229            if 2 > max_ordinal {
10230                return Ok(());
10231            }
10232
10233            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10234            // are envelope_size bytes.
10235            let cur_offset: usize = (2 - 1) * envelope_size;
10236
10237            // Zero reserved fields.
10238            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10239
10240            // Safety:
10241            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10242            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10243            //   envelope_size bytes, there is always sufficient room.
10244            fidl::encoding::encode_in_envelope_optional::<
10245                u64,
10246                fidl::encoding::DefaultFuchsiaResourceDialect,
10247            >(
10248                self.actual_hz.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10249                encoder,
10250                offset + cur_offset,
10251                depth,
10252            )?;
10253
10254            _prev_end_offset = cur_offset + envelope_size;
10255
10256            Ok(())
10257        }
10258    }
10259
10260    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10261        for PowerElementProviderSetClockLimitResponse
10262    {
10263        #[inline(always)]
10264        fn new_empty() -> Self {
10265            Self::default()
10266        }
10267
10268        unsafe fn decode(
10269            &mut self,
10270            decoder: &mut fidl::encoding::Decoder<
10271                '_,
10272                fidl::encoding::DefaultFuchsiaResourceDialect,
10273            >,
10274            offset: usize,
10275            mut depth: fidl::encoding::Depth,
10276        ) -> fidl::Result<()> {
10277            decoder.debug_check_bounds::<Self>(offset);
10278            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10279                None => return Err(fidl::Error::NotNullable),
10280                Some(len) => len,
10281            };
10282            // Calling decoder.out_of_line_offset(0) is not allowed.
10283            if len == 0 {
10284                return Ok(());
10285            };
10286            depth.increment()?;
10287            let envelope_size = 8;
10288            let bytes_len = len * envelope_size;
10289            let offset = decoder.out_of_line_offset(bytes_len)?;
10290            // Decode the envelope for each type.
10291            let mut _next_ordinal_to_read = 0;
10292            let mut next_offset = offset;
10293            let end_offset = offset + bytes_len;
10294            _next_ordinal_to_read += 1;
10295            if next_offset >= end_offset {
10296                return Ok(());
10297            }
10298
10299            // Decode unknown envelopes for gaps in ordinals.
10300            while _next_ordinal_to_read < 1 {
10301                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10302                _next_ordinal_to_read += 1;
10303                next_offset += envelope_size;
10304            }
10305
10306            let next_out_of_line = decoder.next_out_of_line();
10307            let handles_before = decoder.remaining_handles();
10308            if let Some((inlined, num_bytes, num_handles)) =
10309                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10310            {
10311                let member_inline_size = <fidl::encoding::HandleType<
10312                    fidl::EventPair,
10313                    { fidl::ObjectType::EVENTPAIR.into_raw() },
10314                    2147483648,
10315                > as fidl::encoding::TypeMarker>::inline_size(
10316                    decoder.context
10317                );
10318                if inlined != (member_inline_size <= 4) {
10319                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10320                }
10321                let inner_offset;
10322                let mut inner_depth = depth.clone();
10323                if inlined {
10324                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10325                    inner_offset = next_offset;
10326                } else {
10327                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10328                    inner_depth.increment()?;
10329                }
10330                let val_ref =
10331                self.handle.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
10332                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10333                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10334                {
10335                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10336                }
10337                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10338                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10339                }
10340            }
10341
10342            next_offset += envelope_size;
10343            _next_ordinal_to_read += 1;
10344            if next_offset >= end_offset {
10345                return Ok(());
10346            }
10347
10348            // Decode unknown envelopes for gaps in ordinals.
10349            while _next_ordinal_to_read < 2 {
10350                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10351                _next_ordinal_to_read += 1;
10352                next_offset += envelope_size;
10353            }
10354
10355            let next_out_of_line = decoder.next_out_of_line();
10356            let handles_before = decoder.remaining_handles();
10357            if let Some((inlined, num_bytes, num_handles)) =
10358                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10359            {
10360                let member_inline_size =
10361                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10362                if inlined != (member_inline_size <= 4) {
10363                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10364                }
10365                let inner_offset;
10366                let mut inner_depth = depth.clone();
10367                if inlined {
10368                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10369                    inner_offset = next_offset;
10370                } else {
10371                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10372                    inner_depth.increment()?;
10373                }
10374                let val_ref = self.actual_hz.get_or_insert_with(|| {
10375                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
10376                });
10377                fidl::decode!(
10378                    u64,
10379                    fidl::encoding::DefaultFuchsiaResourceDialect,
10380                    val_ref,
10381                    decoder,
10382                    inner_offset,
10383                    inner_depth
10384                )?;
10385                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10386                {
10387                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10388                }
10389                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10390                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10391                }
10392            }
10393
10394            next_offset += envelope_size;
10395
10396            // Decode the remaining unknown envelopes.
10397            while next_offset < end_offset {
10398                _next_ordinal_to_read += 1;
10399                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10400                next_offset += envelope_size;
10401            }
10402
10403            Ok(())
10404        }
10405    }
10406
10407    impl PowerGoal {
10408        #[inline(always)]
10409        fn max_ordinal_present(&self) -> u64 {
10410            if let Some(_) = self.token {
10411                return 2;
10412            }
10413            if let Some(_) = self.type_ {
10414                return 1;
10415            }
10416            0
10417        }
10418    }
10419
10420    impl fidl::encoding::ResourceTypeMarker for PowerGoal {
10421        type Borrowed<'a> = &'a mut Self;
10422        fn take_or_borrow<'a>(
10423            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10424        ) -> Self::Borrowed<'a> {
10425            value
10426        }
10427    }
10428
10429    unsafe impl fidl::encoding::TypeMarker for PowerGoal {
10430        type Owned = Self;
10431
10432        #[inline(always)]
10433        fn inline_align(_context: fidl::encoding::Context) -> usize {
10434            8
10435        }
10436
10437        #[inline(always)]
10438        fn inline_size(_context: fidl::encoding::Context) -> usize {
10439            16
10440        }
10441    }
10442
10443    unsafe impl fidl::encoding::Encode<PowerGoal, fidl::encoding::DefaultFuchsiaResourceDialect>
10444        for &mut PowerGoal
10445    {
10446        unsafe fn encode(
10447            self,
10448            encoder: &mut fidl::encoding::Encoder<
10449                '_,
10450                fidl::encoding::DefaultFuchsiaResourceDialect,
10451            >,
10452            offset: usize,
10453            mut depth: fidl::encoding::Depth,
10454        ) -> fidl::Result<()> {
10455            encoder.debug_check_bounds::<PowerGoal>(offset);
10456            // Vector header
10457            let max_ordinal: u64 = self.max_ordinal_present();
10458            encoder.write_num(max_ordinal, offset);
10459            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10460            // Calling encoder.out_of_line_offset(0) is not allowed.
10461            if max_ordinal == 0 {
10462                return Ok(());
10463            }
10464            depth.increment()?;
10465            let envelope_size = 8;
10466            let bytes_len = max_ordinal as usize * envelope_size;
10467            #[allow(unused_variables)]
10468            let offset = encoder.out_of_line_offset(bytes_len);
10469            let mut _prev_end_offset: usize = 0;
10470            if 1 > max_ordinal {
10471                return Ok(());
10472            }
10473
10474            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10475            // are envelope_size bytes.
10476            let cur_offset: usize = (1 - 1) * envelope_size;
10477
10478            // Zero reserved fields.
10479            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10480
10481            // Safety:
10482            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10483            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10484            //   envelope_size bytes, there is always sufficient room.
10485            fidl::encoding::encode_in_envelope_optional::<
10486                PowerGoalType,
10487                fidl::encoding::DefaultFuchsiaResourceDialect,
10488            >(
10489                self.type_.as_ref().map(<PowerGoalType as fidl::encoding::ValueTypeMarker>::borrow),
10490                encoder,
10491                offset + cur_offset,
10492                depth,
10493            )?;
10494
10495            _prev_end_offset = cur_offset + envelope_size;
10496            if 2 > max_ordinal {
10497                return Ok(());
10498            }
10499
10500            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10501            // are envelope_size bytes.
10502            let cur_offset: usize = (2 - 1) * envelope_size;
10503
10504            // Zero reserved fields.
10505            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10506
10507            // Safety:
10508            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10509            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10510            //   envelope_size bytes, there is always sufficient room.
10511            fidl::encoding::encode_in_envelope_optional::<
10512                fidl::encoding::HandleType<
10513                    fidl::Event,
10514                    { fidl::ObjectType::EVENT.into_raw() },
10515                    2147483648,
10516                >,
10517                fidl::encoding::DefaultFuchsiaResourceDialect,
10518            >(
10519                self.token.as_mut().map(
10520                    <fidl::encoding::HandleType<
10521                        fidl::Event,
10522                        { fidl::ObjectType::EVENT.into_raw() },
10523                        2147483648,
10524                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10525                ),
10526                encoder,
10527                offset + cur_offset,
10528                depth,
10529            )?;
10530
10531            _prev_end_offset = cur_offset + envelope_size;
10532
10533            Ok(())
10534        }
10535    }
10536
10537    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PowerGoal {
10538        #[inline(always)]
10539        fn new_empty() -> Self {
10540            Self::default()
10541        }
10542
10543        unsafe fn decode(
10544            &mut self,
10545            decoder: &mut fidl::encoding::Decoder<
10546                '_,
10547                fidl::encoding::DefaultFuchsiaResourceDialect,
10548            >,
10549            offset: usize,
10550            mut depth: fidl::encoding::Depth,
10551        ) -> fidl::Result<()> {
10552            decoder.debug_check_bounds::<Self>(offset);
10553            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10554                None => return Err(fidl::Error::NotNullable),
10555                Some(len) => len,
10556            };
10557            // Calling decoder.out_of_line_offset(0) is not allowed.
10558            if len == 0 {
10559                return Ok(());
10560            };
10561            depth.increment()?;
10562            let envelope_size = 8;
10563            let bytes_len = len * envelope_size;
10564            let offset = decoder.out_of_line_offset(bytes_len)?;
10565            // Decode the envelope for each type.
10566            let mut _next_ordinal_to_read = 0;
10567            let mut next_offset = offset;
10568            let end_offset = offset + bytes_len;
10569            _next_ordinal_to_read += 1;
10570            if next_offset >= end_offset {
10571                return Ok(());
10572            }
10573
10574            // Decode unknown envelopes for gaps in ordinals.
10575            while _next_ordinal_to_read < 1 {
10576                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10577                _next_ordinal_to_read += 1;
10578                next_offset += envelope_size;
10579            }
10580
10581            let next_out_of_line = decoder.next_out_of_line();
10582            let handles_before = decoder.remaining_handles();
10583            if let Some((inlined, num_bytes, num_handles)) =
10584                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10585            {
10586                let member_inline_size =
10587                    <PowerGoalType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10588                if inlined != (member_inline_size <= 4) {
10589                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10590                }
10591                let inner_offset;
10592                let mut inner_depth = depth.clone();
10593                if inlined {
10594                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10595                    inner_offset = next_offset;
10596                } else {
10597                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10598                    inner_depth.increment()?;
10599                }
10600                let val_ref = self.type_.get_or_insert_with(|| {
10601                    fidl::new_empty!(PowerGoalType, fidl::encoding::DefaultFuchsiaResourceDialect)
10602                });
10603                fidl::decode!(
10604                    PowerGoalType,
10605                    fidl::encoding::DefaultFuchsiaResourceDialect,
10606                    val_ref,
10607                    decoder,
10608                    inner_offset,
10609                    inner_depth
10610                )?;
10611                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10612                {
10613                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10614                }
10615                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10616                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10617                }
10618            }
10619
10620            next_offset += envelope_size;
10621            _next_ordinal_to_read += 1;
10622            if next_offset >= end_offset {
10623                return Ok(());
10624            }
10625
10626            // Decode unknown envelopes for gaps in ordinals.
10627            while _next_ordinal_to_read < 2 {
10628                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10629                _next_ordinal_to_read += 1;
10630                next_offset += envelope_size;
10631            }
10632
10633            let next_out_of_line = decoder.next_out_of_line();
10634            let handles_before = decoder.remaining_handles();
10635            if let Some((inlined, num_bytes, num_handles)) =
10636                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10637            {
10638                let member_inline_size = <fidl::encoding::HandleType<
10639                    fidl::Event,
10640                    { fidl::ObjectType::EVENT.into_raw() },
10641                    2147483648,
10642                > as fidl::encoding::TypeMarker>::inline_size(
10643                    decoder.context
10644                );
10645                if inlined != (member_inline_size <= 4) {
10646                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10647                }
10648                let inner_offset;
10649                let mut inner_depth = depth.clone();
10650                if inlined {
10651                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10652                    inner_offset = next_offset;
10653                } else {
10654                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10655                    inner_depth.increment()?;
10656                }
10657                let val_ref =
10658                self.token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
10659                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10660                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10661                {
10662                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10663                }
10664                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10665                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10666                }
10667            }
10668
10669            next_offset += envelope_size;
10670
10671            // Decode the remaining unknown envelopes.
10672            while next_offset < end_offset {
10673                _next_ordinal_to_read += 1;
10674                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10675                next_offset += envelope_size;
10676            }
10677
10678            Ok(())
10679        }
10680    }
10681
10682    impl PrimaryImportObjectRequest {
10683        #[inline(always)]
10684        fn max_ordinal_present(&self) -> u64 {
10685            if let Some(_) = self.flags {
10686                return 4;
10687            }
10688            if let Some(_) = self.object_id {
10689                return 3;
10690            }
10691            if let Some(_) = self.object_type {
10692                return 2;
10693            }
10694            if let Some(_) = self.object {
10695                return 1;
10696            }
10697            0
10698        }
10699    }
10700
10701    impl fidl::encoding::ResourceTypeMarker for PrimaryImportObjectRequest {
10702        type Borrowed<'a> = &'a mut Self;
10703        fn take_or_borrow<'a>(
10704            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10705        ) -> Self::Borrowed<'a> {
10706            value
10707        }
10708    }
10709
10710    unsafe impl fidl::encoding::TypeMarker for PrimaryImportObjectRequest {
10711        type Owned = Self;
10712
10713        #[inline(always)]
10714        fn inline_align(_context: fidl::encoding::Context) -> usize {
10715            8
10716        }
10717
10718        #[inline(always)]
10719        fn inline_size(_context: fidl::encoding::Context) -> usize {
10720            16
10721        }
10722    }
10723
10724    unsafe impl
10725        fidl::encoding::Encode<
10726            PrimaryImportObjectRequest,
10727            fidl::encoding::DefaultFuchsiaResourceDialect,
10728        > for &mut PrimaryImportObjectRequest
10729    {
10730        unsafe fn encode(
10731            self,
10732            encoder: &mut fidl::encoding::Encoder<
10733                '_,
10734                fidl::encoding::DefaultFuchsiaResourceDialect,
10735            >,
10736            offset: usize,
10737            mut depth: fidl::encoding::Depth,
10738        ) -> fidl::Result<()> {
10739            encoder.debug_check_bounds::<PrimaryImportObjectRequest>(offset);
10740            // Vector header
10741            let max_ordinal: u64 = self.max_ordinal_present();
10742            encoder.write_num(max_ordinal, offset);
10743            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10744            // Calling encoder.out_of_line_offset(0) is not allowed.
10745            if max_ordinal == 0 {
10746                return Ok(());
10747            }
10748            depth.increment()?;
10749            let envelope_size = 8;
10750            let bytes_len = max_ordinal as usize * envelope_size;
10751            #[allow(unused_variables)]
10752            let offset = encoder.out_of_line_offset(bytes_len);
10753            let mut _prev_end_offset: usize = 0;
10754            if 1 > max_ordinal {
10755                return Ok(());
10756            }
10757
10758            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10759            // are envelope_size bytes.
10760            let cur_offset: usize = (1 - 1) * envelope_size;
10761
10762            // Zero reserved fields.
10763            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10764
10765            // Safety:
10766            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10767            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10768            //   envelope_size bytes, there is always sufficient room.
10769            fidl::encoding::encode_in_envelope_optional::<
10770                Object,
10771                fidl::encoding::DefaultFuchsiaResourceDialect,
10772            >(
10773                self.object
10774                    .as_mut()
10775                    .map(<Object as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10776                encoder,
10777                offset + cur_offset,
10778                depth,
10779            )?;
10780
10781            _prev_end_offset = cur_offset + envelope_size;
10782            if 2 > max_ordinal {
10783                return Ok(());
10784            }
10785
10786            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10787            // are envelope_size bytes.
10788            let cur_offset: usize = (2 - 1) * envelope_size;
10789
10790            // Zero reserved fields.
10791            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10792
10793            // Safety:
10794            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10795            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10796            //   envelope_size bytes, there is always sufficient room.
10797            fidl::encoding::encode_in_envelope_optional::<
10798                ObjectType,
10799                fidl::encoding::DefaultFuchsiaResourceDialect,
10800            >(
10801                self.object_type
10802                    .as_ref()
10803                    .map(<ObjectType as fidl::encoding::ValueTypeMarker>::borrow),
10804                encoder,
10805                offset + cur_offset,
10806                depth,
10807            )?;
10808
10809            _prev_end_offset = cur_offset + envelope_size;
10810            if 3 > max_ordinal {
10811                return Ok(());
10812            }
10813
10814            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10815            // are envelope_size bytes.
10816            let cur_offset: usize = (3 - 1) * envelope_size;
10817
10818            // Zero reserved fields.
10819            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10820
10821            // Safety:
10822            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10823            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10824            //   envelope_size bytes, there is always sufficient room.
10825            fidl::encoding::encode_in_envelope_optional::<
10826                u64,
10827                fidl::encoding::DefaultFuchsiaResourceDialect,
10828            >(
10829                self.object_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
10830                encoder,
10831                offset + cur_offset,
10832                depth,
10833            )?;
10834
10835            _prev_end_offset = cur_offset + envelope_size;
10836            if 4 > max_ordinal {
10837                return Ok(());
10838            }
10839
10840            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10841            // are envelope_size bytes.
10842            let cur_offset: usize = (4 - 1) * envelope_size;
10843
10844            // Zero reserved fields.
10845            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10846
10847            // Safety:
10848            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10849            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10850            //   envelope_size bytes, there is always sufficient room.
10851            fidl::encoding::encode_in_envelope_optional::<
10852                ImportFlags,
10853                fidl::encoding::DefaultFuchsiaResourceDialect,
10854            >(
10855                self.flags.as_ref().map(<ImportFlags as fidl::encoding::ValueTypeMarker>::borrow),
10856                encoder,
10857                offset + cur_offset,
10858                depth,
10859            )?;
10860
10861            _prev_end_offset = cur_offset + envelope_size;
10862
10863            Ok(())
10864        }
10865    }
10866
10867    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10868        for PrimaryImportObjectRequest
10869    {
10870        #[inline(always)]
10871        fn new_empty() -> Self {
10872            Self::default()
10873        }
10874
10875        unsafe fn decode(
10876            &mut self,
10877            decoder: &mut fidl::encoding::Decoder<
10878                '_,
10879                fidl::encoding::DefaultFuchsiaResourceDialect,
10880            >,
10881            offset: usize,
10882            mut depth: fidl::encoding::Depth,
10883        ) -> fidl::Result<()> {
10884            decoder.debug_check_bounds::<Self>(offset);
10885            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10886                None => return Err(fidl::Error::NotNullable),
10887                Some(len) => len,
10888            };
10889            // Calling decoder.out_of_line_offset(0) is not allowed.
10890            if len == 0 {
10891                return Ok(());
10892            };
10893            depth.increment()?;
10894            let envelope_size = 8;
10895            let bytes_len = len * envelope_size;
10896            let offset = decoder.out_of_line_offset(bytes_len)?;
10897            // Decode the envelope for each type.
10898            let mut _next_ordinal_to_read = 0;
10899            let mut next_offset = offset;
10900            let end_offset = offset + bytes_len;
10901            _next_ordinal_to_read += 1;
10902            if next_offset >= end_offset {
10903                return Ok(());
10904            }
10905
10906            // Decode unknown envelopes for gaps in ordinals.
10907            while _next_ordinal_to_read < 1 {
10908                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10909                _next_ordinal_to_read += 1;
10910                next_offset += envelope_size;
10911            }
10912
10913            let next_out_of_line = decoder.next_out_of_line();
10914            let handles_before = decoder.remaining_handles();
10915            if let Some((inlined, num_bytes, num_handles)) =
10916                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10917            {
10918                let member_inline_size =
10919                    <Object as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10920                if inlined != (member_inline_size <= 4) {
10921                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10922                }
10923                let inner_offset;
10924                let mut inner_depth = depth.clone();
10925                if inlined {
10926                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10927                    inner_offset = next_offset;
10928                } else {
10929                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10930                    inner_depth.increment()?;
10931                }
10932                let val_ref = self.object.get_or_insert_with(|| {
10933                    fidl::new_empty!(Object, fidl::encoding::DefaultFuchsiaResourceDialect)
10934                });
10935                fidl::decode!(
10936                    Object,
10937                    fidl::encoding::DefaultFuchsiaResourceDialect,
10938                    val_ref,
10939                    decoder,
10940                    inner_offset,
10941                    inner_depth
10942                )?;
10943                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10944                {
10945                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10946                }
10947                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10948                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10949                }
10950            }
10951
10952            next_offset += envelope_size;
10953            _next_ordinal_to_read += 1;
10954            if next_offset >= end_offset {
10955                return Ok(());
10956            }
10957
10958            // Decode unknown envelopes for gaps in ordinals.
10959            while _next_ordinal_to_read < 2 {
10960                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10961                _next_ordinal_to_read += 1;
10962                next_offset += envelope_size;
10963            }
10964
10965            let next_out_of_line = decoder.next_out_of_line();
10966            let handles_before = decoder.remaining_handles();
10967            if let Some((inlined, num_bytes, num_handles)) =
10968                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10969            {
10970                let member_inline_size =
10971                    <ObjectType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10972                if inlined != (member_inline_size <= 4) {
10973                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10974                }
10975                let inner_offset;
10976                let mut inner_depth = depth.clone();
10977                if inlined {
10978                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10979                    inner_offset = next_offset;
10980                } else {
10981                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10982                    inner_depth.increment()?;
10983                }
10984                let val_ref = self.object_type.get_or_insert_with(|| {
10985                    fidl::new_empty!(ObjectType, fidl::encoding::DefaultFuchsiaResourceDialect)
10986                });
10987                fidl::decode!(
10988                    ObjectType,
10989                    fidl::encoding::DefaultFuchsiaResourceDialect,
10990                    val_ref,
10991                    decoder,
10992                    inner_offset,
10993                    inner_depth
10994                )?;
10995                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10996                {
10997                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10998                }
10999                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11000                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11001                }
11002            }
11003
11004            next_offset += envelope_size;
11005            _next_ordinal_to_read += 1;
11006            if next_offset >= end_offset {
11007                return Ok(());
11008            }
11009
11010            // Decode unknown envelopes for gaps in ordinals.
11011            while _next_ordinal_to_read < 3 {
11012                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11013                _next_ordinal_to_read += 1;
11014                next_offset += envelope_size;
11015            }
11016
11017            let next_out_of_line = decoder.next_out_of_line();
11018            let handles_before = decoder.remaining_handles();
11019            if let Some((inlined, num_bytes, num_handles)) =
11020                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11021            {
11022                let member_inline_size =
11023                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11024                if inlined != (member_inline_size <= 4) {
11025                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11026                }
11027                let inner_offset;
11028                let mut inner_depth = depth.clone();
11029                if inlined {
11030                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11031                    inner_offset = next_offset;
11032                } else {
11033                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11034                    inner_depth.increment()?;
11035                }
11036                let val_ref = self.object_id.get_or_insert_with(|| {
11037                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
11038                });
11039                fidl::decode!(
11040                    u64,
11041                    fidl::encoding::DefaultFuchsiaResourceDialect,
11042                    val_ref,
11043                    decoder,
11044                    inner_offset,
11045                    inner_depth
11046                )?;
11047                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11048                {
11049                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11050                }
11051                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11052                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11053                }
11054            }
11055
11056            next_offset += envelope_size;
11057            _next_ordinal_to_read += 1;
11058            if next_offset >= end_offset {
11059                return Ok(());
11060            }
11061
11062            // Decode unknown envelopes for gaps in ordinals.
11063            while _next_ordinal_to_read < 4 {
11064                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11065                _next_ordinal_to_read += 1;
11066                next_offset += envelope_size;
11067            }
11068
11069            let next_out_of_line = decoder.next_out_of_line();
11070            let handles_before = decoder.remaining_handles();
11071            if let Some((inlined, num_bytes, num_handles)) =
11072                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11073            {
11074                let member_inline_size =
11075                    <ImportFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11076                if inlined != (member_inline_size <= 4) {
11077                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11078                }
11079                let inner_offset;
11080                let mut inner_depth = depth.clone();
11081                if inlined {
11082                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11083                    inner_offset = next_offset;
11084                } else {
11085                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11086                    inner_depth.increment()?;
11087                }
11088                let val_ref = self.flags.get_or_insert_with(|| {
11089                    fidl::new_empty!(ImportFlags, fidl::encoding::DefaultFuchsiaResourceDialect)
11090                });
11091                fidl::decode!(
11092                    ImportFlags,
11093                    fidl::encoding::DefaultFuchsiaResourceDialect,
11094                    val_ref,
11095                    decoder,
11096                    inner_offset,
11097                    inner_depth
11098                )?;
11099                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11100                {
11101                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11102                }
11103                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11104                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11105                }
11106            }
11107
11108            next_offset += envelope_size;
11109
11110            // Decode the remaining unknown envelopes.
11111            while next_offset < end_offset {
11112                _next_ordinal_to_read += 1;
11113                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11114                next_offset += envelope_size;
11115            }
11116
11117            Ok(())
11118        }
11119    }
11120
11121    impl fidl::encoding::ResourceTypeMarker for DeviceQueryResponse {
11122        type Borrowed<'a> = &'a mut Self;
11123        fn take_or_borrow<'a>(
11124            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11125        ) -> Self::Borrowed<'a> {
11126            value
11127        }
11128    }
11129
11130    unsafe impl fidl::encoding::TypeMarker for DeviceQueryResponse {
11131        type Owned = Self;
11132
11133        #[inline(always)]
11134        fn inline_align(_context: fidl::encoding::Context) -> usize {
11135            8
11136        }
11137
11138        #[inline(always)]
11139        fn inline_size(_context: fidl::encoding::Context) -> usize {
11140            16
11141        }
11142    }
11143
11144    unsafe impl
11145        fidl::encoding::Encode<DeviceQueryResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
11146        for &mut DeviceQueryResponse
11147    {
11148        #[inline]
11149        unsafe fn encode(
11150            self,
11151            encoder: &mut fidl::encoding::Encoder<
11152                '_,
11153                fidl::encoding::DefaultFuchsiaResourceDialect,
11154            >,
11155            offset: usize,
11156            _depth: fidl::encoding::Depth,
11157        ) -> fidl::Result<()> {
11158            encoder.debug_check_bounds::<DeviceQueryResponse>(offset);
11159            encoder.write_num::<u64>(self.ordinal(), offset);
11160            match self {
11161                DeviceQueryResponse::SimpleResult(ref val) => fidl::encoding::encode_in_envelope::<
11162                    u64,
11163                    fidl::encoding::DefaultFuchsiaResourceDialect,
11164                >(
11165                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
11166                    encoder,
11167                    offset + 8,
11168                    _depth,
11169                ),
11170                DeviceQueryResponse::BufferResult(ref mut val) => {
11171                    fidl::encoding::encode_in_envelope::<
11172                        fidl::encoding::HandleType<
11173                            fidl::Vmo,
11174                            { fidl::ObjectType::VMO.into_raw() },
11175                            2147483648,
11176                        >,
11177                        fidl::encoding::DefaultFuchsiaResourceDialect,
11178                    >(
11179                        <fidl::encoding::HandleType<
11180                            fidl::Vmo,
11181                            { fidl::ObjectType::VMO.into_raw() },
11182                            2147483648,
11183                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11184                            val
11185                        ),
11186                        encoder,
11187                        offset + 8,
11188                        _depth,
11189                    )
11190                }
11191            }
11192        }
11193    }
11194
11195    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11196        for DeviceQueryResponse
11197    {
11198        #[inline(always)]
11199        fn new_empty() -> Self {
11200            Self::SimpleResult(fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect))
11201        }
11202
11203        #[inline]
11204        unsafe fn decode(
11205            &mut self,
11206            decoder: &mut fidl::encoding::Decoder<
11207                '_,
11208                fidl::encoding::DefaultFuchsiaResourceDialect,
11209            >,
11210            offset: usize,
11211            mut depth: fidl::encoding::Depth,
11212        ) -> fidl::Result<()> {
11213            decoder.debug_check_bounds::<Self>(offset);
11214            #[allow(unused_variables)]
11215            let next_out_of_line = decoder.next_out_of_line();
11216            let handles_before = decoder.remaining_handles();
11217            let (ordinal, inlined, num_bytes, num_handles) =
11218                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
11219
11220            let member_inline_size = match ordinal {
11221                1 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11222                2 => <fidl::encoding::HandleType<
11223                    fidl::Vmo,
11224                    { fidl::ObjectType::VMO.into_raw() },
11225                    2147483648,
11226                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11227                _ => return Err(fidl::Error::UnknownUnionTag),
11228            };
11229
11230            if inlined != (member_inline_size <= 4) {
11231                return Err(fidl::Error::InvalidInlineBitInEnvelope);
11232            }
11233            let _inner_offset;
11234            if inlined {
11235                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
11236                _inner_offset = offset + 8;
11237            } else {
11238                depth.increment()?;
11239                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11240            }
11241            match ordinal {
11242                1 => {
11243                    #[allow(irrefutable_let_patterns)]
11244                    if let DeviceQueryResponse::SimpleResult(_) = self {
11245                        // Do nothing, read the value into the object
11246                    } else {
11247                        // Initialize `self` to the right variant
11248                        *self = DeviceQueryResponse::SimpleResult(fidl::new_empty!(
11249                            u64,
11250                            fidl::encoding::DefaultFuchsiaResourceDialect
11251                        ));
11252                    }
11253                    #[allow(irrefutable_let_patterns)]
11254                    if let DeviceQueryResponse::SimpleResult(ref mut val) = self {
11255                        fidl::decode!(
11256                            u64,
11257                            fidl::encoding::DefaultFuchsiaResourceDialect,
11258                            val,
11259                            decoder,
11260                            _inner_offset,
11261                            depth
11262                        )?;
11263                    } else {
11264                        unreachable!()
11265                    }
11266                }
11267                2 => {
11268                    #[allow(irrefutable_let_patterns)]
11269                    if let DeviceQueryResponse::BufferResult(_) = self {
11270                        // Do nothing, read the value into the object
11271                    } else {
11272                        // Initialize `self` to the right variant
11273                        *self = DeviceQueryResponse::BufferResult(
11274                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11275                        );
11276                    }
11277                    #[allow(irrefutable_let_patterns)]
11278                    if let DeviceQueryResponse::BufferResult(ref mut val) = self {
11279                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11280                    } else {
11281                        unreachable!()
11282                    }
11283                }
11284                ordinal => panic!("unexpected ordinal {:?}", ordinal),
11285            }
11286            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
11287                return Err(fidl::Error::InvalidNumBytesInEnvelope);
11288            }
11289            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11290                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11291            }
11292            Ok(())
11293        }
11294    }
11295
11296    impl fidl::encoding::ResourceTypeMarker for Object {
11297        type Borrowed<'a> = &'a mut Self;
11298        fn take_or_borrow<'a>(
11299            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11300        ) -> Self::Borrowed<'a> {
11301            value
11302        }
11303    }
11304
11305    unsafe impl fidl::encoding::TypeMarker for Object {
11306        type Owned = Self;
11307
11308        #[inline(always)]
11309        fn inline_align(_context: fidl::encoding::Context) -> usize {
11310            8
11311        }
11312
11313        #[inline(always)]
11314        fn inline_size(_context: fidl::encoding::Context) -> usize {
11315            16
11316        }
11317    }
11318
11319    unsafe impl fidl::encoding::Encode<Object, fidl::encoding::DefaultFuchsiaResourceDialect>
11320        for &mut Object
11321    {
11322        #[inline]
11323        unsafe fn encode(
11324            self,
11325            encoder: &mut fidl::encoding::Encoder<
11326                '_,
11327                fidl::encoding::DefaultFuchsiaResourceDialect,
11328            >,
11329            offset: usize,
11330            _depth: fidl::encoding::Depth,
11331        ) -> fidl::Result<()> {
11332            encoder.debug_check_bounds::<Object>(offset);
11333            encoder.write_num::<u64>(self.ordinal(), offset);
11334            match self {
11335                Object::Semaphore(ref mut val) => fidl::encoding::encode_in_envelope::<
11336                    fidl::encoding::HandleType<
11337                        fidl::Event,
11338                        { fidl::ObjectType::EVENT.into_raw() },
11339                        2147483648,
11340                    >,
11341                    fidl::encoding::DefaultFuchsiaResourceDialect,
11342                >(
11343                    <fidl::encoding::HandleType<
11344                        fidl::Event,
11345                        { fidl::ObjectType::EVENT.into_raw() },
11346                        2147483648,
11347                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11348                        val
11349                    ),
11350                    encoder,
11351                    offset + 8,
11352                    _depth,
11353                ),
11354                Object::Buffer(ref mut val) => fidl::encoding::encode_in_envelope::<
11355                    fidl::encoding::HandleType<
11356                        fidl::Vmo,
11357                        { fidl::ObjectType::VMO.into_raw() },
11358                        2147483648,
11359                    >,
11360                    fidl::encoding::DefaultFuchsiaResourceDialect,
11361                >(
11362                    <fidl::encoding::HandleType<
11363                        fidl::Vmo,
11364                        { fidl::ObjectType::VMO.into_raw() },
11365                        2147483648,
11366                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11367                        val
11368                    ),
11369                    encoder,
11370                    offset + 8,
11371                    _depth,
11372                ),
11373                Object::VmoSemaphore(ref mut val) => fidl::encoding::encode_in_envelope::<
11374                    fidl::encoding::HandleType<
11375                        fidl::Vmo,
11376                        { fidl::ObjectType::VMO.into_raw() },
11377                        2147483648,
11378                    >,
11379                    fidl::encoding::DefaultFuchsiaResourceDialect,
11380                >(
11381                    <fidl::encoding::HandleType<
11382                        fidl::Vmo,
11383                        { fidl::ObjectType::VMO.into_raw() },
11384                        2147483648,
11385                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11386                        val
11387                    ),
11388                    encoder,
11389                    offset + 8,
11390                    _depth,
11391                ),
11392                Object::CounterSemaphore(ref mut val) => fidl::encoding::encode_in_envelope::<
11393                    fidl::encoding::HandleType<
11394                        fidl::Counter,
11395                        { fidl::ObjectType::COUNTER.into_raw() },
11396                        2147483648,
11397                    >,
11398                    fidl::encoding::DefaultFuchsiaResourceDialect,
11399                >(
11400                    <fidl::encoding::HandleType<
11401                        fidl::Counter,
11402                        { fidl::ObjectType::COUNTER.into_raw() },
11403                        2147483648,
11404                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11405                        val
11406                    ),
11407                    encoder,
11408                    offset + 8,
11409                    _depth,
11410                ),
11411                Object::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
11412            }
11413        }
11414    }
11415
11416    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Object {
11417        #[inline(always)]
11418        fn new_empty() -> Self {
11419            Self::__SourceBreaking { unknown_ordinal: 0 }
11420        }
11421
11422        #[inline]
11423        unsafe fn decode(
11424            &mut self,
11425            decoder: &mut fidl::encoding::Decoder<
11426                '_,
11427                fidl::encoding::DefaultFuchsiaResourceDialect,
11428            >,
11429            offset: usize,
11430            mut depth: fidl::encoding::Depth,
11431        ) -> fidl::Result<()> {
11432            decoder.debug_check_bounds::<Self>(offset);
11433            #[allow(unused_variables)]
11434            let next_out_of_line = decoder.next_out_of_line();
11435            let handles_before = decoder.remaining_handles();
11436            let (ordinal, inlined, num_bytes, num_handles) =
11437                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
11438
11439            let member_inline_size = match ordinal {
11440                1 => <fidl::encoding::HandleType<
11441                    fidl::Event,
11442                    { fidl::ObjectType::EVENT.into_raw() },
11443                    2147483648,
11444                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11445                2 => <fidl::encoding::HandleType<
11446                    fidl::Vmo,
11447                    { fidl::ObjectType::VMO.into_raw() },
11448                    2147483648,
11449                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11450                3 => <fidl::encoding::HandleType<
11451                    fidl::Vmo,
11452                    { fidl::ObjectType::VMO.into_raw() },
11453                    2147483648,
11454                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11455                4 => <fidl::encoding::HandleType<
11456                    fidl::Counter,
11457                    { fidl::ObjectType::COUNTER.into_raw() },
11458                    2147483648,
11459                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
11460                0 => return Err(fidl::Error::UnknownUnionTag),
11461                _ => num_bytes as usize,
11462            };
11463
11464            if inlined != (member_inline_size <= 4) {
11465                return Err(fidl::Error::InvalidInlineBitInEnvelope);
11466            }
11467            let _inner_offset;
11468            if inlined {
11469                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
11470                _inner_offset = offset + 8;
11471            } else {
11472                depth.increment()?;
11473                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11474            }
11475            match ordinal {
11476                1 => {
11477                    #[allow(irrefutable_let_patterns)]
11478                    if let Object::Semaphore(_) = self {
11479                        // Do nothing, read the value into the object
11480                    } else {
11481                        // Initialize `self` to the right variant
11482                        *self = Object::Semaphore(
11483                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11484                        );
11485                    }
11486                    #[allow(irrefutable_let_patterns)]
11487                    if let Object::Semaphore(ref mut val) = self {
11488                        fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11489                    } else {
11490                        unreachable!()
11491                    }
11492                }
11493                2 => {
11494                    #[allow(irrefutable_let_patterns)]
11495                    if let Object::Buffer(_) = self {
11496                        // Do nothing, read the value into the object
11497                    } else {
11498                        // Initialize `self` to the right variant
11499                        *self = Object::Buffer(
11500                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11501                        );
11502                    }
11503                    #[allow(irrefutable_let_patterns)]
11504                    if let Object::Buffer(ref mut val) = self {
11505                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11506                    } else {
11507                        unreachable!()
11508                    }
11509                }
11510                3 => {
11511                    #[allow(irrefutable_let_patterns)]
11512                    if let Object::VmoSemaphore(_) = self {
11513                        // Do nothing, read the value into the object
11514                    } else {
11515                        // Initialize `self` to the right variant
11516                        *self = Object::VmoSemaphore(
11517                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11518                        );
11519                    }
11520                    #[allow(irrefutable_let_patterns)]
11521                    if let Object::VmoSemaphore(ref mut val) = self {
11522                        fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11523                    } else {
11524                        unreachable!()
11525                    }
11526                }
11527                4 => {
11528                    #[allow(irrefutable_let_patterns)]
11529                    if let Object::CounterSemaphore(_) = self {
11530                        // Do nothing, read the value into the object
11531                    } else {
11532                        // Initialize `self` to the right variant
11533                        *self = Object::CounterSemaphore(
11534                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Counter, { fidl::ObjectType::COUNTER.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
11535                        );
11536                    }
11537                    #[allow(irrefutable_let_patterns)]
11538                    if let Object::CounterSemaphore(ref mut val) = self {
11539                        fidl::decode!(fidl::encoding::HandleType<fidl::Counter, { fidl::ObjectType::COUNTER.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
11540                    } else {
11541                        unreachable!()
11542                    }
11543                }
11544                #[allow(deprecated)]
11545                ordinal => {
11546                    for _ in 0..num_handles {
11547                        decoder.drop_next_handle()?;
11548                    }
11549                    *self = Object::__SourceBreaking { unknown_ordinal: ordinal };
11550                }
11551            }
11552            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
11553                return Err(fidl::Error::InvalidNumBytesInEnvelope);
11554            }
11555            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11556                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11557            }
11558            Ok(())
11559        }
11560    }
11561}