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_fidl_test_imported__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ComposedMarker;
16
17impl fidl::endpoints::ProtocolMarker for ComposedMarker {
18 type Proxy = ComposedProxy;
19 type RequestStream = ComposedRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ComposedSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "(anonymous) Composed";
24}
25pub type ComposedEchoUnionResponseWithErrorComposedResult =
26 Result<ComposedEchoUnionResponseWithErrorComposedResponse, u32>;
27
28pub trait ComposedProxyInterface: Send + Sync {
29 type EchoTableRequestComposedResponseFut: std::future::Future<Output = Result<SimpleStruct, fidl::Error>>
30 + Send;
31 fn r#echo_table_request_composed(
32 &self,
33 payload: &ComposedEchoTableRequestComposedRequest,
34 ) -> Self::EchoTableRequestComposedResponseFut;
35 type EchoUnionResponseWithErrorComposedResponseFut: std::future::Future<
36 Output = Result<ComposedEchoUnionResponseWithErrorComposedResult, fidl::Error>,
37 > + Send;
38 fn r#echo_union_response_with_error_composed(
39 &self,
40 value: i64,
41 want_absolute_value: bool,
42 forward_to_server: &str,
43 result_err: u32,
44 result_variant: WantResponse,
45 ) -> Self::EchoUnionResponseWithErrorComposedResponseFut;
46}
47#[derive(Debug)]
48#[cfg(target_os = "fuchsia")]
49pub struct ComposedSynchronousProxy {
50 client: fidl::client::sync::Client,
51}
52
53#[cfg(target_os = "fuchsia")]
54impl fidl::endpoints::SynchronousProxy for ComposedSynchronousProxy {
55 type Proxy = ComposedProxy;
56 type Protocol = ComposedMarker;
57
58 fn from_channel(inner: fidl::Channel) -> Self {
59 Self::new(inner)
60 }
61
62 fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 fn as_channel(&self) -> &fidl::Channel {
67 self.client.as_channel()
68 }
69}
70
71#[cfg(target_os = "fuchsia")]
72impl ComposedSynchronousProxy {
73 pub fn new(channel: fidl::Channel) -> Self {
74 Self { client: fidl::client::sync::Client::new(channel) }
75 }
76
77 pub fn into_channel(self) -> fidl::Channel {
78 self.client.into_channel()
79 }
80
81 pub fn wait_for_event(
84 &self,
85 deadline: zx::MonotonicInstant,
86 ) -> Result<ComposedEvent, fidl::Error> {
87 ComposedEvent::decode(self.client.wait_for_event::<ComposedMarker>(deadline)?)
88 }
89
90 pub fn r#echo_table_request_composed(
91 &self,
92 mut payload: &ComposedEchoTableRequestComposedRequest,
93 ___deadline: zx::MonotonicInstant,
94 ) -> Result<SimpleStruct, fidl::Error> {
95 let _response = self
96 .client
97 .send_query::<ComposedEchoTableRequestComposedRequest, ResponseStruct, ComposedMarker>(
98 payload,
99 0x1d545c738c7a8ee,
100 fidl::encoding::DynamicFlags::empty(),
101 ___deadline,
102 )?;
103 Ok(_response.value)
104 }
105
106 pub fn r#echo_union_response_with_error_composed(
107 &self,
108 mut value: i64,
109 mut want_absolute_value: bool,
110 mut forward_to_server: &str,
111 mut result_err: u32,
112 mut result_variant: WantResponse,
113 ___deadline: zx::MonotonicInstant,
114 ) -> Result<ComposedEchoUnionResponseWithErrorComposedResult, fidl::Error> {
115 let _response = self.client.send_query::<
116 ComposedEchoUnionResponseWithErrorComposedRequest,
117 fidl::encoding::ResultType<ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
118 ComposedMarker,
119 >(
120 (value, want_absolute_value, forward_to_server, result_err, result_variant,),
121 0x38a67e88d6106443,
122 fidl::encoding::DynamicFlags::empty(),
123 ___deadline,
124 )?;
125 Ok(_response.map(|x| x))
126 }
127}
128
129#[cfg(target_os = "fuchsia")]
130impl From<ComposedSynchronousProxy> for zx::NullableHandle {
131 fn from(value: ComposedSynchronousProxy) -> Self {
132 value.into_channel().into()
133 }
134}
135
136#[cfg(target_os = "fuchsia")]
137impl From<fidl::Channel> for ComposedSynchronousProxy {
138 fn from(value: fidl::Channel) -> Self {
139 Self::new(value)
140 }
141}
142
143#[cfg(target_os = "fuchsia")]
144impl fidl::endpoints::FromClient for ComposedSynchronousProxy {
145 type Protocol = ComposedMarker;
146
147 fn from_client(value: fidl::endpoints::ClientEnd<ComposedMarker>) -> Self {
148 Self::new(value.into_channel())
149 }
150}
151
152#[derive(Debug, Clone)]
153pub struct ComposedProxy {
154 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
155}
156
157impl fidl::endpoints::Proxy for ComposedProxy {
158 type Protocol = ComposedMarker;
159
160 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
161 Self::new(inner)
162 }
163
164 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
165 self.client.into_channel().map_err(|client| Self { client })
166 }
167
168 fn as_channel(&self) -> &::fidl::AsyncChannel {
169 self.client.as_channel()
170 }
171}
172
173impl ComposedProxy {
174 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
176 let protocol_name = <ComposedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
177 Self { client: fidl::client::Client::new(channel, protocol_name) }
178 }
179
180 pub fn take_event_stream(&self) -> ComposedEventStream {
186 ComposedEventStream { event_receiver: self.client.take_event_receiver() }
187 }
188
189 pub fn r#echo_table_request_composed(
190 &self,
191 mut payload: &ComposedEchoTableRequestComposedRequest,
192 ) -> fidl::client::QueryResponseFut<SimpleStruct, fidl::encoding::DefaultFuchsiaResourceDialect>
193 {
194 ComposedProxyInterface::r#echo_table_request_composed(self, payload)
195 }
196
197 pub fn r#echo_union_response_with_error_composed(
198 &self,
199 mut value: i64,
200 mut want_absolute_value: bool,
201 mut forward_to_server: &str,
202 mut result_err: u32,
203 mut result_variant: WantResponse,
204 ) -> fidl::client::QueryResponseFut<
205 ComposedEchoUnionResponseWithErrorComposedResult,
206 fidl::encoding::DefaultFuchsiaResourceDialect,
207 > {
208 ComposedProxyInterface::r#echo_union_response_with_error_composed(
209 self,
210 value,
211 want_absolute_value,
212 forward_to_server,
213 result_err,
214 result_variant,
215 )
216 }
217}
218
219impl ComposedProxyInterface for ComposedProxy {
220 type EchoTableRequestComposedResponseFut =
221 fidl::client::QueryResponseFut<SimpleStruct, fidl::encoding::DefaultFuchsiaResourceDialect>;
222 fn r#echo_table_request_composed(
223 &self,
224 mut payload: &ComposedEchoTableRequestComposedRequest,
225 ) -> Self::EchoTableRequestComposedResponseFut {
226 fn _decode(
227 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
228 ) -> Result<SimpleStruct, fidl::Error> {
229 let _response = fidl::client::decode_transaction_body::<
230 ResponseStruct,
231 fidl::encoding::DefaultFuchsiaResourceDialect,
232 0x1d545c738c7a8ee,
233 >(_buf?)?;
234 Ok(_response.value)
235 }
236 self.client.send_query_and_decode::<ComposedEchoTableRequestComposedRequest, SimpleStruct>(
237 payload,
238 0x1d545c738c7a8ee,
239 fidl::encoding::DynamicFlags::empty(),
240 _decode,
241 )
242 }
243
244 type EchoUnionResponseWithErrorComposedResponseFut = fidl::client::QueryResponseFut<
245 ComposedEchoUnionResponseWithErrorComposedResult,
246 fidl::encoding::DefaultFuchsiaResourceDialect,
247 >;
248 fn r#echo_union_response_with_error_composed(
249 &self,
250 mut value: i64,
251 mut want_absolute_value: bool,
252 mut forward_to_server: &str,
253 mut result_err: u32,
254 mut result_variant: WantResponse,
255 ) -> Self::EchoUnionResponseWithErrorComposedResponseFut {
256 fn _decode(
257 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
258 ) -> Result<ComposedEchoUnionResponseWithErrorComposedResult, fidl::Error> {
259 let _response = fidl::client::decode_transaction_body::<
260 fidl::encoding::ResultType<ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
261 fidl::encoding::DefaultFuchsiaResourceDialect,
262 0x38a67e88d6106443,
263 >(_buf?)?;
264 Ok(_response.map(|x| x))
265 }
266 self.client.send_query_and_decode::<
267 ComposedEchoUnionResponseWithErrorComposedRequest,
268 ComposedEchoUnionResponseWithErrorComposedResult,
269 >(
270 (value, want_absolute_value, forward_to_server, result_err, result_variant,),
271 0x38a67e88d6106443,
272 fidl::encoding::DynamicFlags::empty(),
273 _decode,
274 )
275 }
276}
277
278pub struct ComposedEventStream {
279 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
280}
281
282impl std::marker::Unpin for ComposedEventStream {}
283
284impl futures::stream::FusedStream for ComposedEventStream {
285 fn is_terminated(&self) -> bool {
286 self.event_receiver.is_terminated()
287 }
288}
289
290impl futures::Stream for ComposedEventStream {
291 type Item = Result<ComposedEvent, fidl::Error>;
292
293 fn poll_next(
294 mut self: std::pin::Pin<&mut Self>,
295 cx: &mut std::task::Context<'_>,
296 ) -> std::task::Poll<Option<Self::Item>> {
297 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
298 &mut self.event_receiver,
299 cx
300 )?) {
301 Some(buf) => std::task::Poll::Ready(Some(ComposedEvent::decode(buf))),
302 None => std::task::Poll::Ready(None),
303 }
304 }
305}
306
307#[derive(Debug)]
308pub enum ComposedEvent {}
309
310impl ComposedEvent {
311 fn decode(
313 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
314 ) -> Result<ComposedEvent, fidl::Error> {
315 let (bytes, _handles) = buf.split_mut();
316 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
317 debug_assert_eq!(tx_header.tx_id, 0);
318 match tx_header.ordinal {
319 _ => Err(fidl::Error::UnknownOrdinal {
320 ordinal: tx_header.ordinal,
321 protocol_name: <ComposedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
322 }),
323 }
324 }
325}
326
327pub struct ComposedRequestStream {
329 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
330 is_terminated: bool,
331}
332
333impl std::marker::Unpin for ComposedRequestStream {}
334
335impl futures::stream::FusedStream for ComposedRequestStream {
336 fn is_terminated(&self) -> bool {
337 self.is_terminated
338 }
339}
340
341impl fidl::endpoints::RequestStream for ComposedRequestStream {
342 type Protocol = ComposedMarker;
343 type ControlHandle = ComposedControlHandle;
344
345 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
346 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
347 }
348
349 fn control_handle(&self) -> Self::ControlHandle {
350 ComposedControlHandle { inner: self.inner.clone() }
351 }
352
353 fn into_inner(
354 self,
355 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
356 {
357 (self.inner, self.is_terminated)
358 }
359
360 fn from_inner(
361 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
362 is_terminated: bool,
363 ) -> Self {
364 Self { inner, is_terminated }
365 }
366}
367
368impl futures::Stream for ComposedRequestStream {
369 type Item = Result<ComposedRequest, fidl::Error>;
370
371 fn poll_next(
372 mut self: std::pin::Pin<&mut Self>,
373 cx: &mut std::task::Context<'_>,
374 ) -> std::task::Poll<Option<Self::Item>> {
375 let this = &mut *self;
376 if this.inner.check_shutdown(cx) {
377 this.is_terminated = true;
378 return std::task::Poll::Ready(None);
379 }
380 if this.is_terminated {
381 panic!("polled ComposedRequestStream after completion");
382 }
383 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
384 |bytes, handles| {
385 match this.inner.channel().read_etc(cx, bytes, handles) {
386 std::task::Poll::Ready(Ok(())) => {}
387 std::task::Poll::Pending => return std::task::Poll::Pending,
388 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
389 this.is_terminated = true;
390 return std::task::Poll::Ready(None);
391 }
392 std::task::Poll::Ready(Err(e)) => {
393 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
394 e.into(),
395 ))));
396 }
397 }
398
399 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
401
402 std::task::Poll::Ready(Some(match header.ordinal {
403 0x1d545c738c7a8ee => {
404 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
405 let mut req = fidl::new_empty!(
406 ComposedEchoTableRequestComposedRequest,
407 fidl::encoding::DefaultFuchsiaResourceDialect
408 );
409 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ComposedEchoTableRequestComposedRequest>(&header, _body_bytes, handles, &mut req)?;
410 let control_handle = ComposedControlHandle { inner: this.inner.clone() };
411 Ok(ComposedRequest::EchoTableRequestComposed {
412 payload: req,
413 responder: ComposedEchoTableRequestComposedResponder {
414 control_handle: std::mem::ManuallyDrop::new(control_handle),
415 tx_id: header.tx_id,
416 },
417 })
418 }
419 0x38a67e88d6106443 => {
420 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
421 let mut req = fidl::new_empty!(
422 ComposedEchoUnionResponseWithErrorComposedRequest,
423 fidl::encoding::DefaultFuchsiaResourceDialect
424 );
425 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ComposedEchoUnionResponseWithErrorComposedRequest>(&header, _body_bytes, handles, &mut req)?;
426 let control_handle = ComposedControlHandle { inner: this.inner.clone() };
427 Ok(ComposedRequest::EchoUnionResponseWithErrorComposed {
428 value: req.value,
429 want_absolute_value: req.want_absolute_value,
430 forward_to_server: req.forward_to_server,
431 result_err: req.result_err,
432 result_variant: req.result_variant,
433
434 responder: ComposedEchoUnionResponseWithErrorComposedResponder {
435 control_handle: std::mem::ManuallyDrop::new(control_handle),
436 tx_id: header.tx_id,
437 },
438 })
439 }
440 _ => Err(fidl::Error::UnknownOrdinal {
441 ordinal: header.ordinal,
442 protocol_name:
443 <ComposedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
444 }),
445 }))
446 },
447 )
448 }
449}
450
451#[derive(Debug)]
452pub enum ComposedRequest {
453 EchoTableRequestComposed {
454 payload: ComposedEchoTableRequestComposedRequest,
455 responder: ComposedEchoTableRequestComposedResponder,
456 },
457 EchoUnionResponseWithErrorComposed {
458 value: i64,
459 want_absolute_value: bool,
460 forward_to_server: String,
461 result_err: u32,
462 result_variant: WantResponse,
463 responder: ComposedEchoUnionResponseWithErrorComposedResponder,
464 },
465}
466
467impl ComposedRequest {
468 #[allow(irrefutable_let_patterns)]
469 pub fn into_echo_table_request_composed(
470 self,
471 ) -> Option<(ComposedEchoTableRequestComposedRequest, ComposedEchoTableRequestComposedResponder)>
472 {
473 if let ComposedRequest::EchoTableRequestComposed { payload, responder } = self {
474 Some((payload, responder))
475 } else {
476 None
477 }
478 }
479
480 #[allow(irrefutable_let_patterns)]
481 pub fn into_echo_union_response_with_error_composed(
482 self,
483 ) -> Option<(
484 i64,
485 bool,
486 String,
487 u32,
488 WantResponse,
489 ComposedEchoUnionResponseWithErrorComposedResponder,
490 )> {
491 if let ComposedRequest::EchoUnionResponseWithErrorComposed {
492 value,
493 want_absolute_value,
494 forward_to_server,
495 result_err,
496 result_variant,
497 responder,
498 } = self
499 {
500 Some((
501 value,
502 want_absolute_value,
503 forward_to_server,
504 result_err,
505 result_variant,
506 responder,
507 ))
508 } else {
509 None
510 }
511 }
512
513 pub fn method_name(&self) -> &'static str {
515 match *self {
516 ComposedRequest::EchoTableRequestComposed { .. } => "echo_table_request_composed",
517 ComposedRequest::EchoUnionResponseWithErrorComposed { .. } => {
518 "echo_union_response_with_error_composed"
519 }
520 }
521 }
522}
523
524#[derive(Debug, Clone)]
525pub struct ComposedControlHandle {
526 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
527}
528
529impl fidl::endpoints::ControlHandle for ComposedControlHandle {
530 fn shutdown(&self) {
531 self.inner.shutdown()
532 }
533
534 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
535 self.inner.shutdown_with_epitaph(status)
536 }
537
538 fn is_closed(&self) -> bool {
539 self.inner.channel().is_closed()
540 }
541 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
542 self.inner.channel().on_closed()
543 }
544
545 #[cfg(target_os = "fuchsia")]
546 fn signal_peer(
547 &self,
548 clear_mask: zx::Signals,
549 set_mask: zx::Signals,
550 ) -> Result<(), zx_status::Status> {
551 use fidl::Peered;
552 self.inner.channel().signal_peer(clear_mask, set_mask)
553 }
554}
555
556impl ComposedControlHandle {}
557
558#[must_use = "FIDL methods require a response to be sent"]
559#[derive(Debug)]
560pub struct ComposedEchoTableRequestComposedResponder {
561 control_handle: std::mem::ManuallyDrop<ComposedControlHandle>,
562 tx_id: u32,
563}
564
565impl std::ops::Drop for ComposedEchoTableRequestComposedResponder {
569 fn drop(&mut self) {
570 self.control_handle.shutdown();
571 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
573 }
574}
575
576impl fidl::endpoints::Responder for ComposedEchoTableRequestComposedResponder {
577 type ControlHandle = ComposedControlHandle;
578
579 fn control_handle(&self) -> &ComposedControlHandle {
580 &self.control_handle
581 }
582
583 fn drop_without_shutdown(mut self) {
584 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
586 std::mem::forget(self);
588 }
589}
590
591impl ComposedEchoTableRequestComposedResponder {
592 pub fn send(self, mut value: &SimpleStruct) -> Result<(), fidl::Error> {
596 let _result = self.send_raw(value);
597 if _result.is_err() {
598 self.control_handle.shutdown();
599 }
600 self.drop_without_shutdown();
601 _result
602 }
603
604 pub fn send_no_shutdown_on_err(self, mut value: &SimpleStruct) -> Result<(), fidl::Error> {
606 let _result = self.send_raw(value);
607 self.drop_without_shutdown();
608 _result
609 }
610
611 fn send_raw(&self, mut value: &SimpleStruct) -> Result<(), fidl::Error> {
612 self.control_handle.inner.send::<ResponseStruct>(
613 (value,),
614 self.tx_id,
615 0x1d545c738c7a8ee,
616 fidl::encoding::DynamicFlags::empty(),
617 )
618 }
619}
620
621#[must_use = "FIDL methods require a response to be sent"]
622#[derive(Debug)]
623pub struct ComposedEchoUnionResponseWithErrorComposedResponder {
624 control_handle: std::mem::ManuallyDrop<ComposedControlHandle>,
625 tx_id: u32,
626}
627
628impl std::ops::Drop for ComposedEchoUnionResponseWithErrorComposedResponder {
632 fn drop(&mut self) {
633 self.control_handle.shutdown();
634 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
636 }
637}
638
639impl fidl::endpoints::Responder for ComposedEchoUnionResponseWithErrorComposedResponder {
640 type ControlHandle = ComposedControlHandle;
641
642 fn control_handle(&self) -> &ComposedControlHandle {
643 &self.control_handle
644 }
645
646 fn drop_without_shutdown(mut self) {
647 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
649 std::mem::forget(self);
651 }
652}
653
654impl ComposedEchoUnionResponseWithErrorComposedResponder {
655 pub fn send(
659 self,
660 mut result: Result<&ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
661 ) -> Result<(), fidl::Error> {
662 let _result = self.send_raw(result);
663 if _result.is_err() {
664 self.control_handle.shutdown();
665 }
666 self.drop_without_shutdown();
667 _result
668 }
669
670 pub fn send_no_shutdown_on_err(
672 self,
673 mut result: Result<&ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
674 ) -> Result<(), fidl::Error> {
675 let _result = self.send_raw(result);
676 self.drop_without_shutdown();
677 _result
678 }
679
680 fn send_raw(
681 &self,
682 mut result: Result<&ComposedEchoUnionResponseWithErrorComposedResponse, u32>,
683 ) -> Result<(), fidl::Error> {
684 self.control_handle.inner.send::<fidl::encoding::ResultType<
685 ComposedEchoUnionResponseWithErrorComposedResponse,
686 u32,
687 >>(
688 result,
689 self.tx_id,
690 0x38a67e88d6106443,
691 fidl::encoding::DynamicFlags::empty(),
692 )
693 }
694}
695
696mod internal {
697 use super::*;
698}