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