Skip to main content

fidl_fuchsia_hardware_spi/
fidl_fuchsia_hardware_spi.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_hardware_spi_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ControllerOpenSessionRequest {
16    pub session: fidl::endpoints::ServerEnd<DeviceMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for ControllerOpenSessionRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct TestConnectSpiLoopbackRequest {
26    pub server: fidl::endpoints::ServerEnd<DeviceMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for TestConnectSpiLoopbackRequest
31{
32}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub struct ControllerMarker;
36
37impl fidl::endpoints::ProtocolMarker for ControllerMarker {
38    type Proxy = ControllerProxy;
39    type RequestStream = ControllerRequestStream;
40    #[cfg(target_os = "fuchsia")]
41    type SynchronousProxy = ControllerSynchronousProxy;
42
43    const DEBUG_NAME: &'static str = "(anonymous) Controller";
44}
45
46pub trait ControllerProxyInterface: Send + Sync {
47    fn r#open_session(
48        &self,
49        session: fidl::endpoints::ServerEnd<DeviceMarker>,
50    ) -> Result<(), fidl::Error>;
51}
52#[derive(Debug)]
53#[cfg(target_os = "fuchsia")]
54pub struct ControllerSynchronousProxy {
55    client: fidl::client::sync::Client,
56}
57
58#[cfg(target_os = "fuchsia")]
59impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
60    type Proxy = ControllerProxy;
61    type Protocol = ControllerMarker;
62
63    fn from_channel(inner: fidl::Channel) -> Self {
64        Self::new(inner)
65    }
66
67    fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    fn as_channel(&self) -> &fidl::Channel {
72        self.client.as_channel()
73    }
74}
75
76#[cfg(target_os = "fuchsia")]
77impl ControllerSynchronousProxy {
78    pub fn new(channel: fidl::Channel) -> Self {
79        Self { client: fidl::client::sync::Client::new(channel) }
80    }
81
82    pub fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    /// Waits until an event arrives and returns it. It is safe for other
87    /// threads to make concurrent requests while waiting for an event.
88    pub fn wait_for_event(
89        &self,
90        deadline: zx::MonotonicInstant,
91    ) -> Result<ControllerEvent, fidl::Error> {
92        ControllerEvent::decode(self.client.wait_for_event::<ControllerMarker>(deadline)?)
93    }
94
95    /// Opens a new session on the device.
96    ///
97    /// At most one session is permitted at one time; the server end will be
98    /// closed with `ZX_ERR_ALREADY_BOUND` if a session already exists.
99    pub fn r#open_session(
100        &self,
101        mut session: fidl::endpoints::ServerEnd<DeviceMarker>,
102    ) -> Result<(), fidl::Error> {
103        self.client.send::<ControllerOpenSessionRequest>(
104            (session,),
105            0x19d861074d409b34,
106            fidl::encoding::DynamicFlags::empty(),
107        )
108    }
109}
110
111#[cfg(target_os = "fuchsia")]
112impl From<ControllerSynchronousProxy> for zx::NullableHandle {
113    fn from(value: ControllerSynchronousProxy) -> Self {
114        value.into_channel().into()
115    }
116}
117
118#[cfg(target_os = "fuchsia")]
119impl From<fidl::Channel> for ControllerSynchronousProxy {
120    fn from(value: fidl::Channel) -> Self {
121        Self::new(value)
122    }
123}
124
125#[cfg(target_os = "fuchsia")]
126impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
127    type Protocol = ControllerMarker;
128
129    fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
130        Self::new(value.into_channel())
131    }
132}
133
134#[derive(Debug, Clone)]
135pub struct ControllerProxy {
136    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
137}
138
139impl fidl::endpoints::Proxy for ControllerProxy {
140    type Protocol = ControllerMarker;
141
142    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
143        Self::new(inner)
144    }
145
146    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
147        self.client.into_channel().map_err(|client| Self { client })
148    }
149
150    fn as_channel(&self) -> &::fidl::AsyncChannel {
151        self.client.as_channel()
152    }
153}
154
155impl ControllerProxy {
156    /// Create a new Proxy for fuchsia.hardware.spi/Controller.
157    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
158        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
159        Self { client: fidl::client::Client::new(channel, protocol_name) }
160    }
161
162    /// Get a Stream of events from the remote end of the protocol.
163    ///
164    /// # Panics
165    ///
166    /// Panics if the event stream was already taken.
167    pub fn take_event_stream(&self) -> ControllerEventStream {
168        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
169    }
170
171    /// Opens a new session on the device.
172    ///
173    /// At most one session is permitted at one time; the server end will be
174    /// closed with `ZX_ERR_ALREADY_BOUND` if a session already exists.
175    pub fn r#open_session(
176        &self,
177        mut session: fidl::endpoints::ServerEnd<DeviceMarker>,
178    ) -> Result<(), fidl::Error> {
179        ControllerProxyInterface::r#open_session(self, session)
180    }
181}
182
183impl ControllerProxyInterface for ControllerProxy {
184    fn r#open_session(
185        &self,
186        mut session: fidl::endpoints::ServerEnd<DeviceMarker>,
187    ) -> Result<(), fidl::Error> {
188        self.client.send::<ControllerOpenSessionRequest>(
189            (session,),
190            0x19d861074d409b34,
191            fidl::encoding::DynamicFlags::empty(),
192        )
193    }
194}
195
196pub struct ControllerEventStream {
197    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
198}
199
200impl std::marker::Unpin for ControllerEventStream {}
201
202impl futures::stream::FusedStream for ControllerEventStream {
203    fn is_terminated(&self) -> bool {
204        self.event_receiver.is_terminated()
205    }
206}
207
208impl futures::Stream for ControllerEventStream {
209    type Item = Result<ControllerEvent, fidl::Error>;
210
211    fn poll_next(
212        mut self: std::pin::Pin<&mut Self>,
213        cx: &mut std::task::Context<'_>,
214    ) -> std::task::Poll<Option<Self::Item>> {
215        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
216            &mut self.event_receiver,
217            cx
218        )?) {
219            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
220            None => std::task::Poll::Ready(None),
221        }
222    }
223}
224
225#[derive(Debug)]
226pub enum ControllerEvent {}
227
228impl ControllerEvent {
229    /// Decodes a message buffer as a [`ControllerEvent`].
230    fn decode(
231        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
232    ) -> Result<ControllerEvent, fidl::Error> {
233        let (bytes, _handles) = buf.split_mut();
234        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
235        debug_assert_eq!(tx_header.tx_id, 0);
236        match tx_header.ordinal {
237            _ => Err(fidl::Error::UnknownOrdinal {
238                ordinal: tx_header.ordinal,
239                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
240            }),
241        }
242    }
243}
244
245/// A Stream of incoming requests for fuchsia.hardware.spi/Controller.
246pub struct ControllerRequestStream {
247    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
248    is_terminated: bool,
249}
250
251impl std::marker::Unpin for ControllerRequestStream {}
252
253impl futures::stream::FusedStream for ControllerRequestStream {
254    fn is_terminated(&self) -> bool {
255        self.is_terminated
256    }
257}
258
259impl fidl::endpoints::RequestStream for ControllerRequestStream {
260    type Protocol = ControllerMarker;
261    type ControlHandle = ControllerControlHandle;
262
263    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
264        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
265    }
266
267    fn control_handle(&self) -> Self::ControlHandle {
268        ControllerControlHandle { inner: self.inner.clone() }
269    }
270
271    fn into_inner(
272        self,
273    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
274    {
275        (self.inner, self.is_terminated)
276    }
277
278    fn from_inner(
279        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
280        is_terminated: bool,
281    ) -> Self {
282        Self { inner, is_terminated }
283    }
284}
285
286impl futures::Stream for ControllerRequestStream {
287    type Item = Result<ControllerRequest, fidl::Error>;
288
289    fn poll_next(
290        mut self: std::pin::Pin<&mut Self>,
291        cx: &mut std::task::Context<'_>,
292    ) -> std::task::Poll<Option<Self::Item>> {
293        let this = &mut *self;
294        if this.inner.check_shutdown(cx) {
295            this.is_terminated = true;
296            return std::task::Poll::Ready(None);
297        }
298        if this.is_terminated {
299            panic!("polled ControllerRequestStream after completion");
300        }
301        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
302            |bytes, handles| {
303                match this.inner.channel().read_etc(cx, bytes, handles) {
304                    std::task::Poll::Ready(Ok(())) => {}
305                    std::task::Poll::Pending => return std::task::Poll::Pending,
306                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
307                        this.is_terminated = true;
308                        return std::task::Poll::Ready(None);
309                    }
310                    std::task::Poll::Ready(Err(e)) => {
311                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
312                            e.into(),
313                        ))));
314                    }
315                }
316
317                // A message has been received from the channel
318                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
319
320                std::task::Poll::Ready(Some(match header.ordinal {
321                    0x19d861074d409b34 => {
322                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
323                        let mut req = fidl::new_empty!(
324                            ControllerOpenSessionRequest,
325                            fidl::encoding::DefaultFuchsiaResourceDialect
326                        );
327                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerOpenSessionRequest>(&header, _body_bytes, handles, &mut req)?;
328                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
329                        Ok(ControllerRequest::OpenSession { session: req.session, control_handle })
330                    }
331                    _ => Err(fidl::Error::UnknownOrdinal {
332                        ordinal: header.ordinal,
333                        protocol_name:
334                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
335                    }),
336                }))
337            },
338        )
339    }
340}
341
342#[derive(Debug)]
343pub enum ControllerRequest {
344    /// Opens a new session on the device.
345    ///
346    /// At most one session is permitted at one time; the server end will be
347    /// closed with `ZX_ERR_ALREADY_BOUND` if a session already exists.
348    OpenSession {
349        session: fidl::endpoints::ServerEnd<DeviceMarker>,
350        control_handle: ControllerControlHandle,
351    },
352}
353
354impl ControllerRequest {
355    #[allow(irrefutable_let_patterns)]
356    pub fn into_open_session(
357        self,
358    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, ControllerControlHandle)> {
359        if let ControllerRequest::OpenSession { session, control_handle } = self {
360            Some((session, control_handle))
361        } else {
362            None
363        }
364    }
365
366    /// Name of the method defined in FIDL
367    pub fn method_name(&self) -> &'static str {
368        match *self {
369            ControllerRequest::OpenSession { .. } => "open_session",
370        }
371    }
372}
373
374#[derive(Debug, Clone)]
375pub struct ControllerControlHandle {
376    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
377}
378
379impl ControllerControlHandle {
380    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
381        self.inner.shutdown_with_epitaph(status.into())
382    }
383}
384
385impl fidl::endpoints::ControlHandle for ControllerControlHandle {
386    fn shutdown(&self) {
387        self.inner.shutdown()
388    }
389
390    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
391        self.inner.shutdown_with_epitaph(status)
392    }
393
394    fn is_closed(&self) -> bool {
395        self.inner.channel().is_closed()
396    }
397    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
398        self.inner.channel().on_closed()
399    }
400
401    #[cfg(target_os = "fuchsia")]
402    fn signal_peer(
403        &self,
404        clear_mask: zx::Signals,
405        set_mask: zx::Signals,
406    ) -> Result<(), zx_status::Status> {
407        use fidl::Peered;
408        self.inner.channel().signal_peer(clear_mask, set_mask)
409    }
410}
411
412impl ControllerControlHandle {}
413
414#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
415pub struct DeviceMarker;
416
417impl fidl::endpoints::ProtocolMarker for DeviceMarker {
418    type Proxy = DeviceProxy;
419    type RequestStream = DeviceRequestStream;
420    #[cfg(target_os = "fuchsia")]
421    type SynchronousProxy = DeviceSynchronousProxy;
422
423    const DEBUG_NAME: &'static str = "fuchsia.hardware.spi.Device";
424}
425impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
426
427pub trait DeviceProxyInterface: Send + Sync {
428    type TransmitResponseFut: std::future::Future<
429            Output = Result<
430                fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitResult,
431                fidl::Error,
432            >,
433        > + Send;
434    fn r#transmit(
435        &self,
436        buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
437    ) -> Self::TransmitResponseFut;
438    type ReceiveResponseFut: std::future::Future<
439            Output = Result<
440                fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveResult,
441                fidl::Error,
442            >,
443        > + Send;
444    fn r#receive(
445        &self,
446        buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
447    ) -> Self::ReceiveResponseFut;
448    type ExchangeResponseFut: std::future::Future<
449            Output = Result<
450                fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeResult,
451                fidl::Error,
452            >,
453        > + Send;
454    fn r#exchange(
455        &self,
456        tx_buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
457        rx_buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
458    ) -> Self::ExchangeResponseFut;
459    type RegisterVmoResponseFut: std::future::Future<
460            Output = Result<
461                fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoResult,
462                fidl::Error,
463            >,
464        > + Send;
465    fn r#register_vmo(
466        &self,
467        vmo_id: u32,
468        vmo: fidl_fuchsia_mem::Range,
469        rights: fidl_fuchsia_hardware_sharedmemory::SharedVmoRight,
470    ) -> Self::RegisterVmoResponseFut;
471    type UnregisterVmoResponseFut: std::future::Future<
472            Output = Result<
473                fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResult,
474                fidl::Error,
475            >,
476        > + Send;
477    fn r#unregister_vmo(&self, vmo_id: u32) -> Self::UnregisterVmoResponseFut;
478    type TransmitVectorResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
479    fn r#transmit_vector(&self, data: &[u8]) -> Self::TransmitVectorResponseFut;
480    type ReceiveVectorResponseFut: std::future::Future<Output = Result<(i32, Vec<u8>), fidl::Error>>
481        + Send;
482    fn r#receive_vector(&self, size: u32) -> Self::ReceiveVectorResponseFut;
483    type ExchangeVectorResponseFut: std::future::Future<Output = Result<(i32, Vec<u8>), fidl::Error>>
484        + Send;
485    fn r#exchange_vector(&self, txdata: &[u8]) -> Self::ExchangeVectorResponseFut;
486    type CanAssertCsResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
487    fn r#can_assert_cs(&self) -> Self::CanAssertCsResponseFut;
488    type AssertCsResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
489    fn r#assert_cs(&self) -> Self::AssertCsResponseFut;
490    type DeassertCsResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
491    fn r#deassert_cs(&self) -> Self::DeassertCsResponseFut;
492}
493#[derive(Debug)]
494#[cfg(target_os = "fuchsia")]
495pub struct DeviceSynchronousProxy {
496    client: fidl::client::sync::Client,
497}
498
499#[cfg(target_os = "fuchsia")]
500impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
501    type Proxy = DeviceProxy;
502    type Protocol = DeviceMarker;
503
504    fn from_channel(inner: fidl::Channel) -> Self {
505        Self::new(inner)
506    }
507
508    fn into_channel(self) -> fidl::Channel {
509        self.client.into_channel()
510    }
511
512    fn as_channel(&self) -> &fidl::Channel {
513        self.client.as_channel()
514    }
515}
516
517#[cfg(target_os = "fuchsia")]
518impl DeviceSynchronousProxy {
519    pub fn new(channel: fidl::Channel) -> Self {
520        Self { client: fidl::client::sync::Client::new(channel) }
521    }
522
523    pub fn into_channel(self) -> fidl::Channel {
524        self.client.into_channel()
525    }
526
527    /// Waits until an event arrives and returns it. It is safe for other
528    /// threads to make concurrent requests while waiting for an event.
529    pub fn wait_for_event(
530        &self,
531        deadline: zx::MonotonicInstant,
532    ) -> Result<DeviceEvent, fidl::Error> {
533        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
534    }
535
536    /// Sends the data in buffer to the device.
537    pub fn r#transmit(
538        &self,
539        mut buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
540        ___deadline: zx::MonotonicInstant,
541    ) -> Result<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitResult, fidl::Error> {
542        let _response = self.client.send_query::<
543            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitRequest,
544            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
545            DeviceMarker,
546        >(
547            (buffer,),
548            0x791970e4c961b0bf,
549            fidl::encoding::DynamicFlags::empty(),
550            ___deadline,
551        )?;
552        Ok(_response.map(|x| x))
553    }
554
555    /// Receives data from the device into buffer.
556    pub fn r#receive(
557        &self,
558        mut buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
559        ___deadline: zx::MonotonicInstant,
560    ) -> Result<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveResult, fidl::Error> {
561        let _response = self.client.send_query::<
562            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveRequest,
563            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
564            DeviceMarker,
565        >(
566            (buffer,),
567            0x1c31986cc443db59,
568            fidl::encoding::DynamicFlags::empty(),
569            ___deadline,
570        )?;
571        Ok(_response.map(|x| x))
572    }
573
574    /// Simultaneously transmits and receives data. The size fields of tx_buffer and rx_buffer must
575    /// be the same.
576    pub fn r#exchange(
577        &self,
578        mut tx_buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
579        mut rx_buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
580        ___deadline: zx::MonotonicInstant,
581    ) -> Result<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeResult, fidl::Error> {
582        let _response = self.client.send_query::<
583            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeRequest,
584            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
585            DeviceMarker,
586        >(
587            (tx_buffer, rx_buffer,),
588            0x6ddad3b45d5deccc,
589            fidl::encoding::DynamicFlags::empty(),
590            ___deadline,
591        )?;
592        Ok(_response.map(|x| x))
593    }
594
595    /// Registers a VMO and transfers ownership to the driver.
596    /// vmo_id: The ID chosen by the client that will be used in operations on this VMO.
597    /// vmo: The handle, offset, and size of this VMO. IO operations on this VMO will be relative to
598    /// the offset and size specified here.
599    /// rights: A bit field of SharedVmoRight values indicating how this VMO may be used. Callers
600    /// should assume that the driver will map and/or pin the VMO using these rights.
601    pub fn r#register_vmo(
602        &self,
603        mut vmo_id: u32,
604        mut vmo: fidl_fuchsia_mem::Range,
605        mut rights: fidl_fuchsia_hardware_sharedmemory::SharedVmoRight,
606        ___deadline: zx::MonotonicInstant,
607    ) -> Result<fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoResult, fidl::Error>
608    {
609        let _response = self.client.send_query::<
610            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoRequest,
611            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
612            DeviceMarker,
613        >(
614            (vmo_id, &mut vmo, rights,),
615            0x31df51e1e6ea4a15,
616            fidl::encoding::DynamicFlags::empty(),
617            ___deadline,
618        )?;
619        Ok(_response.map(|x| x))
620    }
621
622    /// Unmaps and/or unpins the VMO and returns the handle to the caller.
623    pub fn r#unregister_vmo(
624        &self,
625        mut vmo_id: u32,
626        ___deadline: zx::MonotonicInstant,
627    ) -> Result<fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResult, fidl::Error>
628    {
629        let _response = self.client.send_query::<
630            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoRequest,
631            fidl::encoding::ResultType<fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResponse, i32>,
632            DeviceMarker,
633        >(
634            (vmo_id,),
635            0x1194e9b693827109,
636            fidl::encoding::DynamicFlags::empty(),
637            ___deadline,
638        )?;
639        Ok(_response.map(|x| x.vmo))
640    }
641
642    /// Half-duplex transmit data to a SPI device; always transmits the entire buffer on success.
643    pub fn r#transmit_vector(
644        &self,
645        mut data: &[u8],
646        ___deadline: zx::MonotonicInstant,
647    ) -> Result<i32, fidl::Error> {
648        let _response = self
649            .client
650            .send_query::<DeviceTransmitVectorRequest, DeviceTransmitVectorResponse, DeviceMarker>(
651                (data,),
652                0x46a82725fcb5e5d2,
653                fidl::encoding::DynamicFlags::empty(),
654                ___deadline,
655            )?;
656        Ok(_response.status)
657    }
658
659    /// Half-duplex receive data from a SPI device; always reads the full size requested.
660    pub fn r#receive_vector(
661        &self,
662        mut size: u32,
663        ___deadline: zx::MonotonicInstant,
664    ) -> Result<(i32, Vec<u8>), fidl::Error> {
665        let _response = self
666            .client
667            .send_query::<DeviceReceiveVectorRequest, DeviceReceiveVectorResponse, DeviceMarker>(
668                (size,),
669                0x37b160ed6bdd3fd6,
670                fidl::encoding::DynamicFlags::empty(),
671                ___deadline,
672            )?;
673        Ok((_response.status, _response.data))
674    }
675
676    /// Full-duplex SPI transaction. Received data will exactly equal the length of the transmit
677    /// buffer.
678    pub fn r#exchange_vector(
679        &self,
680        mut txdata: &[u8],
681        ___deadline: zx::MonotonicInstant,
682    ) -> Result<(i32, Vec<u8>), fidl::Error> {
683        let _response = self
684            .client
685            .send_query::<DeviceExchangeVectorRequest, DeviceExchangeVectorResponse, DeviceMarker>(
686                (txdata,),
687                0x7facbdec2c3c03bd,
688                fidl::encoding::DynamicFlags::empty(),
689                ___deadline,
690            )?;
691        Ok((_response.status, _response.rxdata))
692    }
693
694    /// Returns true if the device can call |AssertCs()| and |DeassertCs()|.
695    pub fn r#can_assert_cs(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
696        let _response = self
697            .client
698            .send_query::<fidl::encoding::EmptyPayload, DeviceCanAssertCsResponse, DeviceMarker>(
699                (),
700                0x1f8c12c089a9a874,
701                fidl::encoding::DynamicFlags::empty(),
702                ___deadline,
703            )?;
704        Ok(_response.can)
705    }
706
707    /// Assert CS for this device.
708    /// Returns ZX_ERR_NOT_SUPPORTED if there is more than one device on the bus.
709    pub fn r#assert_cs(&self, ___deadline: zx::MonotonicInstant) -> Result<i32, fidl::Error> {
710        let _response = self
711            .client
712            .send_query::<fidl::encoding::EmptyPayload, DeviceAssertCsResponse, DeviceMarker>(
713                (),
714                0x4ff66add7bd91ce6,
715                fidl::encoding::DynamicFlags::empty(),
716                ___deadline,
717            )?;
718        Ok(_response.status)
719    }
720
721    /// Deassert CS for this device.
722    /// Returns ZX_ERR_BAD_STATE if CS is already deasserted.
723    /// Returns ZX_ERR_NOT_SUPPORTED if there is more than one device on the bus.
724    pub fn r#deassert_cs(&self, ___deadline: zx::MonotonicInstant) -> Result<i32, fidl::Error> {
725        let _response = self
726            .client
727            .send_query::<fidl::encoding::EmptyPayload, DeviceDeassertCsResponse, DeviceMarker>(
728                (),
729                0x5e4cd660a0bc0db8,
730                fidl::encoding::DynamicFlags::empty(),
731                ___deadline,
732            )?;
733        Ok(_response.status)
734    }
735}
736
737#[cfg(target_os = "fuchsia")]
738impl From<DeviceSynchronousProxy> for zx::NullableHandle {
739    fn from(value: DeviceSynchronousProxy) -> Self {
740        value.into_channel().into()
741    }
742}
743
744#[cfg(target_os = "fuchsia")]
745impl From<fidl::Channel> for DeviceSynchronousProxy {
746    fn from(value: fidl::Channel) -> Self {
747        Self::new(value)
748    }
749}
750
751#[cfg(target_os = "fuchsia")]
752impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
753    type Protocol = DeviceMarker;
754
755    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
756        Self::new(value.into_channel())
757    }
758}
759
760#[derive(Debug, Clone)]
761pub struct DeviceProxy {
762    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
763}
764
765impl fidl::endpoints::Proxy for DeviceProxy {
766    type Protocol = DeviceMarker;
767
768    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
769        Self::new(inner)
770    }
771
772    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
773        self.client.into_channel().map_err(|client| Self { client })
774    }
775
776    fn as_channel(&self) -> &::fidl::AsyncChannel {
777        self.client.as_channel()
778    }
779}
780
781impl DeviceProxy {
782    /// Create a new Proxy for fuchsia.hardware.spi/Device.
783    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
784        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
785        Self { client: fidl::client::Client::new(channel, protocol_name) }
786    }
787
788    /// Get a Stream of events from the remote end of the protocol.
789    ///
790    /// # Panics
791    ///
792    /// Panics if the event stream was already taken.
793    pub fn take_event_stream(&self) -> DeviceEventStream {
794        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
795    }
796
797    /// Sends the data in buffer to the device.
798    pub fn r#transmit(
799        &self,
800        mut buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
801    ) -> fidl::client::QueryResponseFut<
802        fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitResult,
803        fidl::encoding::DefaultFuchsiaResourceDialect,
804    > {
805        DeviceProxyInterface::r#transmit(self, buffer)
806    }
807
808    /// Receives data from the device into buffer.
809    pub fn r#receive(
810        &self,
811        mut buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
812    ) -> fidl::client::QueryResponseFut<
813        fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveResult,
814        fidl::encoding::DefaultFuchsiaResourceDialect,
815    > {
816        DeviceProxyInterface::r#receive(self, buffer)
817    }
818
819    /// Simultaneously transmits and receives data. The size fields of tx_buffer and rx_buffer must
820    /// be the same.
821    pub fn r#exchange(
822        &self,
823        mut tx_buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
824        mut rx_buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
825    ) -> fidl::client::QueryResponseFut<
826        fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeResult,
827        fidl::encoding::DefaultFuchsiaResourceDialect,
828    > {
829        DeviceProxyInterface::r#exchange(self, tx_buffer, rx_buffer)
830    }
831
832    /// Registers a VMO and transfers ownership to the driver.
833    /// vmo_id: The ID chosen by the client that will be used in operations on this VMO.
834    /// vmo: The handle, offset, and size of this VMO. IO operations on this VMO will be relative to
835    /// the offset and size specified here.
836    /// rights: A bit field of SharedVmoRight values indicating how this VMO may be used. Callers
837    /// should assume that the driver will map and/or pin the VMO using these rights.
838    pub fn r#register_vmo(
839        &self,
840        mut vmo_id: u32,
841        mut vmo: fidl_fuchsia_mem::Range,
842        mut rights: fidl_fuchsia_hardware_sharedmemory::SharedVmoRight,
843    ) -> fidl::client::QueryResponseFut<
844        fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoResult,
845        fidl::encoding::DefaultFuchsiaResourceDialect,
846    > {
847        DeviceProxyInterface::r#register_vmo(self, vmo_id, vmo, rights)
848    }
849
850    /// Unmaps and/or unpins the VMO and returns the handle to the caller.
851    pub fn r#unregister_vmo(
852        &self,
853        mut vmo_id: u32,
854    ) -> fidl::client::QueryResponseFut<
855        fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResult,
856        fidl::encoding::DefaultFuchsiaResourceDialect,
857    > {
858        DeviceProxyInterface::r#unregister_vmo(self, vmo_id)
859    }
860
861    /// Half-duplex transmit data to a SPI device; always transmits the entire buffer on success.
862    pub fn r#transmit_vector(
863        &self,
864        mut data: &[u8],
865    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
866        DeviceProxyInterface::r#transmit_vector(self, data)
867    }
868
869    /// Half-duplex receive data from a SPI device; always reads the full size requested.
870    pub fn r#receive_vector(
871        &self,
872        mut size: u32,
873    ) -> fidl::client::QueryResponseFut<(i32, Vec<u8>), fidl::encoding::DefaultFuchsiaResourceDialect>
874    {
875        DeviceProxyInterface::r#receive_vector(self, size)
876    }
877
878    /// Full-duplex SPI transaction. Received data will exactly equal the length of the transmit
879    /// buffer.
880    pub fn r#exchange_vector(
881        &self,
882        mut txdata: &[u8],
883    ) -> fidl::client::QueryResponseFut<(i32, Vec<u8>), fidl::encoding::DefaultFuchsiaResourceDialect>
884    {
885        DeviceProxyInterface::r#exchange_vector(self, txdata)
886    }
887
888    /// Returns true if the device can call |AssertCs()| and |DeassertCs()|.
889    pub fn r#can_assert_cs(
890        &self,
891    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
892        DeviceProxyInterface::r#can_assert_cs(self)
893    }
894
895    /// Assert CS for this device.
896    /// Returns ZX_ERR_NOT_SUPPORTED if there is more than one device on the bus.
897    pub fn r#assert_cs(
898        &self,
899    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
900        DeviceProxyInterface::r#assert_cs(self)
901    }
902
903    /// Deassert CS for this device.
904    /// Returns ZX_ERR_BAD_STATE if CS is already deasserted.
905    /// Returns ZX_ERR_NOT_SUPPORTED if there is more than one device on the bus.
906    pub fn r#deassert_cs(
907        &self,
908    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
909        DeviceProxyInterface::r#deassert_cs(self)
910    }
911}
912
913impl DeviceProxyInterface for DeviceProxy {
914    type TransmitResponseFut = fidl::client::QueryResponseFut<
915        fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitResult,
916        fidl::encoding::DefaultFuchsiaResourceDialect,
917    >;
918    fn r#transmit(
919        &self,
920        mut buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
921    ) -> Self::TransmitResponseFut {
922        fn _decode(
923            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
924        ) -> Result<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitResult, fidl::Error>
925        {
926            let _response = fidl::client::decode_transaction_body::<
927                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
928                fidl::encoding::DefaultFuchsiaResourceDialect,
929                0x791970e4c961b0bf,
930            >(_buf?)?;
931            Ok(_response.map(|x| x))
932        }
933        self.client.send_query_and_decode::<
934            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitRequest,
935            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitResult,
936        >(
937            (buffer,),
938            0x791970e4c961b0bf,
939            fidl::encoding::DynamicFlags::empty(),
940            _decode,
941        )
942    }
943
944    type ReceiveResponseFut = fidl::client::QueryResponseFut<
945        fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveResult,
946        fidl::encoding::DefaultFuchsiaResourceDialect,
947    >;
948    fn r#receive(
949        &self,
950        mut buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
951    ) -> Self::ReceiveResponseFut {
952        fn _decode(
953            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
954        ) -> Result<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveResult, fidl::Error>
955        {
956            let _response = fidl::client::decode_transaction_body::<
957                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
958                fidl::encoding::DefaultFuchsiaResourceDialect,
959                0x1c31986cc443db59,
960            >(_buf?)?;
961            Ok(_response.map(|x| x))
962        }
963        self.client.send_query_and_decode::<
964            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveRequest,
965            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveResult,
966        >(
967            (buffer,),
968            0x1c31986cc443db59,
969            fidl::encoding::DynamicFlags::empty(),
970            _decode,
971        )
972    }
973
974    type ExchangeResponseFut = fidl::client::QueryResponseFut<
975        fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeResult,
976        fidl::encoding::DefaultFuchsiaResourceDialect,
977    >;
978    fn r#exchange(
979        &self,
980        mut tx_buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
981        mut rx_buffer: &fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
982    ) -> Self::ExchangeResponseFut {
983        fn _decode(
984            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
985        ) -> Result<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeResult, fidl::Error>
986        {
987            let _response = fidl::client::decode_transaction_body::<
988                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
989                fidl::encoding::DefaultFuchsiaResourceDialect,
990                0x6ddad3b45d5deccc,
991            >(_buf?)?;
992            Ok(_response.map(|x| x))
993        }
994        self.client.send_query_and_decode::<
995            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeRequest,
996            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeResult,
997        >(
998            (tx_buffer, rx_buffer,),
999            0x6ddad3b45d5deccc,
1000            fidl::encoding::DynamicFlags::empty(),
1001            _decode,
1002        )
1003    }
1004
1005    type RegisterVmoResponseFut = fidl::client::QueryResponseFut<
1006        fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoResult,
1007        fidl::encoding::DefaultFuchsiaResourceDialect,
1008    >;
1009    fn r#register_vmo(
1010        &self,
1011        mut vmo_id: u32,
1012        mut vmo: fidl_fuchsia_mem::Range,
1013        mut rights: fidl_fuchsia_hardware_sharedmemory::SharedVmoRight,
1014    ) -> Self::RegisterVmoResponseFut {
1015        fn _decode(
1016            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1017        ) -> Result<
1018            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoResult,
1019            fidl::Error,
1020        > {
1021            let _response = fidl::client::decode_transaction_body::<
1022                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1023                fidl::encoding::DefaultFuchsiaResourceDialect,
1024                0x31df51e1e6ea4a15,
1025            >(_buf?)?;
1026            Ok(_response.map(|x| x))
1027        }
1028        self.client.send_query_and_decode::<
1029            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoRequest,
1030            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoResult,
1031        >(
1032            (vmo_id, &mut vmo, rights,),
1033            0x31df51e1e6ea4a15,
1034            fidl::encoding::DynamicFlags::empty(),
1035            _decode,
1036        )
1037    }
1038
1039    type UnregisterVmoResponseFut = fidl::client::QueryResponseFut<
1040        fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResult,
1041        fidl::encoding::DefaultFuchsiaResourceDialect,
1042    >;
1043    fn r#unregister_vmo(&self, mut vmo_id: u32) -> Self::UnregisterVmoResponseFut {
1044        fn _decode(
1045            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1046        ) -> Result<
1047            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResult,
1048            fidl::Error,
1049        > {
1050            let _response = fidl::client::decode_transaction_body::<
1051                fidl::encoding::ResultType<
1052                    fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResponse,
1053                    i32,
1054                >,
1055                fidl::encoding::DefaultFuchsiaResourceDialect,
1056                0x1194e9b693827109,
1057            >(_buf?)?;
1058            Ok(_response.map(|x| x.vmo))
1059        }
1060        self.client.send_query_and_decode::<
1061            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoRequest,
1062            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResult,
1063        >(
1064            (vmo_id,),
1065            0x1194e9b693827109,
1066            fidl::encoding::DynamicFlags::empty(),
1067            _decode,
1068        )
1069    }
1070
1071    type TransmitVectorResponseFut =
1072        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1073    fn r#transmit_vector(&self, mut data: &[u8]) -> Self::TransmitVectorResponseFut {
1074        fn _decode(
1075            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1076        ) -> Result<i32, fidl::Error> {
1077            let _response = fidl::client::decode_transaction_body::<
1078                DeviceTransmitVectorResponse,
1079                fidl::encoding::DefaultFuchsiaResourceDialect,
1080                0x46a82725fcb5e5d2,
1081            >(_buf?)?;
1082            Ok(_response.status)
1083        }
1084        self.client.send_query_and_decode::<DeviceTransmitVectorRequest, i32>(
1085            (data,),
1086            0x46a82725fcb5e5d2,
1087            fidl::encoding::DynamicFlags::empty(),
1088            _decode,
1089        )
1090    }
1091
1092    type ReceiveVectorResponseFut = fidl::client::QueryResponseFut<
1093        (i32, Vec<u8>),
1094        fidl::encoding::DefaultFuchsiaResourceDialect,
1095    >;
1096    fn r#receive_vector(&self, mut size: u32) -> Self::ReceiveVectorResponseFut {
1097        fn _decode(
1098            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1099        ) -> Result<(i32, Vec<u8>), fidl::Error> {
1100            let _response = fidl::client::decode_transaction_body::<
1101                DeviceReceiveVectorResponse,
1102                fidl::encoding::DefaultFuchsiaResourceDialect,
1103                0x37b160ed6bdd3fd6,
1104            >(_buf?)?;
1105            Ok((_response.status, _response.data))
1106        }
1107        self.client.send_query_and_decode::<DeviceReceiveVectorRequest, (i32, Vec<u8>)>(
1108            (size,),
1109            0x37b160ed6bdd3fd6,
1110            fidl::encoding::DynamicFlags::empty(),
1111            _decode,
1112        )
1113    }
1114
1115    type ExchangeVectorResponseFut = fidl::client::QueryResponseFut<
1116        (i32, Vec<u8>),
1117        fidl::encoding::DefaultFuchsiaResourceDialect,
1118    >;
1119    fn r#exchange_vector(&self, mut txdata: &[u8]) -> Self::ExchangeVectorResponseFut {
1120        fn _decode(
1121            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1122        ) -> Result<(i32, Vec<u8>), fidl::Error> {
1123            let _response = fidl::client::decode_transaction_body::<
1124                DeviceExchangeVectorResponse,
1125                fidl::encoding::DefaultFuchsiaResourceDialect,
1126                0x7facbdec2c3c03bd,
1127            >(_buf?)?;
1128            Ok((_response.status, _response.rxdata))
1129        }
1130        self.client.send_query_and_decode::<DeviceExchangeVectorRequest, (i32, Vec<u8>)>(
1131            (txdata,),
1132            0x7facbdec2c3c03bd,
1133            fidl::encoding::DynamicFlags::empty(),
1134            _decode,
1135        )
1136    }
1137
1138    type CanAssertCsResponseFut =
1139        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
1140    fn r#can_assert_cs(&self) -> Self::CanAssertCsResponseFut {
1141        fn _decode(
1142            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1143        ) -> Result<bool, fidl::Error> {
1144            let _response = fidl::client::decode_transaction_body::<
1145                DeviceCanAssertCsResponse,
1146                fidl::encoding::DefaultFuchsiaResourceDialect,
1147                0x1f8c12c089a9a874,
1148            >(_buf?)?;
1149            Ok(_response.can)
1150        }
1151        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
1152            (),
1153            0x1f8c12c089a9a874,
1154            fidl::encoding::DynamicFlags::empty(),
1155            _decode,
1156        )
1157    }
1158
1159    type AssertCsResponseFut =
1160        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1161    fn r#assert_cs(&self) -> Self::AssertCsResponseFut {
1162        fn _decode(
1163            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1164        ) -> Result<i32, fidl::Error> {
1165            let _response = fidl::client::decode_transaction_body::<
1166                DeviceAssertCsResponse,
1167                fidl::encoding::DefaultFuchsiaResourceDialect,
1168                0x4ff66add7bd91ce6,
1169            >(_buf?)?;
1170            Ok(_response.status)
1171        }
1172        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
1173            (),
1174            0x4ff66add7bd91ce6,
1175            fidl::encoding::DynamicFlags::empty(),
1176            _decode,
1177        )
1178    }
1179
1180    type DeassertCsResponseFut =
1181        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
1182    fn r#deassert_cs(&self) -> Self::DeassertCsResponseFut {
1183        fn _decode(
1184            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1185        ) -> Result<i32, fidl::Error> {
1186            let _response = fidl::client::decode_transaction_body::<
1187                DeviceDeassertCsResponse,
1188                fidl::encoding::DefaultFuchsiaResourceDialect,
1189                0x5e4cd660a0bc0db8,
1190            >(_buf?)?;
1191            Ok(_response.status)
1192        }
1193        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
1194            (),
1195            0x5e4cd660a0bc0db8,
1196            fidl::encoding::DynamicFlags::empty(),
1197            _decode,
1198        )
1199    }
1200}
1201
1202pub struct DeviceEventStream {
1203    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1204}
1205
1206impl std::marker::Unpin for DeviceEventStream {}
1207
1208impl futures::stream::FusedStream for DeviceEventStream {
1209    fn is_terminated(&self) -> bool {
1210        self.event_receiver.is_terminated()
1211    }
1212}
1213
1214impl futures::Stream for DeviceEventStream {
1215    type Item = Result<DeviceEvent, fidl::Error>;
1216
1217    fn poll_next(
1218        mut self: std::pin::Pin<&mut Self>,
1219        cx: &mut std::task::Context<'_>,
1220    ) -> std::task::Poll<Option<Self::Item>> {
1221        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1222            &mut self.event_receiver,
1223            cx
1224        )?) {
1225            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1226            None => std::task::Poll::Ready(None),
1227        }
1228    }
1229}
1230
1231#[derive(Debug)]
1232pub enum DeviceEvent {}
1233
1234impl DeviceEvent {
1235    /// Decodes a message buffer as a [`DeviceEvent`].
1236    fn decode(
1237        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1238    ) -> Result<DeviceEvent, fidl::Error> {
1239        let (bytes, _handles) = buf.split_mut();
1240        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1241        debug_assert_eq!(tx_header.tx_id, 0);
1242        match tx_header.ordinal {
1243            _ => Err(fidl::Error::UnknownOrdinal {
1244                ordinal: tx_header.ordinal,
1245                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1246            }),
1247        }
1248    }
1249}
1250
1251/// A Stream of incoming requests for fuchsia.hardware.spi/Device.
1252pub struct DeviceRequestStream {
1253    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1254    is_terminated: bool,
1255}
1256
1257impl std::marker::Unpin for DeviceRequestStream {}
1258
1259impl futures::stream::FusedStream for DeviceRequestStream {
1260    fn is_terminated(&self) -> bool {
1261        self.is_terminated
1262    }
1263}
1264
1265impl fidl::endpoints::RequestStream for DeviceRequestStream {
1266    type Protocol = DeviceMarker;
1267    type ControlHandle = DeviceControlHandle;
1268
1269    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1270        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1271    }
1272
1273    fn control_handle(&self) -> Self::ControlHandle {
1274        DeviceControlHandle { inner: self.inner.clone() }
1275    }
1276
1277    fn into_inner(
1278        self,
1279    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1280    {
1281        (self.inner, self.is_terminated)
1282    }
1283
1284    fn from_inner(
1285        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1286        is_terminated: bool,
1287    ) -> Self {
1288        Self { inner, is_terminated }
1289    }
1290}
1291
1292impl futures::Stream for DeviceRequestStream {
1293    type Item = Result<DeviceRequest, fidl::Error>;
1294
1295    fn poll_next(
1296        mut self: std::pin::Pin<&mut Self>,
1297        cx: &mut std::task::Context<'_>,
1298    ) -> std::task::Poll<Option<Self::Item>> {
1299        let this = &mut *self;
1300        if this.inner.check_shutdown(cx) {
1301            this.is_terminated = true;
1302            return std::task::Poll::Ready(None);
1303        }
1304        if this.is_terminated {
1305            panic!("polled DeviceRequestStream after completion");
1306        }
1307        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1308            |bytes, handles| {
1309                match this.inner.channel().read_etc(cx, bytes, handles) {
1310                    std::task::Poll::Ready(Ok(())) => {}
1311                    std::task::Poll::Pending => return std::task::Poll::Pending,
1312                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1313                        this.is_terminated = true;
1314                        return std::task::Poll::Ready(None);
1315                    }
1316                    std::task::Poll::Ready(Err(e)) => {
1317                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1318                            e.into(),
1319                        ))));
1320                    }
1321                }
1322
1323                // A message has been received from the channel
1324                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1325
1326                std::task::Poll::Ready(Some(match header.ordinal {
1327                    0x791970e4c961b0bf => {
1328                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1329                        let mut req = fidl::new_empty!(
1330                            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitRequest,
1331                            fidl::encoding::DefaultFuchsiaResourceDialect
1332                        );
1333                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoTransmitRequest>(&header, _body_bytes, handles, &mut req)?;
1334                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1335                        Ok(DeviceRequest::Transmit {
1336                            buffer: req.buffer,
1337
1338                            responder: DeviceTransmitResponder {
1339                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1340                                tx_id: header.tx_id,
1341                            },
1342                        })
1343                    }
1344                    0x1c31986cc443db59 => {
1345                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1346                        let mut req = fidl::new_empty!(
1347                            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveRequest,
1348                            fidl::encoding::DefaultFuchsiaResourceDialect
1349                        );
1350                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoReceiveRequest>(&header, _body_bytes, handles, &mut req)?;
1351                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1352                        Ok(DeviceRequest::Receive {
1353                            buffer: req.buffer,
1354
1355                            responder: DeviceReceiveResponder {
1356                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1357                                tx_id: header.tx_id,
1358                            },
1359                        })
1360                    }
1361                    0x6ddad3b45d5deccc => {
1362                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1363                        let mut req = fidl::new_empty!(
1364                            fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeRequest,
1365                            fidl::encoding::DefaultFuchsiaResourceDialect
1366                        );
1367                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_sharedmemory::SharedVmoIoExchangeRequest>(&header, _body_bytes, handles, &mut req)?;
1368                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1369                        Ok(DeviceRequest::Exchange {
1370                            tx_buffer: req.tx_buffer,
1371                            rx_buffer: req.rx_buffer,
1372
1373                            responder: DeviceExchangeResponder {
1374                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1375                                tx_id: header.tx_id,
1376                            },
1377                        })
1378                    }
1379                    0x31df51e1e6ea4a15 => {
1380                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1381                        let mut req = fidl::new_empty!(
1382                            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoRequest,
1383                            fidl::encoding::DefaultFuchsiaResourceDialect
1384                        );
1385                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterRegisterVmoRequest>(&header, _body_bytes, handles, &mut req)?;
1386                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1387                        Ok(DeviceRequest::RegisterVmo {
1388                            vmo_id: req.vmo_id,
1389                            vmo: req.vmo,
1390                            rights: req.rights,
1391
1392                            responder: DeviceRegisterVmoResponder {
1393                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1394                                tx_id: header.tx_id,
1395                            },
1396                        })
1397                    }
1398                    0x1194e9b693827109 => {
1399                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1400                        let mut req = fidl::new_empty!(fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1401                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoRequest>(&header, _body_bytes, handles, &mut req)?;
1402                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1403                        Ok(DeviceRequest::UnregisterVmo {
1404                            vmo_id: req.vmo_id,
1405
1406                            responder: DeviceUnregisterVmoResponder {
1407                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1408                                tx_id: header.tx_id,
1409                            },
1410                        })
1411                    }
1412                    0x46a82725fcb5e5d2 => {
1413                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1414                        let mut req = fidl::new_empty!(
1415                            DeviceTransmitVectorRequest,
1416                            fidl::encoding::DefaultFuchsiaResourceDialect
1417                        );
1418                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceTransmitVectorRequest>(&header, _body_bytes, handles, &mut req)?;
1419                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1420                        Ok(DeviceRequest::TransmitVector {
1421                            data: req.data,
1422
1423                            responder: DeviceTransmitVectorResponder {
1424                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1425                                tx_id: header.tx_id,
1426                            },
1427                        })
1428                    }
1429                    0x37b160ed6bdd3fd6 => {
1430                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1431                        let mut req = fidl::new_empty!(
1432                            DeviceReceiveVectorRequest,
1433                            fidl::encoding::DefaultFuchsiaResourceDialect
1434                        );
1435                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceReceiveVectorRequest>(&header, _body_bytes, handles, &mut req)?;
1436                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1437                        Ok(DeviceRequest::ReceiveVector {
1438                            size: req.size,
1439
1440                            responder: DeviceReceiveVectorResponder {
1441                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1442                                tx_id: header.tx_id,
1443                            },
1444                        })
1445                    }
1446                    0x7facbdec2c3c03bd => {
1447                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1448                        let mut req = fidl::new_empty!(
1449                            DeviceExchangeVectorRequest,
1450                            fidl::encoding::DefaultFuchsiaResourceDialect
1451                        );
1452                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceExchangeVectorRequest>(&header, _body_bytes, handles, &mut req)?;
1453                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1454                        Ok(DeviceRequest::ExchangeVector {
1455                            txdata: req.txdata,
1456
1457                            responder: DeviceExchangeVectorResponder {
1458                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1459                                tx_id: header.tx_id,
1460                            },
1461                        })
1462                    }
1463                    0x1f8c12c089a9a874 => {
1464                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1465                        let mut req = fidl::new_empty!(
1466                            fidl::encoding::EmptyPayload,
1467                            fidl::encoding::DefaultFuchsiaResourceDialect
1468                        );
1469                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1470                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1471                        Ok(DeviceRequest::CanAssertCs {
1472                            responder: DeviceCanAssertCsResponder {
1473                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1474                                tx_id: header.tx_id,
1475                            },
1476                        })
1477                    }
1478                    0x4ff66add7bd91ce6 => {
1479                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1480                        let mut req = fidl::new_empty!(
1481                            fidl::encoding::EmptyPayload,
1482                            fidl::encoding::DefaultFuchsiaResourceDialect
1483                        );
1484                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1485                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1486                        Ok(DeviceRequest::AssertCs {
1487                            responder: DeviceAssertCsResponder {
1488                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1489                                tx_id: header.tx_id,
1490                            },
1491                        })
1492                    }
1493                    0x5e4cd660a0bc0db8 => {
1494                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1495                        let mut req = fidl::new_empty!(
1496                            fidl::encoding::EmptyPayload,
1497                            fidl::encoding::DefaultFuchsiaResourceDialect
1498                        );
1499                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1500                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1501                        Ok(DeviceRequest::DeassertCs {
1502                            responder: DeviceDeassertCsResponder {
1503                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1504                                tx_id: header.tx_id,
1505                            },
1506                        })
1507                    }
1508                    _ => Err(fidl::Error::UnknownOrdinal {
1509                        ordinal: header.ordinal,
1510                        protocol_name:
1511                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1512                    }),
1513                }))
1514            },
1515        )
1516    }
1517}
1518
1519#[derive(Debug)]
1520pub enum DeviceRequest {
1521    /// Sends the data in buffer to the device.
1522    Transmit {
1523        buffer: fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
1524        responder: DeviceTransmitResponder,
1525    },
1526    /// Receives data from the device into buffer.
1527    Receive {
1528        buffer: fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
1529        responder: DeviceReceiveResponder,
1530    },
1531    /// Simultaneously transmits and receives data. The size fields of tx_buffer and rx_buffer must
1532    /// be the same.
1533    Exchange {
1534        tx_buffer: fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
1535        rx_buffer: fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
1536        responder: DeviceExchangeResponder,
1537    },
1538    /// Registers a VMO and transfers ownership to the driver.
1539    /// vmo_id: The ID chosen by the client that will be used in operations on this VMO.
1540    /// vmo: The handle, offset, and size of this VMO. IO operations on this VMO will be relative to
1541    /// the offset and size specified here.
1542    /// rights: A bit field of SharedVmoRight values indicating how this VMO may be used. Callers
1543    /// should assume that the driver will map and/or pin the VMO using these rights.
1544    RegisterVmo {
1545        vmo_id: u32,
1546        vmo: fidl_fuchsia_mem::Range,
1547        rights: fidl_fuchsia_hardware_sharedmemory::SharedVmoRight,
1548        responder: DeviceRegisterVmoResponder,
1549    },
1550    /// Unmaps and/or unpins the VMO and returns the handle to the caller.
1551    UnregisterVmo { vmo_id: u32, responder: DeviceUnregisterVmoResponder },
1552    /// Half-duplex transmit data to a SPI device; always transmits the entire buffer on success.
1553    TransmitVector { data: Vec<u8>, responder: DeviceTransmitVectorResponder },
1554    /// Half-duplex receive data from a SPI device; always reads the full size requested.
1555    ReceiveVector { size: u32, responder: DeviceReceiveVectorResponder },
1556    /// Full-duplex SPI transaction. Received data will exactly equal the length of the transmit
1557    /// buffer.
1558    ExchangeVector { txdata: Vec<u8>, responder: DeviceExchangeVectorResponder },
1559    /// Returns true if the device can call |AssertCs()| and |DeassertCs()|.
1560    CanAssertCs { responder: DeviceCanAssertCsResponder },
1561    /// Assert CS for this device.
1562    /// Returns ZX_ERR_NOT_SUPPORTED if there is more than one device on the bus.
1563    AssertCs { responder: DeviceAssertCsResponder },
1564    /// Deassert CS for this device.
1565    /// Returns ZX_ERR_BAD_STATE if CS is already deasserted.
1566    /// Returns ZX_ERR_NOT_SUPPORTED if there is more than one device on the bus.
1567    DeassertCs { responder: DeviceDeassertCsResponder },
1568}
1569
1570impl DeviceRequest {
1571    #[allow(irrefutable_let_patterns)]
1572    pub fn into_transmit(
1573        self,
1574    ) -> Option<(fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer, DeviceTransmitResponder)>
1575    {
1576        if let DeviceRequest::Transmit { buffer, responder } = self {
1577            Some((buffer, responder))
1578        } else {
1579            None
1580        }
1581    }
1582
1583    #[allow(irrefutable_let_patterns)]
1584    pub fn into_receive(
1585        self,
1586    ) -> Option<(fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer, DeviceReceiveResponder)> {
1587        if let DeviceRequest::Receive { buffer, responder } = self {
1588            Some((buffer, responder))
1589        } else {
1590            None
1591        }
1592    }
1593
1594    #[allow(irrefutable_let_patterns)]
1595    pub fn into_exchange(
1596        self,
1597    ) -> Option<(
1598        fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
1599        fidl_fuchsia_hardware_sharedmemory::SharedVmoBuffer,
1600        DeviceExchangeResponder,
1601    )> {
1602        if let DeviceRequest::Exchange { tx_buffer, rx_buffer, responder } = self {
1603            Some((tx_buffer, rx_buffer, responder))
1604        } else {
1605            None
1606        }
1607    }
1608
1609    #[allow(irrefutable_let_patterns)]
1610    pub fn into_register_vmo(
1611        self,
1612    ) -> Option<(
1613        u32,
1614        fidl_fuchsia_mem::Range,
1615        fidl_fuchsia_hardware_sharedmemory::SharedVmoRight,
1616        DeviceRegisterVmoResponder,
1617    )> {
1618        if let DeviceRequest::RegisterVmo { vmo_id, vmo, rights, responder } = self {
1619            Some((vmo_id, vmo, rights, responder))
1620        } else {
1621            None
1622        }
1623    }
1624
1625    #[allow(irrefutable_let_patterns)]
1626    pub fn into_unregister_vmo(self) -> Option<(u32, DeviceUnregisterVmoResponder)> {
1627        if let DeviceRequest::UnregisterVmo { vmo_id, responder } = self {
1628            Some((vmo_id, responder))
1629        } else {
1630            None
1631        }
1632    }
1633
1634    #[allow(irrefutable_let_patterns)]
1635    pub fn into_transmit_vector(self) -> Option<(Vec<u8>, DeviceTransmitVectorResponder)> {
1636        if let DeviceRequest::TransmitVector { data, responder } = self {
1637            Some((data, responder))
1638        } else {
1639            None
1640        }
1641    }
1642
1643    #[allow(irrefutable_let_patterns)]
1644    pub fn into_receive_vector(self) -> Option<(u32, DeviceReceiveVectorResponder)> {
1645        if let DeviceRequest::ReceiveVector { size, responder } = self {
1646            Some((size, responder))
1647        } else {
1648            None
1649        }
1650    }
1651
1652    #[allow(irrefutable_let_patterns)]
1653    pub fn into_exchange_vector(self) -> Option<(Vec<u8>, DeviceExchangeVectorResponder)> {
1654        if let DeviceRequest::ExchangeVector { txdata, responder } = self {
1655            Some((txdata, responder))
1656        } else {
1657            None
1658        }
1659    }
1660
1661    #[allow(irrefutable_let_patterns)]
1662    pub fn into_can_assert_cs(self) -> Option<(DeviceCanAssertCsResponder)> {
1663        if let DeviceRequest::CanAssertCs { responder } = self { Some((responder)) } else { None }
1664    }
1665
1666    #[allow(irrefutable_let_patterns)]
1667    pub fn into_assert_cs(self) -> Option<(DeviceAssertCsResponder)> {
1668        if let DeviceRequest::AssertCs { responder } = self { Some((responder)) } else { None }
1669    }
1670
1671    #[allow(irrefutable_let_patterns)]
1672    pub fn into_deassert_cs(self) -> Option<(DeviceDeassertCsResponder)> {
1673        if let DeviceRequest::DeassertCs { responder } = self { Some((responder)) } else { None }
1674    }
1675
1676    /// Name of the method defined in FIDL
1677    pub fn method_name(&self) -> &'static str {
1678        match *self {
1679            DeviceRequest::Transmit { .. } => "transmit",
1680            DeviceRequest::Receive { .. } => "receive",
1681            DeviceRequest::Exchange { .. } => "exchange",
1682            DeviceRequest::RegisterVmo { .. } => "register_vmo",
1683            DeviceRequest::UnregisterVmo { .. } => "unregister_vmo",
1684            DeviceRequest::TransmitVector { .. } => "transmit_vector",
1685            DeviceRequest::ReceiveVector { .. } => "receive_vector",
1686            DeviceRequest::ExchangeVector { .. } => "exchange_vector",
1687            DeviceRequest::CanAssertCs { .. } => "can_assert_cs",
1688            DeviceRequest::AssertCs { .. } => "assert_cs",
1689            DeviceRequest::DeassertCs { .. } => "deassert_cs",
1690        }
1691    }
1692}
1693
1694#[derive(Debug, Clone)]
1695pub struct DeviceControlHandle {
1696    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1697}
1698
1699impl DeviceControlHandle {
1700    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1701        self.inner.shutdown_with_epitaph(status.into())
1702    }
1703}
1704
1705impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1706    fn shutdown(&self) {
1707        self.inner.shutdown()
1708    }
1709
1710    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1711        self.inner.shutdown_with_epitaph(status)
1712    }
1713
1714    fn is_closed(&self) -> bool {
1715        self.inner.channel().is_closed()
1716    }
1717    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1718        self.inner.channel().on_closed()
1719    }
1720
1721    #[cfg(target_os = "fuchsia")]
1722    fn signal_peer(
1723        &self,
1724        clear_mask: zx::Signals,
1725        set_mask: zx::Signals,
1726    ) -> Result<(), zx_status::Status> {
1727        use fidl::Peered;
1728        self.inner.channel().signal_peer(clear_mask, set_mask)
1729    }
1730}
1731
1732impl DeviceControlHandle {}
1733
1734#[must_use = "FIDL methods require a response to be sent"]
1735#[derive(Debug)]
1736pub struct DeviceTransmitResponder {
1737    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1738    tx_id: u32,
1739}
1740
1741/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1742/// if the responder is dropped without sending a response, so that the client
1743/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1744impl std::ops::Drop for DeviceTransmitResponder {
1745    fn drop(&mut self) {
1746        self.control_handle.shutdown();
1747        // Safety: drops once, never accessed again
1748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1749    }
1750}
1751
1752impl fidl::endpoints::Responder for DeviceTransmitResponder {
1753    type ControlHandle = DeviceControlHandle;
1754
1755    fn control_handle(&self) -> &DeviceControlHandle {
1756        &self.control_handle
1757    }
1758
1759    fn drop_without_shutdown(mut self) {
1760        // Safety: drops once, never accessed again due to mem::forget
1761        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1762        // Prevent Drop from running (which would shut down the channel)
1763        std::mem::forget(self);
1764    }
1765}
1766
1767impl DeviceTransmitResponder {
1768    /// Sends a response to the FIDL transaction.
1769    ///
1770    /// Sets the channel to shutdown if an error occurs.
1771    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1772        let _result = self.send_raw(result);
1773        if _result.is_err() {
1774            self.control_handle.shutdown();
1775        }
1776        self.drop_without_shutdown();
1777        _result
1778    }
1779
1780    /// Similar to "send" but does not shutdown the channel if an error occurs.
1781    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1782        let _result = self.send_raw(result);
1783        self.drop_without_shutdown();
1784        _result
1785    }
1786
1787    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1788        self.control_handle
1789            .inner
1790            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1791                result,
1792                self.tx_id,
1793                0x791970e4c961b0bf,
1794                fidl::encoding::DynamicFlags::empty(),
1795            )
1796    }
1797}
1798
1799#[must_use = "FIDL methods require a response to be sent"]
1800#[derive(Debug)]
1801pub struct DeviceReceiveResponder {
1802    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1803    tx_id: u32,
1804}
1805
1806/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1807/// if the responder is dropped without sending a response, so that the client
1808/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1809impl std::ops::Drop for DeviceReceiveResponder {
1810    fn drop(&mut self) {
1811        self.control_handle.shutdown();
1812        // Safety: drops once, never accessed again
1813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1814    }
1815}
1816
1817impl fidl::endpoints::Responder for DeviceReceiveResponder {
1818    type ControlHandle = DeviceControlHandle;
1819
1820    fn control_handle(&self) -> &DeviceControlHandle {
1821        &self.control_handle
1822    }
1823
1824    fn drop_without_shutdown(mut self) {
1825        // Safety: drops once, never accessed again due to mem::forget
1826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1827        // Prevent Drop from running (which would shut down the channel)
1828        std::mem::forget(self);
1829    }
1830}
1831
1832impl DeviceReceiveResponder {
1833    /// Sends a response to the FIDL transaction.
1834    ///
1835    /// Sets the channel to shutdown if an error occurs.
1836    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1837        let _result = self.send_raw(result);
1838        if _result.is_err() {
1839            self.control_handle.shutdown();
1840        }
1841        self.drop_without_shutdown();
1842        _result
1843    }
1844
1845    /// Similar to "send" but does not shutdown the channel if an error occurs.
1846    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1847        let _result = self.send_raw(result);
1848        self.drop_without_shutdown();
1849        _result
1850    }
1851
1852    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1853        self.control_handle
1854            .inner
1855            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1856                result,
1857                self.tx_id,
1858                0x1c31986cc443db59,
1859                fidl::encoding::DynamicFlags::empty(),
1860            )
1861    }
1862}
1863
1864#[must_use = "FIDL methods require a response to be sent"]
1865#[derive(Debug)]
1866pub struct DeviceExchangeResponder {
1867    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1868    tx_id: u32,
1869}
1870
1871/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1872/// if the responder is dropped without sending a response, so that the client
1873/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1874impl std::ops::Drop for DeviceExchangeResponder {
1875    fn drop(&mut self) {
1876        self.control_handle.shutdown();
1877        // Safety: drops once, never accessed again
1878        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1879    }
1880}
1881
1882impl fidl::endpoints::Responder for DeviceExchangeResponder {
1883    type ControlHandle = DeviceControlHandle;
1884
1885    fn control_handle(&self) -> &DeviceControlHandle {
1886        &self.control_handle
1887    }
1888
1889    fn drop_without_shutdown(mut self) {
1890        // Safety: drops once, never accessed again due to mem::forget
1891        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1892        // Prevent Drop from running (which would shut down the channel)
1893        std::mem::forget(self);
1894    }
1895}
1896
1897impl DeviceExchangeResponder {
1898    /// Sends a response to the FIDL transaction.
1899    ///
1900    /// Sets the channel to shutdown if an error occurs.
1901    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1902        let _result = self.send_raw(result);
1903        if _result.is_err() {
1904            self.control_handle.shutdown();
1905        }
1906        self.drop_without_shutdown();
1907        _result
1908    }
1909
1910    /// Similar to "send" but does not shutdown the channel if an error occurs.
1911    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1912        let _result = self.send_raw(result);
1913        self.drop_without_shutdown();
1914        _result
1915    }
1916
1917    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1918        self.control_handle
1919            .inner
1920            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1921                result,
1922                self.tx_id,
1923                0x6ddad3b45d5deccc,
1924                fidl::encoding::DynamicFlags::empty(),
1925            )
1926    }
1927}
1928
1929#[must_use = "FIDL methods require a response to be sent"]
1930#[derive(Debug)]
1931pub struct DeviceRegisterVmoResponder {
1932    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1933    tx_id: u32,
1934}
1935
1936/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
1937/// if the responder is dropped without sending a response, so that the client
1938/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1939impl std::ops::Drop for DeviceRegisterVmoResponder {
1940    fn drop(&mut self) {
1941        self.control_handle.shutdown();
1942        // Safety: drops once, never accessed again
1943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1944    }
1945}
1946
1947impl fidl::endpoints::Responder for DeviceRegisterVmoResponder {
1948    type ControlHandle = DeviceControlHandle;
1949
1950    fn control_handle(&self) -> &DeviceControlHandle {
1951        &self.control_handle
1952    }
1953
1954    fn drop_without_shutdown(mut self) {
1955        // Safety: drops once, never accessed again due to mem::forget
1956        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1957        // Prevent Drop from running (which would shut down the channel)
1958        std::mem::forget(self);
1959    }
1960}
1961
1962impl DeviceRegisterVmoResponder {
1963    /// Sends a response to the FIDL transaction.
1964    ///
1965    /// Sets the channel to shutdown if an error occurs.
1966    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1967        let _result = self.send_raw(result);
1968        if _result.is_err() {
1969            self.control_handle.shutdown();
1970        }
1971        self.drop_without_shutdown();
1972        _result
1973    }
1974
1975    /// Similar to "send" but does not shutdown the channel if an error occurs.
1976    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1977        let _result = self.send_raw(result);
1978        self.drop_without_shutdown();
1979        _result
1980    }
1981
1982    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1983        self.control_handle
1984            .inner
1985            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1986                result,
1987                self.tx_id,
1988                0x31df51e1e6ea4a15,
1989                fidl::encoding::DynamicFlags::empty(),
1990            )
1991    }
1992}
1993
1994#[must_use = "FIDL methods require a response to be sent"]
1995#[derive(Debug)]
1996pub struct DeviceUnregisterVmoResponder {
1997    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1998    tx_id: u32,
1999}
2000
2001/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2002/// if the responder is dropped without sending a response, so that the client
2003/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2004impl std::ops::Drop for DeviceUnregisterVmoResponder {
2005    fn drop(&mut self) {
2006        self.control_handle.shutdown();
2007        // Safety: drops once, never accessed again
2008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2009    }
2010}
2011
2012impl fidl::endpoints::Responder for DeviceUnregisterVmoResponder {
2013    type ControlHandle = DeviceControlHandle;
2014
2015    fn control_handle(&self) -> &DeviceControlHandle {
2016        &self.control_handle
2017    }
2018
2019    fn drop_without_shutdown(mut self) {
2020        // Safety: drops once, never accessed again due to mem::forget
2021        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2022        // Prevent Drop from running (which would shut down the channel)
2023        std::mem::forget(self);
2024    }
2025}
2026
2027impl DeviceUnregisterVmoResponder {
2028    /// Sends a response to the FIDL transaction.
2029    ///
2030    /// Sets the channel to shutdown if an error occurs.
2031    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
2032        let _result = self.send_raw(result);
2033        if _result.is_err() {
2034            self.control_handle.shutdown();
2035        }
2036        self.drop_without_shutdown();
2037        _result
2038    }
2039
2040    /// Similar to "send" but does not shutdown the channel if an error occurs.
2041    pub fn send_no_shutdown_on_err(
2042        self,
2043        mut result: Result<fidl::Vmo, i32>,
2044    ) -> Result<(), fidl::Error> {
2045        let _result = self.send_raw(result);
2046        self.drop_without_shutdown();
2047        _result
2048    }
2049
2050    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
2051        self.control_handle.inner.send::<fidl::encoding::ResultType<
2052            fidl_fuchsia_hardware_sharedmemory::SharedVmoRegisterUnregisterVmoResponse,
2053            i32,
2054        >>(
2055            result.map(|vmo| (vmo,)),
2056            self.tx_id,
2057            0x1194e9b693827109,
2058            fidl::encoding::DynamicFlags::empty(),
2059        )
2060    }
2061}
2062
2063#[must_use = "FIDL methods require a response to be sent"]
2064#[derive(Debug)]
2065pub struct DeviceTransmitVectorResponder {
2066    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2067    tx_id: u32,
2068}
2069
2070/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2071/// if the responder is dropped without sending a response, so that the client
2072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2073impl std::ops::Drop for DeviceTransmitVectorResponder {
2074    fn drop(&mut self) {
2075        self.control_handle.shutdown();
2076        // Safety: drops once, never accessed again
2077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2078    }
2079}
2080
2081impl fidl::endpoints::Responder for DeviceTransmitVectorResponder {
2082    type ControlHandle = DeviceControlHandle;
2083
2084    fn control_handle(&self) -> &DeviceControlHandle {
2085        &self.control_handle
2086    }
2087
2088    fn drop_without_shutdown(mut self) {
2089        // Safety: drops once, never accessed again due to mem::forget
2090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2091        // Prevent Drop from running (which would shut down the channel)
2092        std::mem::forget(self);
2093    }
2094}
2095
2096impl DeviceTransmitVectorResponder {
2097    /// Sends a response to the FIDL transaction.
2098    ///
2099    /// Sets the channel to shutdown if an error occurs.
2100    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2101        let _result = self.send_raw(status);
2102        if _result.is_err() {
2103            self.control_handle.shutdown();
2104        }
2105        self.drop_without_shutdown();
2106        _result
2107    }
2108
2109    /// Similar to "send" but does not shutdown the channel if an error occurs.
2110    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2111        let _result = self.send_raw(status);
2112        self.drop_without_shutdown();
2113        _result
2114    }
2115
2116    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2117        self.control_handle.inner.send::<DeviceTransmitVectorResponse>(
2118            (status,),
2119            self.tx_id,
2120            0x46a82725fcb5e5d2,
2121            fidl::encoding::DynamicFlags::empty(),
2122        )
2123    }
2124}
2125
2126#[must_use = "FIDL methods require a response to be sent"]
2127#[derive(Debug)]
2128pub struct DeviceReceiveVectorResponder {
2129    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2130    tx_id: u32,
2131}
2132
2133/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2134/// if the responder is dropped without sending a response, so that the client
2135/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2136impl std::ops::Drop for DeviceReceiveVectorResponder {
2137    fn drop(&mut self) {
2138        self.control_handle.shutdown();
2139        // Safety: drops once, never accessed again
2140        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2141    }
2142}
2143
2144impl fidl::endpoints::Responder for DeviceReceiveVectorResponder {
2145    type ControlHandle = DeviceControlHandle;
2146
2147    fn control_handle(&self) -> &DeviceControlHandle {
2148        &self.control_handle
2149    }
2150
2151    fn drop_without_shutdown(mut self) {
2152        // Safety: drops once, never accessed again due to mem::forget
2153        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2154        // Prevent Drop from running (which would shut down the channel)
2155        std::mem::forget(self);
2156    }
2157}
2158
2159impl DeviceReceiveVectorResponder {
2160    /// Sends a response to the FIDL transaction.
2161    ///
2162    /// Sets the channel to shutdown if an error occurs.
2163    pub fn send(self, mut status: i32, mut data: &[u8]) -> Result<(), fidl::Error> {
2164        let _result = self.send_raw(status, data);
2165        if _result.is_err() {
2166            self.control_handle.shutdown();
2167        }
2168        self.drop_without_shutdown();
2169        _result
2170    }
2171
2172    /// Similar to "send" but does not shutdown the channel if an error occurs.
2173    pub fn send_no_shutdown_on_err(
2174        self,
2175        mut status: i32,
2176        mut data: &[u8],
2177    ) -> Result<(), fidl::Error> {
2178        let _result = self.send_raw(status, data);
2179        self.drop_without_shutdown();
2180        _result
2181    }
2182
2183    fn send_raw(&self, mut status: i32, mut data: &[u8]) -> Result<(), fidl::Error> {
2184        self.control_handle.inner.send::<DeviceReceiveVectorResponse>(
2185            (status, data),
2186            self.tx_id,
2187            0x37b160ed6bdd3fd6,
2188            fidl::encoding::DynamicFlags::empty(),
2189        )
2190    }
2191}
2192
2193#[must_use = "FIDL methods require a response to be sent"]
2194#[derive(Debug)]
2195pub struct DeviceExchangeVectorResponder {
2196    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2197    tx_id: u32,
2198}
2199
2200/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2201/// if the responder is dropped without sending a response, so that the client
2202/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2203impl std::ops::Drop for DeviceExchangeVectorResponder {
2204    fn drop(&mut self) {
2205        self.control_handle.shutdown();
2206        // Safety: drops once, never accessed again
2207        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2208    }
2209}
2210
2211impl fidl::endpoints::Responder for DeviceExchangeVectorResponder {
2212    type ControlHandle = DeviceControlHandle;
2213
2214    fn control_handle(&self) -> &DeviceControlHandle {
2215        &self.control_handle
2216    }
2217
2218    fn drop_without_shutdown(mut self) {
2219        // Safety: drops once, never accessed again due to mem::forget
2220        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2221        // Prevent Drop from running (which would shut down the channel)
2222        std::mem::forget(self);
2223    }
2224}
2225
2226impl DeviceExchangeVectorResponder {
2227    /// Sends a response to the FIDL transaction.
2228    ///
2229    /// Sets the channel to shutdown if an error occurs.
2230    pub fn send(self, mut status: i32, mut rxdata: &[u8]) -> Result<(), fidl::Error> {
2231        let _result = self.send_raw(status, rxdata);
2232        if _result.is_err() {
2233            self.control_handle.shutdown();
2234        }
2235        self.drop_without_shutdown();
2236        _result
2237    }
2238
2239    /// Similar to "send" but does not shutdown the channel if an error occurs.
2240    pub fn send_no_shutdown_on_err(
2241        self,
2242        mut status: i32,
2243        mut rxdata: &[u8],
2244    ) -> Result<(), fidl::Error> {
2245        let _result = self.send_raw(status, rxdata);
2246        self.drop_without_shutdown();
2247        _result
2248    }
2249
2250    fn send_raw(&self, mut status: i32, mut rxdata: &[u8]) -> Result<(), fidl::Error> {
2251        self.control_handle.inner.send::<DeviceExchangeVectorResponse>(
2252            (status, rxdata),
2253            self.tx_id,
2254            0x7facbdec2c3c03bd,
2255            fidl::encoding::DynamicFlags::empty(),
2256        )
2257    }
2258}
2259
2260#[must_use = "FIDL methods require a response to be sent"]
2261#[derive(Debug)]
2262pub struct DeviceCanAssertCsResponder {
2263    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2264    tx_id: u32,
2265}
2266
2267/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2268/// if the responder is dropped without sending a response, so that the client
2269/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2270impl std::ops::Drop for DeviceCanAssertCsResponder {
2271    fn drop(&mut self) {
2272        self.control_handle.shutdown();
2273        // Safety: drops once, never accessed again
2274        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2275    }
2276}
2277
2278impl fidl::endpoints::Responder for DeviceCanAssertCsResponder {
2279    type ControlHandle = DeviceControlHandle;
2280
2281    fn control_handle(&self) -> &DeviceControlHandle {
2282        &self.control_handle
2283    }
2284
2285    fn drop_without_shutdown(mut self) {
2286        // Safety: drops once, never accessed again due to mem::forget
2287        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2288        // Prevent Drop from running (which would shut down the channel)
2289        std::mem::forget(self);
2290    }
2291}
2292
2293impl DeviceCanAssertCsResponder {
2294    /// Sends a response to the FIDL transaction.
2295    ///
2296    /// Sets the channel to shutdown if an error occurs.
2297    pub fn send(self, mut can: bool) -> Result<(), fidl::Error> {
2298        let _result = self.send_raw(can);
2299        if _result.is_err() {
2300            self.control_handle.shutdown();
2301        }
2302        self.drop_without_shutdown();
2303        _result
2304    }
2305
2306    /// Similar to "send" but does not shutdown the channel if an error occurs.
2307    pub fn send_no_shutdown_on_err(self, mut can: bool) -> Result<(), fidl::Error> {
2308        let _result = self.send_raw(can);
2309        self.drop_without_shutdown();
2310        _result
2311    }
2312
2313    fn send_raw(&self, mut can: bool) -> Result<(), fidl::Error> {
2314        self.control_handle.inner.send::<DeviceCanAssertCsResponse>(
2315            (can,),
2316            self.tx_id,
2317            0x1f8c12c089a9a874,
2318            fidl::encoding::DynamicFlags::empty(),
2319        )
2320    }
2321}
2322
2323#[must_use = "FIDL methods require a response to be sent"]
2324#[derive(Debug)]
2325pub struct DeviceAssertCsResponder {
2326    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2327    tx_id: u32,
2328}
2329
2330/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2331/// if the responder is dropped without sending a response, so that the client
2332/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2333impl std::ops::Drop for DeviceAssertCsResponder {
2334    fn drop(&mut self) {
2335        self.control_handle.shutdown();
2336        // Safety: drops once, never accessed again
2337        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2338    }
2339}
2340
2341impl fidl::endpoints::Responder for DeviceAssertCsResponder {
2342    type ControlHandle = DeviceControlHandle;
2343
2344    fn control_handle(&self) -> &DeviceControlHandle {
2345        &self.control_handle
2346    }
2347
2348    fn drop_without_shutdown(mut self) {
2349        // Safety: drops once, never accessed again due to mem::forget
2350        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2351        // Prevent Drop from running (which would shut down the channel)
2352        std::mem::forget(self);
2353    }
2354}
2355
2356impl DeviceAssertCsResponder {
2357    /// Sends a response to the FIDL transaction.
2358    ///
2359    /// Sets the channel to shutdown if an error occurs.
2360    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2361        let _result = self.send_raw(status);
2362        if _result.is_err() {
2363            self.control_handle.shutdown();
2364        }
2365        self.drop_without_shutdown();
2366        _result
2367    }
2368
2369    /// Similar to "send" but does not shutdown the channel if an error occurs.
2370    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2371        let _result = self.send_raw(status);
2372        self.drop_without_shutdown();
2373        _result
2374    }
2375
2376    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2377        self.control_handle.inner.send::<DeviceAssertCsResponse>(
2378            (status,),
2379            self.tx_id,
2380            0x4ff66add7bd91ce6,
2381            fidl::encoding::DynamicFlags::empty(),
2382        )
2383    }
2384}
2385
2386#[must_use = "FIDL methods require a response to be sent"]
2387#[derive(Debug)]
2388pub struct DeviceDeassertCsResponder {
2389    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2390    tx_id: u32,
2391}
2392
2393/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
2394/// if the responder is dropped without sending a response, so that the client
2395/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2396impl std::ops::Drop for DeviceDeassertCsResponder {
2397    fn drop(&mut self) {
2398        self.control_handle.shutdown();
2399        // Safety: drops once, never accessed again
2400        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2401    }
2402}
2403
2404impl fidl::endpoints::Responder for DeviceDeassertCsResponder {
2405    type ControlHandle = DeviceControlHandle;
2406
2407    fn control_handle(&self) -> &DeviceControlHandle {
2408        &self.control_handle
2409    }
2410
2411    fn drop_without_shutdown(mut self) {
2412        // Safety: drops once, never accessed again due to mem::forget
2413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2414        // Prevent Drop from running (which would shut down the channel)
2415        std::mem::forget(self);
2416    }
2417}
2418
2419impl DeviceDeassertCsResponder {
2420    /// Sends a response to the FIDL transaction.
2421    ///
2422    /// Sets the channel to shutdown if an error occurs.
2423    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
2424        let _result = self.send_raw(status);
2425        if _result.is_err() {
2426            self.control_handle.shutdown();
2427        }
2428        self.drop_without_shutdown();
2429        _result
2430    }
2431
2432    /// Similar to "send" but does not shutdown the channel if an error occurs.
2433    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
2434        let _result = self.send_raw(status);
2435        self.drop_without_shutdown();
2436        _result
2437    }
2438
2439    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
2440        self.control_handle.inner.send::<DeviceDeassertCsResponse>(
2441            (status,),
2442            self.tx_id,
2443            0x5e4cd660a0bc0db8,
2444            fidl::encoding::DynamicFlags::empty(),
2445        )
2446    }
2447}
2448
2449#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2450pub struct TestMarker;
2451
2452impl fidl::endpoints::ProtocolMarker for TestMarker {
2453    type Proxy = TestProxy;
2454    type RequestStream = TestRequestStream;
2455    #[cfg(target_os = "fuchsia")]
2456    type SynchronousProxy = TestSynchronousProxy;
2457
2458    const DEBUG_NAME: &'static str = "(anonymous) Test";
2459}
2460pub type TestConnectSpiLoopbackResult = Result<(), i32>;
2461
2462pub trait TestProxyInterface: Send + Sync {
2463    type GetResponseFut: std::future::Future<
2464            Output = Result<fidl_fuchsia_driver_token::NodeTokenGetResult, fidl::Error>,
2465        > + Send;
2466    fn r#get(&self) -> Self::GetResponseFut;
2467    type ConnectSpiLoopbackResponseFut: std::future::Future<Output = Result<TestConnectSpiLoopbackResult, fidl::Error>>
2468        + Send;
2469    fn r#connect_spi_loopback(
2470        &self,
2471        server: fidl::endpoints::ServerEnd<DeviceMarker>,
2472    ) -> Self::ConnectSpiLoopbackResponseFut;
2473}
2474#[derive(Debug)]
2475#[cfg(target_os = "fuchsia")]
2476pub struct TestSynchronousProxy {
2477    client: fidl::client::sync::Client,
2478}
2479
2480#[cfg(target_os = "fuchsia")]
2481impl fidl::endpoints::SynchronousProxy for TestSynchronousProxy {
2482    type Proxy = TestProxy;
2483    type Protocol = TestMarker;
2484
2485    fn from_channel(inner: fidl::Channel) -> Self {
2486        Self::new(inner)
2487    }
2488
2489    fn into_channel(self) -> fidl::Channel {
2490        self.client.into_channel()
2491    }
2492
2493    fn as_channel(&self) -> &fidl::Channel {
2494        self.client.as_channel()
2495    }
2496}
2497
2498#[cfg(target_os = "fuchsia")]
2499impl TestSynchronousProxy {
2500    pub fn new(channel: fidl::Channel) -> Self {
2501        Self { client: fidl::client::sync::Client::new(channel) }
2502    }
2503
2504    pub fn into_channel(self) -> fidl::Channel {
2505        self.client.into_channel()
2506    }
2507
2508    /// Waits until an event arrives and returns it. It is safe for other
2509    /// threads to make concurrent requests while waiting for an event.
2510    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<TestEvent, fidl::Error> {
2511        TestEvent::decode(self.client.wait_for_event::<TestMarker>(deadline)?)
2512    }
2513
2514    pub fn r#get(
2515        &self,
2516        ___deadline: zx::MonotonicInstant,
2517    ) -> Result<fidl_fuchsia_driver_token::NodeTokenGetResult, fidl::Error> {
2518        let _response =
2519            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
2520                fidl_fuchsia_driver_token::NodeTokenGetResponse,
2521                i32,
2522            >, TestMarker>(
2523                (),
2524                0x64166e3a6984b1d9,
2525                fidl::encoding::DynamicFlags::empty(),
2526                ___deadline,
2527            )?;
2528        Ok(_response.map(|x| x.token))
2529    }
2530
2531    /// Opens a connection to a SPI device in loopback mode, to be used for testing.
2532    ///
2533    /// Returns ZX_ERR_NOT_SUPPORTED if debugging is not enabled in this build.
2534    ///
2535    /// If the SPI implementation driver itself does not support loopback mode, this call will
2536    /// succeed, but calls to the Device will fail with ZX_ERR_NOT_SUPPORTED instead.
2537    pub fn r#connect_spi_loopback(
2538        &self,
2539        mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
2540        ___deadline: zx::MonotonicInstant,
2541    ) -> Result<TestConnectSpiLoopbackResult, fidl::Error> {
2542        let _response = self.client.send_query::<
2543            TestConnectSpiLoopbackRequest,
2544            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2545            TestMarker,
2546        >(
2547            (server,),
2548            0x420403db2950bb2a,
2549            fidl::encoding::DynamicFlags::empty(),
2550            ___deadline,
2551        )?;
2552        Ok(_response.map(|x| x))
2553    }
2554}
2555
2556#[cfg(target_os = "fuchsia")]
2557impl From<TestSynchronousProxy> for zx::NullableHandle {
2558    fn from(value: TestSynchronousProxy) -> Self {
2559        value.into_channel().into()
2560    }
2561}
2562
2563#[cfg(target_os = "fuchsia")]
2564impl From<fidl::Channel> for TestSynchronousProxy {
2565    fn from(value: fidl::Channel) -> Self {
2566        Self::new(value)
2567    }
2568}
2569
2570#[cfg(target_os = "fuchsia")]
2571impl fidl::endpoints::FromClient for TestSynchronousProxy {
2572    type Protocol = TestMarker;
2573
2574    fn from_client(value: fidl::endpoints::ClientEnd<TestMarker>) -> Self {
2575        Self::new(value.into_channel())
2576    }
2577}
2578
2579#[derive(Debug, Clone)]
2580pub struct TestProxy {
2581    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2582}
2583
2584impl fidl::endpoints::Proxy for TestProxy {
2585    type Protocol = TestMarker;
2586
2587    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2588        Self::new(inner)
2589    }
2590
2591    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2592        self.client.into_channel().map_err(|client| Self { client })
2593    }
2594
2595    fn as_channel(&self) -> &::fidl::AsyncChannel {
2596        self.client.as_channel()
2597    }
2598}
2599
2600impl TestProxy {
2601    /// Create a new Proxy for fuchsia.hardware.spi/Test.
2602    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2603        let protocol_name = <TestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2604        Self { client: fidl::client::Client::new(channel, protocol_name) }
2605    }
2606
2607    /// Get a Stream of events from the remote end of the protocol.
2608    ///
2609    /// # Panics
2610    ///
2611    /// Panics if the event stream was already taken.
2612    pub fn take_event_stream(&self) -> TestEventStream {
2613        TestEventStream { event_receiver: self.client.take_event_receiver() }
2614    }
2615
2616    pub fn r#get(
2617        &self,
2618    ) -> fidl::client::QueryResponseFut<
2619        fidl_fuchsia_driver_token::NodeTokenGetResult,
2620        fidl::encoding::DefaultFuchsiaResourceDialect,
2621    > {
2622        TestProxyInterface::r#get(self)
2623    }
2624
2625    /// Opens a connection to a SPI device in loopback mode, to be used for testing.
2626    ///
2627    /// Returns ZX_ERR_NOT_SUPPORTED if debugging is not enabled in this build.
2628    ///
2629    /// If the SPI implementation driver itself does not support loopback mode, this call will
2630    /// succeed, but calls to the Device will fail with ZX_ERR_NOT_SUPPORTED instead.
2631    pub fn r#connect_spi_loopback(
2632        &self,
2633        mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
2634    ) -> fidl::client::QueryResponseFut<
2635        TestConnectSpiLoopbackResult,
2636        fidl::encoding::DefaultFuchsiaResourceDialect,
2637    > {
2638        TestProxyInterface::r#connect_spi_loopback(self, server)
2639    }
2640}
2641
2642impl TestProxyInterface for TestProxy {
2643    type GetResponseFut = fidl::client::QueryResponseFut<
2644        fidl_fuchsia_driver_token::NodeTokenGetResult,
2645        fidl::encoding::DefaultFuchsiaResourceDialect,
2646    >;
2647    fn r#get(&self) -> Self::GetResponseFut {
2648        fn _decode(
2649            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2650        ) -> Result<fidl_fuchsia_driver_token::NodeTokenGetResult, fidl::Error> {
2651            let _response = fidl::client::decode_transaction_body::<
2652                fidl::encoding::ResultType<fidl_fuchsia_driver_token::NodeTokenGetResponse, i32>,
2653                fidl::encoding::DefaultFuchsiaResourceDialect,
2654                0x64166e3a6984b1d9,
2655            >(_buf?)?;
2656            Ok(_response.map(|x| x.token))
2657        }
2658        self.client.send_query_and_decode::<
2659            fidl::encoding::EmptyPayload,
2660            fidl_fuchsia_driver_token::NodeTokenGetResult,
2661        >(
2662            (),
2663            0x64166e3a6984b1d9,
2664            fidl::encoding::DynamicFlags::empty(),
2665            _decode,
2666        )
2667    }
2668
2669    type ConnectSpiLoopbackResponseFut = fidl::client::QueryResponseFut<
2670        TestConnectSpiLoopbackResult,
2671        fidl::encoding::DefaultFuchsiaResourceDialect,
2672    >;
2673    fn r#connect_spi_loopback(
2674        &self,
2675        mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
2676    ) -> Self::ConnectSpiLoopbackResponseFut {
2677        fn _decode(
2678            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2679        ) -> Result<TestConnectSpiLoopbackResult, fidl::Error> {
2680            let _response = fidl::client::decode_transaction_body::<
2681                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2682                fidl::encoding::DefaultFuchsiaResourceDialect,
2683                0x420403db2950bb2a,
2684            >(_buf?)?;
2685            Ok(_response.map(|x| x))
2686        }
2687        self.client
2688            .send_query_and_decode::<TestConnectSpiLoopbackRequest, TestConnectSpiLoopbackResult>(
2689                (server,),
2690                0x420403db2950bb2a,
2691                fidl::encoding::DynamicFlags::empty(),
2692                _decode,
2693            )
2694    }
2695}
2696
2697pub struct TestEventStream {
2698    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2699}
2700
2701impl std::marker::Unpin for TestEventStream {}
2702
2703impl futures::stream::FusedStream for TestEventStream {
2704    fn is_terminated(&self) -> bool {
2705        self.event_receiver.is_terminated()
2706    }
2707}
2708
2709impl futures::Stream for TestEventStream {
2710    type Item = Result<TestEvent, fidl::Error>;
2711
2712    fn poll_next(
2713        mut self: std::pin::Pin<&mut Self>,
2714        cx: &mut std::task::Context<'_>,
2715    ) -> std::task::Poll<Option<Self::Item>> {
2716        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2717            &mut self.event_receiver,
2718            cx
2719        )?) {
2720            Some(buf) => std::task::Poll::Ready(Some(TestEvent::decode(buf))),
2721            None => std::task::Poll::Ready(None),
2722        }
2723    }
2724}
2725
2726#[derive(Debug)]
2727pub enum TestEvent {
2728    #[non_exhaustive]
2729    _UnknownEvent {
2730        /// Ordinal of the event that was sent.
2731        ordinal: u64,
2732    },
2733}
2734
2735impl TestEvent {
2736    /// Decodes a message buffer as a [`TestEvent`].
2737    fn decode(
2738        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2739    ) -> Result<TestEvent, fidl::Error> {
2740        let (bytes, _handles) = buf.split_mut();
2741        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2742        debug_assert_eq!(tx_header.tx_id, 0);
2743        match tx_header.ordinal {
2744            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2745                Ok(TestEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2746            }
2747            _ => Err(fidl::Error::UnknownOrdinal {
2748                ordinal: tx_header.ordinal,
2749                protocol_name: <TestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2750            }),
2751        }
2752    }
2753}
2754
2755/// A Stream of incoming requests for fuchsia.hardware.spi/Test.
2756pub struct TestRequestStream {
2757    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2758    is_terminated: bool,
2759}
2760
2761impl std::marker::Unpin for TestRequestStream {}
2762
2763impl futures::stream::FusedStream for TestRequestStream {
2764    fn is_terminated(&self) -> bool {
2765        self.is_terminated
2766    }
2767}
2768
2769impl fidl::endpoints::RequestStream for TestRequestStream {
2770    type Protocol = TestMarker;
2771    type ControlHandle = TestControlHandle;
2772
2773    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2774        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2775    }
2776
2777    fn control_handle(&self) -> Self::ControlHandle {
2778        TestControlHandle { inner: self.inner.clone() }
2779    }
2780
2781    fn into_inner(
2782        self,
2783    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2784    {
2785        (self.inner, self.is_terminated)
2786    }
2787
2788    fn from_inner(
2789        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2790        is_terminated: bool,
2791    ) -> Self {
2792        Self { inner, is_terminated }
2793    }
2794}
2795
2796impl futures::Stream for TestRequestStream {
2797    type Item = Result<TestRequest, fidl::Error>;
2798
2799    fn poll_next(
2800        mut self: std::pin::Pin<&mut Self>,
2801        cx: &mut std::task::Context<'_>,
2802    ) -> std::task::Poll<Option<Self::Item>> {
2803        let this = &mut *self;
2804        if this.inner.check_shutdown(cx) {
2805            this.is_terminated = true;
2806            return std::task::Poll::Ready(None);
2807        }
2808        if this.is_terminated {
2809            panic!("polled TestRequestStream after completion");
2810        }
2811        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2812            |bytes, handles| {
2813                match this.inner.channel().read_etc(cx, bytes, handles) {
2814                    std::task::Poll::Ready(Ok(())) => {}
2815                    std::task::Poll::Pending => return std::task::Poll::Pending,
2816                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2817                        this.is_terminated = true;
2818                        return std::task::Poll::Ready(None);
2819                    }
2820                    std::task::Poll::Ready(Err(e)) => {
2821                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2822                            e.into(),
2823                        ))));
2824                    }
2825                }
2826
2827                // A message has been received from the channel
2828                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2829
2830                std::task::Poll::Ready(Some(match header.ordinal {
2831                    0x64166e3a6984b1d9 => {
2832                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2833                        let mut req = fidl::new_empty!(
2834                            fidl::encoding::EmptyPayload,
2835                            fidl::encoding::DefaultFuchsiaResourceDialect
2836                        );
2837                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2838                        let control_handle = TestControlHandle { inner: this.inner.clone() };
2839                        Ok(TestRequest::Get {
2840                            responder: TestGetResponder {
2841                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2842                                tx_id: header.tx_id,
2843                            },
2844                        })
2845                    }
2846                    0x420403db2950bb2a => {
2847                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2848                        let mut req = fidl::new_empty!(
2849                            TestConnectSpiLoopbackRequest,
2850                            fidl::encoding::DefaultFuchsiaResourceDialect
2851                        );
2852                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TestConnectSpiLoopbackRequest>(&header, _body_bytes, handles, &mut req)?;
2853                        let control_handle = TestControlHandle { inner: this.inner.clone() };
2854                        Ok(TestRequest::ConnectSpiLoopback {
2855                            server: req.server,
2856
2857                            responder: TestConnectSpiLoopbackResponder {
2858                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2859                                tx_id: header.tx_id,
2860                            },
2861                        })
2862                    }
2863                    _ if header.tx_id == 0
2864                        && header
2865                            .dynamic_flags()
2866                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2867                    {
2868                        Ok(TestRequest::_UnknownMethod {
2869                            ordinal: header.ordinal,
2870                            control_handle: TestControlHandle { inner: this.inner.clone() },
2871                            method_type: fidl::MethodType::OneWay,
2872                        })
2873                    }
2874                    _ if header
2875                        .dynamic_flags()
2876                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2877                    {
2878                        this.inner.send_framework_err(
2879                            fidl::encoding::FrameworkErr::UnknownMethod,
2880                            header.tx_id,
2881                            header.ordinal,
2882                            header.dynamic_flags(),
2883                            (bytes, handles),
2884                        )?;
2885                        Ok(TestRequest::_UnknownMethod {
2886                            ordinal: header.ordinal,
2887                            control_handle: TestControlHandle { inner: this.inner.clone() },
2888                            method_type: fidl::MethodType::TwoWay,
2889                        })
2890                    }
2891                    _ => Err(fidl::Error::UnknownOrdinal {
2892                        ordinal: header.ordinal,
2893                        protocol_name: <TestMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2894                    }),
2895                }))
2896            },
2897        )
2898    }
2899}
2900
2901#[derive(Debug)]
2902pub enum TestRequest {
2903    Get {
2904        responder: TestGetResponder,
2905    },
2906    /// Opens a connection to a SPI device in loopback mode, to be used for testing.
2907    ///
2908    /// Returns ZX_ERR_NOT_SUPPORTED if debugging is not enabled in this build.
2909    ///
2910    /// If the SPI implementation driver itself does not support loopback mode, this call will
2911    /// succeed, but calls to the Device will fail with ZX_ERR_NOT_SUPPORTED instead.
2912    ConnectSpiLoopback {
2913        server: fidl::endpoints::ServerEnd<DeviceMarker>,
2914        responder: TestConnectSpiLoopbackResponder,
2915    },
2916    /// An interaction was received which does not match any known method.
2917    #[non_exhaustive]
2918    _UnknownMethod {
2919        /// Ordinal of the method that was called.
2920        ordinal: u64,
2921        control_handle: TestControlHandle,
2922        method_type: fidl::MethodType,
2923    },
2924}
2925
2926impl TestRequest {
2927    #[allow(irrefutable_let_patterns)]
2928    pub fn into_get(self) -> Option<(TestGetResponder)> {
2929        if let TestRequest::Get { responder } = self { Some((responder)) } else { None }
2930    }
2931
2932    #[allow(irrefutable_let_patterns)]
2933    pub fn into_connect_spi_loopback(
2934        self,
2935    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, TestConnectSpiLoopbackResponder)> {
2936        if let TestRequest::ConnectSpiLoopback { server, responder } = self {
2937            Some((server, responder))
2938        } else {
2939            None
2940        }
2941    }
2942
2943    /// Name of the method defined in FIDL
2944    pub fn method_name(&self) -> &'static str {
2945        match *self {
2946            TestRequest::Get { .. } => "get",
2947            TestRequest::ConnectSpiLoopback { .. } => "connect_spi_loopback",
2948            TestRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2949                "unknown one-way method"
2950            }
2951            TestRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2952                "unknown two-way method"
2953            }
2954        }
2955    }
2956}
2957
2958#[derive(Debug, Clone)]
2959pub struct TestControlHandle {
2960    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2961}
2962
2963impl TestControlHandle {
2964    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2965        self.inner.shutdown_with_epitaph(status.into())
2966    }
2967}
2968
2969impl fidl::endpoints::ControlHandle for TestControlHandle {
2970    fn shutdown(&self) {
2971        self.inner.shutdown()
2972    }
2973
2974    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2975        self.inner.shutdown_with_epitaph(status)
2976    }
2977
2978    fn is_closed(&self) -> bool {
2979        self.inner.channel().is_closed()
2980    }
2981    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2982        self.inner.channel().on_closed()
2983    }
2984
2985    #[cfg(target_os = "fuchsia")]
2986    fn signal_peer(
2987        &self,
2988        clear_mask: zx::Signals,
2989        set_mask: zx::Signals,
2990    ) -> Result<(), zx_status::Status> {
2991        use fidl::Peered;
2992        self.inner.channel().signal_peer(clear_mask, set_mask)
2993    }
2994}
2995
2996impl TestControlHandle {}
2997
2998#[must_use = "FIDL methods require a response to be sent"]
2999#[derive(Debug)]
3000pub struct TestGetResponder {
3001    control_handle: std::mem::ManuallyDrop<TestControlHandle>,
3002    tx_id: u32,
3003}
3004
3005/// Set the the channel to be shutdown (see [`TestControlHandle::shutdown`])
3006/// if the responder is dropped without sending a response, so that the client
3007/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3008impl std::ops::Drop for TestGetResponder {
3009    fn drop(&mut self) {
3010        self.control_handle.shutdown();
3011        // Safety: drops once, never accessed again
3012        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3013    }
3014}
3015
3016impl fidl::endpoints::Responder for TestGetResponder {
3017    type ControlHandle = TestControlHandle;
3018
3019    fn control_handle(&self) -> &TestControlHandle {
3020        &self.control_handle
3021    }
3022
3023    fn drop_without_shutdown(mut self) {
3024        // Safety: drops once, never accessed again due to mem::forget
3025        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3026        // Prevent Drop from running (which would shut down the channel)
3027        std::mem::forget(self);
3028    }
3029}
3030
3031impl TestGetResponder {
3032    /// Sends a response to the FIDL transaction.
3033    ///
3034    /// Sets the channel to shutdown if an error occurs.
3035    pub fn send(self, mut result: Result<fidl::Event, i32>) -> Result<(), fidl::Error> {
3036        let _result = self.send_raw(result);
3037        if _result.is_err() {
3038            self.control_handle.shutdown();
3039        }
3040        self.drop_without_shutdown();
3041        _result
3042    }
3043
3044    /// Similar to "send" but does not shutdown the channel if an error occurs.
3045    pub fn send_no_shutdown_on_err(
3046        self,
3047        mut result: Result<fidl::Event, i32>,
3048    ) -> Result<(), fidl::Error> {
3049        let _result = self.send_raw(result);
3050        self.drop_without_shutdown();
3051        _result
3052    }
3053
3054    fn send_raw(&self, mut result: Result<fidl::Event, i32>) -> Result<(), fidl::Error> {
3055        self.control_handle.inner.send::<fidl::encoding::ResultType<
3056            fidl_fuchsia_driver_token::NodeTokenGetResponse,
3057            i32,
3058        >>(
3059            result.map(|token| (token,)),
3060            self.tx_id,
3061            0x64166e3a6984b1d9,
3062            fidl::encoding::DynamicFlags::empty(),
3063        )
3064    }
3065}
3066
3067#[must_use = "FIDL methods require a response to be sent"]
3068#[derive(Debug)]
3069pub struct TestConnectSpiLoopbackResponder {
3070    control_handle: std::mem::ManuallyDrop<TestControlHandle>,
3071    tx_id: u32,
3072}
3073
3074/// Set the the channel to be shutdown (see [`TestControlHandle::shutdown`])
3075/// if the responder is dropped without sending a response, so that the client
3076/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3077impl std::ops::Drop for TestConnectSpiLoopbackResponder {
3078    fn drop(&mut self) {
3079        self.control_handle.shutdown();
3080        // Safety: drops once, never accessed again
3081        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3082    }
3083}
3084
3085impl fidl::endpoints::Responder for TestConnectSpiLoopbackResponder {
3086    type ControlHandle = TestControlHandle;
3087
3088    fn control_handle(&self) -> &TestControlHandle {
3089        &self.control_handle
3090    }
3091
3092    fn drop_without_shutdown(mut self) {
3093        // Safety: drops once, never accessed again due to mem::forget
3094        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3095        // Prevent Drop from running (which would shut down the channel)
3096        std::mem::forget(self);
3097    }
3098}
3099
3100impl TestConnectSpiLoopbackResponder {
3101    /// Sends a response to the FIDL transaction.
3102    ///
3103    /// Sets the channel to shutdown if an error occurs.
3104    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3105        let _result = self.send_raw(result);
3106        if _result.is_err() {
3107            self.control_handle.shutdown();
3108        }
3109        self.drop_without_shutdown();
3110        _result
3111    }
3112
3113    /// Similar to "send" but does not shutdown the channel if an error occurs.
3114    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3115        let _result = self.send_raw(result);
3116        self.drop_without_shutdown();
3117        _result
3118    }
3119
3120    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3121        self.control_handle
3122            .inner
3123            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3124                result,
3125                self.tx_id,
3126                0x420403db2950bb2a,
3127                fidl::encoding::DynamicFlags::empty(),
3128            )
3129    }
3130}
3131
3132#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3133pub struct ControllerServiceMarker;
3134
3135#[cfg(target_os = "fuchsia")]
3136impl fidl::endpoints::ServiceMarker for ControllerServiceMarker {
3137    type Proxy = ControllerServiceProxy;
3138    type Request = ControllerServiceRequest;
3139    const SERVICE_NAME: &'static str = "fuchsia.hardware.spi.ControllerService";
3140}
3141
3142/// A request for one of the member protocols of ControllerService.
3143///
3144#[cfg(target_os = "fuchsia")]
3145pub enum ControllerServiceRequest {
3146    Device(ControllerRequestStream),
3147}
3148
3149#[cfg(target_os = "fuchsia")]
3150impl fidl::endpoints::ServiceRequest for ControllerServiceRequest {
3151    type Service = ControllerServiceMarker;
3152
3153    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
3154        match name {
3155            "device" => Self::Device(
3156                <ControllerRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
3157            ),
3158            _ => panic!("no such member protocol name for service ControllerService"),
3159        }
3160    }
3161
3162    fn member_names() -> &'static [&'static str] {
3163        &["device"]
3164    }
3165}
3166#[cfg(target_os = "fuchsia")]
3167pub struct ControllerServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
3168
3169#[cfg(target_os = "fuchsia")]
3170impl fidl::endpoints::ServiceProxy for ControllerServiceProxy {
3171    type Service = ControllerServiceMarker;
3172
3173    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
3174        Self(opener)
3175    }
3176}
3177
3178#[cfg(target_os = "fuchsia")]
3179impl ControllerServiceProxy {
3180    pub fn connect_to_device(&self) -> Result<ControllerProxy, fidl::Error> {
3181        let (proxy, server_end) = fidl::endpoints::create_proxy::<ControllerMarker>();
3182        self.connect_channel_to_device(server_end)?;
3183        Ok(proxy)
3184    }
3185
3186    /// Like `connect_to_device`, but returns a sync proxy.
3187    /// See [`Self::connect_to_device`] for more details.
3188    pub fn connect_to_device_sync(&self) -> Result<ControllerSynchronousProxy, fidl::Error> {
3189        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ControllerMarker>();
3190        self.connect_channel_to_device(server_end)?;
3191        Ok(proxy)
3192    }
3193
3194    /// Like `connect_to_device`, but accepts a server end.
3195    /// See [`Self::connect_to_device`] for more details.
3196    pub fn connect_channel_to_device(
3197        &self,
3198        server_end: fidl::endpoints::ServerEnd<ControllerMarker>,
3199    ) -> Result<(), fidl::Error> {
3200        self.0.open_member("device", server_end.into_channel())
3201    }
3202
3203    pub fn instance_name(&self) -> &str {
3204        self.0.instance_name()
3205    }
3206}
3207
3208#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3209pub struct ServiceMarker;
3210
3211#[cfg(target_os = "fuchsia")]
3212impl fidl::endpoints::ServiceMarker for ServiceMarker {
3213    type Proxy = ServiceProxy;
3214    type Request = ServiceRequest;
3215    const SERVICE_NAME: &'static str = "fuchsia.hardware.spi.Service";
3216}
3217
3218/// A request for one of the member protocols of Service.
3219///
3220#[cfg(target_os = "fuchsia")]
3221pub enum ServiceRequest {
3222    Device(DeviceRequestStream),
3223}
3224
3225#[cfg(target_os = "fuchsia")]
3226impl fidl::endpoints::ServiceRequest for ServiceRequest {
3227    type Service = ServiceMarker;
3228
3229    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
3230        match name {
3231            "device" => Self::Device(
3232                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
3233            ),
3234            _ => panic!("no such member protocol name for service Service"),
3235        }
3236    }
3237
3238    fn member_names() -> &'static [&'static str] {
3239        &["device"]
3240    }
3241}
3242#[cfg(target_os = "fuchsia")]
3243pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
3244
3245#[cfg(target_os = "fuchsia")]
3246impl fidl::endpoints::ServiceProxy for ServiceProxy {
3247    type Service = ServiceMarker;
3248
3249    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
3250        Self(opener)
3251    }
3252}
3253
3254#[cfg(target_os = "fuchsia")]
3255impl ServiceProxy {
3256    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
3257        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
3258        self.connect_channel_to_device(server_end)?;
3259        Ok(proxy)
3260    }
3261
3262    /// Like `connect_to_device`, but returns a sync proxy.
3263    /// See [`Self::connect_to_device`] for more details.
3264    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
3265        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
3266        self.connect_channel_to_device(server_end)?;
3267        Ok(proxy)
3268    }
3269
3270    /// Like `connect_to_device`, but accepts a server end.
3271    /// See [`Self::connect_to_device`] for more details.
3272    pub fn connect_channel_to_device(
3273        &self,
3274        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
3275    ) -> Result<(), fidl::Error> {
3276        self.0.open_member("device", server_end.into_channel())
3277    }
3278
3279    pub fn instance_name(&self) -> &str {
3280        self.0.instance_name()
3281    }
3282}
3283
3284#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3285pub struct TestServiceMarker;
3286
3287#[cfg(target_os = "fuchsia")]
3288impl fidl::endpoints::ServiceMarker for TestServiceMarker {
3289    type Proxy = TestServiceProxy;
3290    type Request = TestServiceRequest;
3291    const SERVICE_NAME: &'static str = "fuchsia.hardware.spi.TestService";
3292}
3293
3294/// A request for one of the member protocols of TestService.
3295///
3296#[cfg(target_os = "fuchsia")]
3297pub enum TestServiceRequest {
3298    Test(TestRequestStream),
3299}
3300
3301#[cfg(target_os = "fuchsia")]
3302impl fidl::endpoints::ServiceRequest for TestServiceRequest {
3303    type Service = TestServiceMarker;
3304
3305    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
3306        match name {
3307            "test" => Self::Test(
3308                <TestRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
3309            ),
3310            _ => panic!("no such member protocol name for service TestService"),
3311        }
3312    }
3313
3314    fn member_names() -> &'static [&'static str] {
3315        &["test"]
3316    }
3317}
3318#[cfg(target_os = "fuchsia")]
3319pub struct TestServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
3320
3321#[cfg(target_os = "fuchsia")]
3322impl fidl::endpoints::ServiceProxy for TestServiceProxy {
3323    type Service = TestServiceMarker;
3324
3325    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
3326        Self(opener)
3327    }
3328}
3329
3330#[cfg(target_os = "fuchsia")]
3331impl TestServiceProxy {
3332    pub fn connect_to_test(&self) -> Result<TestProxy, fidl::Error> {
3333        let (proxy, server_end) = fidl::endpoints::create_proxy::<TestMarker>();
3334        self.connect_channel_to_test(server_end)?;
3335        Ok(proxy)
3336    }
3337
3338    /// Like `connect_to_test`, but returns a sync proxy.
3339    /// See [`Self::connect_to_test`] for more details.
3340    pub fn connect_to_test_sync(&self) -> Result<TestSynchronousProxy, fidl::Error> {
3341        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<TestMarker>();
3342        self.connect_channel_to_test(server_end)?;
3343        Ok(proxy)
3344    }
3345
3346    /// Like `connect_to_test`, but accepts a server end.
3347    /// See [`Self::connect_to_test`] for more details.
3348    pub fn connect_channel_to_test(
3349        &self,
3350        server_end: fidl::endpoints::ServerEnd<TestMarker>,
3351    ) -> Result<(), fidl::Error> {
3352        self.0.open_member("test", server_end.into_channel())
3353    }
3354
3355    pub fn instance_name(&self) -> &str {
3356        self.0.instance_name()
3357    }
3358}
3359
3360mod internal {
3361    use super::*;
3362
3363    impl fidl::encoding::ResourceTypeMarker for ControllerOpenSessionRequest {
3364        type Borrowed<'a> = &'a mut Self;
3365        fn take_or_borrow<'a>(
3366            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3367        ) -> Self::Borrowed<'a> {
3368            value
3369        }
3370    }
3371
3372    unsafe impl fidl::encoding::TypeMarker for ControllerOpenSessionRequest {
3373        type Owned = Self;
3374
3375        #[inline(always)]
3376        fn inline_align(_context: fidl::encoding::Context) -> usize {
3377            4
3378        }
3379
3380        #[inline(always)]
3381        fn inline_size(_context: fidl::encoding::Context) -> usize {
3382            4
3383        }
3384    }
3385
3386    unsafe impl
3387        fidl::encoding::Encode<
3388            ControllerOpenSessionRequest,
3389            fidl::encoding::DefaultFuchsiaResourceDialect,
3390        > for &mut ControllerOpenSessionRequest
3391    {
3392        #[inline]
3393        unsafe fn encode(
3394            self,
3395            encoder: &mut fidl::encoding::Encoder<
3396                '_,
3397                fidl::encoding::DefaultFuchsiaResourceDialect,
3398            >,
3399            offset: usize,
3400            _depth: fidl::encoding::Depth,
3401        ) -> fidl::Result<()> {
3402            encoder.debug_check_bounds::<ControllerOpenSessionRequest>(offset);
3403            // Delegate to tuple encoding.
3404            fidl::encoding::Encode::<ControllerOpenSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3405                (
3406                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
3407                ),
3408                encoder, offset, _depth
3409            )
3410        }
3411    }
3412    unsafe impl<
3413        T0: fidl::encoding::Encode<
3414                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3415                fidl::encoding::DefaultFuchsiaResourceDialect,
3416            >,
3417    >
3418        fidl::encoding::Encode<
3419            ControllerOpenSessionRequest,
3420            fidl::encoding::DefaultFuchsiaResourceDialect,
3421        > for (T0,)
3422    {
3423        #[inline]
3424        unsafe fn encode(
3425            self,
3426            encoder: &mut fidl::encoding::Encoder<
3427                '_,
3428                fidl::encoding::DefaultFuchsiaResourceDialect,
3429            >,
3430            offset: usize,
3431            depth: fidl::encoding::Depth,
3432        ) -> fidl::Result<()> {
3433            encoder.debug_check_bounds::<ControllerOpenSessionRequest>(offset);
3434            // Zero out padding regions. There's no need to apply masks
3435            // because the unmasked parts will be overwritten by fields.
3436            // Write the fields.
3437            self.0.encode(encoder, offset + 0, depth)?;
3438            Ok(())
3439        }
3440    }
3441
3442    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3443        for ControllerOpenSessionRequest
3444    {
3445        #[inline(always)]
3446        fn new_empty() -> Self {
3447            Self {
3448                session: fidl::new_empty!(
3449                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3450                    fidl::encoding::DefaultFuchsiaResourceDialect
3451                ),
3452            }
3453        }
3454
3455        #[inline]
3456        unsafe fn decode(
3457            &mut self,
3458            decoder: &mut fidl::encoding::Decoder<
3459                '_,
3460                fidl::encoding::DefaultFuchsiaResourceDialect,
3461            >,
3462            offset: usize,
3463            _depth: fidl::encoding::Depth,
3464        ) -> fidl::Result<()> {
3465            decoder.debug_check_bounds::<Self>(offset);
3466            // Verify that padding bytes are zero.
3467            fidl::decode!(
3468                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3469                fidl::encoding::DefaultFuchsiaResourceDialect,
3470                &mut self.session,
3471                decoder,
3472                offset + 0,
3473                _depth
3474            )?;
3475            Ok(())
3476        }
3477    }
3478
3479    impl fidl::encoding::ResourceTypeMarker for TestConnectSpiLoopbackRequest {
3480        type Borrowed<'a> = &'a mut Self;
3481        fn take_or_borrow<'a>(
3482            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3483        ) -> Self::Borrowed<'a> {
3484            value
3485        }
3486    }
3487
3488    unsafe impl fidl::encoding::TypeMarker for TestConnectSpiLoopbackRequest {
3489        type Owned = Self;
3490
3491        #[inline(always)]
3492        fn inline_align(_context: fidl::encoding::Context) -> usize {
3493            4
3494        }
3495
3496        #[inline(always)]
3497        fn inline_size(_context: fidl::encoding::Context) -> usize {
3498            4
3499        }
3500    }
3501
3502    unsafe impl
3503        fidl::encoding::Encode<
3504            TestConnectSpiLoopbackRequest,
3505            fidl::encoding::DefaultFuchsiaResourceDialect,
3506        > for &mut TestConnectSpiLoopbackRequest
3507    {
3508        #[inline]
3509        unsafe fn encode(
3510            self,
3511            encoder: &mut fidl::encoding::Encoder<
3512                '_,
3513                fidl::encoding::DefaultFuchsiaResourceDialect,
3514            >,
3515            offset: usize,
3516            _depth: fidl::encoding::Depth,
3517        ) -> fidl::Result<()> {
3518            encoder.debug_check_bounds::<TestConnectSpiLoopbackRequest>(offset);
3519            // Delegate to tuple encoding.
3520            fidl::encoding::Encode::<TestConnectSpiLoopbackRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3521                (
3522                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server),
3523                ),
3524                encoder, offset, _depth
3525            )
3526        }
3527    }
3528    unsafe impl<
3529        T0: fidl::encoding::Encode<
3530                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3531                fidl::encoding::DefaultFuchsiaResourceDialect,
3532            >,
3533    >
3534        fidl::encoding::Encode<
3535            TestConnectSpiLoopbackRequest,
3536            fidl::encoding::DefaultFuchsiaResourceDialect,
3537        > for (T0,)
3538    {
3539        #[inline]
3540        unsafe fn encode(
3541            self,
3542            encoder: &mut fidl::encoding::Encoder<
3543                '_,
3544                fidl::encoding::DefaultFuchsiaResourceDialect,
3545            >,
3546            offset: usize,
3547            depth: fidl::encoding::Depth,
3548        ) -> fidl::Result<()> {
3549            encoder.debug_check_bounds::<TestConnectSpiLoopbackRequest>(offset);
3550            // Zero out padding regions. There's no need to apply masks
3551            // because the unmasked parts will be overwritten by fields.
3552            // Write the fields.
3553            self.0.encode(encoder, offset + 0, depth)?;
3554            Ok(())
3555        }
3556    }
3557
3558    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3559        for TestConnectSpiLoopbackRequest
3560    {
3561        #[inline(always)]
3562        fn new_empty() -> Self {
3563            Self {
3564                server: fidl::new_empty!(
3565                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3566                    fidl::encoding::DefaultFuchsiaResourceDialect
3567                ),
3568            }
3569        }
3570
3571        #[inline]
3572        unsafe fn decode(
3573            &mut self,
3574            decoder: &mut fidl::encoding::Decoder<
3575                '_,
3576                fidl::encoding::DefaultFuchsiaResourceDialect,
3577            >,
3578            offset: usize,
3579            _depth: fidl::encoding::Depth,
3580        ) -> fidl::Result<()> {
3581            decoder.debug_check_bounds::<Self>(offset);
3582            // Verify that padding bytes are zero.
3583            fidl::decode!(
3584                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
3585                fidl::encoding::DefaultFuchsiaResourceDialect,
3586                &mut self.server,
3587                decoder,
3588                offset + 0,
3589                _depth
3590            )?;
3591            Ok(())
3592        }
3593    }
3594}