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