fidl_fuchsia_examples_services_common/
fidl_fuchsia_examples_services_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12#[repr(C)]
13pub struct ReadOnlyAccountGetBalanceResponse {
14    pub balance: i64,
15}
16
17impl fidl::Persistable for ReadOnlyAccountGetBalanceResponse {}
18
19#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20pub struct ReadOnlyAccountGetOwnerResponse {
21    pub owner: String,
22}
23
24impl fidl::Persistable for ReadOnlyAccountGetOwnerResponse {}
25
26#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27#[repr(C)]
28pub struct ReadWriteAccountCreditRequest {
29    pub amount: i64,
30}
31
32impl fidl::Persistable for ReadWriteAccountCreditRequest {}
33
34#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35#[repr(C)]
36pub struct ReadWriteAccountDebitRequest {
37    pub amount: i64,
38}
39
40impl fidl::Persistable for ReadWriteAccountDebitRequest {}
41
42#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
43pub struct ReadWriteAccountDebitResponse {
44    pub succeeded: bool,
45}
46
47impl fidl::Persistable for ReadWriteAccountDebitResponse {}
48
49mod internal {
50    use super::*;
51
52    impl fidl::encoding::ValueTypeMarker for ReadOnlyAccountGetBalanceResponse {
53        type Borrowed<'a> = &'a Self;
54        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
55            value
56        }
57    }
58
59    unsafe impl fidl::encoding::TypeMarker for ReadOnlyAccountGetBalanceResponse {
60        type Owned = Self;
61
62        #[inline(always)]
63        fn inline_align(_context: fidl::encoding::Context) -> usize {
64            8
65        }
66
67        #[inline(always)]
68        fn inline_size(_context: fidl::encoding::Context) -> usize {
69            8
70        }
71        #[inline(always)]
72        fn encode_is_copy() -> bool {
73            true
74        }
75
76        #[inline(always)]
77        fn decode_is_copy() -> bool {
78            true
79        }
80    }
81
82    unsafe impl<D: fidl::encoding::ResourceDialect>
83        fidl::encoding::Encode<ReadOnlyAccountGetBalanceResponse, D>
84        for &ReadOnlyAccountGetBalanceResponse
85    {
86        #[inline]
87        unsafe fn encode(
88            self,
89            encoder: &mut fidl::encoding::Encoder<'_, D>,
90            offset: usize,
91            _depth: fidl::encoding::Depth,
92        ) -> fidl::Result<()> {
93            encoder.debug_check_bounds::<ReadOnlyAccountGetBalanceResponse>(offset);
94            unsafe {
95                // Copy the object into the buffer.
96                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
97                (buf_ptr as *mut ReadOnlyAccountGetBalanceResponse)
98                    .write_unaligned((self as *const ReadOnlyAccountGetBalanceResponse).read());
99                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
100                // done second because the memcpy will write garbage to these bytes.
101            }
102            Ok(())
103        }
104    }
105    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
106        fidl::encoding::Encode<ReadOnlyAccountGetBalanceResponse, D> for (T0,)
107    {
108        #[inline]
109        unsafe fn encode(
110            self,
111            encoder: &mut fidl::encoding::Encoder<'_, D>,
112            offset: usize,
113            depth: fidl::encoding::Depth,
114        ) -> fidl::Result<()> {
115            encoder.debug_check_bounds::<ReadOnlyAccountGetBalanceResponse>(offset);
116            // Zero out padding regions. There's no need to apply masks
117            // because the unmasked parts will be overwritten by fields.
118            // Write the fields.
119            self.0.encode(encoder, offset + 0, depth)?;
120            Ok(())
121        }
122    }
123
124    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
125        for ReadOnlyAccountGetBalanceResponse
126    {
127        #[inline(always)]
128        fn new_empty() -> Self {
129            Self { balance: fidl::new_empty!(i64, D) }
130        }
131
132        #[inline]
133        unsafe fn decode(
134            &mut self,
135            decoder: &mut fidl::encoding::Decoder<'_, D>,
136            offset: usize,
137            _depth: fidl::encoding::Depth,
138        ) -> fidl::Result<()> {
139            decoder.debug_check_bounds::<Self>(offset);
140            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
141            // Verify that padding bytes are zero.
142            // Copy from the buffer into the object.
143            unsafe {
144                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
145            }
146            Ok(())
147        }
148    }
149
150    impl fidl::encoding::ValueTypeMarker for ReadOnlyAccountGetOwnerResponse {
151        type Borrowed<'a> = &'a Self;
152        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
153            value
154        }
155    }
156
157    unsafe impl fidl::encoding::TypeMarker for ReadOnlyAccountGetOwnerResponse {
158        type Owned = Self;
159
160        #[inline(always)]
161        fn inline_align(_context: fidl::encoding::Context) -> usize {
162            8
163        }
164
165        #[inline(always)]
166        fn inline_size(_context: fidl::encoding::Context) -> usize {
167            16
168        }
169    }
170
171    unsafe impl<D: fidl::encoding::ResourceDialect>
172        fidl::encoding::Encode<ReadOnlyAccountGetOwnerResponse, D>
173        for &ReadOnlyAccountGetOwnerResponse
174    {
175        #[inline]
176        unsafe fn encode(
177            self,
178            encoder: &mut fidl::encoding::Encoder<'_, D>,
179            offset: usize,
180            _depth: fidl::encoding::Depth,
181        ) -> fidl::Result<()> {
182            encoder.debug_check_bounds::<ReadOnlyAccountGetOwnerResponse>(offset);
183            // Delegate to tuple encoding.
184            fidl::encoding::Encode::<ReadOnlyAccountGetOwnerResponse, D>::encode(
185                (<fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
186                    &self.owner,
187                ),),
188                encoder,
189                offset,
190                _depth,
191            )
192        }
193    }
194    unsafe impl<
195            D: fidl::encoding::ResourceDialect,
196            T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
197        > fidl::encoding::Encode<ReadOnlyAccountGetOwnerResponse, D> for (T0,)
198    {
199        #[inline]
200        unsafe fn encode(
201            self,
202            encoder: &mut fidl::encoding::Encoder<'_, D>,
203            offset: usize,
204            depth: fidl::encoding::Depth,
205        ) -> fidl::Result<()> {
206            encoder.debug_check_bounds::<ReadOnlyAccountGetOwnerResponse>(offset);
207            // Zero out padding regions. There's no need to apply masks
208            // because the unmasked parts will be overwritten by fields.
209            // Write the fields.
210            self.0.encode(encoder, offset + 0, depth)?;
211            Ok(())
212        }
213    }
214
215    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
216        for ReadOnlyAccountGetOwnerResponse
217    {
218        #[inline(always)]
219        fn new_empty() -> Self {
220            Self { owner: fidl::new_empty!(fidl::encoding::UnboundedString, D) }
221        }
222
223        #[inline]
224        unsafe fn decode(
225            &mut self,
226            decoder: &mut fidl::encoding::Decoder<'_, D>,
227            offset: usize,
228            _depth: fidl::encoding::Depth,
229        ) -> fidl::Result<()> {
230            decoder.debug_check_bounds::<Self>(offset);
231            // Verify that padding bytes are zero.
232            fidl::decode!(
233                fidl::encoding::UnboundedString,
234                D,
235                &mut self.owner,
236                decoder,
237                offset + 0,
238                _depth
239            )?;
240            Ok(())
241        }
242    }
243
244    impl fidl::encoding::ValueTypeMarker for ReadWriteAccountCreditRequest {
245        type Borrowed<'a> = &'a Self;
246        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
247            value
248        }
249    }
250
251    unsafe impl fidl::encoding::TypeMarker for ReadWriteAccountCreditRequest {
252        type Owned = Self;
253
254        #[inline(always)]
255        fn inline_align(_context: fidl::encoding::Context) -> usize {
256            8
257        }
258
259        #[inline(always)]
260        fn inline_size(_context: fidl::encoding::Context) -> usize {
261            8
262        }
263        #[inline(always)]
264        fn encode_is_copy() -> bool {
265            true
266        }
267
268        #[inline(always)]
269        fn decode_is_copy() -> bool {
270            true
271        }
272    }
273
274    unsafe impl<D: fidl::encoding::ResourceDialect>
275        fidl::encoding::Encode<ReadWriteAccountCreditRequest, D>
276        for &ReadWriteAccountCreditRequest
277    {
278        #[inline]
279        unsafe fn encode(
280            self,
281            encoder: &mut fidl::encoding::Encoder<'_, D>,
282            offset: usize,
283            _depth: fidl::encoding::Depth,
284        ) -> fidl::Result<()> {
285            encoder.debug_check_bounds::<ReadWriteAccountCreditRequest>(offset);
286            unsafe {
287                // Copy the object into the buffer.
288                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
289                (buf_ptr as *mut ReadWriteAccountCreditRequest)
290                    .write_unaligned((self as *const ReadWriteAccountCreditRequest).read());
291                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
292                // done second because the memcpy will write garbage to these bytes.
293            }
294            Ok(())
295        }
296    }
297    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
298        fidl::encoding::Encode<ReadWriteAccountCreditRequest, D> for (T0,)
299    {
300        #[inline]
301        unsafe fn encode(
302            self,
303            encoder: &mut fidl::encoding::Encoder<'_, D>,
304            offset: usize,
305            depth: fidl::encoding::Depth,
306        ) -> fidl::Result<()> {
307            encoder.debug_check_bounds::<ReadWriteAccountCreditRequest>(offset);
308            // Zero out padding regions. There's no need to apply masks
309            // because the unmasked parts will be overwritten by fields.
310            // Write the fields.
311            self.0.encode(encoder, offset + 0, depth)?;
312            Ok(())
313        }
314    }
315
316    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
317        for ReadWriteAccountCreditRequest
318    {
319        #[inline(always)]
320        fn new_empty() -> Self {
321            Self { amount: fidl::new_empty!(i64, D) }
322        }
323
324        #[inline]
325        unsafe fn decode(
326            &mut self,
327            decoder: &mut fidl::encoding::Decoder<'_, D>,
328            offset: usize,
329            _depth: fidl::encoding::Depth,
330        ) -> fidl::Result<()> {
331            decoder.debug_check_bounds::<Self>(offset);
332            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
333            // Verify that padding bytes are zero.
334            // Copy from the buffer into the object.
335            unsafe {
336                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
337            }
338            Ok(())
339        }
340    }
341
342    impl fidl::encoding::ValueTypeMarker for ReadWriteAccountDebitRequest {
343        type Borrowed<'a> = &'a Self;
344        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
345            value
346        }
347    }
348
349    unsafe impl fidl::encoding::TypeMarker for ReadWriteAccountDebitRequest {
350        type Owned = Self;
351
352        #[inline(always)]
353        fn inline_align(_context: fidl::encoding::Context) -> usize {
354            8
355        }
356
357        #[inline(always)]
358        fn inline_size(_context: fidl::encoding::Context) -> usize {
359            8
360        }
361        #[inline(always)]
362        fn encode_is_copy() -> bool {
363            true
364        }
365
366        #[inline(always)]
367        fn decode_is_copy() -> bool {
368            true
369        }
370    }
371
372    unsafe impl<D: fidl::encoding::ResourceDialect>
373        fidl::encoding::Encode<ReadWriteAccountDebitRequest, D> for &ReadWriteAccountDebitRequest
374    {
375        #[inline]
376        unsafe fn encode(
377            self,
378            encoder: &mut fidl::encoding::Encoder<'_, D>,
379            offset: usize,
380            _depth: fidl::encoding::Depth,
381        ) -> fidl::Result<()> {
382            encoder.debug_check_bounds::<ReadWriteAccountDebitRequest>(offset);
383            unsafe {
384                // Copy the object into the buffer.
385                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
386                (buf_ptr as *mut ReadWriteAccountDebitRequest)
387                    .write_unaligned((self as *const ReadWriteAccountDebitRequest).read());
388                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
389                // done second because the memcpy will write garbage to these bytes.
390            }
391            Ok(())
392        }
393    }
394    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
395        fidl::encoding::Encode<ReadWriteAccountDebitRequest, D> for (T0,)
396    {
397        #[inline]
398        unsafe fn encode(
399            self,
400            encoder: &mut fidl::encoding::Encoder<'_, D>,
401            offset: usize,
402            depth: fidl::encoding::Depth,
403        ) -> fidl::Result<()> {
404            encoder.debug_check_bounds::<ReadWriteAccountDebitRequest>(offset);
405            // Zero out padding regions. There's no need to apply masks
406            // because the unmasked parts will be overwritten by fields.
407            // Write the fields.
408            self.0.encode(encoder, offset + 0, depth)?;
409            Ok(())
410        }
411    }
412
413    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
414        for ReadWriteAccountDebitRequest
415    {
416        #[inline(always)]
417        fn new_empty() -> Self {
418            Self { amount: fidl::new_empty!(i64, D) }
419        }
420
421        #[inline]
422        unsafe fn decode(
423            &mut self,
424            decoder: &mut fidl::encoding::Decoder<'_, D>,
425            offset: usize,
426            _depth: fidl::encoding::Depth,
427        ) -> fidl::Result<()> {
428            decoder.debug_check_bounds::<Self>(offset);
429            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
430            // Verify that padding bytes are zero.
431            // Copy from the buffer into the object.
432            unsafe {
433                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
434            }
435            Ok(())
436        }
437    }
438
439    impl fidl::encoding::ValueTypeMarker for ReadWriteAccountDebitResponse {
440        type Borrowed<'a> = &'a Self;
441        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
442            value
443        }
444    }
445
446    unsafe impl fidl::encoding::TypeMarker for ReadWriteAccountDebitResponse {
447        type Owned = Self;
448
449        #[inline(always)]
450        fn inline_align(_context: fidl::encoding::Context) -> usize {
451            1
452        }
453
454        #[inline(always)]
455        fn inline_size(_context: fidl::encoding::Context) -> usize {
456            1
457        }
458    }
459
460    unsafe impl<D: fidl::encoding::ResourceDialect>
461        fidl::encoding::Encode<ReadWriteAccountDebitResponse, D>
462        for &ReadWriteAccountDebitResponse
463    {
464        #[inline]
465        unsafe fn encode(
466            self,
467            encoder: &mut fidl::encoding::Encoder<'_, D>,
468            offset: usize,
469            _depth: fidl::encoding::Depth,
470        ) -> fidl::Result<()> {
471            encoder.debug_check_bounds::<ReadWriteAccountDebitResponse>(offset);
472            // Delegate to tuple encoding.
473            fidl::encoding::Encode::<ReadWriteAccountDebitResponse, D>::encode(
474                (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.succeeded),),
475                encoder,
476                offset,
477                _depth,
478            )
479        }
480    }
481    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
482        fidl::encoding::Encode<ReadWriteAccountDebitResponse, D> for (T0,)
483    {
484        #[inline]
485        unsafe fn encode(
486            self,
487            encoder: &mut fidl::encoding::Encoder<'_, D>,
488            offset: usize,
489            depth: fidl::encoding::Depth,
490        ) -> fidl::Result<()> {
491            encoder.debug_check_bounds::<ReadWriteAccountDebitResponse>(offset);
492            // Zero out padding regions. There's no need to apply masks
493            // because the unmasked parts will be overwritten by fields.
494            // Write the fields.
495            self.0.encode(encoder, offset + 0, depth)?;
496            Ok(())
497        }
498    }
499
500    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
501        for ReadWriteAccountDebitResponse
502    {
503        #[inline(always)]
504        fn new_empty() -> Self {
505            Self { succeeded: fidl::new_empty!(bool, D) }
506        }
507
508        #[inline]
509        unsafe fn decode(
510            &mut self,
511            decoder: &mut fidl::encoding::Decoder<'_, D>,
512            offset: usize,
513            _depth: fidl::encoding::Depth,
514        ) -> fidl::Result<()> {
515            decoder.debug_check_bounds::<Self>(offset);
516            // Verify that padding bytes are zero.
517            fidl::decode!(bool, D, &mut self.succeeded, decoder, offset + 0, _depth)?;
518            Ok(())
519        }
520    }
521}