fidl_next_examples_calculator/
fidl_next_examples_calculator.rs

1// DO NOT EDIT: This file is machine-generated by fidlgen
2#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5#[derive(Clone, Debug)]
6#[repr(C)]
7pub struct CalculatorAddRequest {
8    pub a: i32,
9
10    pub b: i32,
11}
12
13impl ::fidl_next::Encodable for CalculatorAddRequest {
14    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireCalculatorAddRequest> = unsafe {
15        ::fidl_next::CopyOptimization::enable_if(
16            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
17                && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
18        )
19    };
20
21    type Encoded = WireCalculatorAddRequest;
22}
23
24unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorAddRequest
25where
26    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
27{
28    #[inline]
29    fn encode(
30        self,
31        encoder: &mut ___E,
32        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
33    ) -> Result<(), ::fidl_next::EncodeError> {
34        ::fidl_next::munge! {
35            let Self::Encoded {
36                a,
37                b,
38
39            } = out;
40        }
41
42        ::fidl_next::Encode::encode(self.a, encoder, a)?;
43
44        ::fidl_next::Encode::encode(self.b, encoder, b)?;
45
46        Ok(())
47    }
48}
49
50unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorAddRequest
51where
52    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
53{
54    #[inline]
55    fn encode_ref(
56        &self,
57        encoder: &mut ___E,
58        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
59    ) -> Result<(), ::fidl_next::EncodeError> {
60        ::fidl_next::munge! {
61            let Self::Encoded {
62                a,
63                b,
64
65            } = out;
66        }
67
68        ::fidl_next::EncodeRef::encode_ref(&self.a, encoder, a)?;
69
70        ::fidl_next::EncodeRef::encode_ref(&self.b, encoder, b)?;
71
72        Ok(())
73    }
74}
75
76impl ::fidl_next::EncodableOption for CalculatorAddRequest {
77    type EncodedOption = ::fidl_next::WireBox<'static, WireCalculatorAddRequest>;
78}
79
80unsafe impl<___E> ::fidl_next::EncodeOption<___E> for CalculatorAddRequest
81where
82    ___E: ::fidl_next::Encoder + ?Sized,
83    CalculatorAddRequest: ::fidl_next::Encode<___E>,
84{
85    #[inline]
86    fn encode_option(
87        this: Option<Self>,
88        encoder: &mut ___E,
89        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
90    ) -> Result<(), ::fidl_next::EncodeError> {
91        if let Some(inner) = this {
92            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
93            ::fidl_next::WireBox::encode_present(out);
94        } else {
95            ::fidl_next::WireBox::encode_absent(out);
96        }
97
98        Ok(())
99    }
100}
101
102unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for CalculatorAddRequest
103where
104    ___E: ::fidl_next::Encoder + ?Sized,
105    CalculatorAddRequest: ::fidl_next::EncodeRef<___E>,
106{
107    #[inline]
108    fn encode_option_ref(
109        this: Option<&Self>,
110        encoder: &mut ___E,
111        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
112    ) -> Result<(), ::fidl_next::EncodeError> {
113        if let Some(inner) = this {
114            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
115            ::fidl_next::WireBox::encode_present(out);
116        } else {
117            ::fidl_next::WireBox::encode_absent(out);
118        }
119
120        Ok(())
121    }
122}
123
124impl ::fidl_next::FromWire<WireCalculatorAddRequest> for CalculatorAddRequest {
125    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireCalculatorAddRequest, Self> = unsafe {
126        ::fidl_next::CopyOptimization::enable_if(
127            true && <i32 as ::fidl_next::FromWire<::fidl_next::WireI32>>::COPY_OPTIMIZATION
128                .is_enabled()
129                && <i32 as ::fidl_next::FromWire<::fidl_next::WireI32>>::COPY_OPTIMIZATION
130                    .is_enabled(),
131        )
132    };
133
134    #[inline]
135    fn from_wire(wire: WireCalculatorAddRequest) -> Self {
136        Self {
137            a: ::fidl_next::FromWire::from_wire(wire.a),
138
139            b: ::fidl_next::FromWire::from_wire(wire.b),
140        }
141    }
142}
143
144impl ::fidl_next::FromWireRef<WireCalculatorAddRequest> for CalculatorAddRequest {
145    #[inline]
146    fn from_wire_ref(wire: &WireCalculatorAddRequest) -> Self {
147        Self {
148            a: ::fidl_next::FromWireRef::from_wire_ref(&wire.a),
149
150            b: ::fidl_next::FromWireRef::from_wire_ref(&wire.b),
151        }
152    }
153}
154
155/// The wire type corresponding to [`CalculatorAddRequest`].
156#[derive(Clone, Debug)]
157#[repr(C)]
158pub struct WireCalculatorAddRequest {
159    pub a: ::fidl_next::WireI32,
160
161    pub b: ::fidl_next::WireI32,
162}
163
164unsafe impl ::fidl_next::Wire for WireCalculatorAddRequest {
165    type Decoded<'de> = WireCalculatorAddRequest;
166
167    #[inline]
168    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
169}
170
171unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorAddRequest
172where
173    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
174{
175    fn decode(
176        slot: ::fidl_next::Slot<'_, Self>,
177        decoder: &mut ___D,
178    ) -> Result<(), ::fidl_next::DecodeError> {
179        ::fidl_next::munge! {
180            let Self {
181                mut a,
182                mut b,
183
184            } = slot;
185        }
186
187        ::fidl_next::Decode::decode(a.as_mut(), decoder)?;
188
189        ::fidl_next::Decode::decode(b.as_mut(), decoder)?;
190
191        Ok(())
192    }
193}
194
195#[derive(Clone, Debug)]
196#[repr(C)]
197pub struct CalculatorAddResponse {
198    pub sum: i32,
199}
200
201impl ::fidl_next::Encodable for CalculatorAddResponse {
202    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireCalculatorAddResponse> = unsafe {
203        ::fidl_next::CopyOptimization::enable_if(
204            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
205        )
206    };
207
208    type Encoded = WireCalculatorAddResponse;
209}
210
211unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorAddResponse
212where
213    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
214{
215    #[inline]
216    fn encode(
217        self,
218        encoder: &mut ___E,
219        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
220    ) -> Result<(), ::fidl_next::EncodeError> {
221        ::fidl_next::munge! {
222            let Self::Encoded {
223                sum,
224
225            } = out;
226        }
227
228        ::fidl_next::Encode::encode(self.sum, encoder, sum)?;
229
230        Ok(())
231    }
232}
233
234unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorAddResponse
235where
236    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
237{
238    #[inline]
239    fn encode_ref(
240        &self,
241        encoder: &mut ___E,
242        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
243    ) -> Result<(), ::fidl_next::EncodeError> {
244        ::fidl_next::munge! {
245            let Self::Encoded {
246                sum,
247
248            } = out;
249        }
250
251        ::fidl_next::EncodeRef::encode_ref(&self.sum, encoder, sum)?;
252
253        Ok(())
254    }
255}
256
257impl ::fidl_next::EncodableOption for CalculatorAddResponse {
258    type EncodedOption = ::fidl_next::WireBox<'static, WireCalculatorAddResponse>;
259}
260
261unsafe impl<___E> ::fidl_next::EncodeOption<___E> for CalculatorAddResponse
262where
263    ___E: ::fidl_next::Encoder + ?Sized,
264    CalculatorAddResponse: ::fidl_next::Encode<___E>,
265{
266    #[inline]
267    fn encode_option(
268        this: Option<Self>,
269        encoder: &mut ___E,
270        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
271    ) -> Result<(), ::fidl_next::EncodeError> {
272        if let Some(inner) = this {
273            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
274            ::fidl_next::WireBox::encode_present(out);
275        } else {
276            ::fidl_next::WireBox::encode_absent(out);
277        }
278
279        Ok(())
280    }
281}
282
283unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for CalculatorAddResponse
284where
285    ___E: ::fidl_next::Encoder + ?Sized,
286    CalculatorAddResponse: ::fidl_next::EncodeRef<___E>,
287{
288    #[inline]
289    fn encode_option_ref(
290        this: Option<&Self>,
291        encoder: &mut ___E,
292        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
293    ) -> Result<(), ::fidl_next::EncodeError> {
294        if let Some(inner) = this {
295            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
296            ::fidl_next::WireBox::encode_present(out);
297        } else {
298            ::fidl_next::WireBox::encode_absent(out);
299        }
300
301        Ok(())
302    }
303}
304
305impl ::fidl_next::FromWire<WireCalculatorAddResponse> for CalculatorAddResponse {
306    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireCalculatorAddResponse, Self> = unsafe {
307        ::fidl_next::CopyOptimization::enable_if(
308            true && <i32 as ::fidl_next::FromWire<::fidl_next::WireI32>>::COPY_OPTIMIZATION
309                .is_enabled(),
310        )
311    };
312
313    #[inline]
314    fn from_wire(wire: WireCalculatorAddResponse) -> Self {
315        Self { sum: ::fidl_next::FromWire::from_wire(wire.sum) }
316    }
317}
318
319impl ::fidl_next::FromWireRef<WireCalculatorAddResponse> for CalculatorAddResponse {
320    #[inline]
321    fn from_wire_ref(wire: &WireCalculatorAddResponse) -> Self {
322        Self { sum: ::fidl_next::FromWireRef::from_wire_ref(&wire.sum) }
323    }
324}
325
326/// The wire type corresponding to [`CalculatorAddResponse`].
327#[derive(Clone, Debug)]
328#[repr(C)]
329pub struct WireCalculatorAddResponse {
330    pub sum: ::fidl_next::WireI32,
331}
332
333unsafe impl ::fidl_next::Wire for WireCalculatorAddResponse {
334    type Decoded<'de> = WireCalculatorAddResponse;
335
336    #[inline]
337    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
338}
339
340unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorAddResponse
341where
342    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
343{
344    fn decode(
345        slot: ::fidl_next::Slot<'_, Self>,
346        decoder: &mut ___D,
347    ) -> Result<(), ::fidl_next::DecodeError> {
348        ::fidl_next::munge! {
349            let Self {
350                mut sum,
351
352            } = slot;
353        }
354
355        ::fidl_next::Decode::decode(sum.as_mut(), decoder)?;
356
357        Ok(())
358    }
359}
360
361#[derive(Clone, Debug)]
362#[repr(C)]
363pub struct CalculatorDivideRequest {
364    pub dividend: i32,
365
366    pub divisor: i32,
367}
368
369impl ::fidl_next::Encodable for CalculatorDivideRequest {
370    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireCalculatorDivideRequest> = unsafe {
371        ::fidl_next::CopyOptimization::enable_if(
372            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
373                && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
374        )
375    };
376
377    type Encoded = WireCalculatorDivideRequest;
378}
379
380unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideRequest
381where
382    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
383{
384    #[inline]
385    fn encode(
386        self,
387        encoder: &mut ___E,
388        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
389    ) -> Result<(), ::fidl_next::EncodeError> {
390        ::fidl_next::munge! {
391            let Self::Encoded {
392                dividend,
393                divisor,
394
395            } = out;
396        }
397
398        ::fidl_next::Encode::encode(self.dividend, encoder, dividend)?;
399
400        ::fidl_next::Encode::encode(self.divisor, encoder, divisor)?;
401
402        Ok(())
403    }
404}
405
406unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorDivideRequest
407where
408    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
409{
410    #[inline]
411    fn encode_ref(
412        &self,
413        encoder: &mut ___E,
414        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
415    ) -> Result<(), ::fidl_next::EncodeError> {
416        ::fidl_next::munge! {
417            let Self::Encoded {
418                dividend,
419                divisor,
420
421            } = out;
422        }
423
424        ::fidl_next::EncodeRef::encode_ref(&self.dividend, encoder, dividend)?;
425
426        ::fidl_next::EncodeRef::encode_ref(&self.divisor, encoder, divisor)?;
427
428        Ok(())
429    }
430}
431
432impl ::fidl_next::EncodableOption for CalculatorDivideRequest {
433    type EncodedOption = ::fidl_next::WireBox<'static, WireCalculatorDivideRequest>;
434}
435
436unsafe impl<___E> ::fidl_next::EncodeOption<___E> for CalculatorDivideRequest
437where
438    ___E: ::fidl_next::Encoder + ?Sized,
439    CalculatorDivideRequest: ::fidl_next::Encode<___E>,
440{
441    #[inline]
442    fn encode_option(
443        this: Option<Self>,
444        encoder: &mut ___E,
445        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
446    ) -> Result<(), ::fidl_next::EncodeError> {
447        if let Some(inner) = this {
448            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
449            ::fidl_next::WireBox::encode_present(out);
450        } else {
451            ::fidl_next::WireBox::encode_absent(out);
452        }
453
454        Ok(())
455    }
456}
457
458unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for CalculatorDivideRequest
459where
460    ___E: ::fidl_next::Encoder + ?Sized,
461    CalculatorDivideRequest: ::fidl_next::EncodeRef<___E>,
462{
463    #[inline]
464    fn encode_option_ref(
465        this: Option<&Self>,
466        encoder: &mut ___E,
467        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
468    ) -> Result<(), ::fidl_next::EncodeError> {
469        if let Some(inner) = this {
470            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
471            ::fidl_next::WireBox::encode_present(out);
472        } else {
473            ::fidl_next::WireBox::encode_absent(out);
474        }
475
476        Ok(())
477    }
478}
479
480impl ::fidl_next::FromWire<WireCalculatorDivideRequest> for CalculatorDivideRequest {
481    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireCalculatorDivideRequest, Self> = unsafe {
482        ::fidl_next::CopyOptimization::enable_if(
483            true && <i32 as ::fidl_next::FromWire<::fidl_next::WireI32>>::COPY_OPTIMIZATION
484                .is_enabled()
485                && <i32 as ::fidl_next::FromWire<::fidl_next::WireI32>>::COPY_OPTIMIZATION
486                    .is_enabled(),
487        )
488    };
489
490    #[inline]
491    fn from_wire(wire: WireCalculatorDivideRequest) -> Self {
492        Self {
493            dividend: ::fidl_next::FromWire::from_wire(wire.dividend),
494
495            divisor: ::fidl_next::FromWire::from_wire(wire.divisor),
496        }
497    }
498}
499
500impl ::fidl_next::FromWireRef<WireCalculatorDivideRequest> for CalculatorDivideRequest {
501    #[inline]
502    fn from_wire_ref(wire: &WireCalculatorDivideRequest) -> Self {
503        Self {
504            dividend: ::fidl_next::FromWireRef::from_wire_ref(&wire.dividend),
505
506            divisor: ::fidl_next::FromWireRef::from_wire_ref(&wire.divisor),
507        }
508    }
509}
510
511/// The wire type corresponding to [`CalculatorDivideRequest`].
512#[derive(Clone, Debug)]
513#[repr(C)]
514pub struct WireCalculatorDivideRequest {
515    pub dividend: ::fidl_next::WireI32,
516
517    pub divisor: ::fidl_next::WireI32,
518}
519
520unsafe impl ::fidl_next::Wire for WireCalculatorDivideRequest {
521    type Decoded<'de> = WireCalculatorDivideRequest;
522
523    #[inline]
524    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
525}
526
527unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorDivideRequest
528where
529    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
530{
531    fn decode(
532        slot: ::fidl_next::Slot<'_, Self>,
533        decoder: &mut ___D,
534    ) -> Result<(), ::fidl_next::DecodeError> {
535        ::fidl_next::munge! {
536            let Self {
537                mut dividend,
538                mut divisor,
539
540            } = slot;
541        }
542
543        ::fidl_next::Decode::decode(dividend.as_mut(), decoder)?;
544
545        ::fidl_next::Decode::decode(divisor.as_mut(), decoder)?;
546
547        Ok(())
548    }
549}
550
551#[derive(Clone, Debug)]
552#[repr(C)]
553pub struct CalculatorDivideResponse {
554    pub quotient: i32,
555
556    pub remainder: i32,
557}
558
559impl ::fidl_next::Encodable for CalculatorDivideResponse {
560    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireCalculatorDivideResponse> = unsafe {
561        ::fidl_next::CopyOptimization::enable_if(
562            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
563                && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
564        )
565    };
566
567    type Encoded = WireCalculatorDivideResponse;
568}
569
570unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideResponse
571where
572    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
573{
574    #[inline]
575    fn encode(
576        self,
577        encoder: &mut ___E,
578        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
579    ) -> Result<(), ::fidl_next::EncodeError> {
580        ::fidl_next::munge! {
581            let Self::Encoded {
582                quotient,
583                remainder,
584
585            } = out;
586        }
587
588        ::fidl_next::Encode::encode(self.quotient, encoder, quotient)?;
589
590        ::fidl_next::Encode::encode(self.remainder, encoder, remainder)?;
591
592        Ok(())
593    }
594}
595
596unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorDivideResponse
597where
598    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
599{
600    #[inline]
601    fn encode_ref(
602        &self,
603        encoder: &mut ___E,
604        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
605    ) -> Result<(), ::fidl_next::EncodeError> {
606        ::fidl_next::munge! {
607            let Self::Encoded {
608                quotient,
609                remainder,
610
611            } = out;
612        }
613
614        ::fidl_next::EncodeRef::encode_ref(&self.quotient, encoder, quotient)?;
615
616        ::fidl_next::EncodeRef::encode_ref(&self.remainder, encoder, remainder)?;
617
618        Ok(())
619    }
620}
621
622impl ::fidl_next::EncodableOption for CalculatorDivideResponse {
623    type EncodedOption = ::fidl_next::WireBox<'static, WireCalculatorDivideResponse>;
624}
625
626unsafe impl<___E> ::fidl_next::EncodeOption<___E> for CalculatorDivideResponse
627where
628    ___E: ::fidl_next::Encoder + ?Sized,
629    CalculatorDivideResponse: ::fidl_next::Encode<___E>,
630{
631    #[inline]
632    fn encode_option(
633        this: Option<Self>,
634        encoder: &mut ___E,
635        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
636    ) -> Result<(), ::fidl_next::EncodeError> {
637        if let Some(inner) = this {
638            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
639            ::fidl_next::WireBox::encode_present(out);
640        } else {
641            ::fidl_next::WireBox::encode_absent(out);
642        }
643
644        Ok(())
645    }
646}
647
648unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for CalculatorDivideResponse
649where
650    ___E: ::fidl_next::Encoder + ?Sized,
651    CalculatorDivideResponse: ::fidl_next::EncodeRef<___E>,
652{
653    #[inline]
654    fn encode_option_ref(
655        this: Option<&Self>,
656        encoder: &mut ___E,
657        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
658    ) -> Result<(), ::fidl_next::EncodeError> {
659        if let Some(inner) = this {
660            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
661            ::fidl_next::WireBox::encode_present(out);
662        } else {
663            ::fidl_next::WireBox::encode_absent(out);
664        }
665
666        Ok(())
667    }
668}
669
670impl ::fidl_next::FromWire<WireCalculatorDivideResponse> for CalculatorDivideResponse {
671    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireCalculatorDivideResponse, Self> = unsafe {
672        ::fidl_next::CopyOptimization::enable_if(
673            true && <i32 as ::fidl_next::FromWire<::fidl_next::WireI32>>::COPY_OPTIMIZATION
674                .is_enabled()
675                && <i32 as ::fidl_next::FromWire<::fidl_next::WireI32>>::COPY_OPTIMIZATION
676                    .is_enabled(),
677        )
678    };
679
680    #[inline]
681    fn from_wire(wire: WireCalculatorDivideResponse) -> Self {
682        Self {
683            quotient: ::fidl_next::FromWire::from_wire(wire.quotient),
684
685            remainder: ::fidl_next::FromWire::from_wire(wire.remainder),
686        }
687    }
688}
689
690impl ::fidl_next::FromWireRef<WireCalculatorDivideResponse> for CalculatorDivideResponse {
691    #[inline]
692    fn from_wire_ref(wire: &WireCalculatorDivideResponse) -> Self {
693        Self {
694            quotient: ::fidl_next::FromWireRef::from_wire_ref(&wire.quotient),
695
696            remainder: ::fidl_next::FromWireRef::from_wire_ref(&wire.remainder),
697        }
698    }
699}
700
701/// The wire type corresponding to [`CalculatorDivideResponse`].
702#[derive(Clone, Debug)]
703#[repr(C)]
704pub struct WireCalculatorDivideResponse {
705    pub quotient: ::fidl_next::WireI32,
706
707    pub remainder: ::fidl_next::WireI32,
708}
709
710unsafe impl ::fidl_next::Wire for WireCalculatorDivideResponse {
711    type Decoded<'de> = WireCalculatorDivideResponse;
712
713    #[inline]
714    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
715}
716
717unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorDivideResponse
718where
719    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
720{
721    fn decode(
722        slot: ::fidl_next::Slot<'_, Self>,
723        decoder: &mut ___D,
724    ) -> Result<(), ::fidl_next::DecodeError> {
725        ::fidl_next::munge! {
726            let Self {
727                mut quotient,
728                mut remainder,
729
730            } = slot;
731        }
732
733        ::fidl_next::Decode::decode(quotient.as_mut(), decoder)?;
734
735        ::fidl_next::Decode::decode(remainder.as_mut(), decoder)?;
736
737        Ok(())
738    }
739}
740
741#[derive(Clone, Copy, Debug, PartialEq, Eq)]
742#[repr(u32)]
743pub enum DivisionError {
744    DivideByZero = 1,
745}
746
747impl ::fidl_next::Encodable for DivisionError {
748    type Encoded = WireDivisionError;
749}
750impl ::std::convert::TryFrom<u32> for DivisionError {
751    type Error = ::fidl_next::UnknownStrictEnumMemberError;
752    fn try_from(value: u32) -> Result<Self, Self::Error> {
753        match value {
754            1 => Ok(Self::DivideByZero),
755
756            _ => Err(Self::Error::new(value.into())),
757        }
758    }
759}
760
761unsafe impl<___E> ::fidl_next::Encode<___E> for DivisionError
762where
763    ___E: ?Sized,
764{
765    #[inline]
766    fn encode(
767        self,
768        encoder: &mut ___E,
769        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
770    ) -> Result<(), ::fidl_next::EncodeError> {
771        ::fidl_next::EncodeRef::encode_ref(&self, encoder, out)
772    }
773}
774
775unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DivisionError
776where
777    ___E: ?Sized,
778{
779    #[inline]
780    fn encode_ref(
781        &self,
782        encoder: &mut ___E,
783        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
784    ) -> Result<(), ::fidl_next::EncodeError> {
785        ::fidl_next::munge!(let WireDivisionError { value } = out);
786        let _ = value.write(::fidl_next::WireU32::from(match *self {
787            Self::DivideByZero => 1,
788        }));
789
790        Ok(())
791    }
792}
793
794impl ::core::convert::From<WireDivisionError> for DivisionError {
795    fn from(wire: WireDivisionError) -> Self {
796        match u32::from(wire.value) {
797            1 => Self::DivideByZero,
798
799            _ => unsafe { ::core::hint::unreachable_unchecked() },
800        }
801    }
802}
803
804impl ::fidl_next::FromWire<WireDivisionError> for DivisionError {
805    #[inline]
806    fn from_wire(wire: WireDivisionError) -> Self {
807        Self::from(wire)
808    }
809}
810
811impl ::fidl_next::FromWireRef<WireDivisionError> for DivisionError {
812    #[inline]
813    fn from_wire_ref(wire: &WireDivisionError) -> Self {
814        Self::from(*wire)
815    }
816}
817
818/// The wire type corresponding to [`DivisionError`].
819#[derive(Clone, Copy, Debug, PartialEq, Eq)]
820#[repr(transparent)]
821pub struct WireDivisionError {
822    value: ::fidl_next::WireU32,
823}
824
825unsafe impl ::fidl_next::Wire for WireDivisionError {
826    type Decoded<'de> = Self;
827
828    #[inline]
829    fn zero_padding(_: &mut ::core::mem::MaybeUninit<Self>) {
830        // Wire enums have no padding
831    }
832}
833
834impl WireDivisionError {
835    pub const DIVIDE_BY_ZERO: WireDivisionError =
836        WireDivisionError { value: ::fidl_next::WireU32(1) };
837}
838
839unsafe impl<___D> ::fidl_next::Decode<___D> for WireDivisionError
840where
841    ___D: ?Sized,
842{
843    fn decode(
844        slot: ::fidl_next::Slot<'_, Self>,
845        _: &mut ___D,
846    ) -> Result<(), ::fidl_next::DecodeError> {
847        ::fidl_next::munge!(let Self { value } = slot);
848
849        match u32::from(*value) {
850            1 => (),
851            unknown => return Err(::fidl_next::DecodeError::InvalidEnumOrdinal(unknown as i128)),
852        }
853
854        Ok(())
855    }
856}
857
858impl ::core::convert::From<DivisionError> for WireDivisionError {
859    fn from(natural: DivisionError) -> Self {
860        match natural {
861            DivisionError::DivideByZero => WireDivisionError::DIVIDE_BY_ZERO,
862        }
863    }
864}
865
866#[derive(Clone, Debug)]
867#[repr(C)]
868pub struct CalculatorOnErrorRequest {
869    pub status_code: u32,
870}
871
872impl ::fidl_next::Encodable for CalculatorOnErrorRequest {
873    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireCalculatorOnErrorRequest> = unsafe {
874        ::fidl_next::CopyOptimization::enable_if(
875            true && <u32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
876        )
877    };
878
879    type Encoded = WireCalculatorOnErrorRequest;
880}
881
882unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorOnErrorRequest
883where
884    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
885{
886    #[inline]
887    fn encode(
888        self,
889        encoder: &mut ___E,
890        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
891    ) -> Result<(), ::fidl_next::EncodeError> {
892        ::fidl_next::munge! {
893            let Self::Encoded {
894                status_code,
895
896            } = out;
897        }
898
899        ::fidl_next::Encode::encode(self.status_code, encoder, status_code)?;
900
901        Ok(())
902    }
903}
904
905unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorOnErrorRequest
906where
907    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
908{
909    #[inline]
910    fn encode_ref(
911        &self,
912        encoder: &mut ___E,
913        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
914    ) -> Result<(), ::fidl_next::EncodeError> {
915        ::fidl_next::munge! {
916            let Self::Encoded {
917                status_code,
918
919            } = out;
920        }
921
922        ::fidl_next::EncodeRef::encode_ref(&self.status_code, encoder, status_code)?;
923
924        Ok(())
925    }
926}
927
928impl ::fidl_next::EncodableOption for CalculatorOnErrorRequest {
929    type EncodedOption = ::fidl_next::WireBox<'static, WireCalculatorOnErrorRequest>;
930}
931
932unsafe impl<___E> ::fidl_next::EncodeOption<___E> for CalculatorOnErrorRequest
933where
934    ___E: ::fidl_next::Encoder + ?Sized,
935    CalculatorOnErrorRequest: ::fidl_next::Encode<___E>,
936{
937    #[inline]
938    fn encode_option(
939        this: Option<Self>,
940        encoder: &mut ___E,
941        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
942    ) -> Result<(), ::fidl_next::EncodeError> {
943        if let Some(inner) = this {
944            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
945            ::fidl_next::WireBox::encode_present(out);
946        } else {
947            ::fidl_next::WireBox::encode_absent(out);
948        }
949
950        Ok(())
951    }
952}
953
954unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for CalculatorOnErrorRequest
955where
956    ___E: ::fidl_next::Encoder + ?Sized,
957    CalculatorOnErrorRequest: ::fidl_next::EncodeRef<___E>,
958{
959    #[inline]
960    fn encode_option_ref(
961        this: Option<&Self>,
962        encoder: &mut ___E,
963        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
964    ) -> Result<(), ::fidl_next::EncodeError> {
965        if let Some(inner) = this {
966            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
967            ::fidl_next::WireBox::encode_present(out);
968        } else {
969            ::fidl_next::WireBox::encode_absent(out);
970        }
971
972        Ok(())
973    }
974}
975
976impl ::fidl_next::FromWire<WireCalculatorOnErrorRequest> for CalculatorOnErrorRequest {
977    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireCalculatorOnErrorRequest, Self> = unsafe {
978        ::fidl_next::CopyOptimization::enable_if(
979            true && <u32 as ::fidl_next::FromWire<::fidl_next::WireU32>>::COPY_OPTIMIZATION
980                .is_enabled(),
981        )
982    };
983
984    #[inline]
985    fn from_wire(wire: WireCalculatorOnErrorRequest) -> Self {
986        Self { status_code: ::fidl_next::FromWire::from_wire(wire.status_code) }
987    }
988}
989
990impl ::fidl_next::FromWireRef<WireCalculatorOnErrorRequest> for CalculatorOnErrorRequest {
991    #[inline]
992    fn from_wire_ref(wire: &WireCalculatorOnErrorRequest) -> Self {
993        Self { status_code: ::fidl_next::FromWireRef::from_wire_ref(&wire.status_code) }
994    }
995}
996
997/// The wire type corresponding to [`CalculatorOnErrorRequest`].
998#[derive(Clone, Debug)]
999#[repr(C)]
1000pub struct WireCalculatorOnErrorRequest {
1001    pub status_code: ::fidl_next::WireU32,
1002}
1003
1004unsafe impl ::fidl_next::Wire for WireCalculatorOnErrorRequest {
1005    type Decoded<'de> = WireCalculatorOnErrorRequest;
1006
1007    #[inline]
1008    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
1009}
1010
1011unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorOnErrorRequest
1012where
1013    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
1014{
1015    fn decode(
1016        slot: ::fidl_next::Slot<'_, Self>,
1017        decoder: &mut ___D,
1018    ) -> Result<(), ::fidl_next::DecodeError> {
1019        ::fidl_next::munge! {
1020            let Self {
1021                mut status_code,
1022
1023            } = slot;
1024        }
1025
1026        ::fidl_next::Decode::decode(status_code.as_mut(), decoder)?;
1027
1028        Ok(())
1029    }
1030}
1031
1032/// The type corresponding to the Calculator protocol.
1033#[derive(Debug)]
1034pub struct Calculator;
1035
1036pub mod calculator {
1037    pub mod prelude {
1038        pub use crate::{Calculator, CalculatorClientHandler, CalculatorServerHandler, calculator};
1039
1040        pub use crate::CalculatorAddRequest;
1041
1042        pub use crate::CalculatorDivideRequest;
1043
1044        pub use crate::CalculatorOnErrorRequest;
1045
1046        pub use crate::CalculatorAddResponse;
1047
1048        pub use crate::CalculatorDivideResponse;
1049
1050        pub use crate::DivisionError;
1051    }
1052
1053    pub struct Add;
1054
1055    impl ::fidl_next::Method for Add {
1056        const ORDINAL: u64 = 8640324702111165953;
1057
1058        type Protocol = crate::Calculator;
1059
1060        type Request = crate::WireCalculatorAddRequest;
1061
1062        type Response = ::fidl_next::WireFlexible<'static, crate::WireCalculatorAddResponse>;
1063    }
1064
1065    pub struct Divide;
1066
1067    impl ::fidl_next::Method for Divide {
1068        const ORDINAL: u64 = 5497947425807432439;
1069
1070        type Protocol = crate::Calculator;
1071
1072        type Request = crate::WireCalculatorDivideRequest;
1073
1074        type Response = ::fidl_next::WireFlexibleResult<
1075            'static,
1076            crate::WireCalculatorDivideResponse,
1077            crate::WireDivisionError,
1078        >;
1079    }
1080
1081    pub struct Clear;
1082
1083    impl ::fidl_next::Method for Clear {
1084        const ORDINAL: u64 = 7439411180362570889;
1085
1086        type Protocol = crate::Calculator;
1087
1088        type Request = ();
1089
1090        type Response = ::fidl_next::Never;
1091    }
1092
1093    pub struct OnError;
1094
1095    impl ::fidl_next::Method for OnError {
1096        const ORDINAL: u64 = 8940578522385404924;
1097
1098        type Protocol = crate::Calculator;
1099
1100        type Request = ::fidl_next::Never;
1101
1102        type Response = crate::WireCalculatorOnErrorRequest;
1103    }
1104
1105    mod ___detail {
1106
1107        pub struct Add<T0, T1> {
1108            a: T0,
1109
1110            b: T1,
1111        }
1112
1113        impl<T0, T1> ::fidl_next::Encodable for Add<T0, T1>
1114        where
1115            T0: ::fidl_next::Encodable<Encoded = ::fidl_next::WireI32>,
1116            T1: ::fidl_next::Encodable<Encoded = ::fidl_next::WireI32>,
1117        {
1118            type Encoded = crate::WireCalculatorAddRequest;
1119        }
1120
1121        unsafe impl<___E, T0, T1> ::fidl_next::Encode<___E> for Add<T0, T1>
1122        where
1123            ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
1124            T0: ::fidl_next::Encode<___E, Encoded = ::fidl_next::WireI32>,
1125            T1: ::fidl_next::Encode<___E, Encoded = ::fidl_next::WireI32>,
1126        {
1127            #[inline]
1128            fn encode(
1129                self,
1130                encoder: &mut ___E,
1131                out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
1132            ) -> Result<(), ::fidl_next::EncodeError> {
1133                ::fidl_next::munge! {
1134                    let Self::Encoded {
1135                        a,
1136                        b,
1137
1138                    } = out;
1139                }
1140
1141                ::fidl_next::Encode::encode(self.a, encoder, a)?;
1142
1143                ::fidl_next::Encode::encode(self.b, encoder, b)?;
1144
1145                Ok(())
1146            }
1147        }
1148
1149        pub struct Divide<T0, T1> {
1150            dividend: T0,
1151
1152            divisor: T1,
1153        }
1154
1155        impl<T0, T1> ::fidl_next::Encodable for Divide<T0, T1>
1156        where
1157            T0: ::fidl_next::Encodable<Encoded = ::fidl_next::WireI32>,
1158            T1: ::fidl_next::Encodable<Encoded = ::fidl_next::WireI32>,
1159        {
1160            type Encoded = crate::WireCalculatorDivideRequest;
1161        }
1162
1163        unsafe impl<___E, T0, T1> ::fidl_next::Encode<___E> for Divide<T0, T1>
1164        where
1165            ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
1166            T0: ::fidl_next::Encode<___E, Encoded = ::fidl_next::WireI32>,
1167            T1: ::fidl_next::Encode<___E, Encoded = ::fidl_next::WireI32>,
1168        {
1169            #[inline]
1170            fn encode(
1171                self,
1172                encoder: &mut ___E,
1173                out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
1174            ) -> Result<(), ::fidl_next::EncodeError> {
1175                ::fidl_next::munge! {
1176                    let Self::Encoded {
1177                        dividend,
1178                        divisor,
1179
1180                    } = out;
1181                }
1182
1183                ::fidl_next::Encode::encode(self.dividend, encoder, dividend)?;
1184
1185                ::fidl_next::Encode::encode(self.divisor, encoder, divisor)?;
1186
1187                Ok(())
1188            }
1189        }
1190
1191        pub struct OnError<T0> {
1192            status_code: T0,
1193        }
1194
1195        impl<T0> ::fidl_next::Encodable for OnError<T0>
1196        where
1197            T0: ::fidl_next::Encodable<Encoded = ::fidl_next::WireU32>,
1198        {
1199            type Encoded = crate::WireCalculatorOnErrorRequest;
1200        }
1201
1202        unsafe impl<___E, T0> ::fidl_next::Encode<___E> for OnError<T0>
1203        where
1204            ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
1205            T0: ::fidl_next::Encode<___E, Encoded = ::fidl_next::WireU32>,
1206        {
1207            #[inline]
1208            fn encode(
1209                self,
1210                encoder: &mut ___E,
1211                out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
1212            ) -> Result<(), ::fidl_next::EncodeError> {
1213                ::fidl_next::munge! {
1214                    let Self::Encoded {
1215                        status_code,
1216
1217                    } = out;
1218                }
1219
1220                ::fidl_next::Encode::encode(self.status_code, encoder, status_code)?;
1221
1222                Ok(())
1223            }
1224        }
1225
1226        unsafe impl<___T> ::fidl_next::Protocol<___T> for crate::Calculator
1227        where
1228            ___T: ::fidl_next::Transport,
1229        {
1230            type ClientSender = CalculatorClientSender<___T>;
1231            type ServerSender = CalculatorServerSender<___T>;
1232        }
1233
1234        /// The client sender for the `Calculator` protocol.
1235        #[repr(transparent)]
1236        pub struct CalculatorClientSender<___T: ::fidl_next::Transport> {
1237            #[allow(dead_code)]
1238            sender: ::fidl_next::protocol::ClientSender<___T>,
1239        }
1240
1241        impl<___T> CalculatorClientSender<___T>
1242        where
1243            ___T: ::fidl_next::Transport,
1244        {
1245            pub fn add(
1246                &self,
1247
1248                a: impl ::fidl_next::Encode<
1249                    <___T as ::fidl_next::Transport>::SendBuffer,
1250                    Encoded = ::fidl_next::WireI32,
1251                >,
1252
1253                b: impl ::fidl_next::Encode<
1254                    <___T as ::fidl_next::Transport>::SendBuffer,
1255                    Encoded = ::fidl_next::WireI32,
1256                >,
1257            ) -> ::fidl_next::TwoWayFuture<'_, super::Add, ___T>
1258            where
1259                <___T as ::fidl_next::Transport>::SendBuffer:
1260                    ::fidl_next::encoder::InternalHandleEncoder,
1261            {
1262                self.add_with(Add { a, b })
1263            }
1264
1265            pub fn add_with<___R>(
1266                &self,
1267                request: ___R,
1268            ) -> ::fidl_next::TwoWayFuture<'_, super::Add, ___T>
1269            where
1270                ___R: ::fidl_next::Encode<
1271                        <___T as ::fidl_next::Transport>::SendBuffer,
1272                        Encoded = crate::WireCalculatorAddRequest,
1273                    >,
1274            {
1275                ::fidl_next::TwoWayFuture::from_untyped(
1276                    self.sender.send_two_way(8640324702111165953, request),
1277                )
1278            }
1279
1280            pub fn divide(
1281                &self,
1282
1283                dividend: impl ::fidl_next::Encode<
1284                    <___T as ::fidl_next::Transport>::SendBuffer,
1285                    Encoded = ::fidl_next::WireI32,
1286                >,
1287
1288                divisor: impl ::fidl_next::Encode<
1289                    <___T as ::fidl_next::Transport>::SendBuffer,
1290                    Encoded = ::fidl_next::WireI32,
1291                >,
1292            ) -> ::fidl_next::TwoWayFuture<'_, super::Divide, ___T>
1293            where
1294                <___T as ::fidl_next::Transport>::SendBuffer:
1295                    ::fidl_next::encoder::InternalHandleEncoder,
1296            {
1297                self.divide_with(Divide { dividend, divisor })
1298            }
1299
1300            pub fn divide_with<___R>(
1301                &self,
1302                request: ___R,
1303            ) -> ::fidl_next::TwoWayFuture<'_, super::Divide, ___T>
1304            where
1305                ___R: ::fidl_next::Encode<
1306                        <___T as ::fidl_next::Transport>::SendBuffer,
1307                        Encoded = crate::WireCalculatorDivideRequest,
1308                    >,
1309            {
1310                ::fidl_next::TwoWayFuture::from_untyped(
1311                    self.sender.send_two_way(5497947425807432439, request),
1312                )
1313            }
1314
1315            pub fn clear(&self) -> ::fidl_next::SendFuture<'_, ___T> {
1316                ::fidl_next::SendFuture::from_untyped(
1317                    self.sender.send_one_way(7439411180362570889, ()),
1318                )
1319            }
1320        }
1321
1322        /// The server sender for the `Calculator` protocol.
1323        #[repr(transparent)]
1324        pub struct CalculatorServerSender<___T: ::fidl_next::Transport> {
1325            sender: ::fidl_next::protocol::ServerSender<___T>,
1326        }
1327
1328        impl<___T> CalculatorServerSender<___T>
1329        where
1330            ___T: ::fidl_next::Transport,
1331        {
1332            pub fn on_error(
1333                &self,
1334
1335                status_code: impl ::fidl_next::Encode<
1336                    <___T as ::fidl_next::Transport>::SendBuffer,
1337                    Encoded = ::fidl_next::WireU32,
1338                >,
1339            ) -> ::fidl_next::SendFuture<'_, ___T>
1340            where
1341                <___T as ::fidl_next::Transport>::SendBuffer:
1342                    ::fidl_next::encoder::InternalHandleEncoder,
1343            {
1344                self.on_error_with(OnError { status_code })
1345            }
1346
1347            pub fn on_error_with<___R>(&self, request: ___R) -> ::fidl_next::SendFuture<'_, ___T>
1348            where
1349                ___R: ::fidl_next::Encode<
1350                        <___T as ::fidl_next::Transport>::SendBuffer,
1351                        Encoded = <super::OnError as ::fidl_next::Method>::Response,
1352                    >,
1353            {
1354                ::fidl_next::SendFuture::from_untyped(
1355                    self.sender.send_event(8940578522385404924, request),
1356                )
1357            }
1358        }
1359    }
1360}
1361
1362/// A client handler for the Calculator protocol.
1363///
1364/// See [`Calculator`] for more details.
1365pub trait CalculatorClientHandler<
1366    #[cfg(not(feature = "fuchsia"))] ___T: ::fidl_next::Transport,
1367    #[cfg(feature = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
1368>
1369{
1370    fn on_error(
1371        &mut self,
1372        sender: &::fidl_next::ClientSender<Calculator, ___T>,
1373
1374        event: ::fidl_next::Response<calculator::OnError, ___T>,
1375    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
1376
1377    fn on_unknown_interaction(
1378        &mut self,
1379        sender: &::fidl_next::ClientSender<Calculator, ___T>,
1380        ordinal: u64,
1381    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
1382        sender.close();
1383        ::core::future::ready(())
1384    }
1385}
1386
1387impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Calculator
1388where
1389    ___H: CalculatorClientHandler<___T> + ::core::marker::Send,
1390    ___T: ::fidl_next::Transport,
1391    <calculator::Add as ::fidl_next::Method>::Response:
1392        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1393    <calculator::Divide as ::fidl_next::Method>::Response:
1394        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1395    <calculator::OnError as ::fidl_next::Method>::Response:
1396        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1397{
1398    async fn on_event(
1399        handler: &mut ___H,
1400        sender: &::fidl_next::ClientSender<Self, ___T>,
1401        ordinal: u64,
1402        buffer: ___T::RecvBuffer,
1403    ) {
1404        match ordinal {
1405            8940578522385404924 => match ::fidl_next::DecoderExt::decode(buffer) {
1406                Ok(decoded) => handler.on_error(sender, decoded).await,
1407                Err(e) => sender.close(),
1408            },
1409
1410            ordinal => handler.on_unknown_interaction(sender, ordinal).await,
1411        }
1412    }
1413}
1414
1415/// A server handler for the Calculator protocol.
1416///
1417/// See [`Calculator`] for more details.
1418pub trait CalculatorServerHandler<
1419    #[cfg(not(feature = "fuchsia"))] ___T: ::fidl_next::Transport,
1420    #[cfg(feature = "fuchsia")] ___T: ::fidl_next::Transport = ::fidl_next::fuchsia::zx::Channel,
1421>
1422{
1423    fn add(
1424        &mut self,
1425        sender: &::fidl_next::ServerSender<Calculator, ___T>,
1426
1427        request: ::fidl_next::Request<calculator::Add, ___T>,
1428
1429        responder: ::fidl_next::Responder<calculator::Add>,
1430    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
1431
1432    fn divide(
1433        &mut self,
1434        sender: &::fidl_next::ServerSender<Calculator, ___T>,
1435
1436        request: ::fidl_next::Request<calculator::Divide, ___T>,
1437
1438        responder: ::fidl_next::Responder<calculator::Divide>,
1439    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
1440
1441    fn clear(
1442        &mut self,
1443        sender: &::fidl_next::ServerSender<Calculator, ___T>,
1444    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
1445
1446    fn on_unknown_interaction(
1447        &mut self,
1448        sender: &::fidl_next::ServerSender<Calculator, ___T>,
1449        ordinal: u64,
1450    ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send {
1451        sender.close();
1452        ::core::future::ready(())
1453    }
1454}
1455
1456impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Calculator
1457where
1458    ___H: CalculatorServerHandler<___T> + ::core::marker::Send,
1459    ___T: ::fidl_next::Transport,
1460    <calculator::Add as ::fidl_next::Method>::Request:
1461        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1462    <calculator::Divide as ::fidl_next::Method>::Request:
1463        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1464{
1465    async fn on_one_way(
1466        handler: &mut ___H,
1467        sender: &::fidl_next::ServerSender<Self, ___T>,
1468        ordinal: u64,
1469        buffer: ___T::RecvBuffer,
1470    ) {
1471        match ordinal {
1472            7439411180362570889 => {
1473                handler.clear(sender).await;
1474            }
1475
1476            ordinal => handler.on_unknown_interaction(sender, ordinal).await,
1477        }
1478    }
1479
1480    async fn on_two_way(
1481        handler: &mut ___H,
1482        sender: &::fidl_next::ServerSender<Self, ___T>,
1483        ordinal: u64,
1484        buffer: ___T::RecvBuffer,
1485        responder: ::fidl_next::protocol::Responder,
1486    ) {
1487        match ordinal {
1488            8640324702111165953 => {
1489                let responder = ::fidl_next::Responder::from_untyped(responder);
1490
1491                match ::fidl_next::DecoderExt::decode(buffer) {
1492                    Ok(decoded) => handler.add(sender, decoded, responder).await,
1493                    Err(e) => sender.close(),
1494                }
1495            }
1496
1497            5497947425807432439 => {
1498                let responder = ::fidl_next::Responder::from_untyped(responder);
1499
1500                match ::fidl_next::DecoderExt::decode(buffer) {
1501                    Ok(decoded) => handler.divide(sender, decoded, responder).await,
1502                    Err(e) => sender.close(),
1503                }
1504            }
1505
1506            ordinal => handler.on_unknown_interaction(sender, ordinal).await,
1507        }
1508    }
1509}
1510
1511/// Compatibility shims which mimic some API surfaces of the current Rust bindings.
1512pub mod compat {
1513
1514    impl ::fidl_next::CompatFrom<crate::CalculatorAddRequest>
1515        for ::fidl_examples_calculator::CalculatorAddRequest
1516    {
1517        #[inline]
1518        fn compat_from(value: crate::CalculatorAddRequest) -> Self {
1519            Self {
1520                a: ::fidl_next::CompatFrom::compat_from(value.a),
1521
1522                b: ::fidl_next::CompatFrom::compat_from(value.b),
1523            }
1524        }
1525    }
1526
1527    impl ::fidl_next::CompatFrom<::fidl_examples_calculator::CalculatorAddRequest>
1528        for crate::CalculatorAddRequest
1529    {
1530        #[inline]
1531        fn compat_from(value: ::fidl_examples_calculator::CalculatorAddRequest) -> Self {
1532            Self {
1533                a: ::fidl_next::CompatFrom::compat_from(value.a),
1534
1535                b: ::fidl_next::CompatFrom::compat_from(value.b),
1536            }
1537        }
1538    }
1539
1540    impl ::fidl_next::CompatFrom<crate::CalculatorAddResponse>
1541        for ::fidl_examples_calculator::CalculatorAddResponse
1542    {
1543        #[inline]
1544        fn compat_from(value: crate::CalculatorAddResponse) -> Self {
1545            Self { sum: ::fidl_next::CompatFrom::compat_from(value.sum) }
1546        }
1547    }
1548
1549    impl ::fidl_next::CompatFrom<::fidl_examples_calculator::CalculatorAddResponse>
1550        for crate::CalculatorAddResponse
1551    {
1552        #[inline]
1553        fn compat_from(value: ::fidl_examples_calculator::CalculatorAddResponse) -> Self {
1554            Self { sum: ::fidl_next::CompatFrom::compat_from(value.sum) }
1555        }
1556    }
1557
1558    impl ::fidl_next::CompatFrom<crate::CalculatorDivideRequest>
1559        for ::fidl_examples_calculator::CalculatorDivideRequest
1560    {
1561        #[inline]
1562        fn compat_from(value: crate::CalculatorDivideRequest) -> Self {
1563            Self {
1564                dividend: ::fidl_next::CompatFrom::compat_from(value.dividend),
1565
1566                divisor: ::fidl_next::CompatFrom::compat_from(value.divisor),
1567            }
1568        }
1569    }
1570
1571    impl ::fidl_next::CompatFrom<::fidl_examples_calculator::CalculatorDivideRequest>
1572        for crate::CalculatorDivideRequest
1573    {
1574        #[inline]
1575        fn compat_from(value: ::fidl_examples_calculator::CalculatorDivideRequest) -> Self {
1576            Self {
1577                dividend: ::fidl_next::CompatFrom::compat_from(value.dividend),
1578
1579                divisor: ::fidl_next::CompatFrom::compat_from(value.divisor),
1580            }
1581        }
1582    }
1583
1584    impl ::fidl_next::CompatFrom<crate::CalculatorDivideResponse>
1585        for ::fidl_examples_calculator::CalculatorDivideResponse
1586    {
1587        #[inline]
1588        fn compat_from(value: crate::CalculatorDivideResponse) -> Self {
1589            Self {
1590                quotient: ::fidl_next::CompatFrom::compat_from(value.quotient),
1591
1592                remainder: ::fidl_next::CompatFrom::compat_from(value.remainder),
1593            }
1594        }
1595    }
1596
1597    impl ::fidl_next::CompatFrom<::fidl_examples_calculator::CalculatorDivideResponse>
1598        for crate::CalculatorDivideResponse
1599    {
1600        #[inline]
1601        fn compat_from(value: ::fidl_examples_calculator::CalculatorDivideResponse) -> Self {
1602            Self {
1603                quotient: ::fidl_next::CompatFrom::compat_from(value.quotient),
1604
1605                remainder: ::fidl_next::CompatFrom::compat_from(value.remainder),
1606            }
1607        }
1608    }
1609
1610    impl ::fidl_next::CompatFrom<crate::DivisionError> for ::fidl_examples_calculator::DivisionError {
1611        fn compat_from(value: crate::DivisionError) -> Self {
1612            match value {
1613                crate::DivisionError::DivideByZero => Self::DivideByZero,
1614            }
1615        }
1616    }
1617
1618    impl ::fidl_next::CompatFrom<::fidl_examples_calculator::DivisionError> for crate::DivisionError {
1619        fn compat_from(value: ::fidl_examples_calculator::DivisionError) -> Self {
1620            match value {
1621                ::fidl_examples_calculator::DivisionError::DivideByZero => Self::DivideByZero,
1622            }
1623        }
1624    }
1625
1626    impl ::fidl_next::CompatFrom<crate::CalculatorOnErrorRequest>
1627        for ::fidl_examples_calculator::CalculatorOnErrorRequest
1628    {
1629        #[inline]
1630        fn compat_from(value: crate::CalculatorOnErrorRequest) -> Self {
1631            Self { status_code: ::fidl_next::CompatFrom::compat_from(value.status_code) }
1632        }
1633    }
1634
1635    impl ::fidl_next::CompatFrom<::fidl_examples_calculator::CalculatorOnErrorRequest>
1636        for crate::CalculatorOnErrorRequest
1637    {
1638        #[inline]
1639        fn compat_from(value: ::fidl_examples_calculator::CalculatorOnErrorRequest) -> Self {
1640            Self { status_code: ::fidl_next::CompatFrom::compat_from(value.status_code) }
1641        }
1642    }
1643
1644    #[cfg(target_os = "fuchsia")]
1645    /// An alias for a client sender over `zx::Channel` for the `Calculator`
1646    /// protocol.
1647    pub type CalculatorProxy = ::fidl_next::ClientSender<crate::Calculator>;
1648
1649    impl ::fidl_next::CompatFrom<crate::Calculator> for ::fidl_examples_calculator::CalculatorMarker {
1650        fn compat_from(_: crate::Calculator) -> Self {
1651            Self
1652        }
1653    }
1654
1655    impl ::fidl_next::CompatFrom<::fidl_examples_calculator::CalculatorMarker> for crate::Calculator {
1656        fn compat_from(_: ::fidl_examples_calculator::CalculatorMarker) -> Self {
1657            Self
1658        }
1659    }
1660
1661    #[cfg(target_os = "fuchsia")]
1662
1663    impl ::fidl_next::ClientCompatFrom<::fidl_examples_calculator::CalculatorProxy>
1664        for crate::Calculator
1665    {
1666        fn client_compat_from(
1667            proxy: ::fidl_examples_calculator::CalculatorProxy,
1668        ) -> ::fidl_next::Client<Self, ::fidl_next::fuchsia::zx::Channel> {
1669            let channel = ::fidl::endpoints::Proxy::into_channel(proxy).unwrap().into_zx_channel();
1670            let client_end = ::fidl_next::ClientEnd::from_untyped(channel);
1671            ::fidl_next::Client::new(client_end)
1672        }
1673    }
1674}