Skip to main content

fidl_fuchsia_hardware_temperature/
fidl_fuchsia_hardware_temperature.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_hardware_temperature__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18    type Proxy = DeviceProxy;
19    type RequestStream = DeviceRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DeviceSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) Device";
24}
25
26pub trait DeviceProxyInterface: Send + Sync {
27    type GetTemperatureCelsiusResponseFut: std::future::Future<Output = Result<(i32, f32), fidl::Error>>
28        + Send;
29    fn r#get_temperature_celsius(&self) -> Self::GetTemperatureCelsiusResponseFut;
30    type GetSensorNameResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
31    fn r#get_sensor_name(&self) -> Self::GetSensorNameResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct DeviceSynchronousProxy {
36    client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
41    type Proxy = DeviceProxy;
42    type Protocol = DeviceMarker;
43
44    fn from_channel(inner: fidl::Channel) -> Self {
45        Self::new(inner)
46    }
47
48    fn into_channel(self) -> fidl::Channel {
49        self.client.into_channel()
50    }
51
52    fn as_channel(&self) -> &fidl::Channel {
53        self.client.as_channel()
54    }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl DeviceSynchronousProxy {
59    pub fn new(channel: fidl::Channel) -> Self {
60        Self { client: fidl::client::sync::Client::new(channel) }
61    }
62
63    pub fn into_channel(self) -> fidl::Channel {
64        self.client.into_channel()
65    }
66
67    /// Waits until an event arrives and returns it. It is safe for other
68    /// threads to make concurrent requests while waiting for an event.
69    pub fn wait_for_event(
70        &self,
71        deadline: zx::MonotonicInstant,
72    ) -> Result<DeviceEvent, fidl::Error> {
73        DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
74    }
75
76    /// Get the current temperature in degrees Celsius.
77    pub fn r#get_temperature_celsius(
78        &self,
79        ___deadline: zx::MonotonicInstant,
80    ) -> Result<(i32, f32), fidl::Error> {
81        let _response = self.client.send_query::<
82            fidl::encoding::EmptyPayload,
83            DeviceGetTemperatureCelsiusResponse,
84            DeviceMarker,
85        >(
86            (),
87            0x755e08b84736133c,
88            fidl::encoding::DynamicFlags::empty(),
89            ___deadline,
90        )?;
91        Ok((_response.status, _response.temp))
92    }
93
94    pub fn r#get_sensor_name(
95        &self,
96        ___deadline: zx::MonotonicInstant,
97    ) -> Result<String, fidl::Error> {
98        let _response = self
99            .client
100            .send_query::<fidl::encoding::EmptyPayload, DeviceGetSensorNameResponse, DeviceMarker>(
101                (),
102                0x4cbd7abaeafc02c1,
103                fidl::encoding::DynamicFlags::empty(),
104                ___deadline,
105            )?;
106        Ok(_response.name)
107    }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl From<DeviceSynchronousProxy> for zx::NullableHandle {
112    fn from(value: DeviceSynchronousProxy) -> Self {
113        value.into_channel().into()
114    }
115}
116
117#[cfg(target_os = "fuchsia")]
118impl From<fidl::Channel> for DeviceSynchronousProxy {
119    fn from(value: fidl::Channel) -> Self {
120        Self::new(value)
121    }
122}
123
124#[cfg(target_os = "fuchsia")]
125impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
126    type Protocol = DeviceMarker;
127
128    fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
129        Self::new(value.into_channel())
130    }
131}
132
133#[derive(Debug, Clone)]
134pub struct DeviceProxy {
135    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
136}
137
138impl fidl::endpoints::Proxy for DeviceProxy {
139    type Protocol = DeviceMarker;
140
141    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
142        Self::new(inner)
143    }
144
145    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
146        self.client.into_channel().map_err(|client| Self { client })
147    }
148
149    fn as_channel(&self) -> &::fidl::AsyncChannel {
150        self.client.as_channel()
151    }
152}
153
154impl DeviceProxy {
155    /// Create a new Proxy for fuchsia.hardware.temperature/Device.
156    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
157        let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
158        Self { client: fidl::client::Client::new(channel, protocol_name) }
159    }
160
161    /// Get a Stream of events from the remote end of the protocol.
162    ///
163    /// # Panics
164    ///
165    /// Panics if the event stream was already taken.
166    pub fn take_event_stream(&self) -> DeviceEventStream {
167        DeviceEventStream { event_receiver: self.client.take_event_receiver() }
168    }
169
170    /// Get the current temperature in degrees Celsius.
171    pub fn r#get_temperature_celsius(
172        &self,
173    ) -> fidl::client::QueryResponseFut<(i32, f32), fidl::encoding::DefaultFuchsiaResourceDialect>
174    {
175        DeviceProxyInterface::r#get_temperature_celsius(self)
176    }
177
178    pub fn r#get_sensor_name(
179        &self,
180    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
181        DeviceProxyInterface::r#get_sensor_name(self)
182    }
183}
184
185impl DeviceProxyInterface for DeviceProxy {
186    type GetTemperatureCelsiusResponseFut =
187        fidl::client::QueryResponseFut<(i32, f32), fidl::encoding::DefaultFuchsiaResourceDialect>;
188    fn r#get_temperature_celsius(&self) -> Self::GetTemperatureCelsiusResponseFut {
189        fn _decode(
190            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
191        ) -> Result<(i32, f32), fidl::Error> {
192            let _response = fidl::client::decode_transaction_body::<
193                DeviceGetTemperatureCelsiusResponse,
194                fidl::encoding::DefaultFuchsiaResourceDialect,
195                0x755e08b84736133c,
196            >(_buf?)?;
197            Ok((_response.status, _response.temp))
198        }
199        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, f32)>(
200            (),
201            0x755e08b84736133c,
202            fidl::encoding::DynamicFlags::empty(),
203            _decode,
204        )
205    }
206
207    type GetSensorNameResponseFut =
208        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
209    fn r#get_sensor_name(&self) -> Self::GetSensorNameResponseFut {
210        fn _decode(
211            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
212        ) -> Result<String, fidl::Error> {
213            let _response = fidl::client::decode_transaction_body::<
214                DeviceGetSensorNameResponse,
215                fidl::encoding::DefaultFuchsiaResourceDialect,
216                0x4cbd7abaeafc02c1,
217            >(_buf?)?;
218            Ok(_response.name)
219        }
220        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
221            (),
222            0x4cbd7abaeafc02c1,
223            fidl::encoding::DynamicFlags::empty(),
224            _decode,
225        )
226    }
227}
228
229pub struct DeviceEventStream {
230    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
231}
232
233impl std::marker::Unpin for DeviceEventStream {}
234
235impl futures::stream::FusedStream for DeviceEventStream {
236    fn is_terminated(&self) -> bool {
237        self.event_receiver.is_terminated()
238    }
239}
240
241impl futures::Stream for DeviceEventStream {
242    type Item = Result<DeviceEvent, fidl::Error>;
243
244    fn poll_next(
245        mut self: std::pin::Pin<&mut Self>,
246        cx: &mut std::task::Context<'_>,
247    ) -> std::task::Poll<Option<Self::Item>> {
248        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
249            &mut self.event_receiver,
250            cx
251        )?) {
252            Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
253            None => std::task::Poll::Ready(None),
254        }
255    }
256}
257
258#[derive(Debug)]
259pub enum DeviceEvent {}
260
261impl DeviceEvent {
262    /// Decodes a message buffer as a [`DeviceEvent`].
263    fn decode(
264        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
265    ) -> Result<DeviceEvent, fidl::Error> {
266        let (bytes, _handles) = buf.split_mut();
267        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
268        debug_assert_eq!(tx_header.tx_id, 0);
269        match tx_header.ordinal {
270            _ => Err(fidl::Error::UnknownOrdinal {
271                ordinal: tx_header.ordinal,
272                protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
273            }),
274        }
275    }
276}
277
278/// A Stream of incoming requests for fuchsia.hardware.temperature/Device.
279pub struct DeviceRequestStream {
280    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
281    is_terminated: bool,
282}
283
284impl std::marker::Unpin for DeviceRequestStream {}
285
286impl futures::stream::FusedStream for DeviceRequestStream {
287    fn is_terminated(&self) -> bool {
288        self.is_terminated
289    }
290}
291
292impl fidl::endpoints::RequestStream for DeviceRequestStream {
293    type Protocol = DeviceMarker;
294    type ControlHandle = DeviceControlHandle;
295
296    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
297        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
298    }
299
300    fn control_handle(&self) -> Self::ControlHandle {
301        DeviceControlHandle { inner: self.inner.clone() }
302    }
303
304    fn into_inner(
305        self,
306    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
307    {
308        (self.inner, self.is_terminated)
309    }
310
311    fn from_inner(
312        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
313        is_terminated: bool,
314    ) -> Self {
315        Self { inner, is_terminated }
316    }
317}
318
319impl futures::Stream for DeviceRequestStream {
320    type Item = Result<DeviceRequest, fidl::Error>;
321
322    fn poll_next(
323        mut self: std::pin::Pin<&mut Self>,
324        cx: &mut std::task::Context<'_>,
325    ) -> std::task::Poll<Option<Self::Item>> {
326        let this = &mut *self;
327        if this.inner.check_shutdown(cx) {
328            this.is_terminated = true;
329            return std::task::Poll::Ready(None);
330        }
331        if this.is_terminated {
332            panic!("polled DeviceRequestStream after completion");
333        }
334        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
335            |bytes, handles| {
336                match this.inner.channel().read_etc(cx, bytes, handles) {
337                    std::task::Poll::Ready(Ok(())) => {}
338                    std::task::Poll::Pending => return std::task::Poll::Pending,
339                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
340                        this.is_terminated = true;
341                        return std::task::Poll::Ready(None);
342                    }
343                    std::task::Poll::Ready(Err(e)) => {
344                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
345                            e.into(),
346                        ))));
347                    }
348                }
349
350                // A message has been received from the channel
351                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
352
353                std::task::Poll::Ready(Some(match header.ordinal {
354                    0x755e08b84736133c => {
355                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
356                        let mut req = fidl::new_empty!(
357                            fidl::encoding::EmptyPayload,
358                            fidl::encoding::DefaultFuchsiaResourceDialect
359                        );
360                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
361                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
362                        Ok(DeviceRequest::GetTemperatureCelsius {
363                            responder: DeviceGetTemperatureCelsiusResponder {
364                                control_handle: std::mem::ManuallyDrop::new(control_handle),
365                                tx_id: header.tx_id,
366                            },
367                        })
368                    }
369                    0x4cbd7abaeafc02c1 => {
370                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
371                        let mut req = fidl::new_empty!(
372                            fidl::encoding::EmptyPayload,
373                            fidl::encoding::DefaultFuchsiaResourceDialect
374                        );
375                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
376                        let control_handle = DeviceControlHandle { inner: this.inner.clone() };
377                        Ok(DeviceRequest::GetSensorName {
378                            responder: DeviceGetSensorNameResponder {
379                                control_handle: std::mem::ManuallyDrop::new(control_handle),
380                                tx_id: header.tx_id,
381                            },
382                        })
383                    }
384                    _ => Err(fidl::Error::UnknownOrdinal {
385                        ordinal: header.ordinal,
386                        protocol_name:
387                            <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
388                    }),
389                }))
390            },
391        )
392    }
393}
394
395#[derive(Debug)]
396pub enum DeviceRequest {
397    /// Get the current temperature in degrees Celsius.
398    GetTemperatureCelsius {
399        responder: DeviceGetTemperatureCelsiusResponder,
400    },
401    GetSensorName {
402        responder: DeviceGetSensorNameResponder,
403    },
404}
405
406impl DeviceRequest {
407    #[allow(irrefutable_let_patterns)]
408    pub fn into_get_temperature_celsius(self) -> Option<(DeviceGetTemperatureCelsiusResponder)> {
409        if let DeviceRequest::GetTemperatureCelsius { responder } = self {
410            Some((responder))
411        } else {
412            None
413        }
414    }
415
416    #[allow(irrefutable_let_patterns)]
417    pub fn into_get_sensor_name(self) -> Option<(DeviceGetSensorNameResponder)> {
418        if let DeviceRequest::GetSensorName { responder } = self { Some((responder)) } else { None }
419    }
420
421    /// Name of the method defined in FIDL
422    pub fn method_name(&self) -> &'static str {
423        match *self {
424            DeviceRequest::GetTemperatureCelsius { .. } => "get_temperature_celsius",
425            DeviceRequest::GetSensorName { .. } => "get_sensor_name",
426        }
427    }
428}
429
430#[derive(Debug, Clone)]
431pub struct DeviceControlHandle {
432    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
433}
434
435impl fidl::endpoints::ControlHandle for DeviceControlHandle {
436    fn shutdown(&self) {
437        self.inner.shutdown()
438    }
439
440    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
441        self.inner.shutdown_with_epitaph(status)
442    }
443
444    fn is_closed(&self) -> bool {
445        self.inner.channel().is_closed()
446    }
447    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
448        self.inner.channel().on_closed()
449    }
450
451    #[cfg(target_os = "fuchsia")]
452    fn signal_peer(
453        &self,
454        clear_mask: zx::Signals,
455        set_mask: zx::Signals,
456    ) -> Result<(), zx_status::Status> {
457        use fidl::Peered;
458        self.inner.channel().signal_peer(clear_mask, set_mask)
459    }
460}
461
462impl DeviceControlHandle {}
463
464#[must_use = "FIDL methods require a response to be sent"]
465#[derive(Debug)]
466pub struct DeviceGetTemperatureCelsiusResponder {
467    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
468    tx_id: u32,
469}
470
471/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
472/// if the responder is dropped without sending a response, so that the client
473/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
474impl std::ops::Drop for DeviceGetTemperatureCelsiusResponder {
475    fn drop(&mut self) {
476        self.control_handle.shutdown();
477        // Safety: drops once, never accessed again
478        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
479    }
480}
481
482impl fidl::endpoints::Responder for DeviceGetTemperatureCelsiusResponder {
483    type ControlHandle = DeviceControlHandle;
484
485    fn control_handle(&self) -> &DeviceControlHandle {
486        &self.control_handle
487    }
488
489    fn drop_without_shutdown(mut self) {
490        // Safety: drops once, never accessed again due to mem::forget
491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
492        // Prevent Drop from running (which would shut down the channel)
493        std::mem::forget(self);
494    }
495}
496
497impl DeviceGetTemperatureCelsiusResponder {
498    /// Sends a response to the FIDL transaction.
499    ///
500    /// Sets the channel to shutdown if an error occurs.
501    pub fn send(self, mut status: i32, mut temp: f32) -> Result<(), fidl::Error> {
502        let _result = self.send_raw(status, temp);
503        if _result.is_err() {
504            self.control_handle.shutdown();
505        }
506        self.drop_without_shutdown();
507        _result
508    }
509
510    /// Similar to "send" but does not shutdown the channel if an error occurs.
511    pub fn send_no_shutdown_on_err(
512        self,
513        mut status: i32,
514        mut temp: f32,
515    ) -> Result<(), fidl::Error> {
516        let _result = self.send_raw(status, temp);
517        self.drop_without_shutdown();
518        _result
519    }
520
521    fn send_raw(&self, mut status: i32, mut temp: f32) -> Result<(), fidl::Error> {
522        self.control_handle.inner.send::<DeviceGetTemperatureCelsiusResponse>(
523            (status, temp),
524            self.tx_id,
525            0x755e08b84736133c,
526            fidl::encoding::DynamicFlags::empty(),
527        )
528    }
529}
530
531#[must_use = "FIDL methods require a response to be sent"]
532#[derive(Debug)]
533pub struct DeviceGetSensorNameResponder {
534    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
535    tx_id: u32,
536}
537
538/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
539/// if the responder is dropped without sending a response, so that the client
540/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
541impl std::ops::Drop for DeviceGetSensorNameResponder {
542    fn drop(&mut self) {
543        self.control_handle.shutdown();
544        // Safety: drops once, never accessed again
545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
546    }
547}
548
549impl fidl::endpoints::Responder for DeviceGetSensorNameResponder {
550    type ControlHandle = DeviceControlHandle;
551
552    fn control_handle(&self) -> &DeviceControlHandle {
553        &self.control_handle
554    }
555
556    fn drop_without_shutdown(mut self) {
557        // Safety: drops once, never accessed again due to mem::forget
558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
559        // Prevent Drop from running (which would shut down the channel)
560        std::mem::forget(self);
561    }
562}
563
564impl DeviceGetSensorNameResponder {
565    /// Sends a response to the FIDL transaction.
566    ///
567    /// Sets the channel to shutdown if an error occurs.
568    pub fn send(self, mut name: &str) -> Result<(), fidl::Error> {
569        let _result = self.send_raw(name);
570        if _result.is_err() {
571            self.control_handle.shutdown();
572        }
573        self.drop_without_shutdown();
574        _result
575    }
576
577    /// Similar to "send" but does not shutdown the channel if an error occurs.
578    pub fn send_no_shutdown_on_err(self, mut name: &str) -> Result<(), fidl::Error> {
579        let _result = self.send_raw(name);
580        self.drop_without_shutdown();
581        _result
582    }
583
584    fn send_raw(&self, mut name: &str) -> Result<(), fidl::Error> {
585        self.control_handle.inner.send::<DeviceGetSensorNameResponse>(
586            (name,),
587            self.tx_id,
588            0x4cbd7abaeafc02c1,
589            fidl::encoding::DynamicFlags::empty(),
590        )
591    }
592}
593
594#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
595pub struct ServiceMarker;
596
597#[cfg(target_os = "fuchsia")]
598impl fidl::endpoints::ServiceMarker for ServiceMarker {
599    type Proxy = ServiceProxy;
600    type Request = ServiceRequest;
601    const SERVICE_NAME: &'static str = "fuchsia.hardware.temperature.Service";
602}
603
604/// A request for one of the member protocols of Service.
605///
606#[cfg(target_os = "fuchsia")]
607pub enum ServiceRequest {
608    Device(DeviceRequestStream),
609    Trippoint(fidl_fuchsia_hardware_trippoint::TripPointRequestStream),
610}
611
612#[cfg(target_os = "fuchsia")]
613impl fidl::endpoints::ServiceRequest for ServiceRequest {
614    type Service = ServiceMarker;
615
616    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
617        match name {
618            "device" => Self::Device(
619                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
620            ),
621            "trippoint" => Self::Trippoint(
622                <fidl_fuchsia_hardware_trippoint::TripPointRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
623            ),
624            _ => panic!("no such member protocol name for service Service"),
625        }
626    }
627
628    fn member_names() -> &'static [&'static str] {
629        &["device", "trippoint"]
630    }
631}
632#[cfg(target_os = "fuchsia")]
633pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
634
635#[cfg(target_os = "fuchsia")]
636impl fidl::endpoints::ServiceProxy for ServiceProxy {
637    type Service = ServiceMarker;
638
639    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
640        Self(opener)
641    }
642}
643
644#[cfg(target_os = "fuchsia")]
645impl ServiceProxy {
646    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
647        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
648        self.connect_channel_to_device(server_end)?;
649        Ok(proxy)
650    }
651
652    /// Like `connect_to_device`, but returns a sync proxy.
653    /// See [`Self::connect_to_device`] for more details.
654    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
655        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
656        self.connect_channel_to_device(server_end)?;
657        Ok(proxy)
658    }
659
660    /// Like `connect_to_device`, but accepts a server end.
661    /// See [`Self::connect_to_device`] for more details.
662    pub fn connect_channel_to_device(
663        &self,
664        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
665    ) -> Result<(), fidl::Error> {
666        self.0.open_member("device", server_end.into_channel())
667    }
668    pub fn connect_to_trippoint(
669        &self,
670    ) -> Result<fidl_fuchsia_hardware_trippoint::TripPointProxy, fidl::Error> {
671        let (proxy, server_end) =
672            fidl::endpoints::create_proxy::<fidl_fuchsia_hardware_trippoint::TripPointMarker>();
673        self.connect_channel_to_trippoint(server_end)?;
674        Ok(proxy)
675    }
676
677    /// Like `connect_to_trippoint`, but returns a sync proxy.
678    /// See [`Self::connect_to_trippoint`] for more details.
679    pub fn connect_to_trippoint_sync(
680        &self,
681    ) -> Result<fidl_fuchsia_hardware_trippoint::TripPointSynchronousProxy, fidl::Error> {
682        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<
683            fidl_fuchsia_hardware_trippoint::TripPointMarker,
684        >();
685        self.connect_channel_to_trippoint(server_end)?;
686        Ok(proxy)
687    }
688
689    /// Like `connect_to_trippoint`, but accepts a server end.
690    /// See [`Self::connect_to_trippoint`] for more details.
691    pub fn connect_channel_to_trippoint(
692        &self,
693        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_trippoint::TripPointMarker>,
694    ) -> Result<(), fidl::Error> {
695        self.0.open_member("trippoint", server_end.into_channel())
696    }
697
698    pub fn instance_name(&self) -> &str {
699        self.0.instance_name()
700    }
701}
702
703mod internal {
704    use super::*;
705}