fidl_fuchsia_hardware_serial/
fidl_fuchsia_hardware_serial.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_serial__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceProxyGetChannelRequest {
16    pub req: fidl::endpoints::ServerEnd<DeviceMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DeviceProxyGetChannelRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct DeviceMarker;
26
27impl fidl::endpoints::ProtocolMarker for DeviceMarker {
28    type Proxy = DeviceProxy;
29    type RequestStream = DeviceRequestStream;
30    #[cfg(target_os = "fuchsia")]
31    type SynchronousProxy = DeviceSynchronousProxy;
32
33    const DEBUG_NAME: &'static str = "(anonymous) Device";
34}
35pub type DeviceReadResult = Result<Vec<u8>, i32>;
36pub type DeviceWriteResult = Result<(), i32>;
37
38pub trait DeviceProxyInterface: Send + Sync {
39    type GetClassResponseFut: std::future::Future<Output = Result<Class, fidl::Error>> + Send;
40    fn r#get_class(&self) -> Self::GetClassResponseFut;
41    type SetConfigResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
42    fn r#set_config(&self, config: &Config) -> Self::SetConfigResponseFut;
43    type ReadResponseFut: std::future::Future<Output = Result<DeviceReadResult, fidl::Error>> + Send;
44    fn r#read(&self) -> Self::ReadResponseFut;
45    type WriteResponseFut: std::future::Future<Output = Result<DeviceWriteResult, fidl::Error>>
46        + Send;
47    fn r#write(&self, data: &[u8]) -> Self::WriteResponseFut;
48}
49#[derive(Debug)]
50#[cfg(target_os = "fuchsia")]
51pub struct DeviceSynchronousProxy {
52    client: fidl::client::sync::Client,
53}
54
55#[cfg(target_os = "fuchsia")]
56impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
57    type Proxy = DeviceProxy;
58    type Protocol = DeviceMarker;
59
60    fn from_channel(inner: fidl::Channel) -> Self {
61        Self::new(inner)
62    }
63
64    fn into_channel(self) -> fidl::Channel {
65        self.client.into_channel()
66    }
67
68    fn as_channel(&self) -> &fidl::Channel {
69        self.client.as_channel()
70    }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl DeviceSynchronousProxy {
75    pub fn new(channel: fidl::Channel) -> Self {
76        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
77        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
78    }
79
80    pub fn into_channel(self) -> fidl::Channel {
81        self.client.into_channel()
82    }
83
84    /// Waits until an event arrives and returns it. It is safe for other
85    /// threads to make concurrent requests while waiting for an event.
86    pub fn wait_for_event(
87        &self,
88        deadline: zx::MonotonicInstant,
89    ) -> Result<DeviceEvent, fidl::Error> {
90        DeviceEvent::decode(self.client.wait_for_event(deadline)?)
91    }
92
93    /// Lookup what type of serial device this is.
94    pub fn r#get_class(&self, ___deadline: zx::MonotonicInstant) -> Result<Class, fidl::Error> {
95        let _response =
96            self.client.send_query::<fidl::encoding::EmptyPayload, DeviceGetClassResponse>(
97                (),
98                0x3d48bbcee248ab8b,
99                fidl::encoding::DynamicFlags::empty(),
100                ___deadline,
101            )?;
102        Ok(_response.device_class)
103    }
104
105    /// Set the configuration of this serial device.
106    pub fn r#set_config(
107        &self,
108        mut config: &Config,
109        ___deadline: zx::MonotonicInstant,
110    ) -> Result<i32, fidl::Error> {
111        let _response = self.client.send_query::<DeviceSetConfigRequest, DeviceSetConfigResponse>(
112            (config,),
113            0x771a0946f6f87173,
114            fidl::encoding::DynamicFlags::empty(),
115            ___deadline,
116        )?;
117        Ok(_response.s)
118    }
119
120    /// Reads data from the serial port.
121    pub fn r#read(
122        &self,
123        ___deadline: zx::MonotonicInstant,
124    ) -> Result<DeviceReadResult, fidl::Error> {
125        let _response = self.client.send_query::<
126            fidl::encoding::EmptyPayload,
127            fidl::encoding::ResultType<DeviceReadResponse, i32>,
128        >(
129            (),
130            0x63c41d3c053fadd8,
131            fidl::encoding::DynamicFlags::empty(),
132            ___deadline,
133        )?;
134        Ok(_response.map(|x| x.data))
135    }
136
137    /// Writes data to the serial port.
138    pub fn r#write(
139        &self,
140        mut data: &[u8],
141        ___deadline: zx::MonotonicInstant,
142    ) -> Result<DeviceWriteResult, fidl::Error> {
143        let _response = self.client.send_query::<
144            DeviceWriteRequest,
145            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
146        >(
147            (data,),
148            0x6aa7adae6841779c,
149            fidl::encoding::DynamicFlags::empty(),
150            ___deadline,
151        )?;
152        Ok(_response.map(|x| x))
153    }
154}
155
156#[cfg(target_os = "fuchsia")]
157impl From<DeviceSynchronousProxy> for zx::Handle {
158    fn from(value: DeviceSynchronousProxy) -> Self {
159        value.into_channel().into()
160    }
161}
162
163#[cfg(target_os = "fuchsia")]
164impl From<fidl::Channel> for DeviceSynchronousProxy {
165    fn from(value: fidl::Channel) -> Self {
166        Self::new(value)
167    }
168}
169
170#[cfg(target_os = "fuchsia")]
171impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
172    type Protocol = DeviceMarker;
173
174    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
175        Self::new(value.into_channel())
176    }
177}
178
179#[derive(Debug, Clone)]
180pub struct DeviceProxy {
181    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
182}
183
184impl fidl::endpoints::Proxy for DeviceProxy {
185    type Protocol = DeviceMarker;
186
187    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
188        Self::new(inner)
189    }
190
191    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
192        self.client.into_channel().map_err(|client| Self { client })
193    }
194
195    fn as_channel(&self) -> &::fidl::AsyncChannel {
196        self.client.as_channel()
197    }
198}
199
200impl DeviceProxy {
201    /// Create a new Proxy for fuchsia.hardware.serial/Device.
202    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
203        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
204        Self { client: fidl::client::Client::new(channel, protocol_name) }
205    }
206
207    /// Get a Stream of events from the remote end of the protocol.
208    ///
209    /// # Panics
210    ///
211    /// Panics if the event stream was already taken.
212    pub fn take_event_stream(&self) -> DeviceEventStream {
213        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
214    }
215
216    /// Lookup what type of serial device this is.
217    pub fn r#get_class(
218        &self,
219    ) -> fidl::client::QueryResponseFut<Class, fidl::encoding::DefaultFuchsiaResourceDialect> {
220        DeviceProxyInterface::r#get_class(self)
221    }
222
223    /// Set the configuration of this serial device.
224    pub fn r#set_config(
225        &self,
226        mut config: &Config,
227    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
228        DeviceProxyInterface::r#set_config(self, config)
229    }
230
231    /// Reads data from the serial port.
232    pub fn r#read(
233        &self,
234    ) -> fidl::client::QueryResponseFut<
235        DeviceReadResult,
236        fidl::encoding::DefaultFuchsiaResourceDialect,
237    > {
238        DeviceProxyInterface::r#read(self)
239    }
240
241    /// Writes data to the serial port.
242    pub fn r#write(
243        &self,
244        mut data: &[u8],
245    ) -> fidl::client::QueryResponseFut<
246        DeviceWriteResult,
247        fidl::encoding::DefaultFuchsiaResourceDialect,
248    > {
249        DeviceProxyInterface::r#write(self, data)
250    }
251}
252
253impl DeviceProxyInterface for DeviceProxy {
254    type GetClassResponseFut =
255        fidl::client::QueryResponseFut<Class, fidl::encoding::DefaultFuchsiaResourceDialect>;
256    fn r#get_class(&self) -> Self::GetClassResponseFut {
257        fn _decode(
258            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
259        ) -> Result<Class, fidl::Error> {
260            let _response = fidl::client::decode_transaction_body::<
261                DeviceGetClassResponse,
262                fidl::encoding::DefaultFuchsiaResourceDialect,
263                0x3d48bbcee248ab8b,
264            >(_buf?)?;
265            Ok(_response.device_class)
266        }
267        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Class>(
268            (),
269            0x3d48bbcee248ab8b,
270            fidl::encoding::DynamicFlags::empty(),
271            _decode,
272        )
273    }
274
275    type SetConfigResponseFut =
276        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
277    fn r#set_config(&self, mut config: &Config) -> Self::SetConfigResponseFut {
278        fn _decode(
279            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
280        ) -> Result<i32, fidl::Error> {
281            let _response = fidl::client::decode_transaction_body::<
282                DeviceSetConfigResponse,
283                fidl::encoding::DefaultFuchsiaResourceDialect,
284                0x771a0946f6f87173,
285            >(_buf?)?;
286            Ok(_response.s)
287        }
288        self.client.send_query_and_decode::<DeviceSetConfigRequest, i32>(
289            (config,),
290            0x771a0946f6f87173,
291            fidl::encoding::DynamicFlags::empty(),
292            _decode,
293        )
294    }
295
296    type ReadResponseFut = fidl::client::QueryResponseFut<
297        DeviceReadResult,
298        fidl::encoding::DefaultFuchsiaResourceDialect,
299    >;
300    fn r#read(&self) -> Self::ReadResponseFut {
301        fn _decode(
302            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
303        ) -> Result<DeviceReadResult, fidl::Error> {
304            let _response = fidl::client::decode_transaction_body::<
305                fidl::encoding::ResultType<DeviceReadResponse, i32>,
306                fidl::encoding::DefaultFuchsiaResourceDialect,
307                0x63c41d3c053fadd8,
308            >(_buf?)?;
309            Ok(_response.map(|x| x.data))
310        }
311        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceReadResult>(
312            (),
313            0x63c41d3c053fadd8,
314            fidl::encoding::DynamicFlags::empty(),
315            _decode,
316        )
317    }
318
319    type WriteResponseFut = fidl::client::QueryResponseFut<
320        DeviceWriteResult,
321        fidl::encoding::DefaultFuchsiaResourceDialect,
322    >;
323    fn r#write(&self, mut data: &[u8]) -> Self::WriteResponseFut {
324        fn _decode(
325            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
326        ) -> Result<DeviceWriteResult, fidl::Error> {
327            let _response = fidl::client::decode_transaction_body::<
328                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
329                fidl::encoding::DefaultFuchsiaResourceDialect,
330                0x6aa7adae6841779c,
331            >(_buf?)?;
332            Ok(_response.map(|x| x))
333        }
334        self.client.send_query_and_decode::<DeviceWriteRequest, DeviceWriteResult>(
335            (data,),
336            0x6aa7adae6841779c,
337            fidl::encoding::DynamicFlags::empty(),
338            _decode,
339        )
340    }
341}
342
343pub struct DeviceEventStream {
344    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
345}
346
347impl std::marker::Unpin for DeviceEventStream {}
348
349impl futures::stream::FusedStream for DeviceEventStream {
350    fn is_terminated(&self) -> bool {
351        self.event_receiver.is_terminated()
352    }
353}
354
355impl futures::Stream for DeviceEventStream {
356    type Item = Result<DeviceEvent, fidl::Error>;
357
358    fn poll_next(
359        mut self: std::pin::Pin<&mut Self>,
360        cx: &mut std::task::Context<'_>,
361    ) -> std::task::Poll<Option<Self::Item>> {
362        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
363            &mut self.event_receiver,
364            cx
365        )?) {
366            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
367            None => std::task::Poll::Ready(None),
368        }
369    }
370}
371
372#[derive(Debug)]
373pub enum DeviceEvent {}
374
375impl DeviceEvent {
376    /// Decodes a message buffer as a [`DeviceEvent`].
377    fn decode(
378        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
379    ) -> Result<DeviceEvent, fidl::Error> {
380        let (bytes, _handles) = buf.split_mut();
381        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
382        debug_assert_eq!(tx_header.tx_id, 0);
383        match tx_header.ordinal {
384            _ => Err(fidl::Error::UnknownOrdinal {
385                ordinal: tx_header.ordinal,
386                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
387            }),
388        }
389    }
390}
391
392/// A Stream of incoming requests for fuchsia.hardware.serial/Device.
393pub struct DeviceRequestStream {
394    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
395    is_terminated: bool,
396}
397
398impl std::marker::Unpin for DeviceRequestStream {}
399
400impl futures::stream::FusedStream for DeviceRequestStream {
401    fn is_terminated(&self) -> bool {
402        self.is_terminated
403    }
404}
405
406impl fidl::endpoints::RequestStream for DeviceRequestStream {
407    type Protocol = DeviceMarker;
408    type ControlHandle = DeviceControlHandle;
409
410    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
411        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
412    }
413
414    fn control_handle(&self) -> Self::ControlHandle {
415        DeviceControlHandle { inner: self.inner.clone() }
416    }
417
418    fn into_inner(
419        self,
420    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
421    {
422        (self.inner, self.is_terminated)
423    }
424
425    fn from_inner(
426        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
427        is_terminated: bool,
428    ) -> Self {
429        Self { inner, is_terminated }
430    }
431}
432
433impl futures::Stream for DeviceRequestStream {
434    type Item = Result<DeviceRequest, fidl::Error>;
435
436    fn poll_next(
437        mut self: std::pin::Pin<&mut Self>,
438        cx: &mut std::task::Context<'_>,
439    ) -> std::task::Poll<Option<Self::Item>> {
440        let this = &mut *self;
441        if this.inner.check_shutdown(cx) {
442            this.is_terminated = true;
443            return std::task::Poll::Ready(None);
444        }
445        if this.is_terminated {
446            panic!("polled DeviceRequestStream after completion");
447        }
448        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
449            |bytes, handles| {
450                match this.inner.channel().read_etc(cx, bytes, handles) {
451                    std::task::Poll::Ready(Ok(())) => {}
452                    std::task::Poll::Pending => return std::task::Poll::Pending,
453                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
454                        this.is_terminated = true;
455                        return std::task::Poll::Ready(None);
456                    }
457                    std::task::Poll::Ready(Err(e)) => {
458                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
459                            e.into(),
460                        ))))
461                    }
462                }
463
464                // A message has been received from the channel
465                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
466
467                std::task::Poll::Ready(Some(match header.ordinal {
468                    0x3d48bbcee248ab8b => {
469                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
470                        let mut req = fidl::new_empty!(
471                            fidl::encoding::EmptyPayload,
472                            fidl::encoding::DefaultFuchsiaResourceDialect
473                        );
474                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
475                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
476                        Ok(DeviceRequest::GetClass {
477                            responder: DeviceGetClassResponder {
478                                control_handle: std::mem::ManuallyDrop::new(control_handle),
479                                tx_id: header.tx_id,
480                            },
481                        })
482                    }
483                    0x771a0946f6f87173 => {
484                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
485                        let mut req = fidl::new_empty!(
486                            DeviceSetConfigRequest,
487                            fidl::encoding::DefaultFuchsiaResourceDialect
488                        );
489                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetConfigRequest>(&header, _body_bytes, handles, &mut req)?;
490                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
491                        Ok(DeviceRequest::SetConfig {
492                            config: req.config,
493
494                            responder: DeviceSetConfigResponder {
495                                control_handle: std::mem::ManuallyDrop::new(control_handle),
496                                tx_id: header.tx_id,
497                            },
498                        })
499                    }
500                    0x63c41d3c053fadd8 => {
501                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
502                        let mut req = fidl::new_empty!(
503                            fidl::encoding::EmptyPayload,
504                            fidl::encoding::DefaultFuchsiaResourceDialect
505                        );
506                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
507                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
508                        Ok(DeviceRequest::Read {
509                            responder: DeviceReadResponder {
510                                control_handle: std::mem::ManuallyDrop::new(control_handle),
511                                tx_id: header.tx_id,
512                            },
513                        })
514                    }
515                    0x6aa7adae6841779c => {
516                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
517                        let mut req = fidl::new_empty!(
518                            DeviceWriteRequest,
519                            fidl::encoding::DefaultFuchsiaResourceDialect
520                        );
521                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceWriteRequest>(&header, _body_bytes, handles, &mut req)?;
522                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
523                        Ok(DeviceRequest::Write {
524                            data: req.data,
525
526                            responder: DeviceWriteResponder {
527                                control_handle: std::mem::ManuallyDrop::new(control_handle),
528                                tx_id: header.tx_id,
529                            },
530                        })
531                    }
532                    _ => Err(fidl::Error::UnknownOrdinal {
533                        ordinal: header.ordinal,
534                        protocol_name:
535                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
536                    }),
537                }))
538            },
539        )
540    }
541}
542
543/// A serial device.
544#[derive(Debug)]
545pub enum DeviceRequest {
546    /// Lookup what type of serial device this is.
547    GetClass { responder: DeviceGetClassResponder },
548    /// Set the configuration of this serial device.
549    SetConfig { config: Config, responder: DeviceSetConfigResponder },
550    /// Reads data from the serial port.
551    Read { responder: DeviceReadResponder },
552    /// Writes data to the serial port.
553    Write { data: Vec<u8>, responder: DeviceWriteResponder },
554}
555
556impl DeviceRequest {
557    #[allow(irrefutable_let_patterns)]
558    pub fn into_get_class(self) -> Option<(DeviceGetClassResponder)> {
559        if let DeviceRequest::GetClass { responder } = self {
560            Some((responder))
561        } else {
562            None
563        }
564    }
565
566    #[allow(irrefutable_let_patterns)]
567    pub fn into_set_config(self) -> Option<(Config, DeviceSetConfigResponder)> {
568        if let DeviceRequest::SetConfig { config, responder } = self {
569            Some((config, responder))
570        } else {
571            None
572        }
573    }
574
575    #[allow(irrefutable_let_patterns)]
576    pub fn into_read(self) -> Option<(DeviceReadResponder)> {
577        if let DeviceRequest::Read { responder } = self {
578            Some((responder))
579        } else {
580            None
581        }
582    }
583
584    #[allow(irrefutable_let_patterns)]
585    pub fn into_write(self) -> Option<(Vec<u8>, DeviceWriteResponder)> {
586        if let DeviceRequest::Write { data, responder } = self {
587            Some((data, responder))
588        } else {
589            None
590        }
591    }
592
593    /// Name of the method defined in FIDL
594    pub fn method_name(&self) -> &'static str {
595        match *self {
596            DeviceRequest::GetClass { .. } => "get_class",
597            DeviceRequest::SetConfig { .. } => "set_config",
598            DeviceRequest::Read { .. } => "read",
599            DeviceRequest::Write { .. } => "write",
600        }
601    }
602}
603
604#[derive(Debug, Clone)]
605pub struct DeviceControlHandle {
606    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
607}
608
609impl fidl::endpoints::ControlHandle for DeviceControlHandle {
610    fn shutdown(&self) {
611        self.inner.shutdown()
612    }
613    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
614        self.inner.shutdown_with_epitaph(status)
615    }
616
617    fn is_closed(&self) -> bool {
618        self.inner.channel().is_closed()
619    }
620    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
621        self.inner.channel().on_closed()
622    }
623
624    #[cfg(target_os = "fuchsia")]
625    fn signal_peer(
626        &self,
627        clear_mask: zx::Signals,
628        set_mask: zx::Signals,
629    ) -> Result<(), zx_status::Status> {
630        use fidl::Peered;
631        self.inner.channel().signal_peer(clear_mask, set_mask)
632    }
633}
634
635impl DeviceControlHandle {}
636
637#[must_use = "FIDL methods require a response to be sent"]
638#[derive(Debug)]
639pub struct DeviceGetClassResponder {
640    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
641    tx_id: u32,
642}
643
644/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
645/// if the responder is dropped without sending a response, so that the client
646/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
647impl std::ops::Drop for DeviceGetClassResponder {
648    fn drop(&mut self) {
649        self.control_handle.shutdown();
650        // Safety: drops once, never accessed again
651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
652    }
653}
654
655impl fidl::endpoints::Responder for DeviceGetClassResponder {
656    type ControlHandle = DeviceControlHandle;
657
658    fn control_handle(&self) -> &DeviceControlHandle {
659        &self.control_handle
660    }
661
662    fn drop_without_shutdown(mut self) {
663        // Safety: drops once, never accessed again due to mem::forget
664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
665        // Prevent Drop from running (which would shut down the channel)
666        std::mem::forget(self);
667    }
668}
669
670impl DeviceGetClassResponder {
671    /// Sends a response to the FIDL transaction.
672    ///
673    /// Sets the channel to shutdown if an error occurs.
674    pub fn send(self, mut device_class: Class) -> Result<(), fidl::Error> {
675        let _result = self.send_raw(device_class);
676        if _result.is_err() {
677            self.control_handle.shutdown();
678        }
679        self.drop_without_shutdown();
680        _result
681    }
682
683    /// Similar to "send" but does not shutdown the channel if an error occurs.
684    pub fn send_no_shutdown_on_err(self, mut device_class: Class) -> Result<(), fidl::Error> {
685        let _result = self.send_raw(device_class);
686        self.drop_without_shutdown();
687        _result
688    }
689
690    fn send_raw(&self, mut device_class: Class) -> Result<(), fidl::Error> {
691        self.control_handle.inner.send::<DeviceGetClassResponse>(
692            (device_class,),
693            self.tx_id,
694            0x3d48bbcee248ab8b,
695            fidl::encoding::DynamicFlags::empty(),
696        )
697    }
698}
699
700#[must_use = "FIDL methods require a response to be sent"]
701#[derive(Debug)]
702pub struct DeviceSetConfigResponder {
703    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
704    tx_id: u32,
705}
706
707/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
708/// if the responder is dropped without sending a response, so that the client
709/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
710impl std::ops::Drop for DeviceSetConfigResponder {
711    fn drop(&mut self) {
712        self.control_handle.shutdown();
713        // Safety: drops once, never accessed again
714        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
715    }
716}
717
718impl fidl::endpoints::Responder for DeviceSetConfigResponder {
719    type ControlHandle = DeviceControlHandle;
720
721    fn control_handle(&self) -> &DeviceControlHandle {
722        &self.control_handle
723    }
724
725    fn drop_without_shutdown(mut self) {
726        // Safety: drops once, never accessed again due to mem::forget
727        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
728        // Prevent Drop from running (which would shut down the channel)
729        std::mem::forget(self);
730    }
731}
732
733impl DeviceSetConfigResponder {
734    /// Sends a response to the FIDL transaction.
735    ///
736    /// Sets the channel to shutdown if an error occurs.
737    pub fn send(self, mut s: i32) -> Result<(), fidl::Error> {
738        let _result = self.send_raw(s);
739        if _result.is_err() {
740            self.control_handle.shutdown();
741        }
742        self.drop_without_shutdown();
743        _result
744    }
745
746    /// Similar to "send" but does not shutdown the channel if an error occurs.
747    pub fn send_no_shutdown_on_err(self, mut s: i32) -> Result<(), fidl::Error> {
748        let _result = self.send_raw(s);
749        self.drop_without_shutdown();
750        _result
751    }
752
753    fn send_raw(&self, mut s: i32) -> Result<(), fidl::Error> {
754        self.control_handle.inner.send::<DeviceSetConfigResponse>(
755            (s,),
756            self.tx_id,
757            0x771a0946f6f87173,
758            fidl::encoding::DynamicFlags::empty(),
759        )
760    }
761}
762
763#[must_use = "FIDL methods require a response to be sent"]
764#[derive(Debug)]
765pub struct DeviceReadResponder {
766    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
767    tx_id: u32,
768}
769
770/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
771/// if the responder is dropped without sending a response, so that the client
772/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
773impl std::ops::Drop for DeviceReadResponder {
774    fn drop(&mut self) {
775        self.control_handle.shutdown();
776        // Safety: drops once, never accessed again
777        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
778    }
779}
780
781impl fidl::endpoints::Responder for DeviceReadResponder {
782    type ControlHandle = DeviceControlHandle;
783
784    fn control_handle(&self) -> &DeviceControlHandle {
785        &self.control_handle
786    }
787
788    fn drop_without_shutdown(mut self) {
789        // Safety: drops once, never accessed again due to mem::forget
790        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
791        // Prevent Drop from running (which would shut down the channel)
792        std::mem::forget(self);
793    }
794}
795
796impl DeviceReadResponder {
797    /// Sends a response to the FIDL transaction.
798    ///
799    /// Sets the channel to shutdown if an error occurs.
800    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
801        let _result = self.send_raw(result);
802        if _result.is_err() {
803            self.control_handle.shutdown();
804        }
805        self.drop_without_shutdown();
806        _result
807    }
808
809    /// Similar to "send" but does not shutdown the channel if an error occurs.
810    pub fn send_no_shutdown_on_err(
811        self,
812        mut result: Result<&[u8], i32>,
813    ) -> Result<(), fidl::Error> {
814        let _result = self.send_raw(result);
815        self.drop_without_shutdown();
816        _result
817    }
818
819    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
820        self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceReadResponse, i32>>(
821            result.map(|data| (data,)),
822            self.tx_id,
823            0x63c41d3c053fadd8,
824            fidl::encoding::DynamicFlags::empty(),
825        )
826    }
827}
828
829#[must_use = "FIDL methods require a response to be sent"]
830#[derive(Debug)]
831pub struct DeviceWriteResponder {
832    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
833    tx_id: u32,
834}
835
836/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
837/// if the responder is dropped without sending a response, so that the client
838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
839impl std::ops::Drop for DeviceWriteResponder {
840    fn drop(&mut self) {
841        self.control_handle.shutdown();
842        // Safety: drops once, never accessed again
843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
844    }
845}
846
847impl fidl::endpoints::Responder for DeviceWriteResponder {
848    type ControlHandle = DeviceControlHandle;
849
850    fn control_handle(&self) -> &DeviceControlHandle {
851        &self.control_handle
852    }
853
854    fn drop_without_shutdown(mut self) {
855        // Safety: drops once, never accessed again due to mem::forget
856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
857        // Prevent Drop from running (which would shut down the channel)
858        std::mem::forget(self);
859    }
860}
861
862impl DeviceWriteResponder {
863    /// Sends a response to the FIDL transaction.
864    ///
865    /// Sets the channel to shutdown if an error occurs.
866    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
867        let _result = self.send_raw(result);
868        if _result.is_err() {
869            self.control_handle.shutdown();
870        }
871        self.drop_without_shutdown();
872        _result
873    }
874
875    /// Similar to "send" but does not shutdown the channel if an error occurs.
876    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
877        let _result = self.send_raw(result);
878        self.drop_without_shutdown();
879        _result
880    }
881
882    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
883        self.control_handle
884            .inner
885            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
886                result,
887                self.tx_id,
888                0x6aa7adae6841779c,
889                fidl::encoding::DynamicFlags::empty(),
890            )
891    }
892}
893
894#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
895pub struct DeviceProxy_Marker;
896
897impl fidl::endpoints::ProtocolMarker for DeviceProxy_Marker {
898    type Proxy = DeviceProxy_Proxy;
899    type RequestStream = DeviceProxy_RequestStream;
900    #[cfg(target_os = "fuchsia")]
901    type SynchronousProxy = DeviceProxy_SynchronousProxy;
902
903    const DEBUG_NAME: &'static str = "fuchsia.hardware.serial.DeviceProxy";
904}
905impl fidl::endpoints::DiscoverableProtocolMarker for DeviceProxy_Marker {}
906
907pub trait DeviceProxy_ProxyInterface: Send + Sync {
908    fn r#get_channel(
909        &self,
910        req: fidl::endpoints::ServerEnd<DeviceMarker>,
911    ) -> Result<(), fidl::Error>;
912}
913#[derive(Debug)]
914#[cfg(target_os = "fuchsia")]
915pub struct DeviceProxy_SynchronousProxy {
916    client: fidl::client::sync::Client,
917}
918
919#[cfg(target_os = "fuchsia")]
920impl fidl::endpoints::SynchronousProxy for DeviceProxy_SynchronousProxy {
921    type Proxy = DeviceProxy_Proxy;
922    type Protocol = DeviceProxy_Marker;
923
924    fn from_channel(inner: fidl::Channel) -> Self {
925        Self::new(inner)
926    }
927
928    fn into_channel(self) -> fidl::Channel {
929        self.client.into_channel()
930    }
931
932    fn as_channel(&self) -> &fidl::Channel {
933        self.client.as_channel()
934    }
935}
936
937#[cfg(target_os = "fuchsia")]
938impl DeviceProxy_SynchronousProxy {
939    pub fn new(channel: fidl::Channel) -> Self {
940        let protocol_name = <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
941        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
942    }
943
944    pub fn into_channel(self) -> fidl::Channel {
945        self.client.into_channel()
946    }
947
948    /// Waits until an event arrives and returns it. It is safe for other
949    /// threads to make concurrent requests while waiting for an event.
950    pub fn wait_for_event(
951        &self,
952        deadline: zx::MonotonicInstant,
953    ) -> Result<DeviceProxy_Event, fidl::Error> {
954        DeviceProxy_Event::decode(self.client.wait_for_event(deadline)?)
955    }
956
957    pub fn r#get_channel(
958        &self,
959        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
960    ) -> Result<(), fidl::Error> {
961        self.client.send::<DeviceProxyGetChannelRequest>(
962            (req,),
963            0x580f1a3ef6c20fff,
964            fidl::encoding::DynamicFlags::empty(),
965        )
966    }
967}
968
969#[cfg(target_os = "fuchsia")]
970impl From<DeviceProxy_SynchronousProxy> for zx::Handle {
971    fn from(value: DeviceProxy_SynchronousProxy) -> Self {
972        value.into_channel().into()
973    }
974}
975
976#[cfg(target_os = "fuchsia")]
977impl From<fidl::Channel> for DeviceProxy_SynchronousProxy {
978    fn from(value: fidl::Channel) -> Self {
979        Self::new(value)
980    }
981}
982
983#[cfg(target_os = "fuchsia")]
984impl fidl::endpoints::FromClient for DeviceProxy_SynchronousProxy {
985    type Protocol = DeviceProxy_Marker;
986
987    fn from_client(value: fidl::endpoints::ClientEnd<DeviceProxy_Marker>) -> Self {
988        Self::new(value.into_channel())
989    }
990}
991
992#[derive(Debug, Clone)]
993pub struct DeviceProxy_Proxy {
994    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
995}
996
997impl fidl::endpoints::Proxy for DeviceProxy_Proxy {
998    type Protocol = DeviceProxy_Marker;
999
1000    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1001        Self::new(inner)
1002    }
1003
1004    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1005        self.client.into_channel().map_err(|client| Self { client })
1006    }
1007
1008    fn as_channel(&self) -> &::fidl::AsyncChannel {
1009        self.client.as_channel()
1010    }
1011}
1012
1013impl DeviceProxy_Proxy {
1014    /// Create a new Proxy for fuchsia.hardware.serial/DeviceProxy.
1015    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1016        let protocol_name = <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1017        Self { client: fidl::client::Client::new(channel, protocol_name) }
1018    }
1019
1020    /// Get a Stream of events from the remote end of the protocol.
1021    ///
1022    /// # Panics
1023    ///
1024    /// Panics if the event stream was already taken.
1025    pub fn take_event_stream(&self) -> DeviceProxy_EventStream {
1026        DeviceProxy_EventStream { event_receiver: self.client.take_event_receiver() }
1027    }
1028
1029    pub fn r#get_channel(
1030        &self,
1031        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
1032    ) -> Result<(), fidl::Error> {
1033        DeviceProxy_ProxyInterface::r#get_channel(self, req)
1034    }
1035}
1036
1037impl DeviceProxy_ProxyInterface for DeviceProxy_Proxy {
1038    fn r#get_channel(
1039        &self,
1040        mut req: fidl::endpoints::ServerEnd<DeviceMarker>,
1041    ) -> Result<(), fidl::Error> {
1042        self.client.send::<DeviceProxyGetChannelRequest>(
1043            (req,),
1044            0x580f1a3ef6c20fff,
1045            fidl::encoding::DynamicFlags::empty(),
1046        )
1047    }
1048}
1049
1050pub struct DeviceProxy_EventStream {
1051    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1052}
1053
1054impl std::marker::Unpin for DeviceProxy_EventStream {}
1055
1056impl futures::stream::FusedStream for DeviceProxy_EventStream {
1057    fn is_terminated(&self) -> bool {
1058        self.event_receiver.is_terminated()
1059    }
1060}
1061
1062impl futures::Stream for DeviceProxy_EventStream {
1063    type Item = Result<DeviceProxy_Event, fidl::Error>;
1064
1065    fn poll_next(
1066        mut self: std::pin::Pin<&mut Self>,
1067        cx: &mut std::task::Context<'_>,
1068    ) -> std::task::Poll<Option<Self::Item>> {
1069        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1070            &mut self.event_receiver,
1071            cx
1072        )?) {
1073            Some(buf) => std::task::Poll::Ready(Some(DeviceProxy_Event::decode(buf))),
1074            None => std::task::Poll::Ready(None),
1075        }
1076    }
1077}
1078
1079#[derive(Debug)]
1080pub enum DeviceProxy_Event {}
1081
1082impl DeviceProxy_Event {
1083    /// Decodes a message buffer as a [`DeviceProxy_Event`].
1084    fn decode(
1085        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1086    ) -> Result<DeviceProxy_Event, fidl::Error> {
1087        let (bytes, _handles) = buf.split_mut();
1088        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1089        debug_assert_eq!(tx_header.tx_id, 0);
1090        match tx_header.ordinal {
1091            _ => Err(fidl::Error::UnknownOrdinal {
1092                ordinal: tx_header.ordinal,
1093                protocol_name: <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1094            }),
1095        }
1096    }
1097}
1098
1099/// A Stream of incoming requests for fuchsia.hardware.serial/DeviceProxy.
1100pub struct DeviceProxy_RequestStream {
1101    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1102    is_terminated: bool,
1103}
1104
1105impl std::marker::Unpin for DeviceProxy_RequestStream {}
1106
1107impl futures::stream::FusedStream for DeviceProxy_RequestStream {
1108    fn is_terminated(&self) -> bool {
1109        self.is_terminated
1110    }
1111}
1112
1113impl fidl::endpoints::RequestStream for DeviceProxy_RequestStream {
1114    type Protocol = DeviceProxy_Marker;
1115    type ControlHandle = DeviceProxy_ControlHandle;
1116
1117    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1118        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1119    }
1120
1121    fn control_handle(&self) -> Self::ControlHandle {
1122        DeviceProxy_ControlHandle { inner: self.inner.clone() }
1123    }
1124
1125    fn into_inner(
1126        self,
1127    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1128    {
1129        (self.inner, self.is_terminated)
1130    }
1131
1132    fn from_inner(
1133        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1134        is_terminated: bool,
1135    ) -> Self {
1136        Self { inner, is_terminated }
1137    }
1138}
1139
1140impl futures::Stream for DeviceProxy_RequestStream {
1141    type Item = Result<DeviceProxy_Request, fidl::Error>;
1142
1143    fn poll_next(
1144        mut self: std::pin::Pin<&mut Self>,
1145        cx: &mut std::task::Context<'_>,
1146    ) -> std::task::Poll<Option<Self::Item>> {
1147        let this = &mut *self;
1148        if this.inner.check_shutdown(cx) {
1149            this.is_terminated = true;
1150            return std::task::Poll::Ready(None);
1151        }
1152        if this.is_terminated {
1153            panic!("polled DeviceProxy_RequestStream after completion");
1154        }
1155        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1156            |bytes, handles| {
1157                match this.inner.channel().read_etc(cx, bytes, handles) {
1158                    std::task::Poll::Ready(Ok(())) => {}
1159                    std::task::Poll::Pending => return std::task::Poll::Pending,
1160                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1161                        this.is_terminated = true;
1162                        return std::task::Poll::Ready(None);
1163                    }
1164                    std::task::Poll::Ready(Err(e)) => {
1165                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1166                            e.into(),
1167                        ))))
1168                    }
1169                }
1170
1171                // A message has been received from the channel
1172                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1173
1174                std::task::Poll::Ready(Some(match header.ordinal {
1175                    0x580f1a3ef6c20fff => {
1176                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1177                        let mut req = fidl::new_empty!(
1178                            DeviceProxyGetChannelRequest,
1179                            fidl::encoding::DefaultFuchsiaResourceDialect
1180                        );
1181                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceProxyGetChannelRequest>(&header, _body_bytes, handles, &mut req)?;
1182                        let control_handle =
1183                            DeviceProxy_ControlHandle { inner: this.inner.clone() };
1184                        Ok(DeviceProxy_Request::GetChannel { req: req.req, control_handle })
1185                    }
1186                    _ => Err(fidl::Error::UnknownOrdinal {
1187                        ordinal: header.ordinal,
1188                        protocol_name:
1189                            <DeviceProxy_Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1190                    }),
1191                }))
1192            },
1193        )
1194    }
1195}
1196
1197#[derive(Debug)]
1198pub enum DeviceProxy_Request {
1199    GetChannel {
1200        req: fidl::endpoints::ServerEnd<DeviceMarker>,
1201        control_handle: DeviceProxy_ControlHandle,
1202    },
1203}
1204
1205impl DeviceProxy_Request {
1206    #[allow(irrefutable_let_patterns)]
1207    pub fn into_get_channel(
1208        self,
1209    ) -> Option<(fidl::endpoints::ServerEnd<DeviceMarker>, DeviceProxy_ControlHandle)> {
1210        if let DeviceProxy_Request::GetChannel { req, control_handle } = self {
1211            Some((req, control_handle))
1212        } else {
1213            None
1214        }
1215    }
1216
1217    /// Name of the method defined in FIDL
1218    pub fn method_name(&self) -> &'static str {
1219        match *self {
1220            DeviceProxy_Request::GetChannel { .. } => "get_channel",
1221        }
1222    }
1223}
1224
1225#[derive(Debug, Clone)]
1226pub struct DeviceProxy_ControlHandle {
1227    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1228}
1229
1230impl fidl::endpoints::ControlHandle for DeviceProxy_ControlHandle {
1231    fn shutdown(&self) {
1232        self.inner.shutdown()
1233    }
1234    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1235        self.inner.shutdown_with_epitaph(status)
1236    }
1237
1238    fn is_closed(&self) -> bool {
1239        self.inner.channel().is_closed()
1240    }
1241    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1242        self.inner.channel().on_closed()
1243    }
1244
1245    #[cfg(target_os = "fuchsia")]
1246    fn signal_peer(
1247        &self,
1248        clear_mask: zx::Signals,
1249        set_mask: zx::Signals,
1250    ) -> Result<(), zx_status::Status> {
1251        use fidl::Peered;
1252        self.inner.channel().signal_peer(clear_mask, set_mask)
1253    }
1254}
1255
1256impl DeviceProxy_ControlHandle {}
1257
1258#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1259pub struct ServiceMarker;
1260
1261#[cfg(target_os = "fuchsia")]
1262impl fidl::endpoints::ServiceMarker for ServiceMarker {
1263    type Proxy = ServiceProxy;
1264    type Request = ServiceRequest;
1265    const SERVICE_NAME: &'static str = "fuchsia.hardware.serial.Service";
1266}
1267
1268/// A request for one of the member protocols of Service.
1269///
1270#[cfg(target_os = "fuchsia")]
1271pub enum ServiceRequest {
1272    Device(DeviceRequestStream),
1273}
1274
1275#[cfg(target_os = "fuchsia")]
1276impl fidl::endpoints::ServiceRequest for ServiceRequest {
1277    type Service = ServiceMarker;
1278
1279    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1280        match name {
1281            "device" => Self::Device(
1282                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1283            ),
1284            _ => panic!("no such member protocol name for service Service"),
1285        }
1286    }
1287
1288    fn member_names() -> &'static [&'static str] {
1289        &["device"]
1290    }
1291}
1292#[cfg(target_os = "fuchsia")]
1293pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1294
1295#[cfg(target_os = "fuchsia")]
1296impl fidl::endpoints::ServiceProxy for ServiceProxy {
1297    type Service = ServiceMarker;
1298
1299    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1300        Self(opener)
1301    }
1302}
1303
1304#[cfg(target_os = "fuchsia")]
1305impl ServiceProxy {
1306    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1307        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1308        self.connect_channel_to_device(server_end)?;
1309        Ok(proxy)
1310    }
1311
1312    /// Like `connect_to_device`, but returns a sync proxy.
1313    /// See [`Self::connect_to_device`] for more details.
1314    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1315        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1316        self.connect_channel_to_device(server_end)?;
1317        Ok(proxy)
1318    }
1319
1320    /// Like `connect_to_device`, but accepts a server end.
1321    /// See [`Self::connect_to_device`] for more details.
1322    pub fn connect_channel_to_device(
1323        &self,
1324        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1325    ) -> Result<(), fidl::Error> {
1326        self.0.open_member("device", server_end.into_channel())
1327    }
1328
1329    pub fn instance_name(&self) -> &str {
1330        self.0.instance_name()
1331    }
1332}
1333
1334mod internal {
1335    use super::*;
1336
1337    impl fidl::encoding::ResourceTypeMarker for DeviceProxyGetChannelRequest {
1338        type Borrowed<'a> = &'a mut Self;
1339        fn take_or_borrow<'a>(
1340            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1341        ) -> Self::Borrowed<'a> {
1342            value
1343        }
1344    }
1345
1346    unsafe impl fidl::encoding::TypeMarker for DeviceProxyGetChannelRequest {
1347        type Owned = Self;
1348
1349        #[inline(always)]
1350        fn inline_align(_context: fidl::encoding::Context) -> usize {
1351            4
1352        }
1353
1354        #[inline(always)]
1355        fn inline_size(_context: fidl::encoding::Context) -> usize {
1356            4
1357        }
1358    }
1359
1360    unsafe impl
1361        fidl::encoding::Encode<
1362            DeviceProxyGetChannelRequest,
1363            fidl::encoding::DefaultFuchsiaResourceDialect,
1364        > for &mut DeviceProxyGetChannelRequest
1365    {
1366        #[inline]
1367        unsafe fn encode(
1368            self,
1369            encoder: &mut fidl::encoding::Encoder<
1370                '_,
1371                fidl::encoding::DefaultFuchsiaResourceDialect,
1372            >,
1373            offset: usize,
1374            _depth: fidl::encoding::Depth,
1375        ) -> fidl::Result<()> {
1376            encoder.debug_check_bounds::<DeviceProxyGetChannelRequest>(offset);
1377            // Delegate to tuple encoding.
1378            fidl::encoding::Encode::<DeviceProxyGetChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1379                (
1380                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.req),
1381                ),
1382                encoder, offset, _depth
1383            )
1384        }
1385    }
1386    unsafe impl<
1387            T0: fidl::encoding::Encode<
1388                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1389                fidl::encoding::DefaultFuchsiaResourceDialect,
1390            >,
1391        >
1392        fidl::encoding::Encode<
1393            DeviceProxyGetChannelRequest,
1394            fidl::encoding::DefaultFuchsiaResourceDialect,
1395        > for (T0,)
1396    {
1397        #[inline]
1398        unsafe fn encode(
1399            self,
1400            encoder: &mut fidl::encoding::Encoder<
1401                '_,
1402                fidl::encoding::DefaultFuchsiaResourceDialect,
1403            >,
1404            offset: usize,
1405            depth: fidl::encoding::Depth,
1406        ) -> fidl::Result<()> {
1407            encoder.debug_check_bounds::<DeviceProxyGetChannelRequest>(offset);
1408            // Zero out padding regions. There's no need to apply masks
1409            // because the unmasked parts will be overwritten by fields.
1410            // Write the fields.
1411            self.0.encode(encoder, offset + 0, depth)?;
1412            Ok(())
1413        }
1414    }
1415
1416    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1417        for DeviceProxyGetChannelRequest
1418    {
1419        #[inline(always)]
1420        fn new_empty() -> Self {
1421            Self {
1422                req: fidl::new_empty!(
1423                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1424                    fidl::encoding::DefaultFuchsiaResourceDialect
1425                ),
1426            }
1427        }
1428
1429        #[inline]
1430        unsafe fn decode(
1431            &mut self,
1432            decoder: &mut fidl::encoding::Decoder<
1433                '_,
1434                fidl::encoding::DefaultFuchsiaResourceDialect,
1435            >,
1436            offset: usize,
1437            _depth: fidl::encoding::Depth,
1438        ) -> fidl::Result<()> {
1439            decoder.debug_check_bounds::<Self>(offset);
1440            // Verify that padding bytes are zero.
1441            fidl::decode!(
1442                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
1443                fidl::encoding::DefaultFuchsiaResourceDialect,
1444                &mut self.req,
1445                decoder,
1446                offset + 0,
1447                _depth
1448            )?;
1449            Ok(())
1450        }
1451    }
1452}