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