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::Handle {
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    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
438        self.inner.shutdown_with_epitaph(status)
439    }
440
441    fn is_closed(&self) -> bool {
442        self.inner.channel().is_closed()
443    }
444    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
445        self.inner.channel().on_closed()
446    }
447
448    #[cfg(target_os = "fuchsia")]
449    fn signal_peer(
450        &self,
451        clear_mask: zx::Signals,
452        set_mask: zx::Signals,
453    ) -> Result<(), zx_status::Status> {
454        use fidl::Peered;
455        self.inner.channel().signal_peer(clear_mask, set_mask)
456    }
457}
458
459impl DeviceControlHandle {}
460
461#[must_use = "FIDL methods require a response to be sent"]
462#[derive(Debug)]
463pub struct DeviceGetTemperatureCelsiusResponder {
464    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
465    tx_id: u32,
466}
467
468/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
469/// if the responder is dropped without sending a response, so that the client
470/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
471impl std::ops::Drop for DeviceGetTemperatureCelsiusResponder {
472    fn drop(&mut self) {
473        self.control_handle.shutdown();
474        // Safety: drops once, never accessed again
475        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
476    }
477}
478
479impl fidl::endpoints::Responder for DeviceGetTemperatureCelsiusResponder {
480    type ControlHandle = DeviceControlHandle;
481
482    fn control_handle(&self) -> &DeviceControlHandle {
483        &self.control_handle
484    }
485
486    fn drop_without_shutdown(mut self) {
487        // Safety: drops once, never accessed again due to mem::forget
488        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
489        // Prevent Drop from running (which would shut down the channel)
490        std::mem::forget(self);
491    }
492}
493
494impl DeviceGetTemperatureCelsiusResponder {
495    /// Sends a response to the FIDL transaction.
496    ///
497    /// Sets the channel to shutdown if an error occurs.
498    pub fn send(self, mut status: i32, mut temp: f32) -> Result<(), fidl::Error> {
499        let _result = self.send_raw(status, temp);
500        if _result.is_err() {
501            self.control_handle.shutdown();
502        }
503        self.drop_without_shutdown();
504        _result
505    }
506
507    /// Similar to "send" but does not shutdown the channel if an error occurs.
508    pub fn send_no_shutdown_on_err(
509        self,
510        mut status: i32,
511        mut temp: f32,
512    ) -> Result<(), fidl::Error> {
513        let _result = self.send_raw(status, temp);
514        self.drop_without_shutdown();
515        _result
516    }
517
518    fn send_raw(&self, mut status: i32, mut temp: f32) -> Result<(), fidl::Error> {
519        self.control_handle.inner.send::<DeviceGetTemperatureCelsiusResponse>(
520            (status, temp),
521            self.tx_id,
522            0x755e08b84736133c,
523            fidl::encoding::DynamicFlags::empty(),
524        )
525    }
526}
527
528#[must_use = "FIDL methods require a response to be sent"]
529#[derive(Debug)]
530pub struct DeviceGetSensorNameResponder {
531    control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
532    tx_id: u32,
533}
534
535/// Set the the channel to be shutdown (see [`DeviceControlHandle::shutdown`])
536/// if the responder is dropped without sending a response, so that the client
537/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
538impl std::ops::Drop for DeviceGetSensorNameResponder {
539    fn drop(&mut self) {
540        self.control_handle.shutdown();
541        // Safety: drops once, never accessed again
542        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
543    }
544}
545
546impl fidl::endpoints::Responder for DeviceGetSensorNameResponder {
547    type ControlHandle = DeviceControlHandle;
548
549    fn control_handle(&self) -> &DeviceControlHandle {
550        &self.control_handle
551    }
552
553    fn drop_without_shutdown(mut self) {
554        // Safety: drops once, never accessed again due to mem::forget
555        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
556        // Prevent Drop from running (which would shut down the channel)
557        std::mem::forget(self);
558    }
559}
560
561impl DeviceGetSensorNameResponder {
562    /// Sends a response to the FIDL transaction.
563    ///
564    /// Sets the channel to shutdown if an error occurs.
565    pub fn send(self, mut name: &str) -> Result<(), fidl::Error> {
566        let _result = self.send_raw(name);
567        if _result.is_err() {
568            self.control_handle.shutdown();
569        }
570        self.drop_without_shutdown();
571        _result
572    }
573
574    /// Similar to "send" but does not shutdown the channel if an error occurs.
575    pub fn send_no_shutdown_on_err(self, mut name: &str) -> Result<(), fidl::Error> {
576        let _result = self.send_raw(name);
577        self.drop_without_shutdown();
578        _result
579    }
580
581    fn send_raw(&self, mut name: &str) -> Result<(), fidl::Error> {
582        self.control_handle.inner.send::<DeviceGetSensorNameResponse>(
583            (name,),
584            self.tx_id,
585            0x4cbd7abaeafc02c1,
586            fidl::encoding::DynamicFlags::empty(),
587        )
588    }
589}
590
591#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
592pub struct ServiceMarker;
593
594#[cfg(target_os = "fuchsia")]
595impl fidl::endpoints::ServiceMarker for ServiceMarker {
596    type Proxy = ServiceProxy;
597    type Request = ServiceRequest;
598    const SERVICE_NAME: &'static str = "fuchsia.hardware.temperature.Service";
599}
600
601/// A request for one of the member protocols of Service.
602///
603#[cfg(target_os = "fuchsia")]
604pub enum ServiceRequest {
605    Device(DeviceRequestStream),
606}
607
608#[cfg(target_os = "fuchsia")]
609impl fidl::endpoints::ServiceRequest for ServiceRequest {
610    type Service = ServiceMarker;
611
612    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
613        match name {
614            "device" => Self::Device(
615                <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
616            ),
617            _ => panic!("no such member protocol name for service Service"),
618        }
619    }
620
621    fn member_names() -> &'static [&'static str] {
622        &["device"]
623    }
624}
625#[cfg(target_os = "fuchsia")]
626pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
627
628#[cfg(target_os = "fuchsia")]
629impl fidl::endpoints::ServiceProxy for ServiceProxy {
630    type Service = ServiceMarker;
631
632    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
633        Self(opener)
634    }
635}
636
637#[cfg(target_os = "fuchsia")]
638impl ServiceProxy {
639    pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
640        let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
641        self.connect_channel_to_device(server_end)?;
642        Ok(proxy)
643    }
644
645    /// Like `connect_to_device`, but returns a sync proxy.
646    /// See [`Self::connect_to_device`] for more details.
647    pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
648        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
649        self.connect_channel_to_device(server_end)?;
650        Ok(proxy)
651    }
652
653    /// Like `connect_to_device`, but accepts a server end.
654    /// See [`Self::connect_to_device`] for more details.
655    pub fn connect_channel_to_device(
656        &self,
657        server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
658    ) -> Result<(), fidl::Error> {
659        self.0.open_member("device", server_end.into_channel())
660    }
661
662    pub fn instance_name(&self) -> &str {
663        self.0.instance_name()
664    }
665}
666
667mod internal {
668    use super::*;
669}