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