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