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> = 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        &mut 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(&mut self.a, encoder, a)?;
43
44        ::fidl_next::Encode::encode(&mut self.b, encoder, b)?;
45
46        Ok(())
47    }
48}
49
50impl ::fidl_next::EncodableOption for Box<CalculatorAddRequest> {
51    type EncodedOption = ::fidl_next::WireBox<WireCalculatorAddRequest>;
52}
53
54unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorAddRequest>
55where
56    ___E: ::fidl_next::Encoder + ?Sized,
57    CalculatorAddRequest: ::fidl_next::Encode<___E>,
58{
59    #[inline]
60    fn encode_option(
61        this: Option<&mut Self>,
62        encoder: &mut ___E,
63        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
64    ) -> Result<(), ::fidl_next::EncodeError> {
65        if let Some(inner) = this {
66            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
67            ::fidl_next::WireBox::encode_present(out);
68        } else {
69            ::fidl_next::WireBox::encode_absent(out);
70        }
71
72        Ok(())
73    }
74}
75
76impl ::fidl_next::TakeFrom<WireCalculatorAddRequest> for CalculatorAddRequest {
77    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
78        ::fidl_next::CopyOptimization::enable_if(
79            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
80                && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
81        )
82    };
83
84    #[inline]
85    fn take_from(from: &WireCalculatorAddRequest) -> Self {
86        Self {
87            a: ::fidl_next::TakeFrom::take_from(&from.a),
88
89            b: ::fidl_next::TakeFrom::take_from(&from.b),
90        }
91    }
92}
93
94/// The wire type corresponding to [`CalculatorAddRequest`].
95#[derive(Clone, Debug)]
96#[repr(C)]
97pub struct WireCalculatorAddRequest {
98    pub a: ::fidl_next::WireI32,
99
100    pub b: ::fidl_next::WireI32,
101}
102
103unsafe impl ::fidl_next::ZeroPadding for WireCalculatorAddRequest {
104    #[inline]
105    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
106}
107
108unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorAddRequest
109where
110    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
111{
112    fn decode(
113        slot: ::fidl_next::Slot<'_, Self>,
114        decoder: &mut ___D,
115    ) -> Result<(), ::fidl_next::DecodeError> {
116        ::fidl_next::munge! {
117            let Self {
118                mut a,
119                mut b,
120
121            } = slot;
122        }
123
124        ::fidl_next::Decode::decode(a.as_mut(), decoder)?;
125
126        ::fidl_next::Decode::decode(b.as_mut(), decoder)?;
127
128        Ok(())
129    }
130}
131
132#[derive(Clone, Debug)]
133#[repr(C)]
134pub struct CalculatorAddResponse {
135    pub sum: i32,
136}
137
138impl ::fidl_next::Encodable for CalculatorAddResponse {
139    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
140        ::fidl_next::CopyOptimization::enable_if(
141            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
142        )
143    };
144
145    type Encoded = WireCalculatorAddResponse;
146}
147
148unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorAddResponse
149where
150    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
151{
152    #[inline]
153    fn encode(
154        &mut self,
155        encoder: &mut ___E,
156        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
157    ) -> Result<(), ::fidl_next::EncodeError> {
158        ::fidl_next::munge! {
159            let Self::Encoded {
160                sum,
161
162            } = out;
163        }
164
165        ::fidl_next::Encode::encode(&mut self.sum, encoder, sum)?;
166
167        Ok(())
168    }
169}
170
171impl ::fidl_next::EncodableOption for Box<CalculatorAddResponse> {
172    type EncodedOption = ::fidl_next::WireBox<WireCalculatorAddResponse>;
173}
174
175unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorAddResponse>
176where
177    ___E: ::fidl_next::Encoder + ?Sized,
178    CalculatorAddResponse: ::fidl_next::Encode<___E>,
179{
180    #[inline]
181    fn encode_option(
182        this: Option<&mut Self>,
183        encoder: &mut ___E,
184        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
185    ) -> Result<(), ::fidl_next::EncodeError> {
186        if let Some(inner) = this {
187            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
188            ::fidl_next::WireBox::encode_present(out);
189        } else {
190            ::fidl_next::WireBox::encode_absent(out);
191        }
192
193        Ok(())
194    }
195}
196
197impl ::fidl_next::TakeFrom<WireCalculatorAddResponse> for CalculatorAddResponse {
198    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
199        ::fidl_next::CopyOptimization::enable_if(
200            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
201        )
202    };
203
204    #[inline]
205    fn take_from(from: &WireCalculatorAddResponse) -> Self {
206        Self { sum: ::fidl_next::TakeFrom::take_from(&from.sum) }
207    }
208}
209
210/// The wire type corresponding to [`CalculatorAddResponse`].
211#[derive(Clone, Debug)]
212#[repr(C)]
213pub struct WireCalculatorAddResponse {
214    pub sum: ::fidl_next::WireI32,
215}
216
217unsafe impl ::fidl_next::ZeroPadding for WireCalculatorAddResponse {
218    #[inline]
219    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
220}
221
222unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorAddResponse
223where
224    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
225{
226    fn decode(
227        slot: ::fidl_next::Slot<'_, Self>,
228        decoder: &mut ___D,
229    ) -> Result<(), ::fidl_next::DecodeError> {
230        ::fidl_next::munge! {
231            let Self {
232                mut sum,
233
234            } = slot;
235        }
236
237        ::fidl_next::Decode::decode(sum.as_mut(), decoder)?;
238
239        Ok(())
240    }
241}
242
243#[derive(Clone, Debug)]
244#[repr(C)]
245pub struct CalculatorDivideRequest {
246    pub dividend: i32,
247
248    pub divisor: i32,
249}
250
251impl ::fidl_next::Encodable for CalculatorDivideRequest {
252    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
253        ::fidl_next::CopyOptimization::enable_if(
254            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
255                && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
256        )
257    };
258
259    type Encoded = WireCalculatorDivideRequest;
260}
261
262unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideRequest
263where
264    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
265{
266    #[inline]
267    fn encode(
268        &mut self,
269        encoder: &mut ___E,
270        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
271    ) -> Result<(), ::fidl_next::EncodeError> {
272        ::fidl_next::munge! {
273            let Self::Encoded {
274                dividend,
275                divisor,
276
277            } = out;
278        }
279
280        ::fidl_next::Encode::encode(&mut self.dividend, encoder, dividend)?;
281
282        ::fidl_next::Encode::encode(&mut self.divisor, encoder, divisor)?;
283
284        Ok(())
285    }
286}
287
288impl ::fidl_next::EncodableOption for Box<CalculatorDivideRequest> {
289    type EncodedOption = ::fidl_next::WireBox<WireCalculatorDivideRequest>;
290}
291
292unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorDivideRequest>
293where
294    ___E: ::fidl_next::Encoder + ?Sized,
295    CalculatorDivideRequest: ::fidl_next::Encode<___E>,
296{
297    #[inline]
298    fn encode_option(
299        this: Option<&mut Self>,
300        encoder: &mut ___E,
301        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
302    ) -> Result<(), ::fidl_next::EncodeError> {
303        if let Some(inner) = this {
304            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
305            ::fidl_next::WireBox::encode_present(out);
306        } else {
307            ::fidl_next::WireBox::encode_absent(out);
308        }
309
310        Ok(())
311    }
312}
313
314impl ::fidl_next::TakeFrom<WireCalculatorDivideRequest> for CalculatorDivideRequest {
315    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
316        ::fidl_next::CopyOptimization::enable_if(
317            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
318                && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
319        )
320    };
321
322    #[inline]
323    fn take_from(from: &WireCalculatorDivideRequest) -> Self {
324        Self {
325            dividend: ::fidl_next::TakeFrom::take_from(&from.dividend),
326
327            divisor: ::fidl_next::TakeFrom::take_from(&from.divisor),
328        }
329    }
330}
331
332/// The wire type corresponding to [`CalculatorDivideRequest`].
333#[derive(Clone, Debug)]
334#[repr(C)]
335pub struct WireCalculatorDivideRequest {
336    pub dividend: ::fidl_next::WireI32,
337
338    pub divisor: ::fidl_next::WireI32,
339}
340
341unsafe impl ::fidl_next::ZeroPadding for WireCalculatorDivideRequest {
342    #[inline]
343    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
344}
345
346unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorDivideRequest
347where
348    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
349{
350    fn decode(
351        slot: ::fidl_next::Slot<'_, Self>,
352        decoder: &mut ___D,
353    ) -> Result<(), ::fidl_next::DecodeError> {
354        ::fidl_next::munge! {
355            let Self {
356                mut dividend,
357                mut divisor,
358
359            } = slot;
360        }
361
362        ::fidl_next::Decode::decode(dividend.as_mut(), decoder)?;
363
364        ::fidl_next::Decode::decode(divisor.as_mut(), decoder)?;
365
366        Ok(())
367    }
368}
369
370#[derive(Clone, Debug)]
371#[repr(C)]
372pub struct CalculatorDivideResponse {
373    pub quotient: i32,
374
375    pub remainder: i32,
376}
377
378impl ::fidl_next::Encodable for CalculatorDivideResponse {
379    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
380        ::fidl_next::CopyOptimization::enable_if(
381            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
382                && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
383        )
384    };
385
386    type Encoded = WireCalculatorDivideResponse;
387}
388
389unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideResponse
390where
391    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
392{
393    #[inline]
394    fn encode(
395        &mut self,
396        encoder: &mut ___E,
397        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
398    ) -> Result<(), ::fidl_next::EncodeError> {
399        ::fidl_next::munge! {
400            let Self::Encoded {
401                quotient,
402                remainder,
403
404            } = out;
405        }
406
407        ::fidl_next::Encode::encode(&mut self.quotient, encoder, quotient)?;
408
409        ::fidl_next::Encode::encode(&mut self.remainder, encoder, remainder)?;
410
411        Ok(())
412    }
413}
414
415impl ::fidl_next::EncodableOption for Box<CalculatorDivideResponse> {
416    type EncodedOption = ::fidl_next::WireBox<WireCalculatorDivideResponse>;
417}
418
419unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorDivideResponse>
420where
421    ___E: ::fidl_next::Encoder + ?Sized,
422    CalculatorDivideResponse: ::fidl_next::Encode<___E>,
423{
424    #[inline]
425    fn encode_option(
426        this: Option<&mut Self>,
427        encoder: &mut ___E,
428        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
429    ) -> Result<(), ::fidl_next::EncodeError> {
430        if let Some(inner) = this {
431            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
432            ::fidl_next::WireBox::encode_present(out);
433        } else {
434            ::fidl_next::WireBox::encode_absent(out);
435        }
436
437        Ok(())
438    }
439}
440
441impl ::fidl_next::TakeFrom<WireCalculatorDivideResponse> for CalculatorDivideResponse {
442    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
443        ::fidl_next::CopyOptimization::enable_if(
444            true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
445                && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
446        )
447    };
448
449    #[inline]
450    fn take_from(from: &WireCalculatorDivideResponse) -> Self {
451        Self {
452            quotient: ::fidl_next::TakeFrom::take_from(&from.quotient),
453
454            remainder: ::fidl_next::TakeFrom::take_from(&from.remainder),
455        }
456    }
457}
458
459/// The wire type corresponding to [`CalculatorDivideResponse`].
460#[derive(Clone, Debug)]
461#[repr(C)]
462pub struct WireCalculatorDivideResponse {
463    pub quotient: ::fidl_next::WireI32,
464
465    pub remainder: ::fidl_next::WireI32,
466}
467
468unsafe impl ::fidl_next::ZeroPadding for WireCalculatorDivideResponse {
469    #[inline]
470    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
471}
472
473unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorDivideResponse
474where
475    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
476{
477    fn decode(
478        slot: ::fidl_next::Slot<'_, Self>,
479        decoder: &mut ___D,
480    ) -> Result<(), ::fidl_next::DecodeError> {
481        ::fidl_next::munge! {
482            let Self {
483                mut quotient,
484                mut remainder,
485
486            } = slot;
487        }
488
489        ::fidl_next::Decode::decode(quotient.as_mut(), decoder)?;
490
491        ::fidl_next::Decode::decode(remainder.as_mut(), decoder)?;
492
493        Ok(())
494    }
495}
496
497#[derive(Clone, Copy, Debug, PartialEq, Eq)]
498#[repr(u32)]
499pub enum DivisionError {
500    DivideByZero = 1,
501}
502
503impl ::fidl_next::Encodable for DivisionError {
504    type Encoded = WireDivisionError;
505}
506
507unsafe impl<___E> ::fidl_next::Encode<___E> for DivisionError
508where
509    ___E: ?Sized,
510{
511    #[inline]
512    fn encode(
513        &mut self,
514        _: &mut ___E,
515        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
516    ) -> Result<(), ::fidl_next::EncodeError> {
517        ::fidl_next::munge!(let WireDivisionError { value } = out);
518        let _ = value.write(::fidl_next::WireU32::from(match *self {
519            Self::DivideByZero => 1,
520        }));
521
522        Ok(())
523    }
524}
525
526impl ::core::convert::From<WireDivisionError> for DivisionError {
527    fn from(wire: WireDivisionError) -> Self {
528        match u32::from(wire.value) {
529            1 => Self::DivideByZero,
530
531            _ => unsafe { ::core::hint::unreachable_unchecked() },
532        }
533    }
534}
535
536impl ::fidl_next::TakeFrom<WireDivisionError> for DivisionError {
537    #[inline]
538    fn take_from(from: &WireDivisionError) -> Self {
539        Self::from(*from)
540    }
541}
542
543/// The wire type corresponding to [`DivisionError`].
544#[derive(Clone, Copy, Debug, PartialEq, Eq)]
545#[repr(transparent)]
546pub struct WireDivisionError {
547    value: ::fidl_next::WireU32,
548}
549
550unsafe impl ::fidl_next::ZeroPadding for WireDivisionError {
551    #[inline]
552    fn zero_padding(_: &mut ::core::mem::MaybeUninit<Self>) {
553        // Wire enums have no padding
554    }
555}
556
557impl WireDivisionError {
558    pub const DIVIDE_BY_ZERO: WireDivisionError =
559        WireDivisionError { value: ::fidl_next::WireU32(1) };
560}
561
562unsafe impl<___D> ::fidl_next::Decode<___D> for WireDivisionError
563where
564    ___D: ?Sized,
565{
566    fn decode(
567        slot: ::fidl_next::Slot<'_, Self>,
568        _: &mut ___D,
569    ) -> Result<(), ::fidl_next::DecodeError> {
570        ::fidl_next::munge!(let Self { value } = slot);
571
572        match u32::from(*value) {
573            1 => (),
574            unknown => return Err(::fidl_next::DecodeError::InvalidEnumOrdinal(unknown as i128)),
575        }
576
577        Ok(())
578    }
579}
580
581impl ::core::convert::From<DivisionError> for WireDivisionError {
582    fn from(natural: DivisionError) -> Self {
583        match natural {
584            DivisionError::DivideByZero => WireDivisionError::DIVIDE_BY_ZERO,
585        }
586    }
587}
588
589#[derive(Clone, Debug)]
590#[repr(C)]
591pub struct CalculatorOnErrorRequest {
592    pub status_code: u32,
593}
594
595impl ::fidl_next::Encodable for CalculatorOnErrorRequest {
596    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
597        ::fidl_next::CopyOptimization::enable_if(
598            true && <u32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
599        )
600    };
601
602    type Encoded = WireCalculatorOnErrorRequest;
603}
604
605unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorOnErrorRequest
606where
607    ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
608{
609    #[inline]
610    fn encode(
611        &mut self,
612        encoder: &mut ___E,
613        out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
614    ) -> Result<(), ::fidl_next::EncodeError> {
615        ::fidl_next::munge! {
616            let Self::Encoded {
617                status_code,
618
619            } = out;
620        }
621
622        ::fidl_next::Encode::encode(&mut self.status_code, encoder, status_code)?;
623
624        Ok(())
625    }
626}
627
628impl ::fidl_next::EncodableOption for Box<CalculatorOnErrorRequest> {
629    type EncodedOption = ::fidl_next::WireBox<WireCalculatorOnErrorRequest>;
630}
631
632unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorOnErrorRequest>
633where
634    ___E: ::fidl_next::Encoder + ?Sized,
635    CalculatorOnErrorRequest: ::fidl_next::Encode<___E>,
636{
637    #[inline]
638    fn encode_option(
639        this: Option<&mut Self>,
640        encoder: &mut ___E,
641        out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
642    ) -> Result<(), ::fidl_next::EncodeError> {
643        if let Some(inner) = this {
644            ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
645            ::fidl_next::WireBox::encode_present(out);
646        } else {
647            ::fidl_next::WireBox::encode_absent(out);
648        }
649
650        Ok(())
651    }
652}
653
654impl ::fidl_next::TakeFrom<WireCalculatorOnErrorRequest> for CalculatorOnErrorRequest {
655    const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
656        ::fidl_next::CopyOptimization::enable_if(
657            true && <u32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
658        )
659    };
660
661    #[inline]
662    fn take_from(from: &WireCalculatorOnErrorRequest) -> Self {
663        Self { status_code: ::fidl_next::TakeFrom::take_from(&from.status_code) }
664    }
665}
666
667/// The wire type corresponding to [`CalculatorOnErrorRequest`].
668#[derive(Clone, Debug)]
669#[repr(C)]
670pub struct WireCalculatorOnErrorRequest {
671    pub status_code: ::fidl_next::WireU32,
672}
673
674unsafe impl ::fidl_next::ZeroPadding for WireCalculatorOnErrorRequest {
675    #[inline]
676    fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
677}
678
679unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorOnErrorRequest
680where
681    ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
682{
683    fn decode(
684        slot: ::fidl_next::Slot<'_, Self>,
685        decoder: &mut ___D,
686    ) -> Result<(), ::fidl_next::DecodeError> {
687        ::fidl_next::munge! {
688            let Self {
689                mut status_code,
690
691            } = slot;
692        }
693
694        ::fidl_next::Decode::decode(status_code.as_mut(), decoder)?;
695
696        Ok(())
697    }
698}
699
700/// The type corresponding to the Calculator protocol.
701#[derive(Debug)]
702pub struct Calculator;
703
704pub mod calculator {
705    pub mod prelude {
706        pub use crate::{
707            calculator, Calculator, CalculatorClientHandler, CalculatorClientSender,
708            CalculatorServerHandler, CalculatorServerSender,
709        };
710
711        pub use crate::CalculatorAddRequest;
712
713        pub use crate::CalculatorDivideRequest;
714
715        pub use crate::CalculatorOnErrorRequest;
716
717        pub use crate::CalculatorAddResponse;
718
719        pub use crate::CalculatorDivideResponse;
720
721        pub use crate::DivisionError;
722    }
723
724    pub struct Add;
725
726    impl ::fidl_next::Method for Add {
727        const ORDINAL: u64 = 8640324702111165953;
728
729        type Protocol = crate::Calculator;
730
731        type Request = crate::WireCalculatorAddRequest;
732
733        type Response = ::fidl_next::WireFlexible<crate::WireCalculatorAddResponse>;
734    }
735
736    pub struct Divide;
737
738    impl ::fidl_next::Method for Divide {
739        const ORDINAL: u64 = 5497947425807432439;
740
741        type Protocol = crate::Calculator;
742
743        type Request = crate::WireCalculatorDivideRequest;
744
745        type Response = ::fidl_next::WireFlexibleResult<
746            crate::WireCalculatorDivideResponse,
747            crate::WireDivisionError,
748        >;
749    }
750
751    pub struct Clear;
752
753    impl ::fidl_next::Method for Clear {
754        const ORDINAL: u64 = 7439411180362570889;
755
756        type Protocol = crate::Calculator;
757
758        type Request = ();
759
760        type Response = ::fidl_next::Never;
761    }
762
763    pub struct OnError;
764
765    impl ::fidl_next::Method for OnError {
766        const ORDINAL: u64 = 8940578522385404924;
767
768        type Protocol = crate::Calculator;
769
770        type Request = ::fidl_next::Never;
771
772        type Response = crate::WireCalculatorOnErrorRequest;
773    }
774}
775
776/// A helper trait for the `Calculator` client sender.
777pub trait CalculatorClientSender {
778    type Transport: ::fidl_next::Transport;
779
780    fn add<___R>(
781        &self,
782        request: &mut ___R,
783    ) -> Result<
784        ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Add>,
785        ::fidl_next::EncodeError,
786    >
787    where
788        ___R: ::fidl_next::Encode<
789            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
790            Encoded = crate::WireCalculatorAddRequest,
791        >;
792
793    fn divide<___R>(
794        &self,
795        request: &mut ___R,
796    ) -> Result<
797        ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Divide>,
798        ::fidl_next::EncodeError,
799    >
800    where
801        ___R: ::fidl_next::Encode<
802            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
803            Encoded = crate::WireCalculatorDivideRequest,
804        >;
805
806    fn clear(
807        &self,
808    ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>;
809}
810
811impl<___T> CalculatorClientSender for ::fidl_next::ClientSender<___T, Calculator>
812where
813    ___T: ::fidl_next::Transport,
814{
815    type Transport = ___T;
816
817    fn add<___R>(
818        &self,
819        request: &mut ___R,
820    ) -> Result<
821        ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Add>,
822        ::fidl_next::EncodeError,
823    >
824    where
825        ___R: ::fidl_next::Encode<
826            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
827            Encoded = crate::WireCalculatorAddRequest,
828        >,
829    {
830        self.as_untyped()
831            .send_two_way(8640324702111165953, request)
832            .map(::fidl_next::ResponseFuture::from_untyped)
833    }
834
835    fn divide<___R>(
836        &self,
837        request: &mut ___R,
838    ) -> Result<
839        ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Divide>,
840        ::fidl_next::EncodeError,
841    >
842    where
843        ___R: ::fidl_next::Encode<
844            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
845            Encoded = crate::WireCalculatorDivideRequest,
846        >,
847    {
848        self.as_untyped()
849            .send_two_way(5497947425807432439, request)
850            .map(::fidl_next::ResponseFuture::from_untyped)
851    }
852
853    fn clear(
854        &self,
855    ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError> {
856        self.as_untyped().send_one_way(7439411180362570889, &mut ())
857    }
858}
859
860/// A client handler for the Calculator protocol.
861///
862/// See [`Calculator`] for more details.
863pub trait CalculatorClientHandler<___T: ::fidl_next::Transport> {
864    fn on_error(
865        &mut self,
866        sender: &::fidl_next::ClientSender<___T, Calculator>,
867
868        message: ::fidl_next::ResponseBuffer<___T, calculator::OnError>,
869    );
870
871    fn on_unknown_interaction(
872        &mut self,
873        sender: &::fidl_next::ClientSender<___T, Calculator>,
874        ordinal: u64,
875    ) {
876        sender.close();
877    }
878}
879
880impl<___T, ___H> ::fidl_next::ClientProtocol<___T, ___H> for Calculator
881where
882    ___T: ::fidl_next::Transport,
883    ___H: CalculatorClientHandler<___T>,
884
885    <calculator::Add as ::fidl_next::Method>::Response:
886        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
887
888    <calculator::Divide as ::fidl_next::Method>::Response:
889        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
890
891    <calculator::OnError as ::fidl_next::Method>::Response:
892        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
893{
894    fn on_event(
895        handler: &mut ___H,
896        sender: &::fidl_next::ClientSender<___T, Self>,
897        ordinal: u64,
898        buffer: ___T::RecvBuffer,
899    ) {
900        match ordinal {
901            8940578522385404924 => {
902                let buffer = ::fidl_next::ResponseBuffer::from_untyped(buffer);
903                handler.on_error(sender, buffer);
904            }
905
906            ordinal => handler.on_unknown_interaction(sender, ordinal),
907        }
908    }
909}
910
911/// A helper trait for the `Calculator` server sender.
912pub trait CalculatorServerSender {
913    type Transport: ::fidl_next::Transport;
914
915    fn on_error<___R>(
916        &self,
917        request: &mut ___R,
918    ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>
919    where
920        ___R: ::fidl_next::Encode<
921            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
922            Encoded = <calculator::OnError as ::fidl_next::Method>::Response,
923        >;
924}
925
926impl<___T> CalculatorServerSender for ::fidl_next::ServerSender<___T, Calculator>
927where
928    ___T: ::fidl_next::Transport,
929{
930    type Transport = ___T;
931
932    fn on_error<___R>(
933        &self,
934        request: &mut ___R,
935    ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>
936    where
937        ___R: ::fidl_next::Encode<
938            <Self::Transport as ::fidl_next::Transport>::SendBuffer,
939            Encoded = <calculator::OnError as ::fidl_next::Method>::Response,
940        >,
941    {
942        self.as_untyped().send_event(8940578522385404924, request)
943    }
944}
945
946/// A server handler for the Calculator protocol.
947///
948/// See [`Calculator`] for more details.
949pub trait CalculatorServerHandler<___T: ::fidl_next::Transport> {
950    fn add(
951        &mut self,
952        sender: &::fidl_next::ServerSender<___T, Calculator>,
953
954        request: ::fidl_next::RequestBuffer<___T, calculator::Add>,
955
956        responder: ::fidl_next::Responder<calculator::Add>,
957    );
958
959    fn divide(
960        &mut self,
961        sender: &::fidl_next::ServerSender<___T, Calculator>,
962
963        request: ::fidl_next::RequestBuffer<___T, calculator::Divide>,
964
965        responder: ::fidl_next::Responder<calculator::Divide>,
966    );
967
968    fn clear(&mut self, sender: &::fidl_next::ServerSender<___T, Calculator>);
969
970    fn on_unknown_interaction(
971        &mut self,
972        sender: &::fidl_next::ServerSender<___T, Calculator>,
973        ordinal: u64,
974    ) {
975        sender.close();
976    }
977}
978
979impl<___T, ___H> ::fidl_next::ServerProtocol<___T, ___H> for Calculator
980where
981    ___T: ::fidl_next::Transport,
982    ___H: CalculatorServerHandler<___T>,
983
984    crate::WireCalculatorAddRequest:
985        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
986
987    crate::WireCalculatorDivideRequest:
988        ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
989{
990    fn on_one_way(
991        handler: &mut ___H,
992        sender: &::fidl_next::ServerSender<___T, Self>,
993        ordinal: u64,
994        buffer: ___T::RecvBuffer,
995    ) {
996        match ordinal {
997            7439411180362570889 => {
998                handler.clear(sender);
999            }
1000
1001            ordinal => handler.on_unknown_interaction(sender, ordinal),
1002        }
1003    }
1004
1005    fn on_two_way(
1006        handler: &mut ___H,
1007        sender: &::fidl_next::ServerSender<___T, Self>,
1008        ordinal: u64,
1009        buffer: ___T::RecvBuffer,
1010        responder: ::fidl_next::protocol::Responder,
1011    ) {
1012        match ordinal {
1013            8640324702111165953 => {
1014                let responder = ::fidl_next::Responder::from_untyped(responder);
1015
1016                let buffer = ::fidl_next::RequestBuffer::from_untyped(buffer);
1017                handler.add(sender, buffer, responder);
1018            }
1019
1020            5497947425807432439 => {
1021                let responder = ::fidl_next::Responder::from_untyped(responder);
1022
1023                let buffer = ::fidl_next::RequestBuffer::from_untyped(buffer);
1024                handler.divide(sender, buffer, responder);
1025            }
1026
1027            ordinal => handler.on_unknown_interaction(sender, ordinal),
1028        }
1029    }
1030}
1031
1032/// Compatibility shims which mimic some API surfaces of the current Rust bindings.
1033pub mod compat {
1034
1035    impl ::fidl_next::TakeFrom<crate::WireCalculatorAddRequest>
1036        for ::fidl_examples_calculator::CalculatorAddRequest
1037    {
1038        #[inline]
1039        fn take_from(from: &crate::WireCalculatorAddRequest) -> Self {
1040            Self {
1041                a: ::fidl_next::TakeFrom::take_from(&from.a),
1042
1043                b: ::fidl_next::TakeFrom::take_from(&from.b),
1044            }
1045        }
1046    }
1047
1048    impl ::fidl_next::TakeFrom<crate::WireCalculatorAddResponse>
1049        for ::fidl_examples_calculator::CalculatorAddResponse
1050    {
1051        #[inline]
1052        fn take_from(from: &crate::WireCalculatorAddResponse) -> Self {
1053            Self { sum: ::fidl_next::TakeFrom::take_from(&from.sum) }
1054        }
1055    }
1056
1057    impl ::fidl_next::TakeFrom<crate::WireCalculatorDivideRequest>
1058        for ::fidl_examples_calculator::CalculatorDivideRequest
1059    {
1060        #[inline]
1061        fn take_from(from: &crate::WireCalculatorDivideRequest) -> Self {
1062            Self {
1063                dividend: ::fidl_next::TakeFrom::take_from(&from.dividend),
1064
1065                divisor: ::fidl_next::TakeFrom::take_from(&from.divisor),
1066            }
1067        }
1068    }
1069
1070    impl ::fidl_next::TakeFrom<crate::WireCalculatorDivideResponse>
1071        for ::fidl_examples_calculator::CalculatorDivideResponse
1072    {
1073        #[inline]
1074        fn take_from(from: &crate::WireCalculatorDivideResponse) -> Self {
1075            Self {
1076                quotient: ::fidl_next::TakeFrom::take_from(&from.quotient),
1077
1078                remainder: ::fidl_next::TakeFrom::take_from(&from.remainder),
1079            }
1080        }
1081    }
1082
1083    impl ::fidl_next::TakeFrom<crate::WireDivisionError> for ::fidl_examples_calculator::DivisionError {
1084        #[inline]
1085        fn take_from(from: &crate::WireDivisionError) -> Self {
1086            match crate::DivisionError::from(*from) {
1087                crate::DivisionError::DivideByZero => Self::DivideByZero,
1088            }
1089        }
1090    }
1091
1092    impl ::fidl_next::TakeFrom<crate::WireCalculatorOnErrorRequest>
1093        for ::fidl_examples_calculator::CalculatorOnErrorRequest
1094    {
1095        #[inline]
1096        fn take_from(from: &crate::WireCalculatorOnErrorRequest) -> Self {
1097            Self { status_code: ::fidl_next::TakeFrom::take_from(&from.status_code) }
1098        }
1099    }
1100
1101    #[cfg(target_os = "fuchsia")]
1102    /// An alias for a client sender over `zx::Channel` for the `Calculator`
1103    /// protocol.
1104    pub type CalculatorProxy =
1105        ::fidl_next::ClientSender<::fidl_next::fuchsia::zx::Channel, crate::Calculator>;
1106
1107    impl ::fidl_next::TakeFrom<crate::Calculator> for ::fidl_examples_calculator::CalculatorMarker {
1108        #[inline]
1109        fn take_from(from: &crate::Calculator) -> Self {
1110            Self
1111        }
1112    }
1113}