Skip to main content

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