fidl_fuchsia_examples_common/
fidl_fuchsia_examples_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
11pub const MAX_STRING_LENGTH: u64 = 32;
12
13#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct EchoEchoStringRequest {
15    pub value: String,
16}
17
18impl fidl::Persistable for EchoEchoStringRequest {}
19
20#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
21pub struct EchoEchoStringResponse {
22    pub response: String,
23}
24
25impl fidl::Persistable for EchoEchoStringResponse {}
26
27mod internal {
28    use super::*;
29
30    impl fidl::encoding::ValueTypeMarker for EchoEchoStringRequest {
31        type Borrowed<'a> = &'a Self;
32        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
33            value
34        }
35    }
36
37    unsafe impl fidl::encoding::TypeMarker for EchoEchoStringRequest {
38        type Owned = Self;
39
40        #[inline(always)]
41        fn inline_align(_context: fidl::encoding::Context) -> usize {
42            8
43        }
44
45        #[inline(always)]
46        fn inline_size(_context: fidl::encoding::Context) -> usize {
47            16
48        }
49    }
50
51    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EchoEchoStringRequest, D>
52        for &EchoEchoStringRequest
53    {
54        #[inline]
55        unsafe fn encode(
56            self,
57            encoder: &mut fidl::encoding::Encoder<'_, D>,
58            offset: usize,
59            _depth: fidl::encoding::Depth,
60        ) -> fidl::Result<()> {
61            encoder.debug_check_bounds::<EchoEchoStringRequest>(offset);
62            // Delegate to tuple encoding.
63            fidl::encoding::Encode::<EchoEchoStringRequest, D>::encode(
64                (<fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(
65                    &self.value,
66                ),),
67                encoder,
68                offset,
69                _depth,
70            )
71        }
72    }
73    unsafe impl<
74            D: fidl::encoding::ResourceDialect,
75            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<32>, D>,
76        > fidl::encoding::Encode<EchoEchoStringRequest, D> for (T0,)
77    {
78        #[inline]
79        unsafe fn encode(
80            self,
81            encoder: &mut fidl::encoding::Encoder<'_, D>,
82            offset: usize,
83            depth: fidl::encoding::Depth,
84        ) -> fidl::Result<()> {
85            encoder.debug_check_bounds::<EchoEchoStringRequest>(offset);
86            // Zero out padding regions. There's no need to apply masks
87            // because the unmasked parts will be overwritten by fields.
88            // Write the fields.
89            self.0.encode(encoder, offset + 0, depth)?;
90            Ok(())
91        }
92    }
93
94    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EchoEchoStringRequest {
95        #[inline(always)]
96        fn new_empty() -> Self {
97            Self { value: fidl::new_empty!(fidl::encoding::BoundedString<32>, D) }
98        }
99
100        #[inline]
101        unsafe fn decode(
102            &mut self,
103            decoder: &mut fidl::encoding::Decoder<'_, D>,
104            offset: usize,
105            _depth: fidl::encoding::Depth,
106        ) -> fidl::Result<()> {
107            decoder.debug_check_bounds::<Self>(offset);
108            // Verify that padding bytes are zero.
109            fidl::decode!(
110                fidl::encoding::BoundedString<32>,
111                D,
112                &mut self.value,
113                decoder,
114                offset + 0,
115                _depth
116            )?;
117            Ok(())
118        }
119    }
120
121    impl fidl::encoding::ValueTypeMarker for EchoEchoStringResponse {
122        type Borrowed<'a> = &'a Self;
123        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
124            value
125        }
126    }
127
128    unsafe impl fidl::encoding::TypeMarker for EchoEchoStringResponse {
129        type Owned = Self;
130
131        #[inline(always)]
132        fn inline_align(_context: fidl::encoding::Context) -> usize {
133            8
134        }
135
136        #[inline(always)]
137        fn inline_size(_context: fidl::encoding::Context) -> usize {
138            16
139        }
140    }
141
142    unsafe impl<D: fidl::encoding::ResourceDialect>
143        fidl::encoding::Encode<EchoEchoStringResponse, D> for &EchoEchoStringResponse
144    {
145        #[inline]
146        unsafe fn encode(
147            self,
148            encoder: &mut fidl::encoding::Encoder<'_, D>,
149            offset: usize,
150            _depth: fidl::encoding::Depth,
151        ) -> fidl::Result<()> {
152            encoder.debug_check_bounds::<EchoEchoStringResponse>(offset);
153            // Delegate to tuple encoding.
154            fidl::encoding::Encode::<EchoEchoStringResponse, D>::encode(
155                (<fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(
156                    &self.response,
157                ),),
158                encoder,
159                offset,
160                _depth,
161            )
162        }
163    }
164    unsafe impl<
165            D: fidl::encoding::ResourceDialect,
166            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<32>, D>,
167        > fidl::encoding::Encode<EchoEchoStringResponse, D> for (T0,)
168    {
169        #[inline]
170        unsafe fn encode(
171            self,
172            encoder: &mut fidl::encoding::Encoder<'_, D>,
173            offset: usize,
174            depth: fidl::encoding::Depth,
175        ) -> fidl::Result<()> {
176            encoder.debug_check_bounds::<EchoEchoStringResponse>(offset);
177            // Zero out padding regions. There's no need to apply masks
178            // because the unmasked parts will be overwritten by fields.
179            // Write the fields.
180            self.0.encode(encoder, offset + 0, depth)?;
181            Ok(())
182        }
183    }
184
185    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
186        for EchoEchoStringResponse
187    {
188        #[inline(always)]
189        fn new_empty() -> Self {
190            Self { response: fidl::new_empty!(fidl::encoding::BoundedString<32>, D) }
191        }
192
193        #[inline]
194        unsafe fn decode(
195            &mut self,
196            decoder: &mut fidl::encoding::Decoder<'_, D>,
197            offset: usize,
198            _depth: fidl::encoding::Depth,
199        ) -> fidl::Result<()> {
200            decoder.debug_check_bounds::<Self>(offset);
201            // Verify that padding bytes are zero.
202            fidl::decode!(
203                fidl::encoding::BoundedString<32>,
204                D,
205                &mut self.response,
206                decoder,
207                offset + 0,
208                _depth
209            )?;
210            Ok(())
211        }
212    }
213}