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 fidl::endpoints::ControlHandle for SysInfoControlHandle {
700    fn shutdown(&self) {
701        self.inner.shutdown()
702    }
703
704    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
705        self.inner.shutdown_with_epitaph(status)
706    }
707
708    fn is_closed(&self) -> bool {
709        self.inner.channel().is_closed()
710    }
711    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
712        self.inner.channel().on_closed()
713    }
714
715    #[cfg(target_os = "fuchsia")]
716    fn signal_peer(
717        &self,
718        clear_mask: zx::Signals,
719        set_mask: zx::Signals,
720    ) -> Result<(), zx_status::Status> {
721        use fidl::Peered;
722        self.inner.channel().signal_peer(clear_mask, set_mask)
723    }
724}
725
726impl SysInfoControlHandle {}
727
728#[must_use = "FIDL methods require a response to be sent"]
729#[derive(Debug)]
730pub struct SysInfoGetBoardNameResponder {
731    control_handle: std::mem::ManuallyDrop<SysInfoControlHandle>,
732    tx_id: u32,
733}
734
735/// Set the the channel to be shutdown (see [`SysInfoControlHandle::shutdown`])
736/// if the responder is dropped without sending a response, so that the client
737/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
738impl std::ops::Drop for SysInfoGetBoardNameResponder {
739    fn drop(&mut self) {
740        self.control_handle.shutdown();
741        // Safety: drops once, never accessed again
742        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
743    }
744}
745
746impl fidl::endpoints::Responder for SysInfoGetBoardNameResponder {
747    type ControlHandle = SysInfoControlHandle;
748
749    fn control_handle(&self) -> &SysInfoControlHandle {
750        &self.control_handle
751    }
752
753    fn drop_without_shutdown(mut self) {
754        // Safety: drops once, never accessed again due to mem::forget
755        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
756        // Prevent Drop from running (which would shut down the channel)
757        std::mem::forget(self);
758    }
759}
760
761impl SysInfoGetBoardNameResponder {
762    /// Sends a response to the FIDL transaction.
763    ///
764    /// Sets the channel to shutdown if an error occurs.
765    pub fn send(self, mut status: i32, mut name: Option<&str>) -> Result<(), fidl::Error> {
766        let _result = self.send_raw(status, name);
767        if _result.is_err() {
768            self.control_handle.shutdown();
769        }
770        self.drop_without_shutdown();
771        _result
772    }
773
774    /// Similar to "send" but does not shutdown the channel if an error occurs.
775    pub fn send_no_shutdown_on_err(
776        self,
777        mut status: i32,
778        mut name: Option<&str>,
779    ) -> Result<(), fidl::Error> {
780        let _result = self.send_raw(status, name);
781        self.drop_without_shutdown();
782        _result
783    }
784
785    fn send_raw(&self, mut status: i32, mut name: Option<&str>) -> Result<(), fidl::Error> {
786        self.control_handle.inner.send::<SysInfoGetBoardNameResponse>(
787            (status, name),
788            self.tx_id,
789            0x6d29d1a6edf9a614,
790            fidl::encoding::DynamicFlags::empty(),
791        )
792    }
793}
794
795#[must_use = "FIDL methods require a response to be sent"]
796#[derive(Debug)]
797pub struct SysInfoGetBoardRevisionResponder {
798    control_handle: std::mem::ManuallyDrop<SysInfoControlHandle>,
799    tx_id: u32,
800}
801
802/// Set the the channel to be shutdown (see [`SysInfoControlHandle::shutdown`])
803/// if the responder is dropped without sending a response, so that the client
804/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
805impl std::ops::Drop for SysInfoGetBoardRevisionResponder {
806    fn drop(&mut self) {
807        self.control_handle.shutdown();
808        // Safety: drops once, never accessed again
809        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
810    }
811}
812
813impl fidl::endpoints::Responder for SysInfoGetBoardRevisionResponder {
814    type ControlHandle = SysInfoControlHandle;
815
816    fn control_handle(&self) -> &SysInfoControlHandle {
817        &self.control_handle
818    }
819
820    fn drop_without_shutdown(mut self) {
821        // Safety: drops once, never accessed again due to mem::forget
822        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
823        // Prevent Drop from running (which would shut down the channel)
824        std::mem::forget(self);
825    }
826}
827
828impl SysInfoGetBoardRevisionResponder {
829    /// Sends a response to the FIDL transaction.
830    ///
831    /// Sets the channel to shutdown if an error occurs.
832    pub fn send(self, mut status: i32, mut revision: u32) -> Result<(), fidl::Error> {
833        let _result = self.send_raw(status, revision);
834        if _result.is_err() {
835            self.control_handle.shutdown();
836        }
837        self.drop_without_shutdown();
838        _result
839    }
840
841    /// Similar to "send" but does not shutdown the channel if an error occurs.
842    pub fn send_no_shutdown_on_err(
843        self,
844        mut status: i32,
845        mut revision: u32,
846    ) -> Result<(), fidl::Error> {
847        let _result = self.send_raw(status, revision);
848        self.drop_without_shutdown();
849        _result
850    }
851
852    fn send_raw(&self, mut status: i32, mut revision: u32) -> Result<(), fidl::Error> {
853        self.control_handle.inner.send::<SysInfoGetBoardRevisionResponse>(
854            (status, revision),
855            self.tx_id,
856            0x3dd050d99012e9cc,
857            fidl::encoding::DynamicFlags::empty(),
858        )
859    }
860}
861
862#[must_use = "FIDL methods require a response to be sent"]
863#[derive(Debug)]
864pub struct SysInfoGetBootloaderVendorResponder {
865    control_handle: std::mem::ManuallyDrop<SysInfoControlHandle>,
866    tx_id: u32,
867}
868
869/// Set the the channel to be shutdown (see [`SysInfoControlHandle::shutdown`])
870/// if the responder is dropped without sending a response, so that the client
871/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
872impl std::ops::Drop for SysInfoGetBootloaderVendorResponder {
873    fn drop(&mut self) {
874        self.control_handle.shutdown();
875        // Safety: drops once, never accessed again
876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877    }
878}
879
880impl fidl::endpoints::Responder for SysInfoGetBootloaderVendorResponder {
881    type ControlHandle = SysInfoControlHandle;
882
883    fn control_handle(&self) -> &SysInfoControlHandle {
884        &self.control_handle
885    }
886
887    fn drop_without_shutdown(mut self) {
888        // Safety: drops once, never accessed again due to mem::forget
889        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
890        // Prevent Drop from running (which would shut down the channel)
891        std::mem::forget(self);
892    }
893}
894
895impl SysInfoGetBootloaderVendorResponder {
896    /// Sends a response to the FIDL transaction.
897    ///
898    /// Sets the channel to shutdown if an error occurs.
899    pub fn send(self, mut status: i32, mut vendor: Option<&str>) -> Result<(), fidl::Error> {
900        let _result = self.send_raw(status, vendor);
901        if _result.is_err() {
902            self.control_handle.shutdown();
903        }
904        self.drop_without_shutdown();
905        _result
906    }
907
908    /// Similar to "send" but does not shutdown the channel if an error occurs.
909    pub fn send_no_shutdown_on_err(
910        self,
911        mut status: i32,
912        mut vendor: Option<&str>,
913    ) -> Result<(), fidl::Error> {
914        let _result = self.send_raw(status, vendor);
915        self.drop_without_shutdown();
916        _result
917    }
918
919    fn send_raw(&self, mut status: i32, mut vendor: Option<&str>) -> Result<(), fidl::Error> {
920        self.control_handle.inner.send::<SysInfoGetBootloaderVendorResponse>(
921            (status, vendor),
922            self.tx_id,
923            0x2511f1c2f9ae2017,
924            fidl::encoding::DynamicFlags::empty(),
925        )
926    }
927}
928
929#[must_use = "FIDL methods require a response to be sent"]
930#[derive(Debug)]
931pub struct SysInfoGetInterruptControllerInfoResponder {
932    control_handle: std::mem::ManuallyDrop<SysInfoControlHandle>,
933    tx_id: u32,
934}
935
936/// Set the the channel to be shutdown (see [`SysInfoControlHandle::shutdown`])
937/// if the responder is dropped without sending a response, so that the client
938/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
939impl std::ops::Drop for SysInfoGetInterruptControllerInfoResponder {
940    fn drop(&mut self) {
941        self.control_handle.shutdown();
942        // Safety: drops once, never accessed again
943        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
944    }
945}
946
947impl fidl::endpoints::Responder for SysInfoGetInterruptControllerInfoResponder {
948    type ControlHandle = SysInfoControlHandle;
949
950    fn control_handle(&self) -> &SysInfoControlHandle {
951        &self.control_handle
952    }
953
954    fn drop_without_shutdown(mut self) {
955        // Safety: drops once, never accessed again due to mem::forget
956        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
957        // Prevent Drop from running (which would shut down the channel)
958        std::mem::forget(self);
959    }
960}
961
962impl SysInfoGetInterruptControllerInfoResponder {
963    /// Sends a response to the FIDL transaction.
964    ///
965    /// Sets the channel to shutdown if an error occurs.
966    pub fn send(
967        self,
968        mut status: i32,
969        mut info: Option<&InterruptControllerInfo>,
970    ) -> Result<(), fidl::Error> {
971        let _result = self.send_raw(status, info);
972        if _result.is_err() {
973            self.control_handle.shutdown();
974        }
975        self.drop_without_shutdown();
976        _result
977    }
978
979    /// Similar to "send" but does not shutdown the channel if an error occurs.
980    pub fn send_no_shutdown_on_err(
981        self,
982        mut status: i32,
983        mut info: Option<&InterruptControllerInfo>,
984    ) -> Result<(), fidl::Error> {
985        let _result = self.send_raw(status, info);
986        self.drop_without_shutdown();
987        _result
988    }
989
990    fn send_raw(
991        &self,
992        mut status: i32,
993        mut info: Option<&InterruptControllerInfo>,
994    ) -> Result<(), fidl::Error> {
995        self.control_handle.inner.send::<SysInfoGetInterruptControllerInfoResponse>(
996            (status, info),
997            self.tx_id,
998            0x31a438b28dca119c,
999            fidl::encoding::DynamicFlags::empty(),
1000        )
1001    }
1002}
1003
1004#[must_use = "FIDL methods require a response to be sent"]
1005#[derive(Debug)]
1006pub struct SysInfoGetSerialNumberResponder {
1007    control_handle: std::mem::ManuallyDrop<SysInfoControlHandle>,
1008    tx_id: u32,
1009}
1010
1011/// Set the the channel to be shutdown (see [`SysInfoControlHandle::shutdown`])
1012/// if the responder is dropped without sending a response, so that the client
1013/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1014impl std::ops::Drop for SysInfoGetSerialNumberResponder {
1015    fn drop(&mut self) {
1016        self.control_handle.shutdown();
1017        // Safety: drops once, never accessed again
1018        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1019    }
1020}
1021
1022impl fidl::endpoints::Responder for SysInfoGetSerialNumberResponder {
1023    type ControlHandle = SysInfoControlHandle;
1024
1025    fn control_handle(&self) -> &SysInfoControlHandle {
1026        &self.control_handle
1027    }
1028
1029    fn drop_without_shutdown(mut self) {
1030        // Safety: drops once, never accessed again due to mem::forget
1031        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1032        // Prevent Drop from running (which would shut down the channel)
1033        std::mem::forget(self);
1034    }
1035}
1036
1037impl SysInfoGetSerialNumberResponder {
1038    /// Sends a response to the FIDL transaction.
1039    ///
1040    /// Sets the channel to shutdown if an error occurs.
1041    pub fn send(self, mut result: Result<&str, i32>) -> Result<(), fidl::Error> {
1042        let _result = self.send_raw(result);
1043        if _result.is_err() {
1044            self.control_handle.shutdown();
1045        }
1046        self.drop_without_shutdown();
1047        _result
1048    }
1049
1050    /// Similar to "send" but does not shutdown the channel if an error occurs.
1051    pub fn send_no_shutdown_on_err(self, mut result: Result<&str, i32>) -> Result<(), fidl::Error> {
1052        let _result = self.send_raw(result);
1053        self.drop_without_shutdown();
1054        _result
1055    }
1056
1057    fn send_raw(&self, mut result: Result<&str, i32>) -> Result<(), fidl::Error> {
1058        self.control_handle
1059            .inner
1060            .send::<fidl::encoding::ResultType<SysInfoGetSerialNumberResponse, i32>>(
1061                result.map(|serial| (serial,)),
1062                self.tx_id,
1063                0x3b6920410a59f01f,
1064                fidl::encoding::DynamicFlags::empty(),
1065            )
1066    }
1067}
1068
1069#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1070pub struct ServiceMarker;
1071
1072#[cfg(target_os = "fuchsia")]
1073impl fidl::endpoints::ServiceMarker for ServiceMarker {
1074    type Proxy = ServiceProxy;
1075    type Request = ServiceRequest;
1076    const SERVICE_NAME: &'static str = "fuchsia.sysinfo.Service";
1077}
1078
1079/// A request for one of the member protocols of Service.
1080///
1081#[cfg(target_os = "fuchsia")]
1082pub enum ServiceRequest {
1083    Device(SysInfoRequestStream),
1084}
1085
1086#[cfg(target_os = "fuchsia")]
1087impl fidl::endpoints::ServiceRequest for ServiceRequest {
1088    type Service = ServiceMarker;
1089
1090    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1091        match name {
1092            "device" => Self::Device(
1093                <SysInfoRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1094            ),
1095            _ => panic!("no such member protocol name for service Service"),
1096        }
1097    }
1098
1099    fn member_names() -> &'static [&'static str] {
1100        &["device"]
1101    }
1102}
1103#[cfg(target_os = "fuchsia")]
1104pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1105
1106#[cfg(target_os = "fuchsia")]
1107impl fidl::endpoints::ServiceProxy for ServiceProxy {
1108    type Service = ServiceMarker;
1109
1110    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1111        Self(opener)
1112    }
1113}
1114
1115#[cfg(target_os = "fuchsia")]
1116impl ServiceProxy {
1117    pub fn connect_to_device(&self) -> Result<SysInfoProxy, fidl::Error> {
1118        let (proxy, server_end) = fidl::endpoints::create_proxy::<SysInfoMarker>();
1119        self.connect_channel_to_device(server_end)?;
1120        Ok(proxy)
1121    }
1122
1123    /// Like `connect_to_device`, but returns a sync proxy.
1124    /// See [`Self::connect_to_device`] for more details.
1125    pub fn connect_to_device_sync(&self) -> Result<SysInfoSynchronousProxy, fidl::Error> {
1126        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<SysInfoMarker>();
1127        self.connect_channel_to_device(server_end)?;
1128        Ok(proxy)
1129    }
1130
1131    /// Like `connect_to_device`, but accepts a server end.
1132    /// See [`Self::connect_to_device`] for more details.
1133    pub fn connect_channel_to_device(
1134        &self,
1135        server_end: fidl::endpoints::ServerEnd<SysInfoMarker>,
1136    ) -> Result<(), fidl::Error> {
1137        self.0.open_member("device", server_end.into_channel())
1138    }
1139
1140    pub fn instance_name(&self) -> &str {
1141        self.0.instance_name()
1142    }
1143}
1144
1145mod internal {
1146    use super::*;
1147}