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