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#[derive(Debug, Clone)]
205pub struct CalculatorProxy {
206 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
207}
208
209impl fidl::endpoints::Proxy for CalculatorProxy {
210 type Protocol = CalculatorMarker;
211
212 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
213 Self::new(inner)
214 }
215
216 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
217 self.client.into_channel().map_err(|client| Self { client })
218 }
219
220 fn as_channel(&self) -> &::fidl::AsyncChannel {
221 self.client.as_channel()
222 }
223}
224
225impl CalculatorProxy {
226 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
228 let protocol_name = <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
229 Self { client: fidl::client::Client::new(channel, protocol_name) }
230 }
231
232 pub fn take_event_stream(&self) -> CalculatorEventStream {
238 CalculatorEventStream { event_receiver: self.client.take_event_receiver() }
239 }
240
241 pub fn r#add(
250 &self,
251 mut a: f64,
252 mut b: f64,
253 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
254 CalculatorProxyInterface::r#add(self, a, b)
255 }
256
257 pub fn r#subtract(
266 &self,
267 mut a: f64,
268 mut b: f64,
269 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
270 CalculatorProxyInterface::r#subtract(self, a, b)
271 }
272
273 pub fn r#multiply(
282 &self,
283 mut a: f64,
284 mut b: f64,
285 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
286 CalculatorProxyInterface::r#multiply(self, a, b)
287 }
288
289 pub fn r#divide(
298 &self,
299 mut dividend: f64,
300 mut divisor: f64,
301 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
302 CalculatorProxyInterface::r#divide(self, dividend, divisor)
303 }
304
305 pub fn r#pow(
316 &self,
317 mut base: f64,
318 mut exponent: f64,
319 ) -> fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect> {
320 CalculatorProxyInterface::r#pow(self, base, exponent)
321 }
322}
323
324impl CalculatorProxyInterface for CalculatorProxy {
325 type AddResponseFut =
326 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
327 fn r#add(&self, mut a: f64, mut b: f64) -> Self::AddResponseFut {
328 fn _decode(
329 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
330 ) -> Result<f64, fidl::Error> {
331 let _response = fidl::client::decode_transaction_body::<
332 CalculatorAddResponse,
333 fidl::encoding::DefaultFuchsiaResourceDialect,
334 0x5f2286171d9ff91e,
335 >(_buf?)?;
336 Ok(_response.sum)
337 }
338 self.client.send_query_and_decode::<CalculatorAddRequest, f64>(
339 (a, b),
340 0x5f2286171d9ff91e,
341 fidl::encoding::DynamicFlags::empty(),
342 _decode,
343 )
344 }
345
346 type SubtractResponseFut =
347 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
348 fn r#subtract(&self, mut a: f64, mut b: f64) -> Self::SubtractResponseFut {
349 fn _decode(
350 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
351 ) -> Result<f64, fidl::Error> {
352 let _response = fidl::client::decode_transaction_body::<
353 CalculatorSubtractResponse,
354 fidl::encoding::DefaultFuchsiaResourceDialect,
355 0x64ce8ff043420d78,
356 >(_buf?)?;
357 Ok(_response.difference)
358 }
359 self.client.send_query_and_decode::<CalculatorSubtractRequest, f64>(
360 (a, b),
361 0x64ce8ff043420d78,
362 fidl::encoding::DynamicFlags::empty(),
363 _decode,
364 )
365 }
366
367 type MultiplyResponseFut =
368 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
369 fn r#multiply(&self, mut a: f64, mut b: f64) -> Self::MultiplyResponseFut {
370 fn _decode(
371 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
372 ) -> Result<f64, fidl::Error> {
373 let _response = fidl::client::decode_transaction_body::<
374 CalculatorMultiplyResponse,
375 fidl::encoding::DefaultFuchsiaResourceDialect,
376 0x4d6fedd51609fc35,
377 >(_buf?)?;
378 Ok(_response.product)
379 }
380 self.client.send_query_and_decode::<CalculatorMultiplyRequest, f64>(
381 (a, b),
382 0x4d6fedd51609fc35,
383 fidl::encoding::DynamicFlags::empty(),
384 _decode,
385 )
386 }
387
388 type DivideResponseFut =
389 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
390 fn r#divide(&self, mut dividend: f64, mut divisor: f64) -> Self::DivideResponseFut {
391 fn _decode(
392 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
393 ) -> Result<f64, fidl::Error> {
394 let _response = fidl::client::decode_transaction_body::<
395 CalculatorDivideResponse,
396 fidl::encoding::DefaultFuchsiaResourceDialect,
397 0x4dc343d7222988ba,
398 >(_buf?)?;
399 Ok(_response.quotient)
400 }
401 self.client.send_query_and_decode::<CalculatorDivideRequest, f64>(
402 (dividend, divisor),
403 0x4dc343d7222988ba,
404 fidl::encoding::DynamicFlags::empty(),
405 _decode,
406 )
407 }
408
409 type PowResponseFut =
410 fidl::client::QueryResponseFut<f64, fidl::encoding::DefaultFuchsiaResourceDialect>;
411 fn r#pow(&self, mut base: f64, mut exponent: f64) -> Self::PowResponseFut {
412 fn _decode(
413 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
414 ) -> Result<f64, fidl::Error> {
415 let _response = fidl::client::decode_transaction_body::<
416 CalculatorPowResponse,
417 fidl::encoding::DefaultFuchsiaResourceDialect,
418 0x3467780dee7ba196,
419 >(_buf?)?;
420 Ok(_response.power)
421 }
422 self.client.send_query_and_decode::<CalculatorPowRequest, f64>(
423 (base, exponent),
424 0x3467780dee7ba196,
425 fidl::encoding::DynamicFlags::empty(),
426 _decode,
427 )
428 }
429}
430
431pub struct CalculatorEventStream {
432 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
433}
434
435impl std::marker::Unpin for CalculatorEventStream {}
436
437impl futures::stream::FusedStream for CalculatorEventStream {
438 fn is_terminated(&self) -> bool {
439 self.event_receiver.is_terminated()
440 }
441}
442
443impl futures::Stream for CalculatorEventStream {
444 type Item = Result<CalculatorEvent, fidl::Error>;
445
446 fn poll_next(
447 mut self: std::pin::Pin<&mut Self>,
448 cx: &mut std::task::Context<'_>,
449 ) -> std::task::Poll<Option<Self::Item>> {
450 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
451 &mut self.event_receiver,
452 cx
453 )?) {
454 Some(buf) => std::task::Poll::Ready(Some(CalculatorEvent::decode(buf))),
455 None => std::task::Poll::Ready(None),
456 }
457 }
458}
459
460#[derive(Debug)]
461pub enum CalculatorEvent {}
462
463impl CalculatorEvent {
464 fn decode(
466 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
467 ) -> Result<CalculatorEvent, fidl::Error> {
468 let (bytes, _handles) = buf.split_mut();
469 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
470 debug_assert_eq!(tx_header.tx_id, 0);
471 match tx_header.ordinal {
472 _ => Err(fidl::Error::UnknownOrdinal {
473 ordinal: tx_header.ordinal,
474 protocol_name: <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
475 }),
476 }
477 }
478}
479
480pub struct CalculatorRequestStream {
482 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
483 is_terminated: bool,
484}
485
486impl std::marker::Unpin for CalculatorRequestStream {}
487
488impl futures::stream::FusedStream for CalculatorRequestStream {
489 fn is_terminated(&self) -> bool {
490 self.is_terminated
491 }
492}
493
494impl fidl::endpoints::RequestStream for CalculatorRequestStream {
495 type Protocol = CalculatorMarker;
496 type ControlHandle = CalculatorControlHandle;
497
498 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
499 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
500 }
501
502 fn control_handle(&self) -> Self::ControlHandle {
503 CalculatorControlHandle { inner: self.inner.clone() }
504 }
505
506 fn into_inner(
507 self,
508 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
509 {
510 (self.inner, self.is_terminated)
511 }
512
513 fn from_inner(
514 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
515 is_terminated: bool,
516 ) -> Self {
517 Self { inner, is_terminated }
518 }
519}
520
521impl futures::Stream for CalculatorRequestStream {
522 type Item = Result<CalculatorRequest, fidl::Error>;
523
524 fn poll_next(
525 mut self: std::pin::Pin<&mut Self>,
526 cx: &mut std::task::Context<'_>,
527 ) -> std::task::Poll<Option<Self::Item>> {
528 let this = &mut *self;
529 if this.inner.check_shutdown(cx) {
530 this.is_terminated = true;
531 return std::task::Poll::Ready(None);
532 }
533 if this.is_terminated {
534 panic!("polled CalculatorRequestStream after completion");
535 }
536 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
537 |bytes, handles| {
538 match this.inner.channel().read_etc(cx, bytes, handles) {
539 std::task::Poll::Ready(Ok(())) => {}
540 std::task::Poll::Pending => return std::task::Poll::Pending,
541 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
542 this.is_terminated = true;
543 return std::task::Poll::Ready(None);
544 }
545 std::task::Poll::Ready(Err(e)) => {
546 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
547 e.into(),
548 ))))
549 }
550 }
551
552 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
554
555 std::task::Poll::Ready(Some(match header.ordinal {
556 0x5f2286171d9ff91e => {
557 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
558 let mut req = fidl::new_empty!(
559 CalculatorAddRequest,
560 fidl::encoding::DefaultFuchsiaResourceDialect
561 );
562 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorAddRequest>(&header, _body_bytes, handles, &mut req)?;
563 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
564 Ok(CalculatorRequest::Add {
565 a: req.a,
566 b: req.b,
567
568 responder: CalculatorAddResponder {
569 control_handle: std::mem::ManuallyDrop::new(control_handle),
570 tx_id: header.tx_id,
571 },
572 })
573 }
574 0x64ce8ff043420d78 => {
575 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
576 let mut req = fidl::new_empty!(
577 CalculatorSubtractRequest,
578 fidl::encoding::DefaultFuchsiaResourceDialect
579 );
580 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorSubtractRequest>(&header, _body_bytes, handles, &mut req)?;
581 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
582 Ok(CalculatorRequest::Subtract {
583 a: req.a,
584 b: req.b,
585
586 responder: CalculatorSubtractResponder {
587 control_handle: std::mem::ManuallyDrop::new(control_handle),
588 tx_id: header.tx_id,
589 },
590 })
591 }
592 0x4d6fedd51609fc35 => {
593 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
594 let mut req = fidl::new_empty!(
595 CalculatorMultiplyRequest,
596 fidl::encoding::DefaultFuchsiaResourceDialect
597 );
598 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorMultiplyRequest>(&header, _body_bytes, handles, &mut req)?;
599 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
600 Ok(CalculatorRequest::Multiply {
601 a: req.a,
602 b: req.b,
603
604 responder: CalculatorMultiplyResponder {
605 control_handle: std::mem::ManuallyDrop::new(control_handle),
606 tx_id: header.tx_id,
607 },
608 })
609 }
610 0x4dc343d7222988ba => {
611 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
612 let mut req = fidl::new_empty!(
613 CalculatorDivideRequest,
614 fidl::encoding::DefaultFuchsiaResourceDialect
615 );
616 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorDivideRequest>(&header, _body_bytes, handles, &mut req)?;
617 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
618 Ok(CalculatorRequest::Divide {
619 dividend: req.dividend,
620 divisor: req.divisor,
621
622 responder: CalculatorDivideResponder {
623 control_handle: std::mem::ManuallyDrop::new(control_handle),
624 tx_id: header.tx_id,
625 },
626 })
627 }
628 0x3467780dee7ba196 => {
629 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
630 let mut req = fidl::new_empty!(
631 CalculatorPowRequest,
632 fidl::encoding::DefaultFuchsiaResourceDialect
633 );
634 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorPowRequest>(&header, _body_bytes, handles, &mut req)?;
635 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
636 Ok(CalculatorRequest::Pow {
637 base: req.base,
638 exponent: req.exponent,
639
640 responder: CalculatorPowResponder {
641 control_handle: std::mem::ManuallyDrop::new(control_handle),
642 tx_id: header.tx_id,
643 },
644 })
645 }
646 _ => Err(fidl::Error::UnknownOrdinal {
647 ordinal: header.ordinal,
648 protocol_name:
649 <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
650 }),
651 }))
652 },
653 )
654 }
655}
656
657#[derive(Debug)]
666pub enum CalculatorRequest {
667 Add { a: f64, b: f64, responder: CalculatorAddResponder },
676 Subtract { a: f64, b: f64, responder: CalculatorSubtractResponder },
685 Multiply { a: f64, b: f64, responder: CalculatorMultiplyResponder },
694 Divide { dividend: f64, divisor: f64, responder: CalculatorDivideResponder },
703 Pow { base: f64, exponent: f64, responder: CalculatorPowResponder },
714}
715
716impl CalculatorRequest {
717 #[allow(irrefutable_let_patterns)]
718 pub fn into_add(self) -> Option<(f64, f64, CalculatorAddResponder)> {
719 if let CalculatorRequest::Add { a, b, responder } = self {
720 Some((a, b, responder))
721 } else {
722 None
723 }
724 }
725
726 #[allow(irrefutable_let_patterns)]
727 pub fn into_subtract(self) -> Option<(f64, f64, CalculatorSubtractResponder)> {
728 if let CalculatorRequest::Subtract { a, b, responder } = self {
729 Some((a, b, responder))
730 } else {
731 None
732 }
733 }
734
735 #[allow(irrefutable_let_patterns)]
736 pub fn into_multiply(self) -> Option<(f64, f64, CalculatorMultiplyResponder)> {
737 if let CalculatorRequest::Multiply { a, b, responder } = self {
738 Some((a, b, responder))
739 } else {
740 None
741 }
742 }
743
744 #[allow(irrefutable_let_patterns)]
745 pub fn into_divide(self) -> Option<(f64, f64, CalculatorDivideResponder)> {
746 if let CalculatorRequest::Divide { dividend, divisor, responder } = self {
747 Some((dividend, divisor, responder))
748 } else {
749 None
750 }
751 }
752
753 #[allow(irrefutable_let_patterns)]
754 pub fn into_pow(self) -> Option<(f64, f64, CalculatorPowResponder)> {
755 if let CalculatorRequest::Pow { base, exponent, responder } = self {
756 Some((base, exponent, responder))
757 } else {
758 None
759 }
760 }
761
762 pub fn method_name(&self) -> &'static str {
764 match *self {
765 CalculatorRequest::Add { .. } => "add",
766 CalculatorRequest::Subtract { .. } => "subtract",
767 CalculatorRequest::Multiply { .. } => "multiply",
768 CalculatorRequest::Divide { .. } => "divide",
769 CalculatorRequest::Pow { .. } => "pow",
770 }
771 }
772}
773
774#[derive(Debug, Clone)]
775pub struct CalculatorControlHandle {
776 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
777}
778
779impl fidl::endpoints::ControlHandle for CalculatorControlHandle {
780 fn shutdown(&self) {
781 self.inner.shutdown()
782 }
783 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
784 self.inner.shutdown_with_epitaph(status)
785 }
786
787 fn is_closed(&self) -> bool {
788 self.inner.channel().is_closed()
789 }
790 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
791 self.inner.channel().on_closed()
792 }
793
794 #[cfg(target_os = "fuchsia")]
795 fn signal_peer(
796 &self,
797 clear_mask: zx::Signals,
798 set_mask: zx::Signals,
799 ) -> Result<(), zx_status::Status> {
800 use fidl::Peered;
801 self.inner.channel().signal_peer(clear_mask, set_mask)
802 }
803}
804
805impl CalculatorControlHandle {}
806
807#[must_use = "FIDL methods require a response to be sent"]
808#[derive(Debug)]
809pub struct CalculatorAddResponder {
810 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
811 tx_id: u32,
812}
813
814impl std::ops::Drop for CalculatorAddResponder {
818 fn drop(&mut self) {
819 self.control_handle.shutdown();
820 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
822 }
823}
824
825impl fidl::endpoints::Responder for CalculatorAddResponder {
826 type ControlHandle = CalculatorControlHandle;
827
828 fn control_handle(&self) -> &CalculatorControlHandle {
829 &self.control_handle
830 }
831
832 fn drop_without_shutdown(mut self) {
833 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
835 std::mem::forget(self);
837 }
838}
839
840impl CalculatorAddResponder {
841 pub fn send(self, mut sum: f64) -> Result<(), fidl::Error> {
845 let _result = self.send_raw(sum);
846 if _result.is_err() {
847 self.control_handle.shutdown();
848 }
849 self.drop_without_shutdown();
850 _result
851 }
852
853 pub fn send_no_shutdown_on_err(self, mut sum: f64) -> Result<(), fidl::Error> {
855 let _result = self.send_raw(sum);
856 self.drop_without_shutdown();
857 _result
858 }
859
860 fn send_raw(&self, mut sum: f64) -> Result<(), fidl::Error> {
861 self.control_handle.inner.send::<CalculatorAddResponse>(
862 (sum,),
863 self.tx_id,
864 0x5f2286171d9ff91e,
865 fidl::encoding::DynamicFlags::empty(),
866 )
867 }
868}
869
870#[must_use = "FIDL methods require a response to be sent"]
871#[derive(Debug)]
872pub struct CalculatorSubtractResponder {
873 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
874 tx_id: u32,
875}
876
877impl std::ops::Drop for CalculatorSubtractResponder {
881 fn drop(&mut self) {
882 self.control_handle.shutdown();
883 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
885 }
886}
887
888impl fidl::endpoints::Responder for CalculatorSubtractResponder {
889 type ControlHandle = CalculatorControlHandle;
890
891 fn control_handle(&self) -> &CalculatorControlHandle {
892 &self.control_handle
893 }
894
895 fn drop_without_shutdown(mut self) {
896 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
898 std::mem::forget(self);
900 }
901}
902
903impl CalculatorSubtractResponder {
904 pub fn send(self, mut difference: f64) -> Result<(), fidl::Error> {
908 let _result = self.send_raw(difference);
909 if _result.is_err() {
910 self.control_handle.shutdown();
911 }
912 self.drop_without_shutdown();
913 _result
914 }
915
916 pub fn send_no_shutdown_on_err(self, mut difference: f64) -> Result<(), fidl::Error> {
918 let _result = self.send_raw(difference);
919 self.drop_without_shutdown();
920 _result
921 }
922
923 fn send_raw(&self, mut difference: f64) -> Result<(), fidl::Error> {
924 self.control_handle.inner.send::<CalculatorSubtractResponse>(
925 (difference,),
926 self.tx_id,
927 0x64ce8ff043420d78,
928 fidl::encoding::DynamicFlags::empty(),
929 )
930 }
931}
932
933#[must_use = "FIDL methods require a response to be sent"]
934#[derive(Debug)]
935pub struct CalculatorMultiplyResponder {
936 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
937 tx_id: u32,
938}
939
940impl std::ops::Drop for CalculatorMultiplyResponder {
944 fn drop(&mut self) {
945 self.control_handle.shutdown();
946 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
948 }
949}
950
951impl fidl::endpoints::Responder for CalculatorMultiplyResponder {
952 type ControlHandle = CalculatorControlHandle;
953
954 fn control_handle(&self) -> &CalculatorControlHandle {
955 &self.control_handle
956 }
957
958 fn drop_without_shutdown(mut self) {
959 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
961 std::mem::forget(self);
963 }
964}
965
966impl CalculatorMultiplyResponder {
967 pub fn send(self, mut product: f64) -> Result<(), fidl::Error> {
971 let _result = self.send_raw(product);
972 if _result.is_err() {
973 self.control_handle.shutdown();
974 }
975 self.drop_without_shutdown();
976 _result
977 }
978
979 pub fn send_no_shutdown_on_err(self, mut product: f64) -> Result<(), fidl::Error> {
981 let _result = self.send_raw(product);
982 self.drop_without_shutdown();
983 _result
984 }
985
986 fn send_raw(&self, mut product: f64) -> Result<(), fidl::Error> {
987 self.control_handle.inner.send::<CalculatorMultiplyResponse>(
988 (product,),
989 self.tx_id,
990 0x4d6fedd51609fc35,
991 fidl::encoding::DynamicFlags::empty(),
992 )
993 }
994}
995
996#[must_use = "FIDL methods require a response to be sent"]
997#[derive(Debug)]
998pub struct CalculatorDivideResponder {
999 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
1000 tx_id: u32,
1001}
1002
1003impl std::ops::Drop for CalculatorDivideResponder {
1007 fn drop(&mut self) {
1008 self.control_handle.shutdown();
1009 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1011 }
1012}
1013
1014impl fidl::endpoints::Responder for CalculatorDivideResponder {
1015 type ControlHandle = CalculatorControlHandle;
1016
1017 fn control_handle(&self) -> &CalculatorControlHandle {
1018 &self.control_handle
1019 }
1020
1021 fn drop_without_shutdown(mut self) {
1022 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1024 std::mem::forget(self);
1026 }
1027}
1028
1029impl CalculatorDivideResponder {
1030 pub fn send(self, mut quotient: f64) -> Result<(), fidl::Error> {
1034 let _result = self.send_raw(quotient);
1035 if _result.is_err() {
1036 self.control_handle.shutdown();
1037 }
1038 self.drop_without_shutdown();
1039 _result
1040 }
1041
1042 pub fn send_no_shutdown_on_err(self, mut quotient: f64) -> Result<(), fidl::Error> {
1044 let _result = self.send_raw(quotient);
1045 self.drop_without_shutdown();
1046 _result
1047 }
1048
1049 fn send_raw(&self, mut quotient: f64) -> Result<(), fidl::Error> {
1050 self.control_handle.inner.send::<CalculatorDivideResponse>(
1051 (quotient,),
1052 self.tx_id,
1053 0x4dc343d7222988ba,
1054 fidl::encoding::DynamicFlags::empty(),
1055 )
1056 }
1057}
1058
1059#[must_use = "FIDL methods require a response to be sent"]
1060#[derive(Debug)]
1061pub struct CalculatorPowResponder {
1062 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
1063 tx_id: u32,
1064}
1065
1066impl std::ops::Drop for CalculatorPowResponder {
1070 fn drop(&mut self) {
1071 self.control_handle.shutdown();
1072 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1074 }
1075}
1076
1077impl fidl::endpoints::Responder for CalculatorPowResponder {
1078 type ControlHandle = CalculatorControlHandle;
1079
1080 fn control_handle(&self) -> &CalculatorControlHandle {
1081 &self.control_handle
1082 }
1083
1084 fn drop_without_shutdown(mut self) {
1085 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1087 std::mem::forget(self);
1089 }
1090}
1091
1092impl CalculatorPowResponder {
1093 pub fn send(self, mut power: f64) -> Result<(), fidl::Error> {
1097 let _result = self.send_raw(power);
1098 if _result.is_err() {
1099 self.control_handle.shutdown();
1100 }
1101 self.drop_without_shutdown();
1102 _result
1103 }
1104
1105 pub fn send_no_shutdown_on_err(self, mut power: f64) -> Result<(), fidl::Error> {
1107 let _result = self.send_raw(power);
1108 self.drop_without_shutdown();
1109 _result
1110 }
1111
1112 fn send_raw(&self, mut power: f64) -> Result<(), fidl::Error> {
1113 self.control_handle.inner.send::<CalculatorPowResponse>(
1114 (power,),
1115 self.tx_id,
1116 0x3467780dee7ba196,
1117 fidl::encoding::DynamicFlags::empty(),
1118 )
1119 }
1120}
1121
1122mod internal {
1123 use super::*;
1124}