fidl_test_time_realm_common/
fidl_test_time_realm_common.rs1#![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_TIME_UPDATES: u64 = 100;
17
18#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
19#[repr(C)]
20pub struct ConnectionsResponse {
21 pub num_lifetime_connections: u32,
22}
23
24impl fidl::Persistable for ConnectionsResponse {}
25
26#[derive(Clone, Debug, PartialEq)]
27pub struct SetSampleArgs {
28 pub sample: fidl_fuchsia_time_external::TimeSample,
29}
30
31impl fidl::Persistable for SetSampleArgs {}
32
33#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct SetStatusArgs {
35 pub status: fidl_fuchsia_time_external::Status,
36}
37
38impl fidl::Persistable for SetStatusArgs {}
39
40mod internal {
41 use super::*;
42
43 impl fidl::encoding::ValueTypeMarker for ConnectionsResponse {
44 type Borrowed<'a> = &'a Self;
45 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
46 value
47 }
48 }
49
50 unsafe impl fidl::encoding::TypeMarker for ConnectionsResponse {
51 type Owned = Self;
52
53 #[inline(always)]
54 fn inline_align(_context: fidl::encoding::Context) -> usize {
55 4
56 }
57
58 #[inline(always)]
59 fn inline_size(_context: fidl::encoding::Context) -> usize {
60 4
61 }
62 #[inline(always)]
63 fn encode_is_copy() -> bool {
64 true
65 }
66
67 #[inline(always)]
68 fn decode_is_copy() -> bool {
69 true
70 }
71 }
72
73 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ConnectionsResponse, D>
74 for &ConnectionsResponse
75 {
76 #[inline]
77 unsafe fn encode(
78 self,
79 encoder: &mut fidl::encoding::Encoder<'_, D>,
80 offset: usize,
81 _depth: fidl::encoding::Depth,
82 ) -> fidl::Result<()> {
83 encoder.debug_check_bounds::<ConnectionsResponse>(offset);
84 unsafe {
85 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
87 (buf_ptr as *mut ConnectionsResponse)
88 .write_unaligned((self as *const ConnectionsResponse).read());
89 }
92 Ok(())
93 }
94 }
95 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
96 fidl::encoding::Encode<ConnectionsResponse, D> for (T0,)
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::<ConnectionsResponse>(offset);
106 self.0.encode(encoder, offset + 0, depth)?;
110 Ok(())
111 }
112 }
113
114 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConnectionsResponse {
115 #[inline(always)]
116 fn new_empty() -> Self {
117 Self { num_lifetime_connections: fidl::new_empty!(u32, D) }
118 }
119
120 #[inline]
121 unsafe fn decode(
122 &mut self,
123 decoder: &mut fidl::encoding::Decoder<'_, D>,
124 offset: usize,
125 _depth: fidl::encoding::Depth,
126 ) -> fidl::Result<()> {
127 decoder.debug_check_bounds::<Self>(offset);
128 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
129 unsafe {
132 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
133 }
134 Ok(())
135 }
136 }
137
138 impl fidl::encoding::ValueTypeMarker for SetSampleArgs {
139 type Borrowed<'a> = &'a Self;
140 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
141 value
142 }
143 }
144
145 unsafe impl fidl::encoding::TypeMarker for SetSampleArgs {
146 type Owned = Self;
147
148 #[inline(always)]
149 fn inline_align(_context: fidl::encoding::Context) -> usize {
150 8
151 }
152
153 #[inline(always)]
154 fn inline_size(_context: fidl::encoding::Context) -> usize {
155 16
156 }
157 }
158
159 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SetSampleArgs, D>
160 for &SetSampleArgs
161 {
162 #[inline]
163 unsafe fn encode(
164 self,
165 encoder: &mut fidl::encoding::Encoder<'_, D>,
166 offset: usize,
167 _depth: fidl::encoding::Depth,
168 ) -> fidl::Result<()> {
169 encoder.debug_check_bounds::<SetSampleArgs>(offset);
170 fidl::encoding::Encode::<SetSampleArgs, D>::encode(
172 (
173 <fidl_fuchsia_time_external::TimeSample as fidl::encoding::ValueTypeMarker>::borrow(&self.sample),
174 ),
175 encoder, offset, _depth
176 )
177 }
178 }
179 unsafe impl<
180 D: fidl::encoding::ResourceDialect,
181 T0: fidl::encoding::Encode<fidl_fuchsia_time_external::TimeSample, D>,
182 > fidl::encoding::Encode<SetSampleArgs, D> for (T0,)
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::<SetSampleArgs>(offset);
192 self.0.encode(encoder, offset + 0, depth)?;
196 Ok(())
197 }
198 }
199
200 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SetSampleArgs {
201 #[inline(always)]
202 fn new_empty() -> Self {
203 Self { sample: fidl::new_empty!(fidl_fuchsia_time_external::TimeSample, D) }
204 }
205
206 #[inline]
207 unsafe fn decode(
208 &mut self,
209 decoder: &mut fidl::encoding::Decoder<'_, D>,
210 offset: usize,
211 _depth: fidl::encoding::Depth,
212 ) -> fidl::Result<()> {
213 decoder.debug_check_bounds::<Self>(offset);
214 fidl::decode!(
216 fidl_fuchsia_time_external::TimeSample,
217 D,
218 &mut self.sample,
219 decoder,
220 offset + 0,
221 _depth
222 )?;
223 Ok(())
224 }
225 }
226
227 impl fidl::encoding::ValueTypeMarker for SetStatusArgs {
228 type Borrowed<'a> = &'a Self;
229 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
230 value
231 }
232 }
233
234 unsafe impl fidl::encoding::TypeMarker for SetStatusArgs {
235 type Owned = Self;
236
237 #[inline(always)]
238 fn inline_align(_context: fidl::encoding::Context) -> usize {
239 4
240 }
241
242 #[inline(always)]
243 fn inline_size(_context: fidl::encoding::Context) -> usize {
244 4
245 }
246 }
247
248 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SetStatusArgs, D>
249 for &SetStatusArgs
250 {
251 #[inline]
252 unsafe fn encode(
253 self,
254 encoder: &mut fidl::encoding::Encoder<'_, D>,
255 offset: usize,
256 _depth: fidl::encoding::Depth,
257 ) -> fidl::Result<()> {
258 encoder.debug_check_bounds::<SetStatusArgs>(offset);
259 fidl::encoding::Encode::<SetStatusArgs, D>::encode(
261 (<fidl_fuchsia_time_external::Status as fidl::encoding::ValueTypeMarker>::borrow(
262 &self.status,
263 ),),
264 encoder,
265 offset,
266 _depth,
267 )
268 }
269 }
270 unsafe impl<
271 D: fidl::encoding::ResourceDialect,
272 T0: fidl::encoding::Encode<fidl_fuchsia_time_external::Status, D>,
273 > fidl::encoding::Encode<SetStatusArgs, D> for (T0,)
274 {
275 #[inline]
276 unsafe fn encode(
277 self,
278 encoder: &mut fidl::encoding::Encoder<'_, D>,
279 offset: usize,
280 depth: fidl::encoding::Depth,
281 ) -> fidl::Result<()> {
282 encoder.debug_check_bounds::<SetStatusArgs>(offset);
283 self.0.encode(encoder, offset + 0, depth)?;
287 Ok(())
288 }
289 }
290
291 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SetStatusArgs {
292 #[inline(always)]
293 fn new_empty() -> Self {
294 Self { status: fidl::new_empty!(fidl_fuchsia_time_external::Status, D) }
295 }
296
297 #[inline]
298 unsafe fn decode(
299 &mut self,
300 decoder: &mut fidl::encoding::Decoder<'_, D>,
301 offset: usize,
302 _depth: fidl::encoding::Depth,
303 ) -> fidl::Result<()> {
304 decoder.debug_check_bounds::<Self>(offset);
305 fidl::decode!(
307 fidl_fuchsia_time_external::Status,
308 D,
309 &mut self.status,
310 decoder,
311 offset + 0,
312 _depth
313 )?;
314 Ok(())
315 }
316 }
317}