1#![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 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 Box<CalculatorAddRequest> {
77 type EncodedOption = ::fidl_next::WireBox<WireCalculatorAddRequest>;
78}
79
80unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<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 Box<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::TakeFrom<WireCalculatorAddRequest> for CalculatorAddRequest {
125 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
126 ::fidl_next::CopyOptimization::enable_if(
127 true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
128 && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
129 )
130 };
131
132 #[inline]
133 fn take_from(from: &WireCalculatorAddRequest) -> Self {
134 Self {
135 a: ::fidl_next::TakeFrom::take_from(&from.a),
136
137 b: ::fidl_next::TakeFrom::take_from(&from.b),
138 }
139 }
140}
141
142#[derive(Clone, Debug)]
144#[repr(C)]
145pub struct WireCalculatorAddRequest {
146 pub a: ::fidl_next::WireI32,
147
148 pub b: ::fidl_next::WireI32,
149}
150
151unsafe impl ::fidl_next::ZeroPadding for WireCalculatorAddRequest {
152 #[inline]
153 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
154}
155
156unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorAddRequest
157where
158 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
159{
160 fn decode(
161 slot: ::fidl_next::Slot<'_, Self>,
162 decoder: &mut ___D,
163 ) -> Result<(), ::fidl_next::DecodeError> {
164 ::fidl_next::munge! {
165 let Self {
166 mut a,
167 mut b,
168
169 } = slot;
170 }
171
172 ::fidl_next::Decode::decode(a.as_mut(), decoder)?;
173
174 ::fidl_next::Decode::decode(b.as_mut(), decoder)?;
175
176 Ok(())
177 }
178}
179
180#[derive(Clone, Debug)]
181#[repr(C)]
182pub struct CalculatorAddResponse {
183 pub sum: i32,
184}
185
186impl ::fidl_next::Encodable for CalculatorAddResponse {
187 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
188 ::fidl_next::CopyOptimization::enable_if(
189 true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
190 )
191 };
192
193 type Encoded = WireCalculatorAddResponse;
194}
195
196unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorAddResponse
197where
198 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
199{
200 #[inline]
201 fn encode(
202 self,
203 encoder: &mut ___E,
204 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
205 ) -> Result<(), ::fidl_next::EncodeError> {
206 ::fidl_next::munge! {
207 let Self::Encoded {
208 sum,
209
210 } = out;
211 }
212
213 ::fidl_next::Encode::encode(self.sum, encoder, sum)?;
214
215 Ok(())
216 }
217}
218
219unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorAddResponse
220where
221 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
222{
223 #[inline]
224 fn encode_ref(
225 &self,
226 encoder: &mut ___E,
227 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
228 ) -> Result<(), ::fidl_next::EncodeError> {
229 ::fidl_next::munge! {
230 let Self::Encoded {
231 sum,
232
233 } = out;
234 }
235
236 ::fidl_next::EncodeRef::encode_ref(&self.sum, encoder, sum)?;
237
238 Ok(())
239 }
240}
241
242impl ::fidl_next::EncodableOption for Box<CalculatorAddResponse> {
243 type EncodedOption = ::fidl_next::WireBox<WireCalculatorAddResponse>;
244}
245
246unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorAddResponse>
247where
248 ___E: ::fidl_next::Encoder + ?Sized,
249 CalculatorAddResponse: ::fidl_next::Encode<___E>,
250{
251 #[inline]
252 fn encode_option(
253 this: Option<Self>,
254 encoder: &mut ___E,
255 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
256 ) -> Result<(), ::fidl_next::EncodeError> {
257 if let Some(inner) = this {
258 ::fidl_next::EncoderExt::encode_next(encoder, *inner)?;
259 ::fidl_next::WireBox::encode_present(out);
260 } else {
261 ::fidl_next::WireBox::encode_absent(out);
262 }
263
264 Ok(())
265 }
266}
267
268unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for Box<CalculatorAddResponse>
269where
270 ___E: ::fidl_next::Encoder + ?Sized,
271 CalculatorAddResponse: ::fidl_next::EncodeRef<___E>,
272{
273 #[inline]
274 fn encode_option_ref(
275 this: Option<&Self>,
276 encoder: &mut ___E,
277 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
278 ) -> Result<(), ::fidl_next::EncodeError> {
279 if let Some(inner) = this {
280 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
281 ::fidl_next::WireBox::encode_present(out);
282 } else {
283 ::fidl_next::WireBox::encode_absent(out);
284 }
285
286 Ok(())
287 }
288}
289
290impl ::fidl_next::TakeFrom<WireCalculatorAddResponse> for CalculatorAddResponse {
291 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
292 ::fidl_next::CopyOptimization::enable_if(
293 true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
294 )
295 };
296
297 #[inline]
298 fn take_from(from: &WireCalculatorAddResponse) -> Self {
299 Self { sum: ::fidl_next::TakeFrom::take_from(&from.sum) }
300 }
301}
302
303#[derive(Clone, Debug)]
305#[repr(C)]
306pub struct WireCalculatorAddResponse {
307 pub sum: ::fidl_next::WireI32,
308}
309
310unsafe impl ::fidl_next::ZeroPadding for WireCalculatorAddResponse {
311 #[inline]
312 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
313}
314
315unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorAddResponse
316where
317 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
318{
319 fn decode(
320 slot: ::fidl_next::Slot<'_, Self>,
321 decoder: &mut ___D,
322 ) -> Result<(), ::fidl_next::DecodeError> {
323 ::fidl_next::munge! {
324 let Self {
325 mut sum,
326
327 } = slot;
328 }
329
330 ::fidl_next::Decode::decode(sum.as_mut(), decoder)?;
331
332 Ok(())
333 }
334}
335
336#[derive(Clone, Debug)]
337#[repr(C)]
338pub struct CalculatorDivideRequest {
339 pub dividend: i32,
340
341 pub divisor: i32,
342}
343
344impl ::fidl_next::Encodable for CalculatorDivideRequest {
345 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
346 ::fidl_next::CopyOptimization::enable_if(
347 true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
348 && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
349 )
350 };
351
352 type Encoded = WireCalculatorDivideRequest;
353}
354
355unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideRequest
356where
357 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
358{
359 #[inline]
360 fn encode(
361 self,
362 encoder: &mut ___E,
363 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
364 ) -> Result<(), ::fidl_next::EncodeError> {
365 ::fidl_next::munge! {
366 let Self::Encoded {
367 dividend,
368 divisor,
369
370 } = out;
371 }
372
373 ::fidl_next::Encode::encode(self.dividend, encoder, dividend)?;
374
375 ::fidl_next::Encode::encode(self.divisor, encoder, divisor)?;
376
377 Ok(())
378 }
379}
380
381unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorDivideRequest
382where
383 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
384{
385 #[inline]
386 fn encode_ref(
387 &self,
388 encoder: &mut ___E,
389 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
390 ) -> Result<(), ::fidl_next::EncodeError> {
391 ::fidl_next::munge! {
392 let Self::Encoded {
393 dividend,
394 divisor,
395
396 } = out;
397 }
398
399 ::fidl_next::EncodeRef::encode_ref(&self.dividend, encoder, dividend)?;
400
401 ::fidl_next::EncodeRef::encode_ref(&self.divisor, encoder, divisor)?;
402
403 Ok(())
404 }
405}
406
407impl ::fidl_next::EncodableOption for Box<CalculatorDivideRequest> {
408 type EncodedOption = ::fidl_next::WireBox<WireCalculatorDivideRequest>;
409}
410
411unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorDivideRequest>
412where
413 ___E: ::fidl_next::Encoder + ?Sized,
414 CalculatorDivideRequest: ::fidl_next::Encode<___E>,
415{
416 #[inline]
417 fn encode_option(
418 this: Option<Self>,
419 encoder: &mut ___E,
420 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
421 ) -> Result<(), ::fidl_next::EncodeError> {
422 if let Some(inner) = this {
423 ::fidl_next::EncoderExt::encode_next(encoder, *inner)?;
424 ::fidl_next::WireBox::encode_present(out);
425 } else {
426 ::fidl_next::WireBox::encode_absent(out);
427 }
428
429 Ok(())
430 }
431}
432
433unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for Box<CalculatorDivideRequest>
434where
435 ___E: ::fidl_next::Encoder + ?Sized,
436 CalculatorDivideRequest: ::fidl_next::EncodeRef<___E>,
437{
438 #[inline]
439 fn encode_option_ref(
440 this: Option<&Self>,
441 encoder: &mut ___E,
442 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
443 ) -> Result<(), ::fidl_next::EncodeError> {
444 if let Some(inner) = this {
445 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
446 ::fidl_next::WireBox::encode_present(out);
447 } else {
448 ::fidl_next::WireBox::encode_absent(out);
449 }
450
451 Ok(())
452 }
453}
454
455impl ::fidl_next::TakeFrom<WireCalculatorDivideRequest> for CalculatorDivideRequest {
456 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
457 ::fidl_next::CopyOptimization::enable_if(
458 true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
459 && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
460 )
461 };
462
463 #[inline]
464 fn take_from(from: &WireCalculatorDivideRequest) -> Self {
465 Self {
466 dividend: ::fidl_next::TakeFrom::take_from(&from.dividend),
467
468 divisor: ::fidl_next::TakeFrom::take_from(&from.divisor),
469 }
470 }
471}
472
473#[derive(Clone, Debug)]
475#[repr(C)]
476pub struct WireCalculatorDivideRequest {
477 pub dividend: ::fidl_next::WireI32,
478
479 pub divisor: ::fidl_next::WireI32,
480}
481
482unsafe impl ::fidl_next::ZeroPadding for WireCalculatorDivideRequest {
483 #[inline]
484 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
485}
486
487unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorDivideRequest
488where
489 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
490{
491 fn decode(
492 slot: ::fidl_next::Slot<'_, Self>,
493 decoder: &mut ___D,
494 ) -> Result<(), ::fidl_next::DecodeError> {
495 ::fidl_next::munge! {
496 let Self {
497 mut dividend,
498 mut divisor,
499
500 } = slot;
501 }
502
503 ::fidl_next::Decode::decode(dividend.as_mut(), decoder)?;
504
505 ::fidl_next::Decode::decode(divisor.as_mut(), decoder)?;
506
507 Ok(())
508 }
509}
510
511#[derive(Clone, Debug)]
512#[repr(C)]
513pub struct CalculatorDivideResponse {
514 pub quotient: i32,
515
516 pub remainder: i32,
517}
518
519impl ::fidl_next::Encodable for CalculatorDivideResponse {
520 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
521 ::fidl_next::CopyOptimization::enable_if(
522 true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
523 && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
524 )
525 };
526
527 type Encoded = WireCalculatorDivideResponse;
528}
529
530unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorDivideResponse
531where
532 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
533{
534 #[inline]
535 fn encode(
536 self,
537 encoder: &mut ___E,
538 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
539 ) -> Result<(), ::fidl_next::EncodeError> {
540 ::fidl_next::munge! {
541 let Self::Encoded {
542 quotient,
543 remainder,
544
545 } = out;
546 }
547
548 ::fidl_next::Encode::encode(self.quotient, encoder, quotient)?;
549
550 ::fidl_next::Encode::encode(self.remainder, encoder, remainder)?;
551
552 Ok(())
553 }
554}
555
556unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorDivideResponse
557where
558 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
559{
560 #[inline]
561 fn encode_ref(
562 &self,
563 encoder: &mut ___E,
564 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
565 ) -> Result<(), ::fidl_next::EncodeError> {
566 ::fidl_next::munge! {
567 let Self::Encoded {
568 quotient,
569 remainder,
570
571 } = out;
572 }
573
574 ::fidl_next::EncodeRef::encode_ref(&self.quotient, encoder, quotient)?;
575
576 ::fidl_next::EncodeRef::encode_ref(&self.remainder, encoder, remainder)?;
577
578 Ok(())
579 }
580}
581
582impl ::fidl_next::EncodableOption for Box<CalculatorDivideResponse> {
583 type EncodedOption = ::fidl_next::WireBox<WireCalculatorDivideResponse>;
584}
585
586unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorDivideResponse>
587where
588 ___E: ::fidl_next::Encoder + ?Sized,
589 CalculatorDivideResponse: ::fidl_next::Encode<___E>,
590{
591 #[inline]
592 fn encode_option(
593 this: Option<Self>,
594 encoder: &mut ___E,
595 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
596 ) -> Result<(), ::fidl_next::EncodeError> {
597 if let Some(inner) = this {
598 ::fidl_next::EncoderExt::encode_next(encoder, *inner)?;
599 ::fidl_next::WireBox::encode_present(out);
600 } else {
601 ::fidl_next::WireBox::encode_absent(out);
602 }
603
604 Ok(())
605 }
606}
607
608unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for Box<CalculatorDivideResponse>
609where
610 ___E: ::fidl_next::Encoder + ?Sized,
611 CalculatorDivideResponse: ::fidl_next::EncodeRef<___E>,
612{
613 #[inline]
614 fn encode_option_ref(
615 this: Option<&Self>,
616 encoder: &mut ___E,
617 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
618 ) -> Result<(), ::fidl_next::EncodeError> {
619 if let Some(inner) = this {
620 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
621 ::fidl_next::WireBox::encode_present(out);
622 } else {
623 ::fidl_next::WireBox::encode_absent(out);
624 }
625
626 Ok(())
627 }
628}
629
630impl ::fidl_next::TakeFrom<WireCalculatorDivideResponse> for CalculatorDivideResponse {
631 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
632 ::fidl_next::CopyOptimization::enable_if(
633 true && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled()
634 && <i32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
635 )
636 };
637
638 #[inline]
639 fn take_from(from: &WireCalculatorDivideResponse) -> Self {
640 Self {
641 quotient: ::fidl_next::TakeFrom::take_from(&from.quotient),
642
643 remainder: ::fidl_next::TakeFrom::take_from(&from.remainder),
644 }
645 }
646}
647
648#[derive(Clone, Debug)]
650#[repr(C)]
651pub struct WireCalculatorDivideResponse {
652 pub quotient: ::fidl_next::WireI32,
653
654 pub remainder: ::fidl_next::WireI32,
655}
656
657unsafe impl ::fidl_next::ZeroPadding for WireCalculatorDivideResponse {
658 #[inline]
659 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
660}
661
662unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorDivideResponse
663where
664 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
665{
666 fn decode(
667 slot: ::fidl_next::Slot<'_, Self>,
668 decoder: &mut ___D,
669 ) -> Result<(), ::fidl_next::DecodeError> {
670 ::fidl_next::munge! {
671 let Self {
672 mut quotient,
673 mut remainder,
674
675 } = slot;
676 }
677
678 ::fidl_next::Decode::decode(quotient.as_mut(), decoder)?;
679
680 ::fidl_next::Decode::decode(remainder.as_mut(), decoder)?;
681
682 Ok(())
683 }
684}
685
686#[derive(Clone, Copy, Debug, PartialEq, Eq)]
687#[repr(u32)]
688pub enum DivisionError {
689 DivideByZero = 1,
690}
691
692impl ::fidl_next::Encodable for DivisionError {
693 type Encoded = WireDivisionError;
694}
695impl ::std::convert::TryFrom<u32> for DivisionError {
696 type Error = ::fidl_next::UnknownStrictEnumMemberError;
697 fn try_from(value: u32) -> Result<Self, Self::Error> {
698 match value {
699 1 => Ok(Self::DivideByZero),
700
701 _ => Err(Self::Error::new(value.into())),
702 }
703 }
704}
705
706unsafe impl<___E> ::fidl_next::Encode<___E> for DivisionError
707where
708 ___E: ?Sized,
709{
710 #[inline]
711 fn encode(
712 self,
713 encoder: &mut ___E,
714 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
715 ) -> Result<(), ::fidl_next::EncodeError> {
716 ::fidl_next::EncodeRef::encode_ref(&self, encoder, out)
717 }
718}
719
720unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DivisionError
721where
722 ___E: ?Sized,
723{
724 #[inline]
725 fn encode_ref(
726 &self,
727 encoder: &mut ___E,
728 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
729 ) -> Result<(), ::fidl_next::EncodeError> {
730 ::fidl_next::munge!(let WireDivisionError { value } = out);
731 let _ = value.write(::fidl_next::WireU32::from(match *self {
732 Self::DivideByZero => 1,
733 }));
734
735 Ok(())
736 }
737}
738
739impl ::core::convert::From<WireDivisionError> for DivisionError {
740 fn from(wire: WireDivisionError) -> Self {
741 match u32::from(wire.value) {
742 1 => Self::DivideByZero,
743
744 _ => unsafe { ::core::hint::unreachable_unchecked() },
745 }
746 }
747}
748
749impl ::fidl_next::TakeFrom<WireDivisionError> for DivisionError {
750 #[inline]
751 fn take_from(from: &WireDivisionError) -> Self {
752 Self::from(*from)
753 }
754}
755
756#[derive(Clone, Copy, Debug, PartialEq, Eq)]
758#[repr(transparent)]
759pub struct WireDivisionError {
760 value: ::fidl_next::WireU32,
761}
762
763unsafe impl ::fidl_next::ZeroPadding for WireDivisionError {
764 #[inline]
765 fn zero_padding(_: &mut ::core::mem::MaybeUninit<Self>) {
766 }
768}
769
770impl WireDivisionError {
771 pub const DIVIDE_BY_ZERO: WireDivisionError =
772 WireDivisionError { value: ::fidl_next::WireU32(1) };
773}
774
775unsafe impl<___D> ::fidl_next::Decode<___D> for WireDivisionError
776where
777 ___D: ?Sized,
778{
779 fn decode(
780 slot: ::fidl_next::Slot<'_, Self>,
781 _: &mut ___D,
782 ) -> Result<(), ::fidl_next::DecodeError> {
783 ::fidl_next::munge!(let Self { value } = slot);
784
785 match u32::from(*value) {
786 1 => (),
787 unknown => return Err(::fidl_next::DecodeError::InvalidEnumOrdinal(unknown as i128)),
788 }
789
790 Ok(())
791 }
792}
793
794impl ::core::convert::From<DivisionError> for WireDivisionError {
795 fn from(natural: DivisionError) -> Self {
796 match natural {
797 DivisionError::DivideByZero => WireDivisionError::DIVIDE_BY_ZERO,
798 }
799 }
800}
801
802#[derive(Clone, Debug)]
803#[repr(C)]
804pub struct CalculatorOnErrorRequest {
805 pub status_code: u32,
806}
807
808impl ::fidl_next::Encodable for CalculatorOnErrorRequest {
809 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
810 ::fidl_next::CopyOptimization::enable_if(
811 true && <u32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
812 )
813 };
814
815 type Encoded = WireCalculatorOnErrorRequest;
816}
817
818unsafe impl<___E> ::fidl_next::Encode<___E> for CalculatorOnErrorRequest
819where
820 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
821{
822 #[inline]
823 fn encode(
824 self,
825 encoder: &mut ___E,
826 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
827 ) -> Result<(), ::fidl_next::EncodeError> {
828 ::fidl_next::munge! {
829 let Self::Encoded {
830 status_code,
831
832 } = out;
833 }
834
835 ::fidl_next::Encode::encode(self.status_code, encoder, status_code)?;
836
837 Ok(())
838 }
839}
840
841unsafe impl<___E> ::fidl_next::EncodeRef<___E> for CalculatorOnErrorRequest
842where
843 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
844{
845 #[inline]
846 fn encode_ref(
847 &self,
848 encoder: &mut ___E,
849 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
850 ) -> Result<(), ::fidl_next::EncodeError> {
851 ::fidl_next::munge! {
852 let Self::Encoded {
853 status_code,
854
855 } = out;
856 }
857
858 ::fidl_next::EncodeRef::encode_ref(&self.status_code, encoder, status_code)?;
859
860 Ok(())
861 }
862}
863
864impl ::fidl_next::EncodableOption for Box<CalculatorOnErrorRequest> {
865 type EncodedOption = ::fidl_next::WireBox<WireCalculatorOnErrorRequest>;
866}
867
868unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<CalculatorOnErrorRequest>
869where
870 ___E: ::fidl_next::Encoder + ?Sized,
871 CalculatorOnErrorRequest: ::fidl_next::Encode<___E>,
872{
873 #[inline]
874 fn encode_option(
875 this: Option<Self>,
876 encoder: &mut ___E,
877 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
878 ) -> Result<(), ::fidl_next::EncodeError> {
879 if let Some(inner) = this {
880 ::fidl_next::EncoderExt::encode_next(encoder, *inner)?;
881 ::fidl_next::WireBox::encode_present(out);
882 } else {
883 ::fidl_next::WireBox::encode_absent(out);
884 }
885
886 Ok(())
887 }
888}
889
890unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for Box<CalculatorOnErrorRequest>
891where
892 ___E: ::fidl_next::Encoder + ?Sized,
893 CalculatorOnErrorRequest: ::fidl_next::EncodeRef<___E>,
894{
895 #[inline]
896 fn encode_option_ref(
897 this: Option<&Self>,
898 encoder: &mut ___E,
899 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
900 ) -> Result<(), ::fidl_next::EncodeError> {
901 if let Some(inner) = this {
902 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
903 ::fidl_next::WireBox::encode_present(out);
904 } else {
905 ::fidl_next::WireBox::encode_absent(out);
906 }
907
908 Ok(())
909 }
910}
911
912impl ::fidl_next::TakeFrom<WireCalculatorOnErrorRequest> for CalculatorOnErrorRequest {
913 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
914 ::fidl_next::CopyOptimization::enable_if(
915 true && <u32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
916 )
917 };
918
919 #[inline]
920 fn take_from(from: &WireCalculatorOnErrorRequest) -> Self {
921 Self { status_code: ::fidl_next::TakeFrom::take_from(&from.status_code) }
922 }
923}
924
925#[derive(Clone, Debug)]
927#[repr(C)]
928pub struct WireCalculatorOnErrorRequest {
929 pub status_code: ::fidl_next::WireU32,
930}
931
932unsafe impl ::fidl_next::ZeroPadding for WireCalculatorOnErrorRequest {
933 #[inline]
934 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
935}
936
937unsafe impl<___D> ::fidl_next::Decode<___D> for WireCalculatorOnErrorRequest
938where
939 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
940{
941 fn decode(
942 slot: ::fidl_next::Slot<'_, Self>,
943 decoder: &mut ___D,
944 ) -> Result<(), ::fidl_next::DecodeError> {
945 ::fidl_next::munge! {
946 let Self {
947 mut status_code,
948
949 } = slot;
950 }
951
952 ::fidl_next::Decode::decode(status_code.as_mut(), decoder)?;
953
954 Ok(())
955 }
956}
957
958#[derive(Debug)]
960pub struct Calculator;
961
962pub mod calculator {
963 pub mod prelude {
964 pub use crate::{
965 calculator, Calculator, CalculatorClientHandler, CalculatorClientSender,
966 CalculatorServerHandler, CalculatorServerSender,
967 };
968
969 pub use crate::CalculatorAddRequest;
970
971 pub use crate::CalculatorDivideRequest;
972
973 pub use crate::CalculatorOnErrorRequest;
974
975 pub use crate::CalculatorAddResponse;
976
977 pub use crate::CalculatorDivideResponse;
978
979 pub use crate::DivisionError;
980 }
981
982 pub struct Add;
983
984 impl ::fidl_next::Method for Add {
985 const ORDINAL: u64 = 8640324702111165953;
986
987 type Protocol = crate::Calculator;
988
989 type Request = crate::WireCalculatorAddRequest;
990
991 type Response = ::fidl_next::WireFlexible<crate::WireCalculatorAddResponse>;
992 }
993
994 pub struct Divide;
995
996 impl ::fidl_next::Method for Divide {
997 const ORDINAL: u64 = 5497947425807432439;
998
999 type Protocol = crate::Calculator;
1000
1001 type Request = crate::WireCalculatorDivideRequest;
1002
1003 type Response = ::fidl_next::WireFlexibleResult<
1004 crate::WireCalculatorDivideResponse,
1005 crate::WireDivisionError,
1006 >;
1007 }
1008
1009 pub struct Clear;
1010
1011 impl ::fidl_next::Method for Clear {
1012 const ORDINAL: u64 = 7439411180362570889;
1013
1014 type Protocol = crate::Calculator;
1015
1016 type Request = ();
1017
1018 type Response = ::fidl_next::Never;
1019 }
1020
1021 pub struct OnError;
1022
1023 impl ::fidl_next::Method for OnError {
1024 const ORDINAL: u64 = 8940578522385404924;
1025
1026 type Protocol = crate::Calculator;
1027
1028 type Request = ::fidl_next::Never;
1029
1030 type Response = crate::WireCalculatorOnErrorRequest;
1031 }
1032}
1033
1034pub trait CalculatorClientSender {
1036 type Transport: ::fidl_next::Transport;
1037
1038 fn add<___R>(
1039 &self,
1040 request: ___R,
1041 ) -> Result<
1042 ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Add>,
1043 ::fidl_next::EncodeError,
1044 >
1045 where
1046 ___R: ::fidl_next::Encode<
1047 <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1048 Encoded = crate::WireCalculatorAddRequest,
1049 >;
1050
1051 fn divide<___R>(
1052 &self,
1053 request: ___R,
1054 ) -> Result<
1055 ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Divide>,
1056 ::fidl_next::EncodeError,
1057 >
1058 where
1059 ___R: ::fidl_next::Encode<
1060 <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1061 Encoded = crate::WireCalculatorDivideRequest,
1062 >;
1063
1064 fn clear(
1065 &self,
1066 ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>;
1067}
1068
1069impl<___T> CalculatorClientSender for ::fidl_next::ClientSender<___T, Calculator>
1070where
1071 ___T: ::fidl_next::Transport,
1072{
1073 type Transport = ___T;
1074
1075 fn add<___R>(
1076 &self,
1077 request: ___R,
1078 ) -> Result<
1079 ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Add>,
1080 ::fidl_next::EncodeError,
1081 >
1082 where
1083 ___R: ::fidl_next::Encode<
1084 <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1085 Encoded = crate::WireCalculatorAddRequest,
1086 >,
1087 {
1088 self.as_untyped()
1089 .send_two_way(8640324702111165953, request)
1090 .map(::fidl_next::ResponseFuture::from_untyped)
1091 }
1092
1093 fn divide<___R>(
1094 &self,
1095 request: ___R,
1096 ) -> Result<
1097 ::fidl_next::ResponseFuture<'_, Self::Transport, calculator::Divide>,
1098 ::fidl_next::EncodeError,
1099 >
1100 where
1101 ___R: ::fidl_next::Encode<
1102 <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1103 Encoded = crate::WireCalculatorDivideRequest,
1104 >,
1105 {
1106 self.as_untyped()
1107 .send_two_way(5497947425807432439, request)
1108 .map(::fidl_next::ResponseFuture::from_untyped)
1109 }
1110
1111 fn clear(
1112 &self,
1113 ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError> {
1114 self.as_untyped().send_one_way(7439411180362570889, ())
1115 }
1116}
1117
1118pub trait CalculatorClientHandler<___T: ::fidl_next::Transport> {
1122 fn on_error(
1123 &mut self,
1124 sender: &::fidl_next::ClientSender<___T, Calculator>,
1125
1126 event: ::fidl_next::Response<___T, calculator::OnError>,
1127 );
1128
1129 fn on_unknown_interaction(
1130 &mut self,
1131 sender: &::fidl_next::ClientSender<___T, Calculator>,
1132 ordinal: u64,
1133 ) {
1134 sender.close();
1135 }
1136}
1137
1138impl<___T, ___H> ::fidl_next::ClientProtocol<___T, ___H> for Calculator
1139where
1140 ___T: ::fidl_next::Transport,
1141 ___H: CalculatorClientHandler<___T>,
1142
1143 <calculator::Add as ::fidl_next::Method>::Response:
1144 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1145
1146 <calculator::Divide as ::fidl_next::Method>::Response:
1147 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1148
1149 <calculator::OnError as ::fidl_next::Method>::Response:
1150 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1151{
1152 fn on_event(
1153 handler: &mut ___H,
1154 sender: &::fidl_next::ClientSender<___T, Self>,
1155 ordinal: u64,
1156 buffer: ___T::RecvBuffer,
1157 ) {
1158 match ordinal {
1159 8940578522385404924 => match ::fidl_next::DecoderExt::decode(buffer) {
1160 Ok(decoded) => handler.on_error(sender, decoded),
1161 Err(e) => {
1162 sender.close();
1163 }
1164 },
1165
1166 ordinal => handler.on_unknown_interaction(sender, ordinal),
1167 }
1168 }
1169}
1170
1171pub trait CalculatorServerSender {
1173 type Transport: ::fidl_next::Transport;
1174
1175 fn on_error<___R>(
1176 &self,
1177 request: ___R,
1178 ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>
1179 where
1180 ___R: ::fidl_next::Encode<
1181 <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1182 Encoded = <calculator::OnError as ::fidl_next::Method>::Response,
1183 >;
1184}
1185
1186impl<___T> CalculatorServerSender for ::fidl_next::ServerSender<___T, Calculator>
1187where
1188 ___T: ::fidl_next::Transport,
1189{
1190 type Transport = ___T;
1191
1192 fn on_error<___R>(
1193 &self,
1194 request: ___R,
1195 ) -> Result<::fidl_next::SendFuture<'_, Self::Transport>, ::fidl_next::EncodeError>
1196 where
1197 ___R: ::fidl_next::Encode<
1198 <Self::Transport as ::fidl_next::Transport>::SendBuffer,
1199 Encoded = <calculator::OnError as ::fidl_next::Method>::Response,
1200 >,
1201 {
1202 self.as_untyped().send_event(8940578522385404924, request)
1203 }
1204}
1205
1206pub trait CalculatorServerHandler<___T: ::fidl_next::Transport> {
1210 fn add(
1211 &mut self,
1212 sender: &::fidl_next::ServerSender<___T, Calculator>,
1213
1214 request: ::fidl_next::Request<___T, calculator::Add>,
1215
1216 responder: ::fidl_next::Responder<calculator::Add>,
1217 );
1218
1219 fn divide(
1220 &mut self,
1221 sender: &::fidl_next::ServerSender<___T, Calculator>,
1222
1223 request: ::fidl_next::Request<___T, calculator::Divide>,
1224
1225 responder: ::fidl_next::Responder<calculator::Divide>,
1226 );
1227
1228 fn clear(&mut self, sender: &::fidl_next::ServerSender<___T, Calculator>);
1229
1230 fn on_unknown_interaction(
1231 &mut self,
1232 sender: &::fidl_next::ServerSender<___T, Calculator>,
1233 ordinal: u64,
1234 ) {
1235 sender.close();
1236 }
1237}
1238
1239impl<___T, ___H> ::fidl_next::ServerProtocol<___T, ___H> for Calculator
1240where
1241 ___T: ::fidl_next::Transport,
1242 ___H: CalculatorServerHandler<___T>,
1243
1244 crate::WireCalculatorAddRequest:
1245 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1246
1247 crate::WireCalculatorDivideRequest:
1248 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
1249{
1250 fn on_one_way(
1251 handler: &mut ___H,
1252 sender: &::fidl_next::ServerSender<___T, Self>,
1253 ordinal: u64,
1254 buffer: ___T::RecvBuffer,
1255 ) {
1256 match ordinal {
1257 7439411180362570889 => {
1258 handler.clear(sender);
1259 }
1260
1261 ordinal => handler.on_unknown_interaction(sender, ordinal),
1262 }
1263 }
1264
1265 fn on_two_way(
1266 handler: &mut ___H,
1267 sender: &::fidl_next::ServerSender<___T, Self>,
1268 ordinal: u64,
1269 buffer: ___T::RecvBuffer,
1270 responder: ::fidl_next::protocol::Responder,
1271 ) {
1272 match ordinal {
1273 8640324702111165953 => {
1274 let responder = ::fidl_next::Responder::from_untyped(responder);
1275
1276 match ::fidl_next::DecoderExt::decode(buffer) {
1277 Ok(decoded) => handler.add(sender, decoded, responder),
1278 Err(e) => {
1279 sender.close();
1280 }
1281 }
1282 }
1283
1284 5497947425807432439 => {
1285 let responder = ::fidl_next::Responder::from_untyped(responder);
1286
1287 match ::fidl_next::DecoderExt::decode(buffer) {
1288 Ok(decoded) => handler.divide(sender, decoded, responder),
1289 Err(e) => {
1290 sender.close();
1291 }
1292 }
1293 }
1294
1295 ordinal => handler.on_unknown_interaction(sender, ordinal),
1296 }
1297 }
1298}
1299
1300pub mod compat {
1302
1303 impl ::fidl_next::TakeFrom<crate::WireCalculatorAddRequest>
1304 for ::fidl_examples_calculator::CalculatorAddRequest
1305 {
1306 #[inline]
1307 fn take_from(from: &crate::WireCalculatorAddRequest) -> Self {
1308 Self {
1309 a: ::fidl_next::TakeFrom::take_from(&from.a),
1310
1311 b: ::fidl_next::TakeFrom::take_from(&from.b),
1312 }
1313 }
1314 }
1315
1316 impl ::fidl_next::TakeFrom<crate::WireCalculatorAddResponse>
1317 for ::fidl_examples_calculator::CalculatorAddResponse
1318 {
1319 #[inline]
1320 fn take_from(from: &crate::WireCalculatorAddResponse) -> Self {
1321 Self { sum: ::fidl_next::TakeFrom::take_from(&from.sum) }
1322 }
1323 }
1324
1325 impl ::fidl_next::TakeFrom<crate::WireCalculatorDivideRequest>
1326 for ::fidl_examples_calculator::CalculatorDivideRequest
1327 {
1328 #[inline]
1329 fn take_from(from: &crate::WireCalculatorDivideRequest) -> Self {
1330 Self {
1331 dividend: ::fidl_next::TakeFrom::take_from(&from.dividend),
1332
1333 divisor: ::fidl_next::TakeFrom::take_from(&from.divisor),
1334 }
1335 }
1336 }
1337
1338 impl ::fidl_next::TakeFrom<crate::WireCalculatorDivideResponse>
1339 for ::fidl_examples_calculator::CalculatorDivideResponse
1340 {
1341 #[inline]
1342 fn take_from(from: &crate::WireCalculatorDivideResponse) -> Self {
1343 Self {
1344 quotient: ::fidl_next::TakeFrom::take_from(&from.quotient),
1345
1346 remainder: ::fidl_next::TakeFrom::take_from(&from.remainder),
1347 }
1348 }
1349 }
1350
1351 impl ::fidl_next::TakeFrom<crate::WireDivisionError> for ::fidl_examples_calculator::DivisionError {
1352 #[inline]
1353 fn take_from(from: &crate::WireDivisionError) -> Self {
1354 match crate::DivisionError::from(*from) {
1355 crate::DivisionError::DivideByZero => Self::DivideByZero,
1356 }
1357 }
1358 }
1359
1360 impl ::fidl_next::TakeFrom<crate::WireCalculatorOnErrorRequest>
1361 for ::fidl_examples_calculator::CalculatorOnErrorRequest
1362 {
1363 #[inline]
1364 fn take_from(from: &crate::WireCalculatorOnErrorRequest) -> Self {
1365 Self { status_code: ::fidl_next::TakeFrom::take_from(&from.status_code) }
1366 }
1367 }
1368
1369 #[cfg(target_os = "fuchsia")]
1370 pub type CalculatorProxy =
1373 ::fidl_next::ClientSender<::fidl_next::fuchsia::zx::Channel, crate::Calculator>;
1374
1375 impl ::fidl_next::TakeFrom<crate::Calculator> for ::fidl_examples_calculator::CalculatorMarker {
1376 #[inline]
1377 fn take_from(from: &crate::Calculator) -> Self {
1378 Self
1379 }
1380 }
1381}