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_component_client_test__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct EmptyProtocolMarker;
16
17impl fidl::endpoints::ProtocolMarker for EmptyProtocolMarker {
18 type Proxy = EmptyProtocolProxy;
19 type RequestStream = EmptyProtocolRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = EmptyProtocolSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.component.client.test.EmptyProtocol";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for EmptyProtocolMarker {}
26
27pub trait EmptyProtocolProxyInterface: Send + Sync {}
28#[derive(Debug)]
29#[cfg(target_os = "fuchsia")]
30pub struct EmptyProtocolSynchronousProxy {
31 client: fidl::client::sync::Client,
32}
33
34#[cfg(target_os = "fuchsia")]
35impl fidl::endpoints::SynchronousProxy for EmptyProtocolSynchronousProxy {
36 type Proxy = EmptyProtocolProxy;
37 type Protocol = EmptyProtocolMarker;
38
39 fn from_channel(inner: fidl::Channel) -> Self {
40 Self::new(inner)
41 }
42
43 fn into_channel(self) -> fidl::Channel {
44 self.client.into_channel()
45 }
46
47 fn as_channel(&self) -> &fidl::Channel {
48 self.client.as_channel()
49 }
50}
51
52#[cfg(target_os = "fuchsia")]
53impl EmptyProtocolSynchronousProxy {
54 pub fn new(channel: fidl::Channel) -> Self {
55 let protocol_name = <EmptyProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
56 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
57 }
58
59 pub fn into_channel(self) -> fidl::Channel {
60 self.client.into_channel()
61 }
62
63 pub fn wait_for_event(
66 &self,
67 deadline: zx::MonotonicInstant,
68 ) -> Result<EmptyProtocolEvent, fidl::Error> {
69 EmptyProtocolEvent::decode(self.client.wait_for_event(deadline)?)
70 }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl From<EmptyProtocolSynchronousProxy> for zx::NullableHandle {
75 fn from(value: EmptyProtocolSynchronousProxy) -> Self {
76 value.into_channel().into()
77 }
78}
79
80#[cfg(target_os = "fuchsia")]
81impl From<fidl::Channel> for EmptyProtocolSynchronousProxy {
82 fn from(value: fidl::Channel) -> Self {
83 Self::new(value)
84 }
85}
86
87#[cfg(target_os = "fuchsia")]
88impl fidl::endpoints::FromClient for EmptyProtocolSynchronousProxy {
89 type Protocol = EmptyProtocolMarker;
90
91 fn from_client(value: fidl::endpoints::ClientEnd<EmptyProtocolMarker>) -> Self {
92 Self::new(value.into_channel())
93 }
94}
95
96#[derive(Debug, Clone)]
97pub struct EmptyProtocolProxy {
98 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
99}
100
101impl fidl::endpoints::Proxy for EmptyProtocolProxy {
102 type Protocol = EmptyProtocolMarker;
103
104 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
105 Self::new(inner)
106 }
107
108 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
109 self.client.into_channel().map_err(|client| Self { client })
110 }
111
112 fn as_channel(&self) -> &::fidl::AsyncChannel {
113 self.client.as_channel()
114 }
115}
116
117impl EmptyProtocolProxy {
118 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
120 let protocol_name = <EmptyProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
121 Self { client: fidl::client::Client::new(channel, protocol_name) }
122 }
123
124 pub fn take_event_stream(&self) -> EmptyProtocolEventStream {
130 EmptyProtocolEventStream { event_receiver: self.client.take_event_receiver() }
131 }
132}
133
134impl EmptyProtocolProxyInterface for EmptyProtocolProxy {}
135
136pub struct EmptyProtocolEventStream {
137 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
138}
139
140impl std::marker::Unpin for EmptyProtocolEventStream {}
141
142impl futures::stream::FusedStream for EmptyProtocolEventStream {
143 fn is_terminated(&self) -> bool {
144 self.event_receiver.is_terminated()
145 }
146}
147
148impl futures::Stream for EmptyProtocolEventStream {
149 type Item = Result<EmptyProtocolEvent, fidl::Error>;
150
151 fn poll_next(
152 mut self: std::pin::Pin<&mut Self>,
153 cx: &mut std::task::Context<'_>,
154 ) -> std::task::Poll<Option<Self::Item>> {
155 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
156 &mut self.event_receiver,
157 cx
158 )?) {
159 Some(buf) => std::task::Poll::Ready(Some(EmptyProtocolEvent::decode(buf))),
160 None => std::task::Poll::Ready(None),
161 }
162 }
163}
164
165#[derive(Debug)]
166pub enum EmptyProtocolEvent {}
167
168impl EmptyProtocolEvent {
169 fn decode(
171 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
172 ) -> Result<EmptyProtocolEvent, fidl::Error> {
173 let (bytes, _handles) = buf.split_mut();
174 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
175 debug_assert_eq!(tx_header.tx_id, 0);
176 match tx_header.ordinal {
177 _ => Err(fidl::Error::UnknownOrdinal {
178 ordinal: tx_header.ordinal,
179 protocol_name: <EmptyProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
180 }),
181 }
182 }
183}
184
185pub struct EmptyProtocolRequestStream {
187 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
188 is_terminated: bool,
189}
190
191impl std::marker::Unpin for EmptyProtocolRequestStream {}
192
193impl futures::stream::FusedStream for EmptyProtocolRequestStream {
194 fn is_terminated(&self) -> bool {
195 self.is_terminated
196 }
197}
198
199impl fidl::endpoints::RequestStream for EmptyProtocolRequestStream {
200 type Protocol = EmptyProtocolMarker;
201 type ControlHandle = EmptyProtocolControlHandle;
202
203 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
204 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
205 }
206
207 fn control_handle(&self) -> Self::ControlHandle {
208 EmptyProtocolControlHandle { inner: self.inner.clone() }
209 }
210
211 fn into_inner(
212 self,
213 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
214 {
215 (self.inner, self.is_terminated)
216 }
217
218 fn from_inner(
219 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
220 is_terminated: bool,
221 ) -> Self {
222 Self { inner, is_terminated }
223 }
224}
225
226impl futures::Stream for EmptyProtocolRequestStream {
227 type Item = Result<EmptyProtocolRequest, fidl::Error>;
228
229 fn poll_next(
230 mut self: std::pin::Pin<&mut Self>,
231 cx: &mut std::task::Context<'_>,
232 ) -> std::task::Poll<Option<Self::Item>> {
233 let this = &mut *self;
234 if this.inner.check_shutdown(cx) {
235 this.is_terminated = true;
236 return std::task::Poll::Ready(None);
237 }
238 if this.is_terminated {
239 panic!("polled EmptyProtocolRequestStream after completion");
240 }
241 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
242 |bytes, handles| {
243 match this.inner.channel().read_etc(cx, bytes, handles) {
244 std::task::Poll::Ready(Ok(())) => {}
245 std::task::Poll::Pending => return std::task::Poll::Pending,
246 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
247 this.is_terminated = true;
248 return std::task::Poll::Ready(None);
249 }
250 std::task::Poll::Ready(Err(e)) => {
251 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
252 e.into(),
253 ))));
254 }
255 }
256
257 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
259
260 std::task::Poll::Ready(Some(match header.ordinal {
261 _ => Err(fidl::Error::UnknownOrdinal {
262 ordinal: header.ordinal,
263 protocol_name:
264 <EmptyProtocolMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
265 }),
266 }))
267 },
268 )
269 }
270}
271
272#[derive(Debug)]
274pub enum EmptyProtocolRequest {}
275
276impl EmptyProtocolRequest {
277 pub fn method_name(&self) -> &'static str {
279 match *self {}
280 }
281}
282
283#[derive(Debug, Clone)]
284pub struct EmptyProtocolControlHandle {
285 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
286}
287
288impl fidl::endpoints::ControlHandle for EmptyProtocolControlHandle {
289 fn shutdown(&self) {
290 self.inner.shutdown()
291 }
292
293 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
294 self.inner.shutdown_with_epitaph(status)
295 }
296
297 fn is_closed(&self) -> bool {
298 self.inner.channel().is_closed()
299 }
300 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
301 self.inner.channel().on_closed()
302 }
303
304 #[cfg(target_os = "fuchsia")]
305 fn signal_peer(
306 &self,
307 clear_mask: zx::Signals,
308 set_mask: zx::Signals,
309 ) -> Result<(), zx_status::Status> {
310 use fidl::Peered;
311 self.inner.channel().signal_peer(clear_mask, set_mask)
312 }
313}
314
315impl EmptyProtocolControlHandle {}
316
317#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
318pub struct ProtocolAMarker;
319
320impl fidl::endpoints::ProtocolMarker for ProtocolAMarker {
321 type Proxy = ProtocolAProxy;
322 type RequestStream = ProtocolARequestStream;
323 #[cfg(target_os = "fuchsia")]
324 type SynchronousProxy = ProtocolASynchronousProxy;
325
326 const DEBUG_NAME: &'static str = "fuchsia.component.client.test.ProtocolA";
327}
328impl fidl::endpoints::DiscoverableProtocolMarker for ProtocolAMarker {}
329
330pub trait ProtocolAProxyInterface: Send + Sync {
331 type FooResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
332 fn r#foo(&self) -> Self::FooResponseFut;
333}
334#[derive(Debug)]
335#[cfg(target_os = "fuchsia")]
336pub struct ProtocolASynchronousProxy {
337 client: fidl::client::sync::Client,
338}
339
340#[cfg(target_os = "fuchsia")]
341impl fidl::endpoints::SynchronousProxy for ProtocolASynchronousProxy {
342 type Proxy = ProtocolAProxy;
343 type Protocol = ProtocolAMarker;
344
345 fn from_channel(inner: fidl::Channel) -> Self {
346 Self::new(inner)
347 }
348
349 fn into_channel(self) -> fidl::Channel {
350 self.client.into_channel()
351 }
352
353 fn as_channel(&self) -> &fidl::Channel {
354 self.client.as_channel()
355 }
356}
357
358#[cfg(target_os = "fuchsia")]
359impl ProtocolASynchronousProxy {
360 pub fn new(channel: fidl::Channel) -> Self {
361 let protocol_name = <ProtocolAMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
362 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
363 }
364
365 pub fn into_channel(self) -> fidl::Channel {
366 self.client.into_channel()
367 }
368
369 pub fn wait_for_event(
372 &self,
373 deadline: zx::MonotonicInstant,
374 ) -> Result<ProtocolAEvent, fidl::Error> {
375 ProtocolAEvent::decode(self.client.wait_for_event(deadline)?)
376 }
377
378 pub fn r#foo(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
380 let _response =
381 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
382 (),
383 0x5acb5937e9c47126,
384 fidl::encoding::DynamicFlags::empty(),
385 ___deadline,
386 )?;
387 Ok(_response)
388 }
389}
390
391#[cfg(target_os = "fuchsia")]
392impl From<ProtocolASynchronousProxy> for zx::NullableHandle {
393 fn from(value: ProtocolASynchronousProxy) -> Self {
394 value.into_channel().into()
395 }
396}
397
398#[cfg(target_os = "fuchsia")]
399impl From<fidl::Channel> for ProtocolASynchronousProxy {
400 fn from(value: fidl::Channel) -> Self {
401 Self::new(value)
402 }
403}
404
405#[cfg(target_os = "fuchsia")]
406impl fidl::endpoints::FromClient for ProtocolASynchronousProxy {
407 type Protocol = ProtocolAMarker;
408
409 fn from_client(value: fidl::endpoints::ClientEnd<ProtocolAMarker>) -> Self {
410 Self::new(value.into_channel())
411 }
412}
413
414#[derive(Debug, Clone)]
415pub struct ProtocolAProxy {
416 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
417}
418
419impl fidl::endpoints::Proxy for ProtocolAProxy {
420 type Protocol = ProtocolAMarker;
421
422 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
423 Self::new(inner)
424 }
425
426 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
427 self.client.into_channel().map_err(|client| Self { client })
428 }
429
430 fn as_channel(&self) -> &::fidl::AsyncChannel {
431 self.client.as_channel()
432 }
433}
434
435impl ProtocolAProxy {
436 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
438 let protocol_name = <ProtocolAMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
439 Self { client: fidl::client::Client::new(channel, protocol_name) }
440 }
441
442 pub fn take_event_stream(&self) -> ProtocolAEventStream {
448 ProtocolAEventStream { event_receiver: self.client.take_event_receiver() }
449 }
450
451 pub fn r#foo(
453 &self,
454 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
455 ProtocolAProxyInterface::r#foo(self)
456 }
457}
458
459impl ProtocolAProxyInterface for ProtocolAProxy {
460 type FooResponseFut =
461 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
462 fn r#foo(&self) -> Self::FooResponseFut {
463 fn _decode(
464 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
465 ) -> Result<(), fidl::Error> {
466 let _response = fidl::client::decode_transaction_body::<
467 fidl::encoding::EmptyPayload,
468 fidl::encoding::DefaultFuchsiaResourceDialect,
469 0x5acb5937e9c47126,
470 >(_buf?)?;
471 Ok(_response)
472 }
473 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
474 (),
475 0x5acb5937e9c47126,
476 fidl::encoding::DynamicFlags::empty(),
477 _decode,
478 )
479 }
480}
481
482pub struct ProtocolAEventStream {
483 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
484}
485
486impl std::marker::Unpin for ProtocolAEventStream {}
487
488impl futures::stream::FusedStream for ProtocolAEventStream {
489 fn is_terminated(&self) -> bool {
490 self.event_receiver.is_terminated()
491 }
492}
493
494impl futures::Stream for ProtocolAEventStream {
495 type Item = Result<ProtocolAEvent, fidl::Error>;
496
497 fn poll_next(
498 mut self: std::pin::Pin<&mut Self>,
499 cx: &mut std::task::Context<'_>,
500 ) -> std::task::Poll<Option<Self::Item>> {
501 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
502 &mut self.event_receiver,
503 cx
504 )?) {
505 Some(buf) => std::task::Poll::Ready(Some(ProtocolAEvent::decode(buf))),
506 None => std::task::Poll::Ready(None),
507 }
508 }
509}
510
511#[derive(Debug)]
512pub enum ProtocolAEvent {}
513
514impl ProtocolAEvent {
515 fn decode(
517 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
518 ) -> Result<ProtocolAEvent, fidl::Error> {
519 let (bytes, _handles) = buf.split_mut();
520 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
521 debug_assert_eq!(tx_header.tx_id, 0);
522 match tx_header.ordinal {
523 _ => Err(fidl::Error::UnknownOrdinal {
524 ordinal: tx_header.ordinal,
525 protocol_name: <ProtocolAMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
526 }),
527 }
528 }
529}
530
531pub struct ProtocolARequestStream {
533 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
534 is_terminated: bool,
535}
536
537impl std::marker::Unpin for ProtocolARequestStream {}
538
539impl futures::stream::FusedStream for ProtocolARequestStream {
540 fn is_terminated(&self) -> bool {
541 self.is_terminated
542 }
543}
544
545impl fidl::endpoints::RequestStream for ProtocolARequestStream {
546 type Protocol = ProtocolAMarker;
547 type ControlHandle = ProtocolAControlHandle;
548
549 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
550 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
551 }
552
553 fn control_handle(&self) -> Self::ControlHandle {
554 ProtocolAControlHandle { inner: self.inner.clone() }
555 }
556
557 fn into_inner(
558 self,
559 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
560 {
561 (self.inner, self.is_terminated)
562 }
563
564 fn from_inner(
565 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
566 is_terminated: bool,
567 ) -> Self {
568 Self { inner, is_terminated }
569 }
570}
571
572impl futures::Stream for ProtocolARequestStream {
573 type Item = Result<ProtocolARequest, fidl::Error>;
574
575 fn poll_next(
576 mut self: std::pin::Pin<&mut Self>,
577 cx: &mut std::task::Context<'_>,
578 ) -> std::task::Poll<Option<Self::Item>> {
579 let this = &mut *self;
580 if this.inner.check_shutdown(cx) {
581 this.is_terminated = true;
582 return std::task::Poll::Ready(None);
583 }
584 if this.is_terminated {
585 panic!("polled ProtocolARequestStream after completion");
586 }
587 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
588 |bytes, handles| {
589 match this.inner.channel().read_etc(cx, bytes, handles) {
590 std::task::Poll::Ready(Ok(())) => {}
591 std::task::Poll::Pending => return std::task::Poll::Pending,
592 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
593 this.is_terminated = true;
594 return std::task::Poll::Ready(None);
595 }
596 std::task::Poll::Ready(Err(e)) => {
597 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
598 e.into(),
599 ))));
600 }
601 }
602
603 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
605
606 std::task::Poll::Ready(Some(match header.ordinal {
607 0x5acb5937e9c47126 => {
608 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
609 let mut req = fidl::new_empty!(
610 fidl::encoding::EmptyPayload,
611 fidl::encoding::DefaultFuchsiaResourceDialect
612 );
613 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
614 let control_handle = ProtocolAControlHandle { inner: this.inner.clone() };
615 Ok(ProtocolARequest::Foo {
616 responder: ProtocolAFooResponder {
617 control_handle: std::mem::ManuallyDrop::new(control_handle),
618 tx_id: header.tx_id,
619 },
620 })
621 }
622 _ => Err(fidl::Error::UnknownOrdinal {
623 ordinal: header.ordinal,
624 protocol_name:
625 <ProtocolAMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
626 }),
627 }))
628 },
629 )
630 }
631}
632
633#[derive(Debug)]
635pub enum ProtocolARequest {
636 Foo { responder: ProtocolAFooResponder },
638}
639
640impl ProtocolARequest {
641 #[allow(irrefutable_let_patterns)]
642 pub fn into_foo(self) -> Option<(ProtocolAFooResponder)> {
643 if let ProtocolARequest::Foo { responder } = self { Some((responder)) } else { None }
644 }
645
646 pub fn method_name(&self) -> &'static str {
648 match *self {
649 ProtocolARequest::Foo { .. } => "foo",
650 }
651 }
652}
653
654#[derive(Debug, Clone)]
655pub struct ProtocolAControlHandle {
656 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
657}
658
659impl fidl::endpoints::ControlHandle for ProtocolAControlHandle {
660 fn shutdown(&self) {
661 self.inner.shutdown()
662 }
663
664 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
665 self.inner.shutdown_with_epitaph(status)
666 }
667
668 fn is_closed(&self) -> bool {
669 self.inner.channel().is_closed()
670 }
671 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
672 self.inner.channel().on_closed()
673 }
674
675 #[cfg(target_os = "fuchsia")]
676 fn signal_peer(
677 &self,
678 clear_mask: zx::Signals,
679 set_mask: zx::Signals,
680 ) -> Result<(), zx_status::Status> {
681 use fidl::Peered;
682 self.inner.channel().signal_peer(clear_mask, set_mask)
683 }
684}
685
686impl ProtocolAControlHandle {}
687
688#[must_use = "FIDL methods require a response to be sent"]
689#[derive(Debug)]
690pub struct ProtocolAFooResponder {
691 control_handle: std::mem::ManuallyDrop<ProtocolAControlHandle>,
692 tx_id: u32,
693}
694
695impl std::ops::Drop for ProtocolAFooResponder {
699 fn drop(&mut self) {
700 self.control_handle.shutdown();
701 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
703 }
704}
705
706impl fidl::endpoints::Responder for ProtocolAFooResponder {
707 type ControlHandle = ProtocolAControlHandle;
708
709 fn control_handle(&self) -> &ProtocolAControlHandle {
710 &self.control_handle
711 }
712
713 fn drop_without_shutdown(mut self) {
714 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
716 std::mem::forget(self);
718 }
719}
720
721impl ProtocolAFooResponder {
722 pub fn send(self) -> Result<(), fidl::Error> {
726 let _result = self.send_raw();
727 if _result.is_err() {
728 self.control_handle.shutdown();
729 }
730 self.drop_without_shutdown();
731 _result
732 }
733
734 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
736 let _result = self.send_raw();
737 self.drop_without_shutdown();
738 _result
739 }
740
741 fn send_raw(&self) -> Result<(), fidl::Error> {
742 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
743 (),
744 self.tx_id,
745 0x5acb5937e9c47126,
746 fidl::encoding::DynamicFlags::empty(),
747 )
748 }
749}
750
751#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
752pub struct ProtocolBMarker;
753
754impl fidl::endpoints::ProtocolMarker for ProtocolBMarker {
755 type Proxy = ProtocolBProxy;
756 type RequestStream = ProtocolBRequestStream;
757 #[cfg(target_os = "fuchsia")]
758 type SynchronousProxy = ProtocolBSynchronousProxy;
759
760 const DEBUG_NAME: &'static str = "fuchsia.component.client.test.ProtocolB";
761}
762impl fidl::endpoints::DiscoverableProtocolMarker for ProtocolBMarker {}
763
764pub trait ProtocolBProxyInterface: Send + Sync {
765 type FooResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
766 fn r#foo(&self) -> Self::FooResponseFut;
767}
768#[derive(Debug)]
769#[cfg(target_os = "fuchsia")]
770pub struct ProtocolBSynchronousProxy {
771 client: fidl::client::sync::Client,
772}
773
774#[cfg(target_os = "fuchsia")]
775impl fidl::endpoints::SynchronousProxy for ProtocolBSynchronousProxy {
776 type Proxy = ProtocolBProxy;
777 type Protocol = ProtocolBMarker;
778
779 fn from_channel(inner: fidl::Channel) -> Self {
780 Self::new(inner)
781 }
782
783 fn into_channel(self) -> fidl::Channel {
784 self.client.into_channel()
785 }
786
787 fn as_channel(&self) -> &fidl::Channel {
788 self.client.as_channel()
789 }
790}
791
792#[cfg(target_os = "fuchsia")]
793impl ProtocolBSynchronousProxy {
794 pub fn new(channel: fidl::Channel) -> Self {
795 let protocol_name = <ProtocolBMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
796 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
797 }
798
799 pub fn into_channel(self) -> fidl::Channel {
800 self.client.into_channel()
801 }
802
803 pub fn wait_for_event(
806 &self,
807 deadline: zx::MonotonicInstant,
808 ) -> Result<ProtocolBEvent, fidl::Error> {
809 ProtocolBEvent::decode(self.client.wait_for_event(deadline)?)
810 }
811
812 pub fn r#foo(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
814 let _response =
815 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
816 (),
817 0x26550949f1431acf,
818 fidl::encoding::DynamicFlags::empty(),
819 ___deadline,
820 )?;
821 Ok(_response)
822 }
823}
824
825#[cfg(target_os = "fuchsia")]
826impl From<ProtocolBSynchronousProxy> for zx::NullableHandle {
827 fn from(value: ProtocolBSynchronousProxy) -> Self {
828 value.into_channel().into()
829 }
830}
831
832#[cfg(target_os = "fuchsia")]
833impl From<fidl::Channel> for ProtocolBSynchronousProxy {
834 fn from(value: fidl::Channel) -> Self {
835 Self::new(value)
836 }
837}
838
839#[cfg(target_os = "fuchsia")]
840impl fidl::endpoints::FromClient for ProtocolBSynchronousProxy {
841 type Protocol = ProtocolBMarker;
842
843 fn from_client(value: fidl::endpoints::ClientEnd<ProtocolBMarker>) -> Self {
844 Self::new(value.into_channel())
845 }
846}
847
848#[derive(Debug, Clone)]
849pub struct ProtocolBProxy {
850 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
851}
852
853impl fidl::endpoints::Proxy for ProtocolBProxy {
854 type Protocol = ProtocolBMarker;
855
856 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
857 Self::new(inner)
858 }
859
860 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
861 self.client.into_channel().map_err(|client| Self { client })
862 }
863
864 fn as_channel(&self) -> &::fidl::AsyncChannel {
865 self.client.as_channel()
866 }
867}
868
869impl ProtocolBProxy {
870 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
872 let protocol_name = <ProtocolBMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
873 Self { client: fidl::client::Client::new(channel, protocol_name) }
874 }
875
876 pub fn take_event_stream(&self) -> ProtocolBEventStream {
882 ProtocolBEventStream { event_receiver: self.client.take_event_receiver() }
883 }
884
885 pub fn r#foo(
887 &self,
888 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
889 ProtocolBProxyInterface::r#foo(self)
890 }
891}
892
893impl ProtocolBProxyInterface for ProtocolBProxy {
894 type FooResponseFut =
895 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
896 fn r#foo(&self) -> Self::FooResponseFut {
897 fn _decode(
898 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
899 ) -> Result<(), fidl::Error> {
900 let _response = fidl::client::decode_transaction_body::<
901 fidl::encoding::EmptyPayload,
902 fidl::encoding::DefaultFuchsiaResourceDialect,
903 0x26550949f1431acf,
904 >(_buf?)?;
905 Ok(_response)
906 }
907 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
908 (),
909 0x26550949f1431acf,
910 fidl::encoding::DynamicFlags::empty(),
911 _decode,
912 )
913 }
914}
915
916pub struct ProtocolBEventStream {
917 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
918}
919
920impl std::marker::Unpin for ProtocolBEventStream {}
921
922impl futures::stream::FusedStream for ProtocolBEventStream {
923 fn is_terminated(&self) -> bool {
924 self.event_receiver.is_terminated()
925 }
926}
927
928impl futures::Stream for ProtocolBEventStream {
929 type Item = Result<ProtocolBEvent, fidl::Error>;
930
931 fn poll_next(
932 mut self: std::pin::Pin<&mut Self>,
933 cx: &mut std::task::Context<'_>,
934 ) -> std::task::Poll<Option<Self::Item>> {
935 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
936 &mut self.event_receiver,
937 cx
938 )?) {
939 Some(buf) => std::task::Poll::Ready(Some(ProtocolBEvent::decode(buf))),
940 None => std::task::Poll::Ready(None),
941 }
942 }
943}
944
945#[derive(Debug)]
946pub enum ProtocolBEvent {}
947
948impl ProtocolBEvent {
949 fn decode(
951 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
952 ) -> Result<ProtocolBEvent, fidl::Error> {
953 let (bytes, _handles) = buf.split_mut();
954 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
955 debug_assert_eq!(tx_header.tx_id, 0);
956 match tx_header.ordinal {
957 _ => Err(fidl::Error::UnknownOrdinal {
958 ordinal: tx_header.ordinal,
959 protocol_name: <ProtocolBMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
960 }),
961 }
962 }
963}
964
965pub struct ProtocolBRequestStream {
967 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
968 is_terminated: bool,
969}
970
971impl std::marker::Unpin for ProtocolBRequestStream {}
972
973impl futures::stream::FusedStream for ProtocolBRequestStream {
974 fn is_terminated(&self) -> bool {
975 self.is_terminated
976 }
977}
978
979impl fidl::endpoints::RequestStream for ProtocolBRequestStream {
980 type Protocol = ProtocolBMarker;
981 type ControlHandle = ProtocolBControlHandle;
982
983 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
984 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
985 }
986
987 fn control_handle(&self) -> Self::ControlHandle {
988 ProtocolBControlHandle { inner: self.inner.clone() }
989 }
990
991 fn into_inner(
992 self,
993 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
994 {
995 (self.inner, self.is_terminated)
996 }
997
998 fn from_inner(
999 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1000 is_terminated: bool,
1001 ) -> Self {
1002 Self { inner, is_terminated }
1003 }
1004}
1005
1006impl futures::Stream for ProtocolBRequestStream {
1007 type Item = Result<ProtocolBRequest, fidl::Error>;
1008
1009 fn poll_next(
1010 mut self: std::pin::Pin<&mut Self>,
1011 cx: &mut std::task::Context<'_>,
1012 ) -> std::task::Poll<Option<Self::Item>> {
1013 let this = &mut *self;
1014 if this.inner.check_shutdown(cx) {
1015 this.is_terminated = true;
1016 return std::task::Poll::Ready(None);
1017 }
1018 if this.is_terminated {
1019 panic!("polled ProtocolBRequestStream after completion");
1020 }
1021 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1022 |bytes, handles| {
1023 match this.inner.channel().read_etc(cx, bytes, handles) {
1024 std::task::Poll::Ready(Ok(())) => {}
1025 std::task::Poll::Pending => return std::task::Poll::Pending,
1026 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1027 this.is_terminated = true;
1028 return std::task::Poll::Ready(None);
1029 }
1030 std::task::Poll::Ready(Err(e)) => {
1031 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1032 e.into(),
1033 ))));
1034 }
1035 }
1036
1037 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1039
1040 std::task::Poll::Ready(Some(match header.ordinal {
1041 0x26550949f1431acf => {
1042 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1043 let mut req = fidl::new_empty!(
1044 fidl::encoding::EmptyPayload,
1045 fidl::encoding::DefaultFuchsiaResourceDialect
1046 );
1047 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1048 let control_handle = ProtocolBControlHandle { inner: this.inner.clone() };
1049 Ok(ProtocolBRequest::Foo {
1050 responder: ProtocolBFooResponder {
1051 control_handle: std::mem::ManuallyDrop::new(control_handle),
1052 tx_id: header.tx_id,
1053 },
1054 })
1055 }
1056 _ => Err(fidl::Error::UnknownOrdinal {
1057 ordinal: header.ordinal,
1058 protocol_name:
1059 <ProtocolBMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1060 }),
1061 }))
1062 },
1063 )
1064 }
1065}
1066
1067#[derive(Debug)]
1069pub enum ProtocolBRequest {
1070 Foo { responder: ProtocolBFooResponder },
1072}
1073
1074impl ProtocolBRequest {
1075 #[allow(irrefutable_let_patterns)]
1076 pub fn into_foo(self) -> Option<(ProtocolBFooResponder)> {
1077 if let ProtocolBRequest::Foo { responder } = self { Some((responder)) } else { None }
1078 }
1079
1080 pub fn method_name(&self) -> &'static str {
1082 match *self {
1083 ProtocolBRequest::Foo { .. } => "foo",
1084 }
1085 }
1086}
1087
1088#[derive(Debug, Clone)]
1089pub struct ProtocolBControlHandle {
1090 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1091}
1092
1093impl fidl::endpoints::ControlHandle for ProtocolBControlHandle {
1094 fn shutdown(&self) {
1095 self.inner.shutdown()
1096 }
1097
1098 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1099 self.inner.shutdown_with_epitaph(status)
1100 }
1101
1102 fn is_closed(&self) -> bool {
1103 self.inner.channel().is_closed()
1104 }
1105 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1106 self.inner.channel().on_closed()
1107 }
1108
1109 #[cfg(target_os = "fuchsia")]
1110 fn signal_peer(
1111 &self,
1112 clear_mask: zx::Signals,
1113 set_mask: zx::Signals,
1114 ) -> Result<(), zx_status::Status> {
1115 use fidl::Peered;
1116 self.inner.channel().signal_peer(clear_mask, set_mask)
1117 }
1118}
1119
1120impl ProtocolBControlHandle {}
1121
1122#[must_use = "FIDL methods require a response to be sent"]
1123#[derive(Debug)]
1124pub struct ProtocolBFooResponder {
1125 control_handle: std::mem::ManuallyDrop<ProtocolBControlHandle>,
1126 tx_id: u32,
1127}
1128
1129impl std::ops::Drop for ProtocolBFooResponder {
1133 fn drop(&mut self) {
1134 self.control_handle.shutdown();
1135 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1137 }
1138}
1139
1140impl fidl::endpoints::Responder for ProtocolBFooResponder {
1141 type ControlHandle = ProtocolBControlHandle;
1142
1143 fn control_handle(&self) -> &ProtocolBControlHandle {
1144 &self.control_handle
1145 }
1146
1147 fn drop_without_shutdown(mut self) {
1148 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1150 std::mem::forget(self);
1152 }
1153}
1154
1155impl ProtocolBFooResponder {
1156 pub fn send(self) -> Result<(), fidl::Error> {
1160 let _result = self.send_raw();
1161 if _result.is_err() {
1162 self.control_handle.shutdown();
1163 }
1164 self.drop_without_shutdown();
1165 _result
1166 }
1167
1168 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1170 let _result = self.send_raw();
1171 self.drop_without_shutdown();
1172 _result
1173 }
1174
1175 fn send_raw(&self) -> Result<(), fidl::Error> {
1176 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1177 (),
1178 self.tx_id,
1179 0x26550949f1431acf,
1180 fidl::encoding::DynamicFlags::empty(),
1181 )
1182 }
1183}
1184
1185#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1186pub struct ServiceMarker;
1187
1188#[cfg(target_os = "fuchsia")]
1189impl fidl::endpoints::ServiceMarker for ServiceMarker {
1190 type Proxy = ServiceProxy;
1191 type Request = ServiceRequest;
1192 const SERVICE_NAME: &'static str = "fuchsia.component.client.test.Service";
1193}
1194
1195#[cfg(target_os = "fuchsia")]
1199pub enum ServiceRequest {
1200 First(ProtocolARequestStream),
1201 Second(ProtocolBRequestStream),
1202}
1203
1204#[cfg(target_os = "fuchsia")]
1205impl fidl::endpoints::ServiceRequest for ServiceRequest {
1206 type Service = ServiceMarker;
1207
1208 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1209 match name {
1210 "first" => Self::First(
1211 <ProtocolARequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1212 ),
1213 "second" => Self::Second(
1214 <ProtocolBRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1215 ),
1216 _ => panic!("no such member protocol name for service Service"),
1217 }
1218 }
1219
1220 fn member_names() -> &'static [&'static str] {
1221 &["first", "second"]
1222 }
1223}
1224#[cfg(target_os = "fuchsia")]
1226pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1227
1228#[cfg(target_os = "fuchsia")]
1229impl fidl::endpoints::ServiceProxy for ServiceProxy {
1230 type Service = ServiceMarker;
1231
1232 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1233 Self(opener)
1234 }
1235}
1236
1237#[cfg(target_os = "fuchsia")]
1238impl ServiceProxy {
1239 pub fn connect_to_first(&self) -> Result<ProtocolAProxy, fidl::Error> {
1240 let (proxy, server_end) = fidl::endpoints::create_proxy::<ProtocolAMarker>();
1241 self.connect_channel_to_first(server_end)?;
1242 Ok(proxy)
1243 }
1244
1245 pub fn connect_to_first_sync(&self) -> Result<ProtocolASynchronousProxy, fidl::Error> {
1248 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ProtocolAMarker>();
1249 self.connect_channel_to_first(server_end)?;
1250 Ok(proxy)
1251 }
1252
1253 pub fn connect_channel_to_first(
1256 &self,
1257 server_end: fidl::endpoints::ServerEnd<ProtocolAMarker>,
1258 ) -> Result<(), fidl::Error> {
1259 self.0.open_member("first", server_end.into_channel())
1260 }
1261 pub fn connect_to_second(&self) -> Result<ProtocolBProxy, fidl::Error> {
1262 let (proxy, server_end) = fidl::endpoints::create_proxy::<ProtocolBMarker>();
1263 self.connect_channel_to_second(server_end)?;
1264 Ok(proxy)
1265 }
1266
1267 pub fn connect_to_second_sync(&self) -> Result<ProtocolBSynchronousProxy, fidl::Error> {
1270 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ProtocolBMarker>();
1271 self.connect_channel_to_second(server_end)?;
1272 Ok(proxy)
1273 }
1274
1275 pub fn connect_channel_to_second(
1278 &self,
1279 server_end: fidl::endpoints::ServerEnd<ProtocolBMarker>,
1280 ) -> Result<(), fidl::Error> {
1281 self.0.open_member("second", server_end.into_channel())
1282 }
1283
1284 pub fn instance_name(&self) -> &str {
1285 self.0.instance_name()
1286 }
1287}
1288
1289mod internal {
1290 use super::*;
1291}