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::{
1039            calculator, Calculator, CalculatorClientHandler, CalculatorClientSender,
1040            CalculatorServerHandler, CalculatorServerSender,
1041        };
1042
1043        pub use crate::CalculatorAddRequest;
1044
1045        pub use crate::CalculatorDivideRequest;
1046
1047        pub use crate::CalculatorOnErrorRequest;
1048
1049        pub use crate::CalculatorAddResponse;
1050
1051        pub use crate::CalculatorDivideResponse;
1052
1053        pub use crate::DivisionError;
1054    }
1055
1056    pub struct Add;
1057
1058    impl ::fidl_next::Method for Add {
1059        const ORDINAL: u64 = 8640324702111165953;
1060
1061        type Protocol = crate::Calculator;
1062
1063        type Request = crate::WireCalculatorAddRequest;
1064
1065        type Response = ::fidl_next::WireFlexible<'static, crate::WireCalculatorAddResponse>;
1066    }
1067
1068    pub struct Divide;
1069
1070    impl ::fidl_next::Method for Divide {
1071        const ORDINAL: u64 = 5497947425807432439;
1072
1073        type Protocol = crate::Calculator;
1074
1075        type Request = crate::WireCalculatorDivideRequest;
1076
1077        type Response = ::fidl_next::WireFlexibleResult<
1078            'static,
1079            crate::WireCalculatorDivideResponse,
1080            crate::WireDivisionError,
1081        >;
1082    }
1083
1084    pub struct Clear;
1085
1086    impl ::fidl_next::Method for Clear {
1087        const ORDINAL: u64 = 7439411180362570889;
1088
1089        type Protocol = crate::Calculator;
1090
1091        type Request = ();
1092
1093        type Response = ::fidl_next::Never;
1094    }
1095
1096    pub struct OnError;
1097
1098    impl ::fidl_next::Method for OnError {
1099        const ORDINAL: u64 = 8940578522385404924;
1100
1101        type Protocol = crate::Calculator;
1102
1103        type Request = ::fidl_next::Never;
1104
1105        type Response = crate::WireCalculatorOnErrorRequest;
1106    }
1107}
1108
1109/// A helper trait for the `Calculator` client sender.
1110pub trait CalculatorClientSender {
1111    type Transport: ::fidl_next::Transport;
1112
1113    fn add<___R>(
1114        &self,
1115        request: ___R,
1116    ) -> Result<
1117        ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Add>,
1118        ::fidl_next::EncodeError,
1119    >
1120    where
1121        ___R: ::fidl_next::Encode<
1122            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1123            Encoded = crate::WireCalculatorAddRequest,
1124        >;
1125
1126    fn divide<___R>(
1127        &self,
1128        request: ___R,
1129    ) -> Result<
1130        ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Divide>,
1131        ::fidl_next::EncodeError,
1132    >
1133    where
1134        ___R: ::fidl_next::Encode<
1135            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1136            Encoded = crate::WireCalculatorDivideRequest,
1137        >;
1138
1139    fn clear(
1140        &self,
1141    ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>;
1142}
1143
1144impl<___T> CalculatorClientSender for ::fidl_next::ClientSender<___T, Calculator>
1145where
1146    ___T: ::fidl_next::Transport,
1147{
1148    type Transport = ___T;
1149
1150    fn add<___R>(
1151        &self,
1152        request: ___R,
1153    ) -> Result<
1154        ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Add>,
1155        ::fidl_next::EncodeError,
1156    >
1157    where
1158        ___R: ::fidl_next::Encode<
1159            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1160            Encoded = crate::WireCalculatorAddRequest,
1161        >,
1162    {
1163        self.as_untyped()
1164            .send_two_way(8640324702111165953, request)
1165            .map(::fidl_next::ResponseFuture::from_untyped)
1166    }
1167
1168    fn divide<___R>(
1169        &self,
1170        request: ___R,
1171    ) -> Result<
1172        ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Divide>,
1173        ::fidl_next::EncodeError,
1174    >
1175    where
1176        ___R: ::fidl_next::Encode<
1177            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1178            Encoded = crate::WireCalculatorDivideRequest,
1179        >,
1180    {
1181        self.as_untyped()
1182            .send_two_way(5497947425807432439, request)
1183            .map(::fidl_next::ResponseFuture::from_untyped)
1184    }
1185
1186    fn clear(
1187        &self,
1188    ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError> {
1189        self.as_untyped().send_one_way(7439411180362570889, ())
1190    }
1191}
1192
1193/// A client handler for the Calculator protocol.
1194///
1195/// See [`Calculator`] for more details.
1196pub trait CalculatorClientHandler<___T: ::fidl_next::Transport> {
1197    fn on_error(
1198        &mut self,
1199        sender: &::fidl_next::ClientSender<___T, Calculator>,
1200
1201        event: ::fidl_next::Response<___T, calculator::OnError>,
1202    );
1203
1204    fn on_unknown_interaction(
1205        &mut self,
1206        sender: &::fidl_next::ClientSender<___T, Calculator>,
1207        ordinal: u64,
1208    ) {
1209        sender.close();
1210    }
1211}
1212
1213impl<___T, ___H> ::fidl_next::ClientProtocol<___T, ___H> for Calculator
1214where
1215    ___T: ::fidl_next::Transport,
1216    ___H: CalculatorClientHandler<___T>,
1217
1218    <calculator::Add as ::fidl_next::Method>::Response:
1219        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1220
1221    <calculator::Divide as ::fidl_next::Method>::Response:
1222        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1223
1224    <calculator::OnError as ::fidl_next::Method>::Response:
1225        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1226{
1227    fn on_event(
1228        handler: &mut ___H,
1229        sender: &::fidl_next::ClientSender<___T, Self>,
1230        ordinal: u64,
1231        buffer: ___T::RecvBuffer,
1232    ) {
1233        match ordinal {
1234            8940578522385404924 => match ::fidl_next::DecoderExt::decode(buffer) {
1235                Ok(decoded) => handler.on_error(sender, decoded),
1236                Err(e) => {
1237                    sender.close();
1238                }
1239            },
1240
1241            ordinal => handler.on_unknown_interaction(sender, ordinal),
1242        }
1243    }
1244}
1245
1246/// A helper trait for the `Calculator` server sender.
1247pub trait CalculatorServerSender {
1248    type Transport: ::fidl_next::Transport;
1249
1250    fn on_error<___R>(
1251        &self,
1252        request: ___R,
1253    ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>
1254    where
1255        ___R: ::fidl_next::Encode<
1256            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1257            Encoded = <calculator::OnError as ::fidl_next::Method>::Response,
1258        >;
1259}
1260
1261impl<___T> CalculatorServerSender for ::fidl_next::ServerSender<___T, Calculator>
1262where
1263    ___T: ::fidl_next::Transport,
1264{
1265    type Transport = ___T;
1266
1267    fn on_error<___R>(
1268        &self,
1269        request: ___R,
1270    ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>
1271    where
1272        ___R: ::fidl_next::Encode<
1273            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1274            Encoded = <calculator::OnError as ::fidl_next::Method>::Response,
1275        >,
1276    {
1277        self.as_untyped().send_event(8940578522385404924, request)
1278    }
1279}
1280
1281/// A server handler for the Calculator protocol.
1282///
1283/// See [`Calculator`] for more details.
1284pub trait CalculatorServerHandler<___T: ::fidl_next::Transport> {
1285    fn add(
1286        &mut self,
1287        sender: &::fidl_next::ServerSender<___T, Calculator>,
1288
1289        request: ::fidl_next::Request<___T, calculator::Add>,
1290
1291        responder: ::fidl_next::Responder<calculator::Add>,
1292    );
1293
1294    fn divide(
1295        &mut self,
1296        sender: &::fidl_next::ServerSender<___T, Calculator>,
1297
1298        request: ::fidl_next::Request<___T, calculator::Divide>,
1299
1300        responder: ::fidl_next::Responder<calculator::Divide>,
1301    );
1302
1303    fn clear(&mut self, sender: &::fidl_next::ServerSender<___T, Calculator>);
1304
1305    fn on_unknown_interaction(
1306        &mut self,
1307        sender: &::fidl_next::ServerSender<___T, Calculator>,
1308        ordinal: u64,
1309    ) {
1310        sender.close();
1311    }
1312}
1313
1314impl<___T, ___H> ::fidl_next::ServerProtocol<___T, ___H> for Calculator
1315where
1316    ___T: ::fidl_next::Transport,
1317    ___H: CalculatorServerHandler<___T>,
1318
1319    <calculator::Add as ::fidl_next::Method>::Request:
1320        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1321
1322    <calculator::Divide as ::fidl_next::Method>::Request:
1323        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1324{
1325    fn on_one_way(
1326        handler: &mut ___H,
1327        sender: &::fidl_next::ServerSender<___T, Self>,
1328        ordinal: u64,
1329        buffer: ___T::RecvBuffer,
1330    ) {
1331        match ordinal {
1332            7439411180362570889 => {
1333                handler.clear(sender);
1334            }
1335
1336            ordinal => handler.on_unknown_interaction(sender, ordinal),
1337        }
1338    }
1339
1340    fn on_two_way(
1341        handler: &mut ___H,
1342        sender: &::fidl_next::ServerSender<___T, Self>,
1343        ordinal: u64,
1344        buffer: ___T::RecvBuffer,
1345        responder: ::fidl_next::protocol::Responder,
1346    ) {
1347        match ordinal {
1348            8640324702111165953 => {
1349                let responder = ::fidl_next::Responder::from_untyped(responder);
1350
1351                match ::fidl_next::DecoderExt::decode(buffer) {
1352                    Ok(decoded) => handler.add(sender, decoded, responder),
1353                    Err(e) => {
1354                        sender.close();
1355                    }
1356                }
1357            }
1358
1359            5497947425807432439 => {
1360                let responder = ::fidl_next::Responder::from_untyped(responder);
1361
1362                match ::fidl_next::DecoderExt::decode(buffer) {
1363                    Ok(decoded) => handler.divide(sender, decoded, responder),
1364                    Err(e) => {
1365                        sender.close();
1366                    }
1367                }
1368            }
1369
1370            ordinal => handler.on_unknown_interaction(sender, ordinal),
1371        }
1372    }
1373}
1374
1375/// Compatibility shims which mimic some API surfaces of the current Rust bindings.
1376pub mod compat {
1377
1378    impl ::core::convert::From<crate::DivisionError> for ::fidl_examples_calculator::DivisionError {
1379        #[inline]
1380        fn from(from: crate::DivisionError) -> Self {
1381            match crate::DivisionError::from(from) {
1382                crate::DivisionError::DivideByZero => Self::DivideByZero,
1383            }
1384        }
1385    }
1386
1387    #[cfg(target_os = "fuchsia")]
1388    /// An alias for a client sender over `zx::Channel` for the `Calculator`
1389    /// protocol.
1390    pub type CalculatorProxy =
1391        ::fidl_next::ClientSender<::fidl_next::fuchsia::zx::Channel, crate::Calculator>;
1392
1393    impl ::core::convert::From<crate::Calculator> for ::fidl_examples_calculator::CalculatorMarker {
1394        #[inline]
1395        fn from(_: crate::Calculator) -> Self {
1396            Self
1397        }
1398    }
1399}