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