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_examples_calculator__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct CalculatorMarker;
16
17impl fidl::endpoints::ProtocolMarker for CalculatorMarker {
18 type Proxy = CalculatorProxy;
19 type RequestStream = CalculatorRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = CalculatorSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.examples.calculator.Calculator";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for CalculatorMarker {}
26
27pub trait CalculatorProxyInterface: Send + Sync {
28 type AddResponseFut: std::future::Future<Output = Result<f64, fidl::Error>> + Send;
29 fn r#add(&self, a: f64, b: f64) -> Self::AddResponseFut;
30 type SubtractResponseFut: std::future::Future<Output = Result<f64, fidl::Error>> + Send;
31 fn r#subtract(&self, a: f64, b: f64) -> Self::SubtractResponseFut;
32 type MultiplyResponseFut: std::future::Future<Output = Result<f64, fidl::Error>> + Send;
33 fn r#multiply(&self, a: f64, b: f64) -> Self::MultiplyResponseFut;
34 type DivideResponseFut: std::future::Future<Output = Result<f64, fidl::Error>> + Send;
35 fn r#divide(&self, dividend: f64, divisor: f64) -> Self::DivideResponseFut;
36 type PowResponseFut: std::future::Future<Output = Result<f64, fidl::Error>> + Send;
37 fn r#pow(&self, base: f64, exponent: f64) -> Self::PowResponseFut;
38}
39#[derive(Debug)]
40#[cfg(target_os = "fuchsia")]
41pub struct CalculatorSynchronousProxy {
42 client: fidl::client::sync::Client,
43}
44
45#[cfg(target_os = "fuchsia")]
46impl fidl::endpoints::SynchronousProxy for CalculatorSynchronousProxy {
47 type Proxy = CalculatorProxy;
48 type Protocol = CalculatorMarker;
49
50 fn from_channel(inner: fidl::Channel) -> Self {
51 Self::new(inner)
52 }
53
54 fn into_channel(self) -> fidl::Channel {
55 self.client.into_channel()
56 }
57
58 fn as_channel(&self) -> &fidl::Channel {
59 self.client.as_channel()
60 }
61}
62
63#[cfg(target_os = "fuchsia")]
64impl CalculatorSynchronousProxy {
65 pub fn new(channel: fidl::Channel) -> Self {
66 let protocol_name = <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
67 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
68 }
69
70 pub fn into_channel(self) -> fidl::Channel {
71 self.client.into_channel()
72 }
73
74 pub fn wait_for_event(
77 &self,
78 deadline: zx::MonotonicInstant,
79 ) -> Result<CalculatorEvent, fidl::Error> {
80 CalculatorEvent::decode(self.client.wait_for_event(deadline)?)
81 }
82
83 pub fn r#add(
92 &self,
93 mut a: f64,
94 mut b: f64,
95 ___deadline: zx::MonotonicInstant,
96 ) -> Result<f64, fidl::Error> {
97 let _response = self.client.send_query::<CalculatorAddRequest, CalculatorAddResponse>(
98 (a, b),
99 0x5f2286171d9ff91e,
100 fidl::encoding::DynamicFlags::empty(),
101 ___deadline,
102 )?;
103 Ok(_response.sum)
104 }
105
106 pub fn r#subtract(
115 &self,
116 mut a: f64,
117 mut b: f64,
118 ___deadline: zx::MonotonicInstant,
119 ) -> Result<f64, fidl::Error> {
120 let _response =
121 self.client.send_query::<CalculatorSubtractRequest, CalculatorSubtractResponse>(
122 (a, b),
123 0x64ce8ff043420d78,
124 fidl::encoding::DynamicFlags::empty(),
125 ___deadline,
126 )?;
127 Ok(_response.difference)
128 }
129
130 pub fn r#multiply(
139 &self,
140 mut a: f64,
141 mut b: f64,
142 ___deadline: zx::MonotonicInstant,
143 ) -> Result<f64, fidl::Error> {
144 let _response =
145 self.client.send_query::<CalculatorMultiplyRequest, CalculatorMultiplyResponse>(
146 (a, b),
147 0x4d6fedd51609fc35,
148 fidl::encoding::DynamicFlags::empty(),
149 ___deadline,
150 )?;
151 Ok(_response.product)
152 }
153
154 pub fn r#divide(
163 &self,
164 mut dividend: f64,
165 mut divisor: f64,
166 ___deadline: zx::MonotonicInstant,
167 ) -> Result<f64, fidl::Error> {
168 let _response =
169 self.client.send_query::<CalculatorDivideRequest, CalculatorDivideResponse>(
170 (dividend, divisor),
171 0x4dc343d7222988ba,
172 fidl::encoding::DynamicFlags::empty(),
173 ___deadline,
174 )?;
175 Ok(_response.quotient)
176 }
177
178 pub fn r#pow(
189 &self,
190 mut base: f64,
191 mut exponent: f64,
192 ___deadline: zx::MonotonicInstant,
193 ) -> Result<f64, fidl::Error> {
194 let _response = self.client.send_query::<CalculatorPowRequest, CalculatorPowResponse>(
195 (base, exponent),
196 0x3467780dee7ba196,
197 fidl::encoding::DynamicFlags::empty(),
198 ___deadline,
199 )?;
200 Ok(_response.power)
201 }
202}
203
204#[cfg(target_os = "fuchsia")]
205impl From<CalculatorSynchronousProxy> for zx::Handle {
206 fn from(value: CalculatorSynchronousProxy) -> Self {
207 value.into_channel().into()
208 }
209}
210
211#[cfg(target_os = "fuchsia")]
212impl From<fidl::Channel> for CalculatorSynchronousProxy {
213 fn from(value: fidl::Channel) -> Self {
214 Self::new(value)
215 }
216}
217
218#[cfg(target_os = "fuchsia")]
219impl fidl::endpoints::FromClient for CalculatorSynchronousProxy {
220 type Protocol = CalculatorMarker;
221
222 fn from_client(value: fidl::endpoints::ClientEnd<CalculatorMarker>) -> Self {
223 Self::new(value.into_channel())
224 }
225}
226
227#[derive(Debug, Clone)]
228pub struct CalculatorProxy {
229 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
230}
231
232impl fidl::endpoints::Proxy for CalculatorProxy {
233 type Protocol = CalculatorMarker;
234
235 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
236 Self::new(inner)
237 }
238
239 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
240 self.client.into_channel().map_err(|client| Self { client })
241 }
242
243 fn as_channel(&self) -> &::fidl::AsyncChannel {
244 self.client.as_channel()
245 }
246}
247
248impl CalculatorProxy {
249 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
251 let protocol_name = <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
252 Self { client: fidl::client::Client::new(channel, protocol_name) }
253 }
254
255 pub fn take_event_stream(&self) -> CalculatorEventStream {
261 CalculatorEventStream { event_receiver: self.client.take_event_receiver() }
262 }
263
264 pub fn r#add(
273 &self,
274 mut a: f64,
275 mut b: f64,
276 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
277 CalculatorProxyInterface::r#add(self, a, b)
278 }
279
280 pub fn r#subtract(
289 &self,
290 mut a: f64,
291 mut b: f64,
292 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
293 CalculatorProxyInterface::r#subtract(self, a, b)
294 }
295
296 pub fn r#multiply(
305 &self,
306 mut a: f64,
307 mut b: f64,
308 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
309 CalculatorProxyInterface::r#multiply(self, a, b)
310 }
311
312 pub fn r#divide(
321 &self,
322 mut dividend: f64,
323 mut divisor: f64,
324 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
325 CalculatorProxyInterface::r#divide(self, dividend, divisor)
326 }
327
328 pub fn r#pow(
339 &self,
340 mut base: f64,
341 mut exponent: f64,
342 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
343 CalculatorProxyInterface::r#pow(self, base, exponent)
344 }
345}
346
347impl CalculatorProxyInterface for CalculatorProxy {
348 type AddResponseFut =
349 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
350 fn r#add(&self, mut a: f64, mut b: f64) -> Self::AddResponseFut {
351 fn _decode(
352 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
353 ) -> Result<f64, fidl::Error> {
354 let _response = fidl::client::decode_transaction_body::<
355 CalculatorAddResponse,
356 fidl::encoding::DefaultFuchsiaResourceDialect,
357 0x5f2286171d9ff91e,
358 >(_buf?)?;
359 Ok(_response.sum)
360 }
361 self.client.send_query_and_decode::<CalculatorAddRequest, f64>(
362 (a, b),
363 0x5f2286171d9ff91e,
364 fidl::encoding::DynamicFlags::empty(),
365 _decode,
366 )
367 }
368
369 type SubtractResponseFut =
370 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
371 fn r#subtract(&self, mut a: f64, mut b: f64) -> Self::SubtractResponseFut {
372 fn _decode(
373 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
374 ) -> Result<f64, fidl::Error> {
375 let _response = fidl::client::decode_transaction_body::<
376 CalculatorSubtractResponse,
377 fidl::encoding::DefaultFuchsiaResourceDialect,
378 0x64ce8ff043420d78,
379 >(_buf?)?;
380 Ok(_response.difference)
381 }
382 self.client.send_query_and_decode::<CalculatorSubtractRequest, f64>(
383 (a, b),
384 0x64ce8ff043420d78,
385 fidl::encoding::DynamicFlags::empty(),
386 _decode,
387 )
388 }
389
390 type MultiplyResponseFut =
391 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
392 fn r#multiply(&self, mut a: f64, mut b: f64) -> Self::MultiplyResponseFut {
393 fn _decode(
394 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
395 ) -> Result<f64, fidl::Error> {
396 let _response = fidl::client::decode_transaction_body::<
397 CalculatorMultiplyResponse,
398 fidl::encoding::DefaultFuchsiaResourceDialect,
399 0x4d6fedd51609fc35,
400 >(_buf?)?;
401 Ok(_response.product)
402 }
403 self.client.send_query_and_decode::<CalculatorMultiplyRequest, f64>(
404 (a, b),
405 0x4d6fedd51609fc35,
406 fidl::encoding::DynamicFlags::empty(),
407 _decode,
408 )
409 }
410
411 type DivideResponseFut =
412 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
413 fn r#divide(&self, mut dividend: f64, mut divisor: f64) -> Self::DivideResponseFut {
414 fn _decode(
415 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
416 ) -> Result<f64, fidl::Error> {
417 let _response = fidl::client::decode_transaction_body::<
418 CalculatorDivideResponse,
419 fidl::encoding::DefaultFuchsiaResourceDialect,
420 0x4dc343d7222988ba,
421 >(_buf?)?;
422 Ok(_response.quotient)
423 }
424 self.client.send_query_and_decode::<CalculatorDivideRequest, f64>(
425 (dividend, divisor),
426 0x4dc343d7222988ba,
427 fidl::encoding::DynamicFlags::empty(),
428 _decode,
429 )
430 }
431
432 type PowResponseFut =
433 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
434 fn r#pow(&self, mut base: f64, mut exponent: f64) -> Self::PowResponseFut {
435 fn _decode(
436 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
437 ) -> Result<f64, fidl::Error> {
438 let _response = fidl::client::decode_transaction_body::<
439 CalculatorPowResponse,
440 fidl::encoding::DefaultFuchsiaResourceDialect,
441 0x3467780dee7ba196,
442 >(_buf?)?;
443 Ok(_response.power)
444 }
445 self.client.send_query_and_decode::<CalculatorPowRequest, f64>(
446 (base, exponent),
447 0x3467780dee7ba196,
448 fidl::encoding::DynamicFlags::empty(),
449 _decode,
450 )
451 }
452}
453
454pub struct CalculatorEventStream {
455 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
456}
457
458impl std::marker::Unpin for CalculatorEventStream {}
459
460impl futures::stream::FusedStream for CalculatorEventStream {
461 fn is_terminated(&self) -> bool {
462 self.event_receiver.is_terminated()
463 }
464}
465
466impl futures::Stream for CalculatorEventStream {
467 type Item = Result<CalculatorEvent, fidl::Error>;
468
469 fn poll_next(
470 mut self: std::pin::Pin<&mut Self>,
471 cx: &mut std::task::Context<'_>,
472 ) -> std::task::Poll<Option<Self::Item>> {
473 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
474 &mut self.event_receiver,
475 cx
476 )?) {
477 Some(buf) => std::task::Poll::Ready(Some(CalculatorEvent::decode(buf))),
478 None => std::task::Poll::Ready(None),
479 }
480 }
481}
482
483#[derive(Debug)]
484pub enum CalculatorEvent {}
485
486impl CalculatorEvent {
487 fn decode(
489 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
490 ) -> Result<CalculatorEvent, fidl::Error> {
491 let (bytes, _handles) = buf.split_mut();
492 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
493 debug_assert_eq!(tx_header.tx_id, 0);
494 match tx_header.ordinal {
495 _ => Err(fidl::Error::UnknownOrdinal {
496 ordinal: tx_header.ordinal,
497 protocol_name: <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
498 }),
499 }
500 }
501}
502
503pub struct CalculatorRequestStream {
505 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
506 is_terminated: bool,
507}
508
509impl std::marker::Unpin for CalculatorRequestStream {}
510
511impl futures::stream::FusedStream for CalculatorRequestStream {
512 fn is_terminated(&self) -> bool {
513 self.is_terminated
514 }
515}
516
517impl fidl::endpoints::RequestStream for CalculatorRequestStream {
518 type Protocol = CalculatorMarker;
519 type ControlHandle = CalculatorControlHandle;
520
521 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
522 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
523 }
524
525 fn control_handle(&self) -> Self::ControlHandle {
526 CalculatorControlHandle { inner: self.inner.clone() }
527 }
528
529 fn into_inner(
530 self,
531 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
532 {
533 (self.inner, self.is_terminated)
534 }
535
536 fn from_inner(
537 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
538 is_terminated: bool,
539 ) -> Self {
540 Self { inner, is_terminated }
541 }
542}
543
544impl futures::Stream for CalculatorRequestStream {
545 type Item = Result<CalculatorRequest, fidl::Error>;
546
547 fn poll_next(
548 mut self: std::pin::Pin<&mut Self>,
549 cx: &mut std::task::Context<'_>,
550 ) -> std::task::Poll<Option<Self::Item>> {
551 let this = &mut *self;
552 if this.inner.check_shutdown(cx) {
553 this.is_terminated = true;
554 return std::task::Poll::Ready(None);
555 }
556 if this.is_terminated {
557 panic!("polled CalculatorRequestStream after completion");
558 }
559 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
560 |bytes, handles| {
561 match this.inner.channel().read_etc(cx, bytes, handles) {
562 std::task::Poll::Ready(Ok(())) => {}
563 std::task::Poll::Pending => return std::task::Poll::Pending,
564 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
565 this.is_terminated = true;
566 return std::task::Poll::Ready(None);
567 }
568 std::task::Poll::Ready(Err(e)) => {
569 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
570 e.into(),
571 ))))
572 }
573 }
574
575 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
577
578 std::task::Poll::Ready(Some(match header.ordinal {
579 0x5f2286171d9ff91e => {
580 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
581 let mut req = fidl::new_empty!(
582 CalculatorAddRequest,
583 fidl::encoding::DefaultFuchsiaResourceDialect
584 );
585 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorAddRequest>(&header, _body_bytes, handles, &mut req)?;
586 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
587 Ok(CalculatorRequest::Add {
588 a: req.a,
589 b: req.b,
590
591 responder: CalculatorAddResponder {
592 control_handle: std::mem::ManuallyDrop::new(control_handle),
593 tx_id: header.tx_id,
594 },
595 })
596 }
597 0x64ce8ff043420d78 => {
598 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
599 let mut req = fidl::new_empty!(
600 CalculatorSubtractRequest,
601 fidl::encoding::DefaultFuchsiaResourceDialect
602 );
603 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorSubtractRequest>(&header, _body_bytes, handles, &mut req)?;
604 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
605 Ok(CalculatorRequest::Subtract {
606 a: req.a,
607 b: req.b,
608
609 responder: CalculatorSubtractResponder {
610 control_handle: std::mem::ManuallyDrop::new(control_handle),
611 tx_id: header.tx_id,
612 },
613 })
614 }
615 0x4d6fedd51609fc35 => {
616 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
617 let mut req = fidl::new_empty!(
618 CalculatorMultiplyRequest,
619 fidl::encoding::DefaultFuchsiaResourceDialect
620 );
621 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorMultiplyRequest>(&header, _body_bytes, handles, &mut req)?;
622 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
623 Ok(CalculatorRequest::Multiply {
624 a: req.a,
625 b: req.b,
626
627 responder: CalculatorMultiplyResponder {
628 control_handle: std::mem::ManuallyDrop::new(control_handle),
629 tx_id: header.tx_id,
630 },
631 })
632 }
633 0x4dc343d7222988ba => {
634 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
635 let mut req = fidl::new_empty!(
636 CalculatorDivideRequest,
637 fidl::encoding::DefaultFuchsiaResourceDialect
638 );
639 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorDivideRequest>(&header, _body_bytes, handles, &mut req)?;
640 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
641 Ok(CalculatorRequest::Divide {
642 dividend: req.dividend,
643 divisor: req.divisor,
644
645 responder: CalculatorDivideResponder {
646 control_handle: std::mem::ManuallyDrop::new(control_handle),
647 tx_id: header.tx_id,
648 },
649 })
650 }
651 0x3467780dee7ba196 => {
652 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
653 let mut req = fidl::new_empty!(
654 CalculatorPowRequest,
655 fidl::encoding::DefaultFuchsiaResourceDialect
656 );
657 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorPowRequest>(&header, _body_bytes, handles, &mut req)?;
658 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
659 Ok(CalculatorRequest::Pow {
660 base: req.base,
661 exponent: req.exponent,
662
663 responder: CalculatorPowResponder {
664 control_handle: std::mem::ManuallyDrop::new(control_handle),
665 tx_id: header.tx_id,
666 },
667 })
668 }
669 _ => Err(fidl::Error::UnknownOrdinal {
670 ordinal: header.ordinal,
671 protocol_name:
672 <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
673 }),
674 }))
675 },
676 )
677 }
678}
679
680#[derive(Debug)]
689pub enum CalculatorRequest {
690 Add { a: f64, b: f64, responder: CalculatorAddResponder },
699 Subtract { a: f64, b: f64, responder: CalculatorSubtractResponder },
708 Multiply { a: f64, b: f64, responder: CalculatorMultiplyResponder },
717 Divide { dividend: f64, divisor: f64, responder: CalculatorDivideResponder },
726 Pow { base: f64, exponent: f64, responder: CalculatorPowResponder },
737}
738
739impl CalculatorRequest {
740 #[allow(irrefutable_let_patterns)]
741 pub fn into_add(self) -> Option<(f64, f64, CalculatorAddResponder)> {
742 if let CalculatorRequest::Add { a, b, responder } = self {
743 Some((a, b, responder))
744 } else {
745 None
746 }
747 }
748
749 #[allow(irrefutable_let_patterns)]
750 pub fn into_subtract(self) -> Option<(f64, f64, CalculatorSubtractResponder)> {
751 if let CalculatorRequest::Subtract { a, b, responder } = self {
752 Some((a, b, responder))
753 } else {
754 None
755 }
756 }
757
758 #[allow(irrefutable_let_patterns)]
759 pub fn into_multiply(self) -> Option<(f64, f64, CalculatorMultiplyResponder)> {
760 if let CalculatorRequest::Multiply { a, b, responder } = self {
761 Some((a, b, responder))
762 } else {
763 None
764 }
765 }
766
767 #[allow(irrefutable_let_patterns)]
768 pub fn into_divide(self) -> Option<(f64, f64, CalculatorDivideResponder)> {
769 if let CalculatorRequest::Divide { dividend, divisor, responder } = self {
770 Some((dividend, divisor, responder))
771 } else {
772 None
773 }
774 }
775
776 #[allow(irrefutable_let_patterns)]
777 pub fn into_pow(self) -> Option<(f64, f64, CalculatorPowResponder)> {
778 if let CalculatorRequest::Pow { base, exponent, responder } = self {
779 Some((base, exponent, responder))
780 } else {
781 None
782 }
783 }
784
785 pub fn method_name(&self) -> &'static str {
787 match *self {
788 CalculatorRequest::Add { .. } => "add",
789 CalculatorRequest::Subtract { .. } => "subtract",
790 CalculatorRequest::Multiply { .. } => "multiply",
791 CalculatorRequest::Divide { .. } => "divide",
792 CalculatorRequest::Pow { .. } => "pow",
793 }
794 }
795}
796
797#[derive(Debug, Clone)]
798pub struct CalculatorControlHandle {
799 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
800}
801
802impl fidl::endpoints::ControlHandle for CalculatorControlHandle {
803 fn shutdown(&self) {
804 self.inner.shutdown()
805 }
806 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
807 self.inner.shutdown_with_epitaph(status)
808 }
809
810 fn is_closed(&self) -> bool {
811 self.inner.channel().is_closed()
812 }
813 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
814 self.inner.channel().on_closed()
815 }
816
817 #[cfg(target_os = "fuchsia")]
818 fn signal_peer(
819 &self,
820 clear_mask: zx::Signals,
821 set_mask: zx::Signals,
822 ) -> Result<(), zx_status::Status> {
823 use fidl::Peered;
824 self.inner.channel().signal_peer(clear_mask, set_mask)
825 }
826}
827
828impl CalculatorControlHandle {}
829
830#[must_use = "FIDL methods require a response to be sent"]
831#[derive(Debug)]
832pub struct CalculatorAddResponder {
833 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
834 tx_id: u32,
835}
836
837impl std::ops::Drop for CalculatorAddResponder {
841 fn drop(&mut self) {
842 self.control_handle.shutdown();
843 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
845 }
846}
847
848impl fidl::endpoints::Responder for CalculatorAddResponder {
849 type ControlHandle = CalculatorControlHandle;
850
851 fn control_handle(&self) -> &CalculatorControlHandle {
852 &self.control_handle
853 }
854
855 fn drop_without_shutdown(mut self) {
856 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
858 std::mem::forget(self);
860 }
861}
862
863impl CalculatorAddResponder {
864 pub fn send(self, mut sum: f64) -> Result<(), fidl::Error> {
868 let _result = self.send_raw(sum);
869 if _result.is_err() {
870 self.control_handle.shutdown();
871 }
872 self.drop_without_shutdown();
873 _result
874 }
875
876 pub fn send_no_shutdown_on_err(self, mut sum: f64) -> Result<(), fidl::Error> {
878 let _result = self.send_raw(sum);
879 self.drop_without_shutdown();
880 _result
881 }
882
883 fn send_raw(&self, mut sum: f64) -> Result<(), fidl::Error> {
884 self.control_handle.inner.send::<CalculatorAddResponse>(
885 (sum,),
886 self.tx_id,
887 0x5f2286171d9ff91e,
888 fidl::encoding::DynamicFlags::empty(),
889 )
890 }
891}
892
893#[must_use = "FIDL methods require a response to be sent"]
894#[derive(Debug)]
895pub struct CalculatorSubtractResponder {
896 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
897 tx_id: u32,
898}
899
900impl std::ops::Drop for CalculatorSubtractResponder {
904 fn drop(&mut self) {
905 self.control_handle.shutdown();
906 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
908 }
909}
910
911impl fidl::endpoints::Responder for CalculatorSubtractResponder {
912 type ControlHandle = CalculatorControlHandle;
913
914 fn control_handle(&self) -> &CalculatorControlHandle {
915 &self.control_handle
916 }
917
918 fn drop_without_shutdown(mut self) {
919 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
921 std::mem::forget(self);
923 }
924}
925
926impl CalculatorSubtractResponder {
927 pub fn send(self, mut difference: f64) -> Result<(), fidl::Error> {
931 let _result = self.send_raw(difference);
932 if _result.is_err() {
933 self.control_handle.shutdown();
934 }
935 self.drop_without_shutdown();
936 _result
937 }
938
939 pub fn send_no_shutdown_on_err(self, mut difference: f64) -> Result<(), fidl::Error> {
941 let _result = self.send_raw(difference);
942 self.drop_without_shutdown();
943 _result
944 }
945
946 fn send_raw(&self, mut difference: f64) -> Result<(), fidl::Error> {
947 self.control_handle.inner.send::<CalculatorSubtractResponse>(
948 (difference,),
949 self.tx_id,
950 0x64ce8ff043420d78,
951 fidl::encoding::DynamicFlags::empty(),
952 )
953 }
954}
955
956#[must_use = "FIDL methods require a response to be sent"]
957#[derive(Debug)]
958pub struct CalculatorMultiplyResponder {
959 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
960 tx_id: u32,
961}
962
963impl std::ops::Drop for CalculatorMultiplyResponder {
967 fn drop(&mut self) {
968 self.control_handle.shutdown();
969 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
971 }
972}
973
974impl fidl::endpoints::Responder for CalculatorMultiplyResponder {
975 type ControlHandle = CalculatorControlHandle;
976
977 fn control_handle(&self) -> &CalculatorControlHandle {
978 &self.control_handle
979 }
980
981 fn drop_without_shutdown(mut self) {
982 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
984 std::mem::forget(self);
986 }
987}
988
989impl CalculatorMultiplyResponder {
990 pub fn send(self, mut product: f64) -> Result<(), fidl::Error> {
994 let _result = self.send_raw(product);
995 if _result.is_err() {
996 self.control_handle.shutdown();
997 }
998 self.drop_without_shutdown();
999 _result
1000 }
1001
1002 pub fn send_no_shutdown_on_err(self, mut product: f64) -> Result<(), fidl::Error> {
1004 let _result = self.send_raw(product);
1005 self.drop_without_shutdown();
1006 _result
1007 }
1008
1009 fn send_raw(&self, mut product: f64) -> Result<(), fidl::Error> {
1010 self.control_handle.inner.send::<CalculatorMultiplyResponse>(
1011 (product,),
1012 self.tx_id,
1013 0x4d6fedd51609fc35,
1014 fidl::encoding::DynamicFlags::empty(),
1015 )
1016 }
1017}
1018
1019#[must_use = "FIDL methods require a response to be sent"]
1020#[derive(Debug)]
1021pub struct CalculatorDivideResponder {
1022 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
1023 tx_id: u32,
1024}
1025
1026impl std::ops::Drop for CalculatorDivideResponder {
1030 fn drop(&mut self) {
1031 self.control_handle.shutdown();
1032 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1034 }
1035}
1036
1037impl fidl::endpoints::Responder for CalculatorDivideResponder {
1038 type ControlHandle = CalculatorControlHandle;
1039
1040 fn control_handle(&self) -> &CalculatorControlHandle {
1041 &self.control_handle
1042 }
1043
1044 fn drop_without_shutdown(mut self) {
1045 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1047 std::mem::forget(self);
1049 }
1050}
1051
1052impl CalculatorDivideResponder {
1053 pub fn send(self, mut quotient: f64) -> Result<(), fidl::Error> {
1057 let _result = self.send_raw(quotient);
1058 if _result.is_err() {
1059 self.control_handle.shutdown();
1060 }
1061 self.drop_without_shutdown();
1062 _result
1063 }
1064
1065 pub fn send_no_shutdown_on_err(self, mut quotient: f64) -> Result<(), fidl::Error> {
1067 let _result = self.send_raw(quotient);
1068 self.drop_without_shutdown();
1069 _result
1070 }
1071
1072 fn send_raw(&self, mut quotient: f64) -> Result<(), fidl::Error> {
1073 self.control_handle.inner.send::<CalculatorDivideResponse>(
1074 (quotient,),
1075 self.tx_id,
1076 0x4dc343d7222988ba,
1077 fidl::encoding::DynamicFlags::empty(),
1078 )
1079 }
1080}
1081
1082#[must_use = "FIDL methods require a response to be sent"]
1083#[derive(Debug)]
1084pub struct CalculatorPowResponder {
1085 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
1086 tx_id: u32,
1087}
1088
1089impl std::ops::Drop for CalculatorPowResponder {
1093 fn drop(&mut self) {
1094 self.control_handle.shutdown();
1095 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1097 }
1098}
1099
1100impl fidl::endpoints::Responder for CalculatorPowResponder {
1101 type ControlHandle = CalculatorControlHandle;
1102
1103 fn control_handle(&self) -> &CalculatorControlHandle {
1104 &self.control_handle
1105 }
1106
1107 fn drop_without_shutdown(mut self) {
1108 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1110 std::mem::forget(self);
1112 }
1113}
1114
1115impl CalculatorPowResponder {
1116 pub fn send(self, mut power: f64) -> Result<(), fidl::Error> {
1120 let _result = self.send_raw(power);
1121 if _result.is_err() {
1122 self.control_handle.shutdown();
1123 }
1124 self.drop_without_shutdown();
1125 _result
1126 }
1127
1128 pub fn send_no_shutdown_on_err(self, mut power: f64) -> Result<(), fidl::Error> {
1130 let _result = self.send_raw(power);
1131 self.drop_without_shutdown();
1132 _result
1133 }
1134
1135 fn send_raw(&self, mut power: f64) -> Result<(), fidl::Error> {
1136 self.control_handle.inner.send::<CalculatorPowResponse>(
1137 (power,),
1138 self.tx_id,
1139 0x3467780dee7ba196,
1140 fidl::encoding::DynamicFlags::empty(),
1141 )
1142 }
1143}
1144
1145mod internal {
1146 use super::*;
1147}