Skip to main content

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