fdomain_fuchsia_hwinfo/
fdomain_fuchsia_hwinfo.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 fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_hwinfo__common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14pub struct BoardMarker;
15
16impl fdomain_client::fidl::ProtocolMarker for BoardMarker {
17    type Proxy = BoardProxy;
18    type RequestStream = BoardRequestStream;
19
20    const DEBUG_NAME: &'static str = "fuchsia.hwinfo.Board";
21}
22impl fdomain_client::fidl::DiscoverableProtocolMarker for BoardMarker {}
23
24pub trait BoardProxyInterface: Send + Sync {
25    type GetInfoResponseFut: std::future::Future<Output = Result<BoardInfo, fidl::Error>> + Send;
26    fn r#get_info(&self) -> Self::GetInfoResponseFut;
27}
28
29#[derive(Debug, Clone)]
30pub struct BoardProxy {
31    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
32}
33
34impl fdomain_client::fidl::Proxy for BoardProxy {
35    type Protocol = BoardMarker;
36
37    fn from_channel(inner: fdomain_client::Channel) -> Self {
38        Self::new(inner)
39    }
40
41    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
42        self.client.into_channel().map_err(|client| Self { client })
43    }
44
45    fn as_channel(&self) -> &fdomain_client::Channel {
46        self.client.as_channel()
47    }
48}
49
50impl BoardProxy {
51    /// Create a new Proxy for fuchsia.hwinfo/Board.
52    pub fn new(channel: fdomain_client::Channel) -> Self {
53        let protocol_name = <BoardMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
54        Self { client: fidl::client::Client::new(channel, protocol_name) }
55    }
56
57    /// Get a Stream of events from the remote end of the protocol.
58    ///
59    /// # Panics
60    ///
61    /// Panics if the event stream was already taken.
62    pub fn take_event_stream(&self) -> BoardEventStream {
63        BoardEventStream { event_receiver: self.client.take_event_receiver() }
64    }
65
66    pub fn r#get_info(
67        &self,
68    ) -> fidl::client::QueryResponseFut<BoardInfo, fdomain_client::fidl::FDomainResourceDialect>
69    {
70        BoardProxyInterface::r#get_info(self)
71    }
72}
73
74impl BoardProxyInterface for BoardProxy {
75    type GetInfoResponseFut =
76        fidl::client::QueryResponseFut<BoardInfo, fdomain_client::fidl::FDomainResourceDialect>;
77    fn r#get_info(&self) -> Self::GetInfoResponseFut {
78        fn _decode(
79            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
80        ) -> Result<BoardInfo, fidl::Error> {
81            let _response = fidl::client::decode_transaction_body::<
82                BoardGetInfoResponse,
83                fdomain_client::fidl::FDomainResourceDialect,
84                0x878a093531d0904,
85            >(_buf?)?;
86            Ok(_response.info)
87        }
88        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BoardInfo>(
89            (),
90            0x878a093531d0904,
91            fidl::encoding::DynamicFlags::empty(),
92            _decode,
93        )
94    }
95}
96
97pub struct BoardEventStream {
98    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
99}
100
101impl std::marker::Unpin for BoardEventStream {}
102
103impl futures::stream::FusedStream for BoardEventStream {
104    fn is_terminated(&self) -> bool {
105        self.event_receiver.is_terminated()
106    }
107}
108
109impl futures::Stream for BoardEventStream {
110    type Item = Result<BoardEvent, fidl::Error>;
111
112    fn poll_next(
113        mut self: std::pin::Pin<&mut Self>,
114        cx: &mut std::task::Context<'_>,
115    ) -> std::task::Poll<Option<Self::Item>> {
116        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
117            &mut self.event_receiver,
118            cx
119        )?) {
120            Some(buf) => std::task::Poll::Ready(Some(BoardEvent::decode(buf))),
121            None => std::task::Poll::Ready(None),
122        }
123    }
124}
125
126#[derive(Debug)]
127pub enum BoardEvent {}
128
129impl BoardEvent {
130    /// Decodes a message buffer as a [`BoardEvent`].
131    fn decode(
132        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
133    ) -> Result<BoardEvent, fidl::Error> {
134        let (bytes, _handles) = buf.split_mut();
135        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
136        debug_assert_eq!(tx_header.tx_id, 0);
137        match tx_header.ordinal {
138            _ => Err(fidl::Error::UnknownOrdinal {
139                ordinal: tx_header.ordinal,
140                protocol_name: <BoardMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
141            }),
142        }
143    }
144}
145
146/// A Stream of incoming requests for fuchsia.hwinfo/Board.
147pub struct BoardRequestStream {
148    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
149    is_terminated: bool,
150}
151
152impl std::marker::Unpin for BoardRequestStream {}
153
154impl futures::stream::FusedStream for BoardRequestStream {
155    fn is_terminated(&self) -> bool {
156        self.is_terminated
157    }
158}
159
160impl fdomain_client::fidl::RequestStream for BoardRequestStream {
161    type Protocol = BoardMarker;
162    type ControlHandle = BoardControlHandle;
163
164    fn from_channel(channel: fdomain_client::Channel) -> Self {
165        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
166    }
167
168    fn control_handle(&self) -> Self::ControlHandle {
169        BoardControlHandle { inner: self.inner.clone() }
170    }
171
172    fn into_inner(
173        self,
174    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
175    {
176        (self.inner, self.is_terminated)
177    }
178
179    fn from_inner(
180        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
181        is_terminated: bool,
182    ) -> Self {
183        Self { inner, is_terminated }
184    }
185}
186
187impl futures::Stream for BoardRequestStream {
188    type Item = Result<BoardRequest, fidl::Error>;
189
190    fn poll_next(
191        mut self: std::pin::Pin<&mut Self>,
192        cx: &mut std::task::Context<'_>,
193    ) -> std::task::Poll<Option<Self::Item>> {
194        let this = &mut *self;
195        if this.inner.check_shutdown(cx) {
196            this.is_terminated = true;
197            return std::task::Poll::Ready(None);
198        }
199        if this.is_terminated {
200            panic!("polled BoardRequestStream after completion");
201        }
202        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
203            |bytes, handles| {
204                match this.inner.channel().read_etc(cx, bytes, handles) {
205                    std::task::Poll::Ready(Ok(())) => {}
206                    std::task::Poll::Pending => return std::task::Poll::Pending,
207                    std::task::Poll::Ready(Err(None)) => {
208                        this.is_terminated = true;
209                        return std::task::Poll::Ready(None);
210                    }
211                    std::task::Poll::Ready(Err(Some(e))) => {
212                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
213                            e.into(),
214                        ))))
215                    }
216                }
217
218                // A message has been received from the channel
219                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
220
221                std::task::Poll::Ready(Some(match header.ordinal {
222                    0x878a093531d0904 => {
223                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
224                        let mut req = fidl::new_empty!(
225                            fidl::encoding::EmptyPayload,
226                            fdomain_client::fidl::FDomainResourceDialect
227                        );
228                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
229                        let control_handle = BoardControlHandle { inner: this.inner.clone() };
230                        Ok(BoardRequest::GetInfo {
231                            responder: BoardGetInfoResponder {
232                                control_handle: std::mem::ManuallyDrop::new(control_handle),
233                                tx_id: header.tx_id,
234                            },
235                        })
236                    }
237                    _ => Err(fidl::Error::UnknownOrdinal {
238                        ordinal: header.ordinal,
239                        protocol_name:
240                            <BoardMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
241                    }),
242                }))
243            },
244        )
245    }
246}
247
248/// Board provides an interface to retrieve hardware-specific information.
249#[derive(Debug)]
250pub enum BoardRequest {
251    GetInfo { responder: BoardGetInfoResponder },
252}
253
254impl BoardRequest {
255    #[allow(irrefutable_let_patterns)]
256    pub fn into_get_info(self) -> Option<(BoardGetInfoResponder)> {
257        if let BoardRequest::GetInfo { responder } = self {
258            Some((responder))
259        } else {
260            None
261        }
262    }
263
264    /// Name of the method defined in FIDL
265    pub fn method_name(&self) -> &'static str {
266        match *self {
267            BoardRequest::GetInfo { .. } => "get_info",
268        }
269    }
270}
271
272#[derive(Debug, Clone)]
273pub struct BoardControlHandle {
274    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
275}
276
277impl fdomain_client::fidl::ControlHandle for BoardControlHandle {
278    fn shutdown(&self) {
279        self.inner.shutdown()
280    }
281
282    fn is_closed(&self) -> bool {
283        self.inner.channel().is_closed()
284    }
285    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
286        self.inner.channel().on_closed()
287    }
288}
289
290impl BoardControlHandle {}
291
292#[must_use = "FIDL methods require a response to be sent"]
293#[derive(Debug)]
294pub struct BoardGetInfoResponder {
295    control_handle: std::mem::ManuallyDrop<BoardControlHandle>,
296    tx_id: u32,
297}
298
299/// Set the the channel to be shutdown (see [`BoardControlHandle::shutdown`])
300/// if the responder is dropped without sending a response, so that the client
301/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
302impl std::ops::Drop for BoardGetInfoResponder {
303    fn drop(&mut self) {
304        self.control_handle.shutdown();
305        // Safety: drops once, never accessed again
306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
307    }
308}
309
310impl fdomain_client::fidl::Responder for BoardGetInfoResponder {
311    type ControlHandle = BoardControlHandle;
312
313    fn control_handle(&self) -> &BoardControlHandle {
314        &self.control_handle
315    }
316
317    fn drop_without_shutdown(mut self) {
318        // Safety: drops once, never accessed again due to mem::forget
319        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
320        // Prevent Drop from running (which would shut down the channel)
321        std::mem::forget(self);
322    }
323}
324
325impl BoardGetInfoResponder {
326    /// Sends a response to the FIDL transaction.
327    ///
328    /// Sets the channel to shutdown if an error occurs.
329    pub fn send(self, mut info: &BoardInfo) -> Result<(), fidl::Error> {
330        let _result = self.send_raw(info);
331        if _result.is_err() {
332            self.control_handle.shutdown();
333        }
334        self.drop_without_shutdown();
335        _result
336    }
337
338    /// Similar to "send" but does not shutdown the channel if an error occurs.
339    pub fn send_no_shutdown_on_err(self, mut info: &BoardInfo) -> Result<(), fidl::Error> {
340        let _result = self.send_raw(info);
341        self.drop_without_shutdown();
342        _result
343    }
344
345    fn send_raw(&self, mut info: &BoardInfo) -> Result<(), fidl::Error> {
346        self.control_handle.inner.send::<BoardGetInfoResponse>(
347            (info,),
348            self.tx_id,
349            0x878a093531d0904,
350            fidl::encoding::DynamicFlags::empty(),
351        )
352    }
353}
354
355#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
356pub struct DeviceMarker;
357
358impl fdomain_client::fidl::ProtocolMarker for DeviceMarker {
359    type Proxy = DeviceProxy;
360    type RequestStream = DeviceRequestStream;
361
362    const DEBUG_NAME: &'static str = "fuchsia.hwinfo.Device";
363}
364impl fdomain_client::fidl::DiscoverableProtocolMarker for DeviceMarker {}
365
366pub trait DeviceProxyInterface: Send + Sync {
367    type GetInfoResponseFut: std::future::Future<Output = Result<DeviceInfo, fidl::Error>> + Send;
368    fn r#get_info(&self) -> Self::GetInfoResponseFut;
369}
370
371#[derive(Debug, Clone)]
372pub struct DeviceProxy {
373    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
374}
375
376impl fdomain_client::fidl::Proxy for DeviceProxy {
377    type Protocol = DeviceMarker;
378
379    fn from_channel(inner: fdomain_client::Channel) -> Self {
380        Self::new(inner)
381    }
382
383    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
384        self.client.into_channel().map_err(|client| Self { client })
385    }
386
387    fn as_channel(&self) -> &fdomain_client::Channel {
388        self.client.as_channel()
389    }
390}
391
392impl DeviceProxy {
393    /// Create a new Proxy for fuchsia.hwinfo/Device.
394    pub fn new(channel: fdomain_client::Channel) -> Self {
395        let protocol_name = <DeviceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
396        Self { client: fidl::client::Client::new(channel, protocol_name) }
397    }
398
399    /// Get a Stream of events from the remote end of the protocol.
400    ///
401    /// # Panics
402    ///
403    /// Panics if the event stream was already taken.
404    pub fn take_event_stream(&self) -> DeviceEventStream {
405        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
406    }
407
408    pub fn r#get_info(
409        &self,
410    ) -> fidl::client::QueryResponseFut<DeviceInfo, fdomain_client::fidl::FDomainResourceDialect>
411    {
412        DeviceProxyInterface::r#get_info(self)
413    }
414}
415
416impl DeviceProxyInterface for DeviceProxy {
417    type GetInfoResponseFut =
418        fidl::client::QueryResponseFut<DeviceInfo, fdomain_client::fidl::FDomainResourceDialect>;
419    fn r#get_info(&self) -> Self::GetInfoResponseFut {
420        fn _decode(
421            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
422        ) -> Result<DeviceInfo, fidl::Error> {
423            let _response = fidl::client::decode_transaction_body::<
424                DeviceGetInfoResponse,
425                fdomain_client::fidl::FDomainResourceDialect,
426                0x4cc66c5e52b0a7d1,
427            >(_buf?)?;
428            Ok(_response.info)
429        }
430        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceInfo>(
431            (),
432            0x4cc66c5e52b0a7d1,
433            fidl::encoding::DynamicFlags::empty(),
434            _decode,
435        )
436    }
437}
438
439pub struct DeviceEventStream {
440    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
441}
442
443impl std::marker::Unpin for DeviceEventStream {}
444
445impl futures::stream::FusedStream for DeviceEventStream {
446    fn is_terminated(&self) -> bool {
447        self.event_receiver.is_terminated()
448    }
449}
450
451impl futures::Stream for DeviceEventStream {
452    type Item = Result<DeviceEvent, fidl::Error>;
453
454    fn poll_next(
455        mut self: std::pin::Pin<&mut Self>,
456        cx: &mut std::task::Context<'_>,
457    ) -> std::task::Poll<Option<Self::Item>> {
458        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
459            &mut self.event_receiver,
460            cx
461        )?) {
462            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
463            None => std::task::Poll::Ready(None),
464        }
465    }
466}
467
468#[derive(Debug)]
469pub enum DeviceEvent {}
470
471impl DeviceEvent {
472    /// Decodes a message buffer as a [`DeviceEvent`].
473    fn decode(
474        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
475    ) -> Result<DeviceEvent, fidl::Error> {
476        let (bytes, _handles) = buf.split_mut();
477        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
478        debug_assert_eq!(tx_header.tx_id, 0);
479        match tx_header.ordinal {
480            _ => Err(fidl::Error::UnknownOrdinal {
481                ordinal: tx_header.ordinal,
482                protocol_name: <DeviceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
483            }),
484        }
485    }
486}
487
488/// A Stream of incoming requests for fuchsia.hwinfo/Device.
489pub struct DeviceRequestStream {
490    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
491    is_terminated: bool,
492}
493
494impl std::marker::Unpin for DeviceRequestStream {}
495
496impl futures::stream::FusedStream for DeviceRequestStream {
497    fn is_terminated(&self) -> bool {
498        self.is_terminated
499    }
500}
501
502impl fdomain_client::fidl::RequestStream for DeviceRequestStream {
503    type Protocol = DeviceMarker;
504    type ControlHandle = DeviceControlHandle;
505
506    fn from_channel(channel: fdomain_client::Channel) -> Self {
507        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
508    }
509
510    fn control_handle(&self) -> Self::ControlHandle {
511        DeviceControlHandle { inner: self.inner.clone() }
512    }
513
514    fn into_inner(
515        self,
516    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
517    {
518        (self.inner, self.is_terminated)
519    }
520
521    fn from_inner(
522        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
523        is_terminated: bool,
524    ) -> Self {
525        Self { inner, is_terminated }
526    }
527}
528
529impl futures::Stream for DeviceRequestStream {
530    type Item = Result<DeviceRequest, fidl::Error>;
531
532    fn poll_next(
533        mut self: std::pin::Pin<&mut Self>,
534        cx: &mut std::task::Context<'_>,
535    ) -> std::task::Poll<Option<Self::Item>> {
536        let this = &mut *self;
537        if this.inner.check_shutdown(cx) {
538            this.is_terminated = true;
539            return std::task::Poll::Ready(None);
540        }
541        if this.is_terminated {
542            panic!("polled DeviceRequestStream after completion");
543        }
544        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
545            |bytes, handles| {
546                match this.inner.channel().read_etc(cx, bytes, handles) {
547                    std::task::Poll::Ready(Ok(())) => {}
548                    std::task::Poll::Pending => return std::task::Poll::Pending,
549                    std::task::Poll::Ready(Err(None)) => {
550                        this.is_terminated = true;
551                        return std::task::Poll::Ready(None);
552                    }
553                    std::task::Poll::Ready(Err(Some(e))) => {
554                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
555                            e.into(),
556                        ))))
557                    }
558                }
559
560                // A message has been received from the channel
561                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
562
563                std::task::Poll::Ready(Some(match header.ordinal {
564                    0x4cc66c5e52b0a7d1 => {
565                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
566                        let mut req = fidl::new_empty!(
567                            fidl::encoding::EmptyPayload,
568                            fdomain_client::fidl::FDomainResourceDialect
569                        );
570                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
571                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
572                        Ok(DeviceRequest::GetInfo {
573                            responder: DeviceGetInfoResponder {
574                                control_handle: std::mem::ManuallyDrop::new(control_handle),
575                                tx_id: header.tx_id,
576                            },
577                        })
578                    }
579                    _ => Err(fidl::Error::UnknownOrdinal {
580                        ordinal: header.ordinal,
581                        protocol_name:
582                            <DeviceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
583                    }),
584                }))
585            },
586        )
587    }
588}
589
590/// Device provides an interface to retrieve device-specific properties.
591#[derive(Debug)]
592pub enum DeviceRequest {
593    GetInfo { responder: DeviceGetInfoResponder },
594}
595
596impl DeviceRequest {
597    #[allow(irrefutable_let_patterns)]
598    pub fn into_get_info(self) -> Option<(DeviceGetInfoResponder)> {
599        if let DeviceRequest::GetInfo { responder } = self {
600            Some((responder))
601        } else {
602            None
603        }
604    }
605
606    /// Name of the method defined in FIDL
607    pub fn method_name(&self) -> &'static str {
608        match *self {
609            DeviceRequest::GetInfo { .. } => "get_info",
610        }
611    }
612}
613
614#[derive(Debug, Clone)]
615pub struct DeviceControlHandle {
616    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
617}
618
619impl fdomain_client::fidl::ControlHandle for DeviceControlHandle {
620    fn shutdown(&self) {
621        self.inner.shutdown()
622    }
623
624    fn is_closed(&self) -> bool {
625        self.inner.channel().is_closed()
626    }
627    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
628        self.inner.channel().on_closed()
629    }
630}
631
632impl DeviceControlHandle {}
633
634#[must_use = "FIDL methods require a response to be sent"]
635#[derive(Debug)]
636pub struct DeviceGetInfoResponder {
637    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
638    tx_id: u32,
639}
640
641/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
642/// if the responder is dropped without sending a response, so that the client
643/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
644impl std::ops::Drop for DeviceGetInfoResponder {
645    fn drop(&mut self) {
646        self.control_handle.shutdown();
647        // Safety: drops once, never accessed again
648        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
649    }
650}
651
652impl fdomain_client::fidl::Responder for DeviceGetInfoResponder {
653    type ControlHandle = DeviceControlHandle;
654
655    fn control_handle(&self) -> &DeviceControlHandle {
656        &self.control_handle
657    }
658
659    fn drop_without_shutdown(mut self) {
660        // Safety: drops once, never accessed again due to mem::forget
661        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
662        // Prevent Drop from running (which would shut down the channel)
663        std::mem::forget(self);
664    }
665}
666
667impl DeviceGetInfoResponder {
668    /// Sends a response to the FIDL transaction.
669    ///
670    /// Sets the channel to shutdown if an error occurs.
671    pub fn send(self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
672        let _result = self.send_raw(info);
673        if _result.is_err() {
674            self.control_handle.shutdown();
675        }
676        self.drop_without_shutdown();
677        _result
678    }
679
680    /// Similar to "send" but does not shutdown the channel if an error occurs.
681    pub fn send_no_shutdown_on_err(self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
682        let _result = self.send_raw(info);
683        self.drop_without_shutdown();
684        _result
685    }
686
687    fn send_raw(&self, mut info: &DeviceInfo) -> Result<(), fidl::Error> {
688        self.control_handle.inner.send::<DeviceGetInfoResponse>(
689            (info,),
690            self.tx_id,
691            0x4cc66c5e52b0a7d1,
692            fidl::encoding::DynamicFlags::empty(),
693        )
694    }
695}
696
697#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
698pub struct ProductMarker;
699
700impl fdomain_client::fidl::ProtocolMarker for ProductMarker {
701    type Proxy = ProductProxy;
702    type RequestStream = ProductRequestStream;
703
704    const DEBUG_NAME: &'static str = "fuchsia.hwinfo.Product";
705}
706impl fdomain_client::fidl::DiscoverableProtocolMarker for ProductMarker {}
707
708pub trait ProductProxyInterface: Send + Sync {
709    type GetInfoResponseFut: std::future::Future<Output = Result<ProductInfo, fidl::Error>> + Send;
710    fn r#get_info(&self) -> Self::GetInfoResponseFut;
711}
712
713#[derive(Debug, Clone)]
714pub struct ProductProxy {
715    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
716}
717
718impl fdomain_client::fidl::Proxy for ProductProxy {
719    type Protocol = ProductMarker;
720
721    fn from_channel(inner: fdomain_client::Channel) -> Self {
722        Self::new(inner)
723    }
724
725    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
726        self.client.into_channel().map_err(|client| Self { client })
727    }
728
729    fn as_channel(&self) -> &fdomain_client::Channel {
730        self.client.as_channel()
731    }
732}
733
734impl ProductProxy {
735    /// Create a new Proxy for fuchsia.hwinfo/Product.
736    pub fn new(channel: fdomain_client::Channel) -> Self {
737        let protocol_name = <ProductMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
738        Self { client: fidl::client::Client::new(channel, protocol_name) }
739    }
740
741    /// Get a Stream of events from the remote end of the protocol.
742    ///
743    /// # Panics
744    ///
745    /// Panics if the event stream was already taken.
746    pub fn take_event_stream(&self) -> ProductEventStream {
747        ProductEventStream { event_receiver: self.client.take_event_receiver() }
748    }
749
750    pub fn r#get_info(
751        &self,
752    ) -> fidl::client::QueryResponseFut<ProductInfo, fdomain_client::fidl::FDomainResourceDialect>
753    {
754        ProductProxyInterface::r#get_info(self)
755    }
756}
757
758impl ProductProxyInterface for ProductProxy {
759    type GetInfoResponseFut =
760        fidl::client::QueryResponseFut<ProductInfo, fdomain_client::fidl::FDomainResourceDialect>;
761    fn r#get_info(&self) -> Self::GetInfoResponseFut {
762        fn _decode(
763            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
764        ) -> Result<ProductInfo, fidl::Error> {
765            let _response = fidl::client::decode_transaction_body::<
766                ProductGetInfoResponse,
767                fdomain_client::fidl::FDomainResourceDialect,
768                0x11a4825cda315828,
769            >(_buf?)?;
770            Ok(_response.info)
771        }
772        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ProductInfo>(
773            (),
774            0x11a4825cda315828,
775            fidl::encoding::DynamicFlags::empty(),
776            _decode,
777        )
778    }
779}
780
781pub struct ProductEventStream {
782    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
783}
784
785impl std::marker::Unpin for ProductEventStream {}
786
787impl futures::stream::FusedStream for ProductEventStream {
788    fn is_terminated(&self) -> bool {
789        self.event_receiver.is_terminated()
790    }
791}
792
793impl futures::Stream for ProductEventStream {
794    type Item = Result<ProductEvent, fidl::Error>;
795
796    fn poll_next(
797        mut self: std::pin::Pin<&mut Self>,
798        cx: &mut std::task::Context<'_>,
799    ) -> std::task::Poll<Option<Self::Item>> {
800        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
801            &mut self.event_receiver,
802            cx
803        )?) {
804            Some(buf) => std::task::Poll::Ready(Some(ProductEvent::decode(buf))),
805            None => std::task::Poll::Ready(None),
806        }
807    }
808}
809
810#[derive(Debug)]
811pub enum ProductEvent {}
812
813impl ProductEvent {
814    /// Decodes a message buffer as a [`ProductEvent`].
815    fn decode(
816        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
817    ) -> Result<ProductEvent, fidl::Error> {
818        let (bytes, _handles) = buf.split_mut();
819        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
820        debug_assert_eq!(tx_header.tx_id, 0);
821        match tx_header.ordinal {
822            _ => Err(fidl::Error::UnknownOrdinal {
823                ordinal: tx_header.ordinal,
824                protocol_name: <ProductMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
825            }),
826        }
827    }
828}
829
830/// A Stream of incoming requests for fuchsia.hwinfo/Product.
831pub struct ProductRequestStream {
832    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
833    is_terminated: bool,
834}
835
836impl std::marker::Unpin for ProductRequestStream {}
837
838impl futures::stream::FusedStream for ProductRequestStream {
839    fn is_terminated(&self) -> bool {
840        self.is_terminated
841    }
842}
843
844impl fdomain_client::fidl::RequestStream for ProductRequestStream {
845    type Protocol = ProductMarker;
846    type ControlHandle = ProductControlHandle;
847
848    fn from_channel(channel: fdomain_client::Channel) -> Self {
849        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
850    }
851
852    fn control_handle(&self) -> Self::ControlHandle {
853        ProductControlHandle { inner: self.inner.clone() }
854    }
855
856    fn into_inner(
857        self,
858    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
859    {
860        (self.inner, self.is_terminated)
861    }
862
863    fn from_inner(
864        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
865        is_terminated: bool,
866    ) -> Self {
867        Self { inner, is_terminated }
868    }
869}
870
871impl futures::Stream for ProductRequestStream {
872    type Item = Result<ProductRequest, fidl::Error>;
873
874    fn poll_next(
875        mut self: std::pin::Pin<&mut Self>,
876        cx: &mut std::task::Context<'_>,
877    ) -> std::task::Poll<Option<Self::Item>> {
878        let this = &mut *self;
879        if this.inner.check_shutdown(cx) {
880            this.is_terminated = true;
881            return std::task::Poll::Ready(None);
882        }
883        if this.is_terminated {
884            panic!("polled ProductRequestStream after completion");
885        }
886        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
887            |bytes, handles| {
888                match this.inner.channel().read_etc(cx, bytes, handles) {
889                    std::task::Poll::Ready(Ok(())) => {}
890                    std::task::Poll::Pending => return std::task::Poll::Pending,
891                    std::task::Poll::Ready(Err(None)) => {
892                        this.is_terminated = true;
893                        return std::task::Poll::Ready(None);
894                    }
895                    std::task::Poll::Ready(Err(Some(e))) => {
896                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
897                            e.into(),
898                        ))))
899                    }
900                }
901
902                // A message has been received from the channel
903                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
904
905                std::task::Poll::Ready(Some(match header.ordinal {
906                    0x11a4825cda315828 => {
907                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
908                        let mut req = fidl::new_empty!(
909                            fidl::encoding::EmptyPayload,
910                            fdomain_client::fidl::FDomainResourceDialect
911                        );
912                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
913                        let control_handle = ProductControlHandle { inner: this.inner.clone() };
914                        Ok(ProductRequest::GetInfo {
915                            responder: ProductGetInfoResponder {
916                                control_handle: std::mem::ManuallyDrop::new(control_handle),
917                                tx_id: header.tx_id,
918                            },
919                        })
920                    }
921                    _ => Err(fidl::Error::UnknownOrdinal {
922                        ordinal: header.ordinal,
923                        protocol_name:
924                            <ProductMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
925                    }),
926                }))
927            },
928        )
929    }
930}
931
932/// Product provides an interface to retrieve product-specific properties.
933#[derive(Debug)]
934pub enum ProductRequest {
935    GetInfo { responder: ProductGetInfoResponder },
936}
937
938impl ProductRequest {
939    #[allow(irrefutable_let_patterns)]
940    pub fn into_get_info(self) -> Option<(ProductGetInfoResponder)> {
941        if let ProductRequest::GetInfo { responder } = self {
942            Some((responder))
943        } else {
944            None
945        }
946    }
947
948    /// Name of the method defined in FIDL
949    pub fn method_name(&self) -> &'static str {
950        match *self {
951            ProductRequest::GetInfo { .. } => "get_info",
952        }
953    }
954}
955
956#[derive(Debug, Clone)]
957pub struct ProductControlHandle {
958    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
959}
960
961impl fdomain_client::fidl::ControlHandle for ProductControlHandle {
962    fn shutdown(&self) {
963        self.inner.shutdown()
964    }
965
966    fn is_closed(&self) -> bool {
967        self.inner.channel().is_closed()
968    }
969    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
970        self.inner.channel().on_closed()
971    }
972}
973
974impl ProductControlHandle {}
975
976#[must_use = "FIDL methods require a response to be sent"]
977#[derive(Debug)]
978pub struct ProductGetInfoResponder {
979    control_handle: std::mem::ManuallyDrop<ProductControlHandle>,
980    tx_id: u32,
981}
982
983/// Set the the channel to be shutdown (see [`ProductControlHandle::shutdown`])
984/// if the responder is dropped without sending a response, so that the client
985/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
986impl std::ops::Drop for ProductGetInfoResponder {
987    fn drop(&mut self) {
988        self.control_handle.shutdown();
989        // Safety: drops once, never accessed again
990        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
991    }
992}
993
994impl fdomain_client::fidl::Responder for ProductGetInfoResponder {
995    type ControlHandle = ProductControlHandle;
996
997    fn control_handle(&self) -> &ProductControlHandle {
998        &self.control_handle
999    }
1000
1001    fn drop_without_shutdown(mut self) {
1002        // Safety: drops once, never accessed again due to mem::forget
1003        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1004        // Prevent Drop from running (which would shut down the channel)
1005        std::mem::forget(self);
1006    }
1007}
1008
1009impl ProductGetInfoResponder {
1010    /// Sends a response to the FIDL transaction.
1011    ///
1012    /// Sets the channel to shutdown if an error occurs.
1013    pub fn send(self, mut info: &ProductInfo) -> Result<(), fidl::Error> {
1014        let _result = self.send_raw(info);
1015        if _result.is_err() {
1016            self.control_handle.shutdown();
1017        }
1018        self.drop_without_shutdown();
1019        _result
1020    }
1021
1022    /// Similar to "send" but does not shutdown the channel if an error occurs.
1023    pub fn send_no_shutdown_on_err(self, mut info: &ProductInfo) -> Result<(), fidl::Error> {
1024        let _result = self.send_raw(info);
1025        self.drop_without_shutdown();
1026        _result
1027    }
1028
1029    fn send_raw(&self, mut info: &ProductInfo) -> Result<(), fidl::Error> {
1030        self.control_handle.inner.send::<ProductGetInfoResponse>(
1031            (info,),
1032            self.tx_id,
1033            0x11a4825cda315828,
1034            fidl::encoding::DynamicFlags::empty(),
1035        )
1036    }
1037}
1038
1039mod internal {
1040    use super::*;
1041}