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