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