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::Handle {
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 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
293 self.inner.shutdown_with_epitaph(status)
294 }
295
296 fn is_closed(&self) -> bool {
297 self.inner.channel().is_closed()
298 }
299 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
300 self.inner.channel().on_closed()
301 }
302
303 #[cfg(target_os = "fuchsia")]
304 fn signal_peer(
305 &self,
306 clear_mask: zx::Signals,
307 set_mask: zx::Signals,
308 ) -> Result<(), zx_status::Status> {
309 use fidl::Peered;
310 self.inner.channel().signal_peer(clear_mask, set_mask)
311 }
312}
313
314impl EmptyProtocolControlHandle {}
315
316#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
317pub struct ProtocolAMarker;
318
319impl fidl::endpoints::ProtocolMarker for ProtocolAMarker {
320 type Proxy = ProtocolAProxy;
321 type RequestStream = ProtocolARequestStream;
322 #[cfg(target_os = "fuchsia")]
323 type SynchronousProxy = ProtocolASynchronousProxy;
324
325 const DEBUG_NAME: &'static str = "fuchsia.component.client.test.ProtocolA";
326}
327impl fidl::endpoints::DiscoverableProtocolMarker for ProtocolAMarker {}
328
329pub trait ProtocolAProxyInterface: Send + Sync {
330 type FooResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
331 fn r#foo(&self) -> Self::FooResponseFut;
332}
333#[derive(Debug)]
334#[cfg(target_os = "fuchsia")]
335pub struct ProtocolASynchronousProxy {
336 client: fidl::client::sync::Client,
337}
338
339#[cfg(target_os = "fuchsia")]
340impl fidl::endpoints::SynchronousProxy for ProtocolASynchronousProxy {
341 type Proxy = ProtocolAProxy;
342 type Protocol = ProtocolAMarker;
343
344 fn from_channel(inner: fidl::Channel) -> Self {
345 Self::new(inner)
346 }
347
348 fn into_channel(self) -> fidl::Channel {
349 self.client.into_channel()
350 }
351
352 fn as_channel(&self) -> &fidl::Channel {
353 self.client.as_channel()
354 }
355}
356
357#[cfg(target_os = "fuchsia")]
358impl ProtocolASynchronousProxy {
359 pub fn new(channel: fidl::Channel) -> Self {
360 let protocol_name = <ProtocolAMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
361 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
362 }
363
364 pub fn into_channel(self) -> fidl::Channel {
365 self.client.into_channel()
366 }
367
368 pub fn wait_for_event(
371 &self,
372 deadline: zx::MonotonicInstant,
373 ) -> Result<ProtocolAEvent, fidl::Error> {
374 ProtocolAEvent::decode(self.client.wait_for_event(deadline)?)
375 }
376
377 pub fn r#foo(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
379 let _response =
380 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
381 (),
382 0x5acb5937e9c47126,
383 fidl::encoding::DynamicFlags::empty(),
384 ___deadline,
385 )?;
386 Ok(_response)
387 }
388}
389
390#[cfg(target_os = "fuchsia")]
391impl From<ProtocolASynchronousProxy> for zx::Handle {
392 fn from(value: ProtocolASynchronousProxy) -> Self {
393 value.into_channel().into()
394 }
395}
396
397#[cfg(target_os = "fuchsia")]
398impl From<fidl::Channel> for ProtocolASynchronousProxy {
399 fn from(value: fidl::Channel) -> Self {
400 Self::new(value)
401 }
402}
403
404#[cfg(target_os = "fuchsia")]
405impl fidl::endpoints::FromClient for ProtocolASynchronousProxy {
406 type Protocol = ProtocolAMarker;
407
408 fn from_client(value: fidl::endpoints::ClientEnd<ProtocolAMarker>) -> Self {
409 Self::new(value.into_channel())
410 }
411}
412
413#[derive(Debug, Clone)]
414pub struct ProtocolAProxy {
415 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
416}
417
418impl fidl::endpoints::Proxy for ProtocolAProxy {
419 type Protocol = ProtocolAMarker;
420
421 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
422 Self::new(inner)
423 }
424
425 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
426 self.client.into_channel().map_err(|client| Self { client })
427 }
428
429 fn as_channel(&self) -> &::fidl::AsyncChannel {
430 self.client.as_channel()
431 }
432}
433
434impl ProtocolAProxy {
435 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
437 let protocol_name = <ProtocolAMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
438 Self { client: fidl::client::Client::new(channel, protocol_name) }
439 }
440
441 pub fn take_event_stream(&self) -> ProtocolAEventStream {
447 ProtocolAEventStream { event_receiver: self.client.take_event_receiver() }
448 }
449
450 pub fn r#foo(
452 &self,
453 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
454 ProtocolAProxyInterface::r#foo(self)
455 }
456}
457
458impl ProtocolAProxyInterface for ProtocolAProxy {
459 type FooResponseFut =
460 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
461 fn r#foo(&self) -> Self::FooResponseFut {
462 fn _decode(
463 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
464 ) -> Result<(), fidl::Error> {
465 let _response = fidl::client::decode_transaction_body::<
466 fidl::encoding::EmptyPayload,
467 fidl::encoding::DefaultFuchsiaResourceDialect,
468 0x5acb5937e9c47126,
469 >(_buf?)?;
470 Ok(_response)
471 }
472 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
473 (),
474 0x5acb5937e9c47126,
475 fidl::encoding::DynamicFlags::empty(),
476 _decode,
477 )
478 }
479}
480
481pub struct ProtocolAEventStream {
482 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
483}
484
485impl std::marker::Unpin for ProtocolAEventStream {}
486
487impl futures::stream::FusedStream for ProtocolAEventStream {
488 fn is_terminated(&self) -> bool {
489 self.event_receiver.is_terminated()
490 }
491}
492
493impl futures::Stream for ProtocolAEventStream {
494 type Item = Result<ProtocolAEvent, fidl::Error>;
495
496 fn poll_next(
497 mut self: std::pin::Pin<&mut Self>,
498 cx: &mut std::task::Context<'_>,
499 ) -> std::task::Poll<Option<Self::Item>> {
500 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
501 &mut self.event_receiver,
502 cx
503 )?) {
504 Some(buf) => std::task::Poll::Ready(Some(ProtocolAEvent::decode(buf))),
505 None => std::task::Poll::Ready(None),
506 }
507 }
508}
509
510#[derive(Debug)]
511pub enum ProtocolAEvent {}
512
513impl ProtocolAEvent {
514 fn decode(
516 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
517 ) -> Result<ProtocolAEvent, fidl::Error> {
518 let (bytes, _handles) = buf.split_mut();
519 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
520 debug_assert_eq!(tx_header.tx_id, 0);
521 match tx_header.ordinal {
522 _ => Err(fidl::Error::UnknownOrdinal {
523 ordinal: tx_header.ordinal,
524 protocol_name: <ProtocolAMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
525 }),
526 }
527 }
528}
529
530pub struct ProtocolARequestStream {
532 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
533 is_terminated: bool,
534}
535
536impl std::marker::Unpin for ProtocolARequestStream {}
537
538impl futures::stream::FusedStream for ProtocolARequestStream {
539 fn is_terminated(&self) -> bool {
540 self.is_terminated
541 }
542}
543
544impl fidl::endpoints::RequestStream for ProtocolARequestStream {
545 type Protocol = ProtocolAMarker;
546 type ControlHandle = ProtocolAControlHandle;
547
548 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
549 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
550 }
551
552 fn control_handle(&self) -> Self::ControlHandle {
553 ProtocolAControlHandle { inner: self.inner.clone() }
554 }
555
556 fn into_inner(
557 self,
558 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
559 {
560 (self.inner, self.is_terminated)
561 }
562
563 fn from_inner(
564 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
565 is_terminated: bool,
566 ) -> Self {
567 Self { inner, is_terminated }
568 }
569}
570
571impl futures::Stream for ProtocolARequestStream {
572 type Item = Result<ProtocolARequest, fidl::Error>;
573
574 fn poll_next(
575 mut self: std::pin::Pin<&mut Self>,
576 cx: &mut std::task::Context<'_>,
577 ) -> std::task::Poll<Option<Self::Item>> {
578 let this = &mut *self;
579 if this.inner.check_shutdown(cx) {
580 this.is_terminated = true;
581 return std::task::Poll::Ready(None);
582 }
583 if this.is_terminated {
584 panic!("polled ProtocolARequestStream after completion");
585 }
586 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
587 |bytes, handles| {
588 match this.inner.channel().read_etc(cx, bytes, handles) {
589 std::task::Poll::Ready(Ok(())) => {}
590 std::task::Poll::Pending => return std::task::Poll::Pending,
591 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
592 this.is_terminated = true;
593 return std::task::Poll::Ready(None);
594 }
595 std::task::Poll::Ready(Err(e)) => {
596 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
597 e.into(),
598 ))))
599 }
600 }
601
602 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
604
605 std::task::Poll::Ready(Some(match header.ordinal {
606 0x5acb5937e9c47126 => {
607 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
608 let mut req = fidl::new_empty!(
609 fidl::encoding::EmptyPayload,
610 fidl::encoding::DefaultFuchsiaResourceDialect
611 );
612 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
613 let control_handle = ProtocolAControlHandle { inner: this.inner.clone() };
614 Ok(ProtocolARequest::Foo {
615 responder: ProtocolAFooResponder {
616 control_handle: std::mem::ManuallyDrop::new(control_handle),
617 tx_id: header.tx_id,
618 },
619 })
620 }
621 _ => Err(fidl::Error::UnknownOrdinal {
622 ordinal: header.ordinal,
623 protocol_name:
624 <ProtocolAMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
625 }),
626 }))
627 },
628 )
629 }
630}
631
632#[derive(Debug)]
634pub enum ProtocolARequest {
635 Foo { responder: ProtocolAFooResponder },
637}
638
639impl ProtocolARequest {
640 #[allow(irrefutable_let_patterns)]
641 pub fn into_foo(self) -> Option<(ProtocolAFooResponder)> {
642 if let ProtocolARequest::Foo { responder } = self {
643 Some((responder))
644 } else {
645 None
646 }
647 }
648
649 pub fn method_name(&self) -> &'static str {
651 match *self {
652 ProtocolARequest::Foo { .. } => "foo",
653 }
654 }
655}
656
657#[derive(Debug, Clone)]
658pub struct ProtocolAControlHandle {
659 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
660}
661
662impl fidl::endpoints::ControlHandle for ProtocolAControlHandle {
663 fn shutdown(&self) {
664 self.inner.shutdown()
665 }
666 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
667 self.inner.shutdown_with_epitaph(status)
668 }
669
670 fn is_closed(&self) -> bool {
671 self.inner.channel().is_closed()
672 }
673 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
674 self.inner.channel().on_closed()
675 }
676
677 #[cfg(target_os = "fuchsia")]
678 fn signal_peer(
679 &self,
680 clear_mask: zx::Signals,
681 set_mask: zx::Signals,
682 ) -> Result<(), zx_status::Status> {
683 use fidl::Peered;
684 self.inner.channel().signal_peer(clear_mask, set_mask)
685 }
686}
687
688impl ProtocolAControlHandle {}
689
690#[must_use = "FIDL methods require a response to be sent"]
691#[derive(Debug)]
692pub struct ProtocolAFooResponder {
693 control_handle: std::mem::ManuallyDrop<ProtocolAControlHandle>,
694 tx_id: u32,
695}
696
697impl std::ops::Drop for ProtocolAFooResponder {
701 fn drop(&mut self) {
702 self.control_handle.shutdown();
703 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
705 }
706}
707
708impl fidl::endpoints::Responder for ProtocolAFooResponder {
709 type ControlHandle = ProtocolAControlHandle;
710
711 fn control_handle(&self) -> &ProtocolAControlHandle {
712 &self.control_handle
713 }
714
715 fn drop_without_shutdown(mut self) {
716 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
718 std::mem::forget(self);
720 }
721}
722
723impl ProtocolAFooResponder {
724 pub fn send(self) -> Result<(), fidl::Error> {
728 let _result = self.send_raw();
729 if _result.is_err() {
730 self.control_handle.shutdown();
731 }
732 self.drop_without_shutdown();
733 _result
734 }
735
736 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
738 let _result = self.send_raw();
739 self.drop_without_shutdown();
740 _result
741 }
742
743 fn send_raw(&self) -> Result<(), fidl::Error> {
744 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
745 (),
746 self.tx_id,
747 0x5acb5937e9c47126,
748 fidl::encoding::DynamicFlags::empty(),
749 )
750 }
751}
752
753#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
754pub struct ProtocolBMarker;
755
756impl fidl::endpoints::ProtocolMarker for ProtocolBMarker {
757 type Proxy = ProtocolBProxy;
758 type RequestStream = ProtocolBRequestStream;
759 #[cfg(target_os = "fuchsia")]
760 type SynchronousProxy = ProtocolBSynchronousProxy;
761
762 const DEBUG_NAME: &'static str = "fuchsia.component.client.test.ProtocolB";
763}
764impl fidl::endpoints::DiscoverableProtocolMarker for ProtocolBMarker {}
765
766pub trait ProtocolBProxyInterface: Send + Sync {
767 type FooResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
768 fn r#foo(&self) -> Self::FooResponseFut;
769}
770#[derive(Debug)]
771#[cfg(target_os = "fuchsia")]
772pub struct ProtocolBSynchronousProxy {
773 client: fidl::client::sync::Client,
774}
775
776#[cfg(target_os = "fuchsia")]
777impl fidl::endpoints::SynchronousProxy for ProtocolBSynchronousProxy {
778 type Proxy = ProtocolBProxy;
779 type Protocol = ProtocolBMarker;
780
781 fn from_channel(inner: fidl::Channel) -> Self {
782 Self::new(inner)
783 }
784
785 fn into_channel(self) -> fidl::Channel {
786 self.client.into_channel()
787 }
788
789 fn as_channel(&self) -> &fidl::Channel {
790 self.client.as_channel()
791 }
792}
793
794#[cfg(target_os = "fuchsia")]
795impl ProtocolBSynchronousProxy {
796 pub fn new(channel: fidl::Channel) -> Self {
797 let protocol_name = <ProtocolBMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
798 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
799 }
800
801 pub fn into_channel(self) -> fidl::Channel {
802 self.client.into_channel()
803 }
804
805 pub fn wait_for_event(
808 &self,
809 deadline: zx::MonotonicInstant,
810 ) -> Result<ProtocolBEvent, fidl::Error> {
811 ProtocolBEvent::decode(self.client.wait_for_event(deadline)?)
812 }
813
814 pub fn r#foo(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
816 let _response =
817 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
818 (),
819 0x26550949f1431acf,
820 fidl::encoding::DynamicFlags::empty(),
821 ___deadline,
822 )?;
823 Ok(_response)
824 }
825}
826
827#[cfg(target_os = "fuchsia")]
828impl From<ProtocolBSynchronousProxy> for zx::Handle {
829 fn from(value: ProtocolBSynchronousProxy) -> Self {
830 value.into_channel().into()
831 }
832}
833
834#[cfg(target_os = "fuchsia")]
835impl From<fidl::Channel> for ProtocolBSynchronousProxy {
836 fn from(value: fidl::Channel) -> Self {
837 Self::new(value)
838 }
839}
840
841#[cfg(target_os = "fuchsia")]
842impl fidl::endpoints::FromClient for ProtocolBSynchronousProxy {
843 type Protocol = ProtocolBMarker;
844
845 fn from_client(value: fidl::endpoints::ClientEnd<ProtocolBMarker>) -> Self {
846 Self::new(value.into_channel())
847 }
848}
849
850#[derive(Debug, Clone)]
851pub struct ProtocolBProxy {
852 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
853}
854
855impl fidl::endpoints::Proxy for ProtocolBProxy {
856 type Protocol = ProtocolBMarker;
857
858 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
859 Self::new(inner)
860 }
861
862 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
863 self.client.into_channel().map_err(|client| Self { client })
864 }
865
866 fn as_channel(&self) -> &::fidl::AsyncChannel {
867 self.client.as_channel()
868 }
869}
870
871impl ProtocolBProxy {
872 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
874 let protocol_name = <ProtocolBMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
875 Self { client: fidl::client::Client::new(channel, protocol_name) }
876 }
877
878 pub fn take_event_stream(&self) -> ProtocolBEventStream {
884 ProtocolBEventStream { event_receiver: self.client.take_event_receiver() }
885 }
886
887 pub fn r#foo(
889 &self,
890 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
891 ProtocolBProxyInterface::r#foo(self)
892 }
893}
894
895impl ProtocolBProxyInterface for ProtocolBProxy {
896 type FooResponseFut =
897 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
898 fn r#foo(&self) -> Self::FooResponseFut {
899 fn _decode(
900 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
901 ) -> Result<(), fidl::Error> {
902 let _response = fidl::client::decode_transaction_body::<
903 fidl::encoding::EmptyPayload,
904 fidl::encoding::DefaultFuchsiaResourceDialect,
905 0x26550949f1431acf,
906 >(_buf?)?;
907 Ok(_response)
908 }
909 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
910 (),
911 0x26550949f1431acf,
912 fidl::encoding::DynamicFlags::empty(),
913 _decode,
914 )
915 }
916}
917
918pub struct ProtocolBEventStream {
919 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
920}
921
922impl std::marker::Unpin for ProtocolBEventStream {}
923
924impl futures::stream::FusedStream for ProtocolBEventStream {
925 fn is_terminated(&self) -> bool {
926 self.event_receiver.is_terminated()
927 }
928}
929
930impl futures::Stream for ProtocolBEventStream {
931 type Item = Result<ProtocolBEvent, fidl::Error>;
932
933 fn poll_next(
934 mut self: std::pin::Pin<&mut Self>,
935 cx: &mut std::task::Context<'_>,
936 ) -> std::task::Poll<Option<Self::Item>> {
937 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
938 &mut self.event_receiver,
939 cx
940 )?) {
941 Some(buf) => std::task::Poll::Ready(Some(ProtocolBEvent::decode(buf))),
942 None => std::task::Poll::Ready(None),
943 }
944 }
945}
946
947#[derive(Debug)]
948pub enum ProtocolBEvent {}
949
950impl ProtocolBEvent {
951 fn decode(
953 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
954 ) -> Result<ProtocolBEvent, fidl::Error> {
955 let (bytes, _handles) = buf.split_mut();
956 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
957 debug_assert_eq!(tx_header.tx_id, 0);
958 match tx_header.ordinal {
959 _ => Err(fidl::Error::UnknownOrdinal {
960 ordinal: tx_header.ordinal,
961 protocol_name: <ProtocolBMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
962 }),
963 }
964 }
965}
966
967pub struct ProtocolBRequestStream {
969 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
970 is_terminated: bool,
971}
972
973impl std::marker::Unpin for ProtocolBRequestStream {}
974
975impl futures::stream::FusedStream for ProtocolBRequestStream {
976 fn is_terminated(&self) -> bool {
977 self.is_terminated
978 }
979}
980
981impl fidl::endpoints::RequestStream for ProtocolBRequestStream {
982 type Protocol = ProtocolBMarker;
983 type ControlHandle = ProtocolBControlHandle;
984
985 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
986 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
987 }
988
989 fn control_handle(&self) -> Self::ControlHandle {
990 ProtocolBControlHandle { inner: self.inner.clone() }
991 }
992
993 fn into_inner(
994 self,
995 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
996 {
997 (self.inner, self.is_terminated)
998 }
999
1000 fn from_inner(
1001 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1002 is_terminated: bool,
1003 ) -> Self {
1004 Self { inner, is_terminated }
1005 }
1006}
1007
1008impl futures::Stream for ProtocolBRequestStream {
1009 type Item = Result<ProtocolBRequest, fidl::Error>;
1010
1011 fn poll_next(
1012 mut self: std::pin::Pin<&mut Self>,
1013 cx: &mut std::task::Context<'_>,
1014 ) -> std::task::Poll<Option<Self::Item>> {
1015 let this = &mut *self;
1016 if this.inner.check_shutdown(cx) {
1017 this.is_terminated = true;
1018 return std::task::Poll::Ready(None);
1019 }
1020 if this.is_terminated {
1021 panic!("polled ProtocolBRequestStream after completion");
1022 }
1023 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1024 |bytes, handles| {
1025 match this.inner.channel().read_etc(cx, bytes, handles) {
1026 std::task::Poll::Ready(Ok(())) => {}
1027 std::task::Poll::Pending => return std::task::Poll::Pending,
1028 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1029 this.is_terminated = true;
1030 return std::task::Poll::Ready(None);
1031 }
1032 std::task::Poll::Ready(Err(e)) => {
1033 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1034 e.into(),
1035 ))))
1036 }
1037 }
1038
1039 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1041
1042 std::task::Poll::Ready(Some(match header.ordinal {
1043 0x26550949f1431acf => {
1044 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1045 let mut req = fidl::new_empty!(
1046 fidl::encoding::EmptyPayload,
1047 fidl::encoding::DefaultFuchsiaResourceDialect
1048 );
1049 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1050 let control_handle = ProtocolBControlHandle { inner: this.inner.clone() };
1051 Ok(ProtocolBRequest::Foo {
1052 responder: ProtocolBFooResponder {
1053 control_handle: std::mem::ManuallyDrop::new(control_handle),
1054 tx_id: header.tx_id,
1055 },
1056 })
1057 }
1058 _ => Err(fidl::Error::UnknownOrdinal {
1059 ordinal: header.ordinal,
1060 protocol_name:
1061 <ProtocolBMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1062 }),
1063 }))
1064 },
1065 )
1066 }
1067}
1068
1069#[derive(Debug)]
1071pub enum ProtocolBRequest {
1072 Foo { responder: ProtocolBFooResponder },
1074}
1075
1076impl ProtocolBRequest {
1077 #[allow(irrefutable_let_patterns)]
1078 pub fn into_foo(self) -> Option<(ProtocolBFooResponder)> {
1079 if let ProtocolBRequest::Foo { responder } = self {
1080 Some((responder))
1081 } else {
1082 None
1083 }
1084 }
1085
1086 pub fn method_name(&self) -> &'static str {
1088 match *self {
1089 ProtocolBRequest::Foo { .. } => "foo",
1090 }
1091 }
1092}
1093
1094#[derive(Debug, Clone)]
1095pub struct ProtocolBControlHandle {
1096 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1097}
1098
1099impl fidl::endpoints::ControlHandle for ProtocolBControlHandle {
1100 fn shutdown(&self) {
1101 self.inner.shutdown()
1102 }
1103 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1104 self.inner.shutdown_with_epitaph(status)
1105 }
1106
1107 fn is_closed(&self) -> bool {
1108 self.inner.channel().is_closed()
1109 }
1110 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1111 self.inner.channel().on_closed()
1112 }
1113
1114 #[cfg(target_os = "fuchsia")]
1115 fn signal_peer(
1116 &self,
1117 clear_mask: zx::Signals,
1118 set_mask: zx::Signals,
1119 ) -> Result<(), zx_status::Status> {
1120 use fidl::Peered;
1121 self.inner.channel().signal_peer(clear_mask, set_mask)
1122 }
1123}
1124
1125impl ProtocolBControlHandle {}
1126
1127#[must_use = "FIDL methods require a response to be sent"]
1128#[derive(Debug)]
1129pub struct ProtocolBFooResponder {
1130 control_handle: std::mem::ManuallyDrop<ProtocolBControlHandle>,
1131 tx_id: u32,
1132}
1133
1134impl std::ops::Drop for ProtocolBFooResponder {
1138 fn drop(&mut self) {
1139 self.control_handle.shutdown();
1140 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1142 }
1143}
1144
1145impl fidl::endpoints::Responder for ProtocolBFooResponder {
1146 type ControlHandle = ProtocolBControlHandle;
1147
1148 fn control_handle(&self) -> &ProtocolBControlHandle {
1149 &self.control_handle
1150 }
1151
1152 fn drop_without_shutdown(mut self) {
1153 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1155 std::mem::forget(self);
1157 }
1158}
1159
1160impl ProtocolBFooResponder {
1161 pub fn send(self) -> Result<(), fidl::Error> {
1165 let _result = self.send_raw();
1166 if _result.is_err() {
1167 self.control_handle.shutdown();
1168 }
1169 self.drop_without_shutdown();
1170 _result
1171 }
1172
1173 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1175 let _result = self.send_raw();
1176 self.drop_without_shutdown();
1177 _result
1178 }
1179
1180 fn send_raw(&self) -> Result<(), fidl::Error> {
1181 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1182 (),
1183 self.tx_id,
1184 0x26550949f1431acf,
1185 fidl::encoding::DynamicFlags::empty(),
1186 )
1187 }
1188}
1189
1190#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1191pub struct ServiceMarker;
1192
1193#[cfg(target_os = "fuchsia")]
1194impl fidl::endpoints::ServiceMarker for ServiceMarker {
1195 type Proxy = ServiceProxy;
1196 type Request = ServiceRequest;
1197 const SERVICE_NAME: &'static str = "fuchsia.component.client.test.Service";
1198}
1199
1200#[cfg(target_os = "fuchsia")]
1204pub enum ServiceRequest {
1205 First(ProtocolARequestStream),
1206 Second(ProtocolBRequestStream),
1207}
1208
1209#[cfg(target_os = "fuchsia")]
1210impl fidl::endpoints::ServiceRequest for ServiceRequest {
1211 type Service = ServiceMarker;
1212
1213 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1214 match name {
1215 "first" => Self::First(
1216 <ProtocolARequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1217 ),
1218 "second" => Self::Second(
1219 <ProtocolBRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1220 ),
1221 _ => panic!("no such member protocol name for service Service"),
1222 }
1223 }
1224
1225 fn member_names() -> &'static [&'static str] {
1226 &["first", "second"]
1227 }
1228}
1229#[cfg(target_os = "fuchsia")]
1231pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1232
1233#[cfg(target_os = "fuchsia")]
1234impl fidl::endpoints::ServiceProxy for ServiceProxy {
1235 type Service = ServiceMarker;
1236
1237 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1238 Self(opener)
1239 }
1240}
1241
1242#[cfg(target_os = "fuchsia")]
1243impl ServiceProxy {
1244 pub fn connect_to_first(&self) -> Result<ProtocolAProxy, fidl::Error> {
1245 let (proxy, server_end) = fidl::endpoints::create_proxy::<ProtocolAMarker>();
1246 self.connect_channel_to_first(server_end)?;
1247 Ok(proxy)
1248 }
1249
1250 pub fn connect_to_first_sync(&self) -> Result<ProtocolASynchronousProxy, fidl::Error> {
1253 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ProtocolAMarker>();
1254 self.connect_channel_to_first(server_end)?;
1255 Ok(proxy)
1256 }
1257
1258 pub fn connect_channel_to_first(
1261 &self,
1262 server_end: fidl::endpoints::ServerEnd<ProtocolAMarker>,
1263 ) -> Result<(), fidl::Error> {
1264 self.0.open_member("first", server_end.into_channel())
1265 }
1266 pub fn connect_to_second(&self) -> Result<ProtocolBProxy, fidl::Error> {
1267 let (proxy, server_end) = fidl::endpoints::create_proxy::<ProtocolBMarker>();
1268 self.connect_channel_to_second(server_end)?;
1269 Ok(proxy)
1270 }
1271
1272 pub fn connect_to_second_sync(&self) -> Result<ProtocolBSynchronousProxy, fidl::Error> {
1275 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ProtocolBMarker>();
1276 self.connect_channel_to_second(server_end)?;
1277 Ok(proxy)
1278 }
1279
1280 pub fn connect_channel_to_second(
1283 &self,
1284 server_end: fidl::endpoints::ServerEnd<ProtocolBMarker>,
1285 ) -> Result<(), fidl::Error> {
1286 self.0.open_member("second", server_end.into_channel())
1287 }
1288
1289 pub fn instance_name(&self) -> &str {
1290 self.0.instance_name()
1291 }
1292}
1293
1294mod internal {
1295 use super::*;
1296}