Skip to main content

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