1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
12#[repr(u32)]
13pub enum DivisionError {
14 DivideByZero = 1,
15}
16
17impl DivisionError {
18 #[inline]
19 pub fn from_primitive(prim: u32) -> Option<Self> {
20 match prim {
21 1 => Some(Self::DivideByZero),
22 _ => None,
23 }
24 }
25
26 #[inline]
27 pub const fn into_primitive(self) -> u32 {
28 self as u32
29 }
30}
31
32#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33#[repr(C)]
34pub struct CalculatorAddRequest {
35 pub a: i32,
36 pub b: i32,
37}
38
39impl fidl::Persistable for CalculatorAddRequest {}
40
41#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42#[repr(C)]
43pub struct CalculatorDivideRequest {
44 pub dividend: i32,
45 pub divisor: i32,
46}
47
48impl fidl::Persistable for CalculatorDivideRequest {}
49
50#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
51#[repr(C)]
52pub struct CalculatorOnErrorRequest {
53 pub status_code: u32,
54}
55
56impl fidl::Persistable for CalculatorOnErrorRequest {}
57
58#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
59#[repr(C)]
60pub struct CalculatorAddResponse {
61 pub sum: i32,
62}
63
64impl fidl::Persistable for CalculatorAddResponse {}
65
66#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67#[repr(C)]
68pub struct CalculatorDivideResponse {
69 pub quotient: i32,
70 pub remainder: i32,
71}
72
73impl fidl::Persistable for CalculatorDivideResponse {}
74
75pub mod calculator_ordinals {
76 pub const ADD: u64 = 0x77e89989c55e6e01;
77 pub const DIVIDE: u64 = 0x4c4ca20ded067af7;
78 pub const CLEAR: u64 = 0x673e190d87949c89;
79 pub const ON_ERROR: u64 = 0x7c1350cc0144d3fc;
80}
81
82mod internal {
83 use super::*;
84 unsafe impl fidl::encoding::TypeMarker for DivisionError {
85 type Owned = Self;
86
87 #[inline(always)]
88 fn inline_align(_context: fidl::encoding::Context) -> usize {
89 std::mem::align_of::<u32>()
90 }
91
92 #[inline(always)]
93 fn inline_size(_context: fidl::encoding::Context) -> usize {
94 std::mem::size_of::<u32>()
95 }
96
97 #[inline(always)]
98 fn encode_is_copy() -> bool {
99 true
100 }
101
102 #[inline(always)]
103 fn decode_is_copy() -> bool {
104 false
105 }
106 }
107
108 impl fidl::encoding::ValueTypeMarker for DivisionError {
109 type Borrowed<'a> = Self;
110 #[inline(always)]
111 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
112 *value
113 }
114 }
115
116 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DivisionError {
117 #[inline]
118 unsafe fn encode(
119 self,
120 encoder: &mut fidl::encoding::Encoder<'_, D>,
121 offset: usize,
122 _depth: fidl::encoding::Depth,
123 ) -> fidl::Result<()> {
124 encoder.debug_check_bounds::<Self>(offset);
125 encoder.write_num(self.into_primitive(), offset);
126 Ok(())
127 }
128 }
129
130 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DivisionError {
131 #[inline(always)]
132 fn new_empty() -> Self {
133 Self::DivideByZero
134 }
135
136 #[inline]
137 unsafe fn decode(
138 &mut self,
139 decoder: &mut fidl::encoding::Decoder<'_, D>,
140 offset: usize,
141 _depth: fidl::encoding::Depth,
142 ) -> fidl::Result<()> {
143 decoder.debug_check_bounds::<Self>(offset);
144 let prim = decoder.read_num::<u32>(offset);
145
146 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
147 Ok(())
148 }
149 }
150
151 impl fidl::encoding::ValueTypeMarker for CalculatorAddRequest {
152 type Borrowed<'a> = &'a Self;
153 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
154 value
155 }
156 }
157
158 unsafe impl fidl::encoding::TypeMarker for CalculatorAddRequest {
159 type Owned = Self;
160
161 #[inline(always)]
162 fn inline_align(_context: fidl::encoding::Context) -> usize {
163 4
164 }
165
166 #[inline(always)]
167 fn inline_size(_context: fidl::encoding::Context) -> usize {
168 8
169 }
170 #[inline(always)]
171 fn encode_is_copy() -> bool {
172 true
173 }
174
175 #[inline(always)]
176 fn decode_is_copy() -> bool {
177 true
178 }
179 }
180
181 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CalculatorAddRequest, D>
182 for &CalculatorAddRequest
183 {
184 #[inline]
185 unsafe fn encode(
186 self,
187 encoder: &mut fidl::encoding::Encoder<'_, D>,
188 offset: usize,
189 _depth: fidl::encoding::Depth,
190 ) -> fidl::Result<()> {
191 encoder.debug_check_bounds::<CalculatorAddRequest>(offset);
192 unsafe {
193 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
195 (buf_ptr as *mut CalculatorAddRequest)
196 .write_unaligned((self as *const CalculatorAddRequest).read());
197 }
200 Ok(())
201 }
202 }
203 unsafe impl<
204 D: fidl::encoding::ResourceDialect,
205 T0: fidl::encoding::Encode<i32, D>,
206 T1: fidl::encoding::Encode<i32, D>,
207 > fidl::encoding::Encode<CalculatorAddRequest, D> for (T0, T1)
208 {
209 #[inline]
210 unsafe fn encode(
211 self,
212 encoder: &mut fidl::encoding::Encoder<'_, D>,
213 offset: usize,
214 depth: fidl::encoding::Depth,
215 ) -> fidl::Result<()> {
216 encoder.debug_check_bounds::<CalculatorAddRequest>(offset);
217 self.0.encode(encoder, offset + 0, depth)?;
221 self.1.encode(encoder, offset + 4, depth)?;
222 Ok(())
223 }
224 }
225
226 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CalculatorAddRequest {
227 #[inline(always)]
228 fn new_empty() -> Self {
229 Self { a: fidl::new_empty!(i32, D), b: fidl::new_empty!(i32, D) }
230 }
231
232 #[inline]
233 unsafe fn decode(
234 &mut self,
235 decoder: &mut fidl::encoding::Decoder<'_, D>,
236 offset: usize,
237 _depth: fidl::encoding::Depth,
238 ) -> fidl::Result<()> {
239 decoder.debug_check_bounds::<Self>(offset);
240 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
241 unsafe {
244 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
245 }
246 Ok(())
247 }
248 }
249
250 impl fidl::encoding::ValueTypeMarker for CalculatorDivideRequest {
251 type Borrowed<'a> = &'a Self;
252 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
253 value
254 }
255 }
256
257 unsafe impl fidl::encoding::TypeMarker for CalculatorDivideRequest {
258 type Owned = Self;
259
260 #[inline(always)]
261 fn inline_align(_context: fidl::encoding::Context) -> usize {
262 4
263 }
264
265 #[inline(always)]
266 fn inline_size(_context: fidl::encoding::Context) -> usize {
267 8
268 }
269 #[inline(always)]
270 fn encode_is_copy() -> bool {
271 true
272 }
273
274 #[inline(always)]
275 fn decode_is_copy() -> bool {
276 true
277 }
278 }
279
280 unsafe impl<D: fidl::encoding::ResourceDialect>
281 fidl::encoding::Encode<CalculatorDivideRequest, D> for &CalculatorDivideRequest
282 {
283 #[inline]
284 unsafe fn encode(
285 self,
286 encoder: &mut fidl::encoding::Encoder<'_, D>,
287 offset: usize,
288 _depth: fidl::encoding::Depth,
289 ) -> fidl::Result<()> {
290 encoder.debug_check_bounds::<CalculatorDivideRequest>(offset);
291 unsafe {
292 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
294 (buf_ptr as *mut CalculatorDivideRequest)
295 .write_unaligned((self as *const CalculatorDivideRequest).read());
296 }
299 Ok(())
300 }
301 }
302 unsafe impl<
303 D: fidl::encoding::ResourceDialect,
304 T0: fidl::encoding::Encode<i32, D>,
305 T1: fidl::encoding::Encode<i32, D>,
306 > fidl::encoding::Encode<CalculatorDivideRequest, D> for (T0, T1)
307 {
308 #[inline]
309 unsafe fn encode(
310 self,
311 encoder: &mut fidl::encoding::Encoder<'_, D>,
312 offset: usize,
313 depth: fidl::encoding::Depth,
314 ) -> fidl::Result<()> {
315 encoder.debug_check_bounds::<CalculatorDivideRequest>(offset);
316 self.0.encode(encoder, offset + 0, depth)?;
320 self.1.encode(encoder, offset + 4, depth)?;
321 Ok(())
322 }
323 }
324
325 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
326 for CalculatorDivideRequest
327 {
328 #[inline(always)]
329 fn new_empty() -> Self {
330 Self { dividend: fidl::new_empty!(i32, D), divisor: fidl::new_empty!(i32, D) }
331 }
332
333 #[inline]
334 unsafe fn decode(
335 &mut self,
336 decoder: &mut fidl::encoding::Decoder<'_, D>,
337 offset: usize,
338 _depth: fidl::encoding::Depth,
339 ) -> fidl::Result<()> {
340 decoder.debug_check_bounds::<Self>(offset);
341 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
342 unsafe {
345 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
346 }
347 Ok(())
348 }
349 }
350
351 impl fidl::encoding::ValueTypeMarker for CalculatorOnErrorRequest {
352 type Borrowed<'a> = &'a Self;
353 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
354 value
355 }
356 }
357
358 unsafe impl fidl::encoding::TypeMarker for CalculatorOnErrorRequest {
359 type Owned = Self;
360
361 #[inline(always)]
362 fn inline_align(_context: fidl::encoding::Context) -> usize {
363 4
364 }
365
366 #[inline(always)]
367 fn inline_size(_context: fidl::encoding::Context) -> usize {
368 4
369 }
370 #[inline(always)]
371 fn encode_is_copy() -> bool {
372 true
373 }
374
375 #[inline(always)]
376 fn decode_is_copy() -> bool {
377 true
378 }
379 }
380
381 unsafe impl<D: fidl::encoding::ResourceDialect>
382 fidl::encoding::Encode<CalculatorOnErrorRequest, D> for &CalculatorOnErrorRequest
383 {
384 #[inline]
385 unsafe fn encode(
386 self,
387 encoder: &mut fidl::encoding::Encoder<'_, D>,
388 offset: usize,
389 _depth: fidl::encoding::Depth,
390 ) -> fidl::Result<()> {
391 encoder.debug_check_bounds::<CalculatorOnErrorRequest>(offset);
392 unsafe {
393 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
395 (buf_ptr as *mut CalculatorOnErrorRequest)
396 .write_unaligned((self as *const CalculatorOnErrorRequest).read());
397 }
400 Ok(())
401 }
402 }
403 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
404 fidl::encoding::Encode<CalculatorOnErrorRequest, D> for (T0,)
405 {
406 #[inline]
407 unsafe fn encode(
408 self,
409 encoder: &mut fidl::encoding::Encoder<'_, D>,
410 offset: usize,
411 depth: fidl::encoding::Depth,
412 ) -> fidl::Result<()> {
413 encoder.debug_check_bounds::<CalculatorOnErrorRequest>(offset);
414 self.0.encode(encoder, offset + 0, depth)?;
418 Ok(())
419 }
420 }
421
422 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
423 for CalculatorOnErrorRequest
424 {
425 #[inline(always)]
426 fn new_empty() -> Self {
427 Self { status_code: fidl::new_empty!(u32, D) }
428 }
429
430 #[inline]
431 unsafe fn decode(
432 &mut self,
433 decoder: &mut fidl::encoding::Decoder<'_, D>,
434 offset: usize,
435 _depth: fidl::encoding::Depth,
436 ) -> fidl::Result<()> {
437 decoder.debug_check_bounds::<Self>(offset);
438 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
439 unsafe {
442 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
443 }
444 Ok(())
445 }
446 }
447
448 impl fidl::encoding::ValueTypeMarker for CalculatorAddResponse {
449 type Borrowed<'a> = &'a Self;
450 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
451 value
452 }
453 }
454
455 unsafe impl fidl::encoding::TypeMarker for CalculatorAddResponse {
456 type Owned = Self;
457
458 #[inline(always)]
459 fn inline_align(_context: fidl::encoding::Context) -> usize {
460 4
461 }
462
463 #[inline(always)]
464 fn inline_size(_context: fidl::encoding::Context) -> usize {
465 4
466 }
467 #[inline(always)]
468 fn encode_is_copy() -> bool {
469 true
470 }
471
472 #[inline(always)]
473 fn decode_is_copy() -> bool {
474 true
475 }
476 }
477
478 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CalculatorAddResponse, D>
479 for &CalculatorAddResponse
480 {
481 #[inline]
482 unsafe fn encode(
483 self,
484 encoder: &mut fidl::encoding::Encoder<'_, D>,
485 offset: usize,
486 _depth: fidl::encoding::Depth,
487 ) -> fidl::Result<()> {
488 encoder.debug_check_bounds::<CalculatorAddResponse>(offset);
489 unsafe {
490 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
492 (buf_ptr as *mut CalculatorAddResponse)
493 .write_unaligned((self as *const CalculatorAddResponse).read());
494 }
497 Ok(())
498 }
499 }
500 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
501 fidl::encoding::Encode<CalculatorAddResponse, D> for (T0,)
502 {
503 #[inline]
504 unsafe fn encode(
505 self,
506 encoder: &mut fidl::encoding::Encoder<'_, D>,
507 offset: usize,
508 depth: fidl::encoding::Depth,
509 ) -> fidl::Result<()> {
510 encoder.debug_check_bounds::<CalculatorAddResponse>(offset);
511 self.0.encode(encoder, offset + 0, depth)?;
515 Ok(())
516 }
517 }
518
519 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CalculatorAddResponse {
520 #[inline(always)]
521 fn new_empty() -> Self {
522 Self { sum: fidl::new_empty!(i32, D) }
523 }
524
525 #[inline]
526 unsafe fn decode(
527 &mut self,
528 decoder: &mut fidl::encoding::Decoder<'_, D>,
529 offset: usize,
530 _depth: fidl::encoding::Depth,
531 ) -> fidl::Result<()> {
532 decoder.debug_check_bounds::<Self>(offset);
533 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
534 unsafe {
537 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
538 }
539 Ok(())
540 }
541 }
542
543 impl fidl::encoding::ValueTypeMarker for CalculatorDivideResponse {
544 type Borrowed<'a> = &'a Self;
545 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
546 value
547 }
548 }
549
550 unsafe impl fidl::encoding::TypeMarker for CalculatorDivideResponse {
551 type Owned = Self;
552
553 #[inline(always)]
554 fn inline_align(_context: fidl::encoding::Context) -> usize {
555 4
556 }
557
558 #[inline(always)]
559 fn inline_size(_context: fidl::encoding::Context) -> usize {
560 8
561 }
562 #[inline(always)]
563 fn encode_is_copy() -> bool {
564 true
565 }
566
567 #[inline(always)]
568 fn decode_is_copy() -> bool {
569 true
570 }
571 }
572
573 unsafe impl<D: fidl::encoding::ResourceDialect>
574 fidl::encoding::Encode<CalculatorDivideResponse, D> for &CalculatorDivideResponse
575 {
576 #[inline]
577 unsafe fn encode(
578 self,
579 encoder: &mut fidl::encoding::Encoder<'_, D>,
580 offset: usize,
581 _depth: fidl::encoding::Depth,
582 ) -> fidl::Result<()> {
583 encoder.debug_check_bounds::<CalculatorDivideResponse>(offset);
584 unsafe {
585 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
587 (buf_ptr as *mut CalculatorDivideResponse)
588 .write_unaligned((self as *const CalculatorDivideResponse).read());
589 }
592 Ok(())
593 }
594 }
595 unsafe impl<
596 D: fidl::encoding::ResourceDialect,
597 T0: fidl::encoding::Encode<i32, D>,
598 T1: fidl::encoding::Encode<i32, D>,
599 > fidl::encoding::Encode<CalculatorDivideResponse, D> for (T0, T1)
600 {
601 #[inline]
602 unsafe fn encode(
603 self,
604 encoder: &mut fidl::encoding::Encoder<'_, D>,
605 offset: usize,
606 depth: fidl::encoding::Depth,
607 ) -> fidl::Result<()> {
608 encoder.debug_check_bounds::<CalculatorDivideResponse>(offset);
609 self.0.encode(encoder, offset + 0, depth)?;
613 self.1.encode(encoder, offset + 4, depth)?;
614 Ok(())
615 }
616 }
617
618 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
619 for CalculatorDivideResponse
620 {
621 #[inline(always)]
622 fn new_empty() -> Self {
623 Self { quotient: fidl::new_empty!(i32, D), remainder: fidl::new_empty!(i32, D) }
624 }
625
626 #[inline]
627 unsafe fn decode(
628 &mut self,
629 decoder: &mut fidl::encoding::Decoder<'_, D>,
630 offset: usize,
631 _depth: fidl::encoding::Depth,
632 ) -> fidl::Result<()> {
633 decoder.debug_check_bounds::<Self>(offset);
634 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
635 unsafe {
638 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
639 }
640 Ok(())
641 }
642 }
643}