fidl_fuchsia_gpu_magma/
fidl_fuchsia_gpu_magma.rs

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