1#![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_basicdriver_ctftest_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 PingResponseFut: std::future::Future<Output = Result<u32, fidl::Error>> + Send;
28 fn r#ping(&self) -> Self::PingResponseFut;
29}
30#[derive(Debug)]
31#[cfg(target_os = "fuchsia")]
32pub struct DeviceSynchronousProxy {
33 client: fidl::client::sync::Client,
34}
35
36#[cfg(target_os = "fuchsia")]
37impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
38 type Proxy = DeviceProxy;
39 type Protocol = DeviceMarker;
40
41 fn from_channel(inner: fidl::Channel) -> Self {
42 Self::new(inner)
43 }
44
45 fn into_channel(self) -> fidl::Channel {
46 self.client.into_channel()
47 }
48
49 fn as_channel(&self) -> &fidl::Channel {
50 self.client.as_channel()
51 }
52}
53
54#[cfg(target_os = "fuchsia")]
55impl DeviceSynchronousProxy {
56 pub fn new(channel: fidl::Channel) -> Self {
57 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
58 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
59 }
60
61 pub fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 pub fn wait_for_event(
68 &self,
69 deadline: zx::MonotonicInstant,
70 ) -> Result<DeviceEvent, fidl::Error> {
71 DeviceEvent::decode(self.client.wait_for_event(deadline)?)
72 }
73
74 pub fn r#ping(&self, ___deadline: zx::MonotonicInstant) -> Result<u32, fidl::Error> {
75 let _response =
76 self.client.send_query::<fidl::encoding::EmptyPayload, DevicePingResponse>(
77 (),
78 0x53eb4e98ccf32729,
79 fidl::encoding::DynamicFlags::empty(),
80 ___deadline,
81 )?;
82 Ok(_response.pong)
83 }
84}
85
86#[derive(Debug, Clone)]
87pub struct DeviceProxy {
88 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
89}
90
91impl fidl::endpoints::Proxy for DeviceProxy {
92 type Protocol = DeviceMarker;
93
94 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
95 Self::new(inner)
96 }
97
98 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
99 self.client.into_channel().map_err(|client| Self { client })
100 }
101
102 fn as_channel(&self) -> &::fidl::AsyncChannel {
103 self.client.as_channel()
104 }
105}
106
107impl DeviceProxy {
108 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
110 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
111 Self { client: fidl::client::Client::new(channel, protocol_name) }
112 }
113
114 pub fn take_event_stream(&self) -> DeviceEventStream {
120 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
121 }
122
123 pub fn r#ping(
124 &self,
125 ) -> fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect> {
126 DeviceProxyInterface::r#ping(self)
127 }
128}
129
130impl DeviceProxyInterface for DeviceProxy {
131 type PingResponseFut =
132 fidl::client::QueryResponseFut<u32, fidl::encoding::DefaultFuchsiaResourceDialect>;
133 fn r#ping(&self) -> Self::PingResponseFut {
134 fn _decode(
135 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
136 ) -> Result<u32, fidl::Error> {
137 let _response = fidl::client::decode_transaction_body::<
138 DevicePingResponse,
139 fidl::encoding::DefaultFuchsiaResourceDialect,
140 0x53eb4e98ccf32729,
141 >(_buf?)?;
142 Ok(_response.pong)
143 }
144 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u32>(
145 (),
146 0x53eb4e98ccf32729,
147 fidl::encoding::DynamicFlags::empty(),
148 _decode,
149 )
150 }
151}
152
153pub struct DeviceEventStream {
154 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
155}
156
157impl std::marker::Unpin for DeviceEventStream {}
158
159impl futures::stream::FusedStream for DeviceEventStream {
160 fn is_terminated(&self) -> bool {
161 self.event_receiver.is_terminated()
162 }
163}
164
165impl futures::Stream for DeviceEventStream {
166 type Item = Result<DeviceEvent, fidl::Error>;
167
168 fn poll_next(
169 mut self: std::pin::Pin<&mut Self>,
170 cx: &mut std::task::Context<'_>,
171 ) -> std::task::Poll<Option<Self::Item>> {
172 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
173 &mut self.event_receiver,
174 cx
175 )?) {
176 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
177 None => std::task::Poll::Ready(None),
178 }
179 }
180}
181
182#[derive(Debug)]
183pub enum DeviceEvent {}
184
185impl DeviceEvent {
186 fn decode(
188 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
189 ) -> Result<DeviceEvent, fidl::Error> {
190 let (bytes, _handles) = buf.split_mut();
191 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
192 debug_assert_eq!(tx_header.tx_id, 0);
193 match tx_header.ordinal {
194 _ => Err(fidl::Error::UnknownOrdinal {
195 ordinal: tx_header.ordinal,
196 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
197 }),
198 }
199 }
200}
201
202pub struct DeviceRequestStream {
204 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
205 is_terminated: bool,
206}
207
208impl std::marker::Unpin for DeviceRequestStream {}
209
210impl futures::stream::FusedStream for DeviceRequestStream {
211 fn is_terminated(&self) -> bool {
212 self.is_terminated
213 }
214}
215
216impl fidl::endpoints::RequestStream for DeviceRequestStream {
217 type Protocol = DeviceMarker;
218 type ControlHandle = DeviceControlHandle;
219
220 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
221 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
222 }
223
224 fn control_handle(&self) -> Self::ControlHandle {
225 DeviceControlHandle { inner: self.inner.clone() }
226 }
227
228 fn into_inner(
229 self,
230 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
231 {
232 (self.inner, self.is_terminated)
233 }
234
235 fn from_inner(
236 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
237 is_terminated: bool,
238 ) -> Self {
239 Self { inner, is_terminated }
240 }
241}
242
243impl futures::Stream for DeviceRequestStream {
244 type Item = Result<DeviceRequest, 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 let this = &mut *self;
251 if this.inner.check_shutdown(cx) {
252 this.is_terminated = true;
253 return std::task::Poll::Ready(None);
254 }
255 if this.is_terminated {
256 panic!("polled DeviceRequestStream after completion");
257 }
258 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
259 |bytes, handles| {
260 match this.inner.channel().read_etc(cx, bytes, handles) {
261 std::task::Poll::Ready(Ok(())) => {}
262 std::task::Poll::Pending => return std::task::Poll::Pending,
263 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
264 this.is_terminated = true;
265 return std::task::Poll::Ready(None);
266 }
267 std::task::Poll::Ready(Err(e)) => {
268 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
269 e.into(),
270 ))))
271 }
272 }
273
274 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
276
277 std::task::Poll::Ready(Some(match header.ordinal {
278 0x53eb4e98ccf32729 => {
279 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
280 let mut req = fidl::new_empty!(
281 fidl::encoding::EmptyPayload,
282 fidl::encoding::DefaultFuchsiaResourceDialect
283 );
284 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
285 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
286 Ok(DeviceRequest::Ping {
287 responder: DevicePingResponder {
288 control_handle: std::mem::ManuallyDrop::new(control_handle),
289 tx_id: header.tx_id,
290 },
291 })
292 }
293 _ => Err(fidl::Error::UnknownOrdinal {
294 ordinal: header.ordinal,
295 protocol_name:
296 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
297 }),
298 }))
299 },
300 )
301 }
302}
303
304#[derive(Debug)]
305pub enum DeviceRequest {
306 Ping { responder: DevicePingResponder },
307}
308
309impl DeviceRequest {
310 #[allow(irrefutable_let_patterns)]
311 pub fn into_ping(self) -> Option<(DevicePingResponder)> {
312 if let DeviceRequest::Ping { responder } = self {
313 Some((responder))
314 } else {
315 None
316 }
317 }
318
319 pub fn method_name(&self) -> &'static str {
321 match *self {
322 DeviceRequest::Ping { .. } => "ping",
323 }
324 }
325}
326
327#[derive(Debug, Clone)]
328pub struct DeviceControlHandle {
329 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
330}
331
332impl fidl::endpoints::ControlHandle for DeviceControlHandle {
333 fn shutdown(&self) {
334 self.inner.shutdown()
335 }
336 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
337 self.inner.shutdown_with_epitaph(status)
338 }
339
340 fn is_closed(&self) -> bool {
341 self.inner.channel().is_closed()
342 }
343 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
344 self.inner.channel().on_closed()
345 }
346
347 #[cfg(target_os = "fuchsia")]
348 fn signal_peer(
349 &self,
350 clear_mask: zx::Signals,
351 set_mask: zx::Signals,
352 ) -> Result<(), zx_status::Status> {
353 use fidl::Peered;
354 self.inner.channel().signal_peer(clear_mask, set_mask)
355 }
356}
357
358impl DeviceControlHandle {}
359
360#[must_use = "FIDL methods require a response to be sent"]
361#[derive(Debug)]
362pub struct DevicePingResponder {
363 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
364 tx_id: u32,
365}
366
367impl std::ops::Drop for DevicePingResponder {
371 fn drop(&mut self) {
372 self.control_handle.shutdown();
373 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
375 }
376}
377
378impl fidl::endpoints::Responder for DevicePingResponder {
379 type ControlHandle = DeviceControlHandle;
380
381 fn control_handle(&self) -> &DeviceControlHandle {
382 &self.control_handle
383 }
384
385 fn drop_without_shutdown(mut self) {
386 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
388 std::mem::forget(self);
390 }
391}
392
393impl DevicePingResponder {
394 pub fn send(self, mut pong: u32) -> Result<(), fidl::Error> {
398 let _result = self.send_raw(pong);
399 if _result.is_err() {
400 self.control_handle.shutdown();
401 }
402 self.drop_without_shutdown();
403 _result
404 }
405
406 pub fn send_no_shutdown_on_err(self, mut pong: u32) -> Result<(), fidl::Error> {
408 let _result = self.send_raw(pong);
409 self.drop_without_shutdown();
410 _result
411 }
412
413 fn send_raw(&self, mut pong: u32) -> Result<(), fidl::Error> {
414 self.control_handle.inner.send::<DevicePingResponse>(
415 (pong,),
416 self.tx_id,
417 0x53eb4e98ccf32729,
418 fidl::encoding::DynamicFlags::empty(),
419 )
420 }
421}
422
423#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
424pub struct WaiterMarker;
425
426impl fidl::endpoints::ProtocolMarker for WaiterMarker {
427 type Proxy = WaiterProxy;
428 type RequestStream = WaiterRequestStream;
429 #[cfg(target_os = "fuchsia")]
430 type SynchronousProxy = WaiterSynchronousProxy;
431
432 const DEBUG_NAME: &'static str = "fuchsia.basicdriver.ctftest.Waiter";
433}
434impl fidl::endpoints::DiscoverableProtocolMarker for WaiterMarker {}
435
436pub trait WaiterProxyInterface: Send + Sync {
437 fn r#ack(&self) -> Result<(), fidl::Error>;
438}
439#[derive(Debug)]
440#[cfg(target_os = "fuchsia")]
441pub struct WaiterSynchronousProxy {
442 client: fidl::client::sync::Client,
443}
444
445#[cfg(target_os = "fuchsia")]
446impl fidl::endpoints::SynchronousProxy for WaiterSynchronousProxy {
447 type Proxy = WaiterProxy;
448 type Protocol = WaiterMarker;
449
450 fn from_channel(inner: fidl::Channel) -> Self {
451 Self::new(inner)
452 }
453
454 fn into_channel(self) -> fidl::Channel {
455 self.client.into_channel()
456 }
457
458 fn as_channel(&self) -> &fidl::Channel {
459 self.client.as_channel()
460 }
461}
462
463#[cfg(target_os = "fuchsia")]
464impl WaiterSynchronousProxy {
465 pub fn new(channel: fidl::Channel) -> Self {
466 let protocol_name = <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
467 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
468 }
469
470 pub fn into_channel(self) -> fidl::Channel {
471 self.client.into_channel()
472 }
473
474 pub fn wait_for_event(
477 &self,
478 deadline: zx::MonotonicInstant,
479 ) -> Result<WaiterEvent, fidl::Error> {
480 WaiterEvent::decode(self.client.wait_for_event(deadline)?)
481 }
482
483 pub fn r#ack(&self) -> Result<(), fidl::Error> {
484 self.client.send::<fidl::encoding::EmptyPayload>(
485 (),
486 0x70e5c3f344540efa,
487 fidl::encoding::DynamicFlags::empty(),
488 )
489 }
490}
491
492#[derive(Debug, Clone)]
493pub struct WaiterProxy {
494 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
495}
496
497impl fidl::endpoints::Proxy for WaiterProxy {
498 type Protocol = WaiterMarker;
499
500 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
501 Self::new(inner)
502 }
503
504 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
505 self.client.into_channel().map_err(|client| Self { client })
506 }
507
508 fn as_channel(&self) -> &::fidl::AsyncChannel {
509 self.client.as_channel()
510 }
511}
512
513impl WaiterProxy {
514 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
516 let protocol_name = <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
517 Self { client: fidl::client::Client::new(channel, protocol_name) }
518 }
519
520 pub fn take_event_stream(&self) -> WaiterEventStream {
526 WaiterEventStream { event_receiver: self.client.take_event_receiver() }
527 }
528
529 pub fn r#ack(&self) -> Result<(), fidl::Error> {
530 WaiterProxyInterface::r#ack(self)
531 }
532}
533
534impl WaiterProxyInterface for WaiterProxy {
535 fn r#ack(&self) -> Result<(), fidl::Error> {
536 self.client.send::<fidl::encoding::EmptyPayload>(
537 (),
538 0x70e5c3f344540efa,
539 fidl::encoding::DynamicFlags::empty(),
540 )
541 }
542}
543
544pub struct WaiterEventStream {
545 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
546}
547
548impl std::marker::Unpin for WaiterEventStream {}
549
550impl futures::stream::FusedStream for WaiterEventStream {
551 fn is_terminated(&self) -> bool {
552 self.event_receiver.is_terminated()
553 }
554}
555
556impl futures::Stream for WaiterEventStream {
557 type Item = Result<WaiterEvent, fidl::Error>;
558
559 fn poll_next(
560 mut self: std::pin::Pin<&mut Self>,
561 cx: &mut std::task::Context<'_>,
562 ) -> std::task::Poll<Option<Self::Item>> {
563 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
564 &mut self.event_receiver,
565 cx
566 )?) {
567 Some(buf) => std::task::Poll::Ready(Some(WaiterEvent::decode(buf))),
568 None => std::task::Poll::Ready(None),
569 }
570 }
571}
572
573#[derive(Debug)]
574pub enum WaiterEvent {}
575
576impl WaiterEvent {
577 fn decode(
579 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
580 ) -> Result<WaiterEvent, fidl::Error> {
581 let (bytes, _handles) = buf.split_mut();
582 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
583 debug_assert_eq!(tx_header.tx_id, 0);
584 match tx_header.ordinal {
585 _ => Err(fidl::Error::UnknownOrdinal {
586 ordinal: tx_header.ordinal,
587 protocol_name: <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
588 }),
589 }
590 }
591}
592
593pub struct WaiterRequestStream {
595 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
596 is_terminated: bool,
597}
598
599impl std::marker::Unpin for WaiterRequestStream {}
600
601impl futures::stream::FusedStream for WaiterRequestStream {
602 fn is_terminated(&self) -> bool {
603 self.is_terminated
604 }
605}
606
607impl fidl::endpoints::RequestStream for WaiterRequestStream {
608 type Protocol = WaiterMarker;
609 type ControlHandle = WaiterControlHandle;
610
611 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
612 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
613 }
614
615 fn control_handle(&self) -> Self::ControlHandle {
616 WaiterControlHandle { inner: self.inner.clone() }
617 }
618
619 fn into_inner(
620 self,
621 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
622 {
623 (self.inner, self.is_terminated)
624 }
625
626 fn from_inner(
627 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
628 is_terminated: bool,
629 ) -> Self {
630 Self { inner, is_terminated }
631 }
632}
633
634impl futures::Stream for WaiterRequestStream {
635 type Item = Result<WaiterRequest, fidl::Error>;
636
637 fn poll_next(
638 mut self: std::pin::Pin<&mut Self>,
639 cx: &mut std::task::Context<'_>,
640 ) -> std::task::Poll<Option<Self::Item>> {
641 let this = &mut *self;
642 if this.inner.check_shutdown(cx) {
643 this.is_terminated = true;
644 return std::task::Poll::Ready(None);
645 }
646 if this.is_terminated {
647 panic!("polled WaiterRequestStream after completion");
648 }
649 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
650 |bytes, handles| {
651 match this.inner.channel().read_etc(cx, bytes, handles) {
652 std::task::Poll::Ready(Ok(())) => {}
653 std::task::Poll::Pending => return std::task::Poll::Pending,
654 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
655 this.is_terminated = true;
656 return std::task::Poll::Ready(None);
657 }
658 std::task::Poll::Ready(Err(e)) => {
659 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
660 e.into(),
661 ))))
662 }
663 }
664
665 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
667
668 std::task::Poll::Ready(Some(match header.ordinal {
669 0x70e5c3f344540efa => {
670 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
671 let mut req = fidl::new_empty!(
672 fidl::encoding::EmptyPayload,
673 fidl::encoding::DefaultFuchsiaResourceDialect
674 );
675 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
676 let control_handle = WaiterControlHandle { inner: this.inner.clone() };
677 Ok(WaiterRequest::Ack { control_handle })
678 }
679 _ => Err(fidl::Error::UnknownOrdinal {
680 ordinal: header.ordinal,
681 protocol_name:
682 <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
683 }),
684 }))
685 },
686 )
687 }
688}
689
690#[derive(Debug)]
691pub enum WaiterRequest {
692 Ack { control_handle: WaiterControlHandle },
693}
694
695impl WaiterRequest {
696 #[allow(irrefutable_let_patterns)]
697 pub fn into_ack(self) -> Option<(WaiterControlHandle)> {
698 if let WaiterRequest::Ack { control_handle } = self {
699 Some((control_handle))
700 } else {
701 None
702 }
703 }
704
705 pub fn method_name(&self) -> &'static str {
707 match *self {
708 WaiterRequest::Ack { .. } => "ack",
709 }
710 }
711}
712
713#[derive(Debug, Clone)]
714pub struct WaiterControlHandle {
715 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
716}
717
718impl fidl::endpoints::ControlHandle for WaiterControlHandle {
719 fn shutdown(&self) {
720 self.inner.shutdown()
721 }
722 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
723 self.inner.shutdown_with_epitaph(status)
724 }
725
726 fn is_closed(&self) -> bool {
727 self.inner.channel().is_closed()
728 }
729 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
730 self.inner.channel().on_closed()
731 }
732
733 #[cfg(target_os = "fuchsia")]
734 fn signal_peer(
735 &self,
736 clear_mask: zx::Signals,
737 set_mask: zx::Signals,
738 ) -> Result<(), zx_status::Status> {
739 use fidl::Peered;
740 self.inner.channel().signal_peer(clear_mask, set_mask)
741 }
742}
743
744impl WaiterControlHandle {}
745
746#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
747pub struct ServiceMarker;
748
749#[cfg(target_os = "fuchsia")]
750impl fidl::endpoints::ServiceMarker for ServiceMarker {
751 type Proxy = ServiceProxy;
752 type Request = ServiceRequest;
753 const SERVICE_NAME: &'static str = "fuchsia.basicdriver.ctftest.Service";
754}
755
756#[cfg(target_os = "fuchsia")]
759pub enum ServiceRequest {
760 Device(DeviceRequestStream),
761}
762
763#[cfg(target_os = "fuchsia")]
764impl fidl::endpoints::ServiceRequest for ServiceRequest {
765 type Service = ServiceMarker;
766
767 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
768 match name {
769 "device" => Self::Device(
770 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
771 ),
772 _ => panic!("no such member protocol name for service Service"),
773 }
774 }
775
776 fn member_names() -> &'static [&'static str] {
777 &["device"]
778 }
779}
780#[cfg(target_os = "fuchsia")]
781pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
782
783#[cfg(target_os = "fuchsia")]
784impl fidl::endpoints::ServiceProxy for ServiceProxy {
785 type Service = ServiceMarker;
786
787 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
788 Self(opener)
789 }
790}
791
792#[cfg(target_os = "fuchsia")]
793impl ServiceProxy {
794 pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
795 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
796 self.connect_channel_to_device(server_end)?;
797 Ok(proxy)
798 }
799
800 pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
803 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
804 self.connect_channel_to_device(server_end)?;
805 Ok(proxy)
806 }
807
808 pub fn connect_channel_to_device(
811 &self,
812 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
813 ) -> Result<(), fidl::Error> {
814 self.0.open_member("device", server_end.into_channel())
815 }
816
817 pub fn instance_name(&self) -> &str {
818 self.0.instance_name()
819 }
820}
821
822mod internal {
823 use super::*;
824}