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