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