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_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 = "(anonymous) Calculator";
24}
25pub type CalculatorDivideResult = Result<(i32, i32), DivisionError>;
26
27pub trait CalculatorProxyInterface: Send + Sync {
28 type AddResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
29 fn r#add(&self, a: i32, b: i32) -> Self::AddResponseFut;
30 type DivideResponseFut: std::future::Future<Output = Result<CalculatorDivideResult, fidl::Error>>
31 + Send;
32 fn r#divide(&self, dividend: i32, divisor: i32) -> Self::DivideResponseFut;
33 fn r#clear(&self) -> Result<(), fidl::Error>;
34}
35#[derive(Debug)]
36#[cfg(target_os = "fuchsia")]
37pub struct CalculatorSynchronousProxy {
38 client: fidl::client::sync::Client,
39}
40
41#[cfg(target_os = "fuchsia")]
42impl fidl::endpoints::SynchronousProxy for CalculatorSynchronousProxy {
43 type Proxy = CalculatorProxy;
44 type Protocol = CalculatorMarker;
45
46 fn from_channel(inner: fidl::Channel) -> Self {
47 Self::new(inner)
48 }
49
50 fn into_channel(self) -> fidl::Channel {
51 self.client.into_channel()
52 }
53
54 fn as_channel(&self) -> &fidl::Channel {
55 self.client.as_channel()
56 }
57}
58
59#[cfg(target_os = "fuchsia")]
60impl CalculatorSynchronousProxy {
61 pub fn new(channel: fidl::Channel) -> Self {
62 let protocol_name = <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
63 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
64 }
65
66 pub fn into_channel(self) -> fidl::Channel {
67 self.client.into_channel()
68 }
69
70 pub fn wait_for_event(
73 &self,
74 deadline: zx::MonotonicInstant,
75 ) -> Result<CalculatorEvent, fidl::Error> {
76 CalculatorEvent::decode(self.client.wait_for_event(deadline)?)
77 }
78
79 pub fn r#add(
80 &self,
81 mut a: i32,
82 mut b: i32,
83 ___deadline: zx::MonotonicInstant,
84 ) -> Result<i32, fidl::Error> {
85 let _response = self.client.send_query::<
86 CalculatorAddRequest,
87 fidl::encoding::FlexibleType<CalculatorAddResponse>,
88 >(
89 (a, b,),
90 0x77e89989c55e6e01,
91 fidl::encoding::DynamicFlags::FLEXIBLE,
92 ___deadline,
93 )?
94 .into_result::<CalculatorMarker>("add")?;
95 Ok(_response.sum)
96 }
97
98 pub fn r#divide(
99 &self,
100 mut dividend: i32,
101 mut divisor: i32,
102 ___deadline: zx::MonotonicInstant,
103 ) -> Result<CalculatorDivideResult, fidl::Error> {
104 let _response = self.client.send_query::<
105 CalculatorDivideRequest,
106 fidl::encoding::FlexibleResultType<CalculatorDivideResponse, DivisionError>,
107 >(
108 (dividend, divisor,),
109 0x4c4ca20ded067af7,
110 fidl::encoding::DynamicFlags::FLEXIBLE,
111 ___deadline,
112 )?
113 .into_result::<CalculatorMarker>("divide")?;
114 Ok(_response.map(|x| (x.quotient, x.remainder)))
115 }
116
117 pub fn r#clear(&self) -> Result<(), fidl::Error> {
118 self.client.send::<fidl::encoding::EmptyPayload>(
119 (),
120 0x673e190d87949c89,
121 fidl::encoding::DynamicFlags::FLEXIBLE,
122 )
123 }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl From<CalculatorSynchronousProxy> for zx::Handle {
128 fn from(value: CalculatorSynchronousProxy) -> Self {
129 value.into_channel().into()
130 }
131}
132
133#[cfg(target_os = "fuchsia")]
134impl From<fidl::Channel> for CalculatorSynchronousProxy {
135 fn from(value: fidl::Channel) -> Self {
136 Self::new(value)
137 }
138}
139
140#[derive(Debug, Clone)]
141pub struct CalculatorProxy {
142 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
143}
144
145impl fidl::endpoints::Proxy for CalculatorProxy {
146 type Protocol = CalculatorMarker;
147
148 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
149 Self::new(inner)
150 }
151
152 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
153 self.client.into_channel().map_err(|client| Self { client })
154 }
155
156 fn as_channel(&self) -> &::fidl::AsyncChannel {
157 self.client.as_channel()
158 }
159}
160
161impl CalculatorProxy {
162 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
164 let protocol_name = <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
165 Self { client: fidl::client::Client::new(channel, protocol_name) }
166 }
167
168 pub fn take_event_stream(&self) -> CalculatorEventStream {
174 CalculatorEventStream { event_receiver: self.client.take_event_receiver() }
175 }
176
177 pub fn r#add(
178 &self,
179 mut a: i32,
180 mut b: i32,
181 ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
182 CalculatorProxyInterface::r#add(self, a, b)
183 }
184
185 pub fn r#divide(
186 &self,
187 mut dividend: i32,
188 mut divisor: i32,
189 ) -> fidl::client::QueryResponseFut<
190 CalculatorDivideResult,
191 fidl::encoding::DefaultFuchsiaResourceDialect,
192 > {
193 CalculatorProxyInterface::r#divide(self, dividend, divisor)
194 }
195
196 pub fn r#clear(&self) -> Result<(), fidl::Error> {
197 CalculatorProxyInterface::r#clear(self)
198 }
199}
200
201impl CalculatorProxyInterface for CalculatorProxy {
202 type AddResponseFut =
203 fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
204 fn r#add(&self, mut a: i32, mut b: i32) -> Self::AddResponseFut {
205 fn _decode(
206 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
207 ) -> Result<i32, fidl::Error> {
208 let _response = fidl::client::decode_transaction_body::<
209 fidl::encoding::FlexibleType<CalculatorAddResponse>,
210 fidl::encoding::DefaultFuchsiaResourceDialect,
211 0x77e89989c55e6e01,
212 >(_buf?)?
213 .into_result::<CalculatorMarker>("add")?;
214 Ok(_response.sum)
215 }
216 self.client.send_query_and_decode::<CalculatorAddRequest, i32>(
217 (a, b),
218 0x77e89989c55e6e01,
219 fidl::encoding::DynamicFlags::FLEXIBLE,
220 _decode,
221 )
222 }
223
224 type DivideResponseFut = fidl::client::QueryResponseFut<
225 CalculatorDivideResult,
226 fidl::encoding::DefaultFuchsiaResourceDialect,
227 >;
228 fn r#divide(&self, mut dividend: i32, mut divisor: i32) -> Self::DivideResponseFut {
229 fn _decode(
230 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
231 ) -> Result<CalculatorDivideResult, fidl::Error> {
232 let _response = fidl::client::decode_transaction_body::<
233 fidl::encoding::FlexibleResultType<CalculatorDivideResponse, DivisionError>,
234 fidl::encoding::DefaultFuchsiaResourceDialect,
235 0x4c4ca20ded067af7,
236 >(_buf?)?
237 .into_result::<CalculatorMarker>("divide")?;
238 Ok(_response.map(|x| (x.quotient, x.remainder)))
239 }
240 self.client.send_query_and_decode::<CalculatorDivideRequest, CalculatorDivideResult>(
241 (dividend, divisor),
242 0x4c4ca20ded067af7,
243 fidl::encoding::DynamicFlags::FLEXIBLE,
244 _decode,
245 )
246 }
247
248 fn r#clear(&self) -> Result<(), fidl::Error> {
249 self.client.send::<fidl::encoding::EmptyPayload>(
250 (),
251 0x673e190d87949c89,
252 fidl::encoding::DynamicFlags::FLEXIBLE,
253 )
254 }
255}
256
257pub struct CalculatorEventStream {
258 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
259}
260
261impl std::marker::Unpin for CalculatorEventStream {}
262
263impl futures::stream::FusedStream for CalculatorEventStream {
264 fn is_terminated(&self) -> bool {
265 self.event_receiver.is_terminated()
266 }
267}
268
269impl futures::Stream for CalculatorEventStream {
270 type Item = Result<CalculatorEvent, fidl::Error>;
271
272 fn poll_next(
273 mut self: std::pin::Pin<&mut Self>,
274 cx: &mut std::task::Context<'_>,
275 ) -> std::task::Poll<Option<Self::Item>> {
276 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
277 &mut self.event_receiver,
278 cx
279 )?) {
280 Some(buf) => std::task::Poll::Ready(Some(CalculatorEvent::decode(buf))),
281 None => std::task::Poll::Ready(None),
282 }
283 }
284}
285
286#[derive(Debug)]
287pub enum CalculatorEvent {
288 OnError {
289 status_code: u32,
290 },
291 #[non_exhaustive]
292 _UnknownEvent {
293 ordinal: u64,
295 },
296}
297
298impl CalculatorEvent {
299 #[allow(irrefutable_let_patterns)]
300 pub fn into_on_error(self) -> Option<u32> {
301 if let CalculatorEvent::OnError { status_code } = self {
302 Some((status_code))
303 } else {
304 None
305 }
306 }
307
308 fn decode(
310 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
311 ) -> Result<CalculatorEvent, fidl::Error> {
312 let (bytes, _handles) = buf.split_mut();
313 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
314 debug_assert_eq!(tx_header.tx_id, 0);
315 match tx_header.ordinal {
316 0x7c1350cc0144d3fc => {
317 let mut out = fidl::new_empty!(
318 CalculatorOnErrorRequest,
319 fidl::encoding::DefaultFuchsiaResourceDialect
320 );
321 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorOnErrorRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
322 Ok((CalculatorEvent::OnError { status_code: out.status_code }))
323 }
324 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
325 Ok(CalculatorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
326 }
327 _ => Err(fidl::Error::UnknownOrdinal {
328 ordinal: tx_header.ordinal,
329 protocol_name: <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
330 }),
331 }
332 }
333}
334
335pub struct CalculatorRequestStream {
337 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
338 is_terminated: bool,
339}
340
341impl std::marker::Unpin for CalculatorRequestStream {}
342
343impl futures::stream::FusedStream for CalculatorRequestStream {
344 fn is_terminated(&self) -> bool {
345 self.is_terminated
346 }
347}
348
349impl fidl::endpoints::RequestStream for CalculatorRequestStream {
350 type Protocol = CalculatorMarker;
351 type ControlHandle = CalculatorControlHandle;
352
353 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
354 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
355 }
356
357 fn control_handle(&self) -> Self::ControlHandle {
358 CalculatorControlHandle { inner: self.inner.clone() }
359 }
360
361 fn into_inner(
362 self,
363 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
364 {
365 (self.inner, self.is_terminated)
366 }
367
368 fn from_inner(
369 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
370 is_terminated: bool,
371 ) -> Self {
372 Self { inner, is_terminated }
373 }
374}
375
376impl futures::Stream for CalculatorRequestStream {
377 type Item = Result<CalculatorRequest, fidl::Error>;
378
379 fn poll_next(
380 mut self: std::pin::Pin<&mut Self>,
381 cx: &mut std::task::Context<'_>,
382 ) -> std::task::Poll<Option<Self::Item>> {
383 let this = &mut *self;
384 if this.inner.check_shutdown(cx) {
385 this.is_terminated = true;
386 return std::task::Poll::Ready(None);
387 }
388 if this.is_terminated {
389 panic!("polled CalculatorRequestStream after completion");
390 }
391 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
392 |bytes, handles| {
393 match this.inner.channel().read_etc(cx, bytes, handles) {
394 std::task::Poll::Ready(Ok(())) => {}
395 std::task::Poll::Pending => return std::task::Poll::Pending,
396 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
397 this.is_terminated = true;
398 return std::task::Poll::Ready(None);
399 }
400 std::task::Poll::Ready(Err(e)) => {
401 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
402 e.into(),
403 ))))
404 }
405 }
406
407 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
409
410 std::task::Poll::Ready(Some(match header.ordinal {
411 0x77e89989c55e6e01 => {
412 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
413 let mut req = fidl::new_empty!(
414 CalculatorAddRequest,
415 fidl::encoding::DefaultFuchsiaResourceDialect
416 );
417 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorAddRequest>(&header, _body_bytes, handles, &mut req)?;
418 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
419 Ok(CalculatorRequest::Add {
420 a: req.a,
421 b: req.b,
422
423 responder: CalculatorAddResponder {
424 control_handle: std::mem::ManuallyDrop::new(control_handle),
425 tx_id: header.tx_id,
426 },
427 })
428 }
429 0x4c4ca20ded067af7 => {
430 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
431 let mut req = fidl::new_empty!(
432 CalculatorDivideRequest,
433 fidl::encoding::DefaultFuchsiaResourceDialect
434 );
435 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CalculatorDivideRequest>(&header, _body_bytes, handles, &mut req)?;
436 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
437 Ok(CalculatorRequest::Divide {
438 dividend: req.dividend,
439 divisor: req.divisor,
440
441 responder: CalculatorDivideResponder {
442 control_handle: std::mem::ManuallyDrop::new(control_handle),
443 tx_id: header.tx_id,
444 },
445 })
446 }
447 0x673e190d87949c89 => {
448 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
449 let mut req = fidl::new_empty!(
450 fidl::encoding::EmptyPayload,
451 fidl::encoding::DefaultFuchsiaResourceDialect
452 );
453 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
454 let control_handle = CalculatorControlHandle { inner: this.inner.clone() };
455 Ok(CalculatorRequest::Clear { control_handle })
456 }
457 _ if header.tx_id == 0
458 && header
459 .dynamic_flags()
460 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
461 {
462 Ok(CalculatorRequest::_UnknownMethod {
463 ordinal: header.ordinal,
464 control_handle: CalculatorControlHandle { inner: this.inner.clone() },
465 method_type: fidl::MethodType::OneWay,
466 })
467 }
468 _ if header
469 .dynamic_flags()
470 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
471 {
472 this.inner.send_framework_err(
473 fidl::encoding::FrameworkErr::UnknownMethod,
474 header.tx_id,
475 header.ordinal,
476 header.dynamic_flags(),
477 (bytes, handles),
478 )?;
479 Ok(CalculatorRequest::_UnknownMethod {
480 ordinal: header.ordinal,
481 control_handle: CalculatorControlHandle { inner: this.inner.clone() },
482 method_type: fidl::MethodType::TwoWay,
483 })
484 }
485 _ => Err(fidl::Error::UnknownOrdinal {
486 ordinal: header.ordinal,
487 protocol_name:
488 <CalculatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
489 }),
490 }))
491 },
492 )
493 }
494}
495
496#[derive(Debug)]
497pub enum CalculatorRequest {
498 Add {
499 a: i32,
500 b: i32,
501 responder: CalculatorAddResponder,
502 },
503 Divide {
504 dividend: i32,
505 divisor: i32,
506 responder: CalculatorDivideResponder,
507 },
508 Clear {
509 control_handle: CalculatorControlHandle,
510 },
511 #[non_exhaustive]
513 _UnknownMethod {
514 ordinal: u64,
516 control_handle: CalculatorControlHandle,
517 method_type: fidl::MethodType,
518 },
519}
520
521impl CalculatorRequest {
522 #[allow(irrefutable_let_patterns)]
523 pub fn into_add(self) -> Option<(i32, i32, CalculatorAddResponder)> {
524 if let CalculatorRequest::Add { a, b, responder } = self {
525 Some((a, b, responder))
526 } else {
527 None
528 }
529 }
530
531 #[allow(irrefutable_let_patterns)]
532 pub fn into_divide(self) -> Option<(i32, i32, CalculatorDivideResponder)> {
533 if let CalculatorRequest::Divide { dividend, divisor, responder } = self {
534 Some((dividend, divisor, responder))
535 } else {
536 None
537 }
538 }
539
540 #[allow(irrefutable_let_patterns)]
541 pub fn into_clear(self) -> Option<(CalculatorControlHandle)> {
542 if let CalculatorRequest::Clear { control_handle } = self {
543 Some((control_handle))
544 } else {
545 None
546 }
547 }
548
549 pub fn method_name(&self) -> &'static str {
551 match *self {
552 CalculatorRequest::Add { .. } => "add",
553 CalculatorRequest::Divide { .. } => "divide",
554 CalculatorRequest::Clear { .. } => "clear",
555 CalculatorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
556 "unknown one-way method"
557 }
558 CalculatorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
559 "unknown two-way method"
560 }
561 }
562 }
563}
564
565#[derive(Debug, Clone)]
566pub struct CalculatorControlHandle {
567 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
568}
569
570impl fidl::endpoints::ControlHandle for CalculatorControlHandle {
571 fn shutdown(&self) {
572 self.inner.shutdown()
573 }
574 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
575 self.inner.shutdown_with_epitaph(status)
576 }
577
578 fn is_closed(&self) -> bool {
579 self.inner.channel().is_closed()
580 }
581 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
582 self.inner.channel().on_closed()
583 }
584
585 #[cfg(target_os = "fuchsia")]
586 fn signal_peer(
587 &self,
588 clear_mask: zx::Signals,
589 set_mask: zx::Signals,
590 ) -> Result<(), zx_status::Status> {
591 use fidl::Peered;
592 self.inner.channel().signal_peer(clear_mask, set_mask)
593 }
594}
595
596impl CalculatorControlHandle {
597 pub fn send_on_error(&self, mut status_code: u32) -> Result<(), fidl::Error> {
598 self.inner.send::<CalculatorOnErrorRequest>(
599 (status_code,),
600 0,
601 0x7c1350cc0144d3fc,
602 fidl::encoding::DynamicFlags::FLEXIBLE,
603 )
604 }
605}
606
607#[must_use = "FIDL methods require a response to be sent"]
608#[derive(Debug)]
609pub struct CalculatorAddResponder {
610 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
611 tx_id: u32,
612}
613
614impl std::ops::Drop for CalculatorAddResponder {
618 fn drop(&mut self) {
619 self.control_handle.shutdown();
620 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
622 }
623}
624
625impl fidl::endpoints::Responder for CalculatorAddResponder {
626 type ControlHandle = CalculatorControlHandle;
627
628 fn control_handle(&self) -> &CalculatorControlHandle {
629 &self.control_handle
630 }
631
632 fn drop_without_shutdown(mut self) {
633 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
635 std::mem::forget(self);
637 }
638}
639
640impl CalculatorAddResponder {
641 pub fn send(self, mut sum: i32) -> Result<(), fidl::Error> {
645 let _result = self.send_raw(sum);
646 if _result.is_err() {
647 self.control_handle.shutdown();
648 }
649 self.drop_without_shutdown();
650 _result
651 }
652
653 pub fn send_no_shutdown_on_err(self, mut sum: i32) -> Result<(), fidl::Error> {
655 let _result = self.send_raw(sum);
656 self.drop_without_shutdown();
657 _result
658 }
659
660 fn send_raw(&self, mut sum: i32) -> Result<(), fidl::Error> {
661 self.control_handle.inner.send::<fidl::encoding::FlexibleType<CalculatorAddResponse>>(
662 fidl::encoding::Flexible::new((sum,)),
663 self.tx_id,
664 0x77e89989c55e6e01,
665 fidl::encoding::DynamicFlags::FLEXIBLE,
666 )
667 }
668}
669
670#[must_use = "FIDL methods require a response to be sent"]
671#[derive(Debug)]
672pub struct CalculatorDivideResponder {
673 control_handle: std::mem::ManuallyDrop<CalculatorControlHandle>,
674 tx_id: u32,
675}
676
677impl std::ops::Drop for CalculatorDivideResponder {
681 fn drop(&mut self) {
682 self.control_handle.shutdown();
683 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
685 }
686}
687
688impl fidl::endpoints::Responder for CalculatorDivideResponder {
689 type ControlHandle = CalculatorControlHandle;
690
691 fn control_handle(&self) -> &CalculatorControlHandle {
692 &self.control_handle
693 }
694
695 fn drop_without_shutdown(mut self) {
696 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
698 std::mem::forget(self);
700 }
701}
702
703impl CalculatorDivideResponder {
704 pub fn send(self, mut result: Result<(i32, i32), DivisionError>) -> Result<(), fidl::Error> {
708 let _result = self.send_raw(result);
709 if _result.is_err() {
710 self.control_handle.shutdown();
711 }
712 self.drop_without_shutdown();
713 _result
714 }
715
716 pub fn send_no_shutdown_on_err(
718 self,
719 mut result: Result<(i32, i32), DivisionError>,
720 ) -> Result<(), fidl::Error> {
721 let _result = self.send_raw(result);
722 self.drop_without_shutdown();
723 _result
724 }
725
726 fn send_raw(&self, mut result: Result<(i32, i32), DivisionError>) -> Result<(), fidl::Error> {
727 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
728 CalculatorDivideResponse,
729 DivisionError,
730 >>(
731 fidl::encoding::FlexibleResult::new(result),
732 self.tx_id,
733 0x4c4ca20ded067af7,
734 fidl::encoding::DynamicFlags::FLEXIBLE,
735 )
736 }
737}
738
739mod internal {
740 use super::*;
741}