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