1#![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 DeviceSet2Request {
14 pub rtc: Time,
15}
16
17impl fidl::Persistable for DeviceSet2Request {}
18
19#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20#[repr(C)]
21pub struct DeviceSetRequest {
22 pub rtc: Time,
23}
24
25impl fidl::Persistable for DeviceSetRequest {}
26
27#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
28#[repr(C)]
29pub struct DeviceGetResponse {
30 pub rtc: Time,
31}
32
33impl fidl::Persistable for DeviceGetResponse {}
34
35#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36#[repr(C)]
37pub struct DeviceSetResponse {
38 pub status: i32,
39}
40
41impl fidl::Persistable for DeviceSetResponse {}
42
43#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
44#[repr(C)]
45pub struct Time {
46 pub seconds: u8,
47 pub minutes: u8,
48 pub hours: u8,
49 pub day: u8,
50 pub month: u8,
51 pub year: u16,
52}
53
54impl fidl::Persistable for Time {}
55
56mod internal {
57 use super::*;
58
59 impl fidl::encoding::ValueTypeMarker for DeviceSet2Request {
60 type Borrowed<'a> = &'a Self;
61 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
62 value
63 }
64 }
65
66 unsafe impl fidl::encoding::TypeMarker for DeviceSet2Request {
67 type Owned = Self;
68
69 #[inline(always)]
70 fn inline_align(_context: fidl::encoding::Context) -> usize {
71 2
72 }
73
74 #[inline(always)]
75 fn inline_size(_context: fidl::encoding::Context) -> usize {
76 8
77 }
78 }
79
80 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceSet2Request, D>
81 for &DeviceSet2Request
82 {
83 #[inline]
84 unsafe fn encode(
85 self,
86 encoder: &mut fidl::encoding::Encoder<'_, D>,
87 offset: usize,
88 _depth: fidl::encoding::Depth,
89 ) -> fidl::Result<()> {
90 encoder.debug_check_bounds::<DeviceSet2Request>(offset);
91 unsafe {
92 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
94 (buf_ptr as *mut DeviceSet2Request)
95 .write_unaligned((self as *const DeviceSet2Request).read());
96 let padding_ptr = buf_ptr.offset(4) as *mut u16;
99 let padding_mask = 0xff00u16;
100 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
101 }
102 Ok(())
103 }
104 }
105 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Time, D>>
106 fidl::encoding::Encode<DeviceSet2Request, 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::<DeviceSet2Request>(offset);
116 self.0.encode(encoder, offset + 0, depth)?;
120 Ok(())
121 }
122 }
123
124 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceSet2Request {
125 #[inline(always)]
126 fn new_empty() -> Self {
127 Self { rtc: fidl::new_empty!(Time, D) }
128 }
129
130 #[inline]
131 unsafe fn decode(
132 &mut self,
133 decoder: &mut fidl::encoding::Decoder<'_, D>,
134 offset: usize,
135 _depth: fidl::encoding::Depth,
136 ) -> fidl::Result<()> {
137 decoder.debug_check_bounds::<Self>(offset);
138 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
139 let ptr = unsafe { buf_ptr.offset(4) };
141 let padval = unsafe { (ptr as *const u16).read_unaligned() };
142 let mask = 0xff00u16;
143 let maskedval = padval & mask;
144 if maskedval != 0 {
145 return Err(fidl::Error::NonZeroPadding {
146 padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
147 });
148 }
149 unsafe {
151 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
152 }
153 Ok(())
154 }
155 }
156
157 impl fidl::encoding::ValueTypeMarker for DeviceSetRequest {
158 type Borrowed<'a> = &'a Self;
159 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
160 value
161 }
162 }
163
164 unsafe impl fidl::encoding::TypeMarker for DeviceSetRequest {
165 type Owned = Self;
166
167 #[inline(always)]
168 fn inline_align(_context: fidl::encoding::Context) -> usize {
169 2
170 }
171
172 #[inline(always)]
173 fn inline_size(_context: fidl::encoding::Context) -> usize {
174 8
175 }
176 }
177
178 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceSetRequest, D>
179 for &DeviceSetRequest
180 {
181 #[inline]
182 unsafe fn encode(
183 self,
184 encoder: &mut fidl::encoding::Encoder<'_, D>,
185 offset: usize,
186 _depth: fidl::encoding::Depth,
187 ) -> fidl::Result<()> {
188 encoder.debug_check_bounds::<DeviceSetRequest>(offset);
189 unsafe {
190 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
192 (buf_ptr as *mut DeviceSetRequest)
193 .write_unaligned((self as *const DeviceSetRequest).read());
194 let padding_ptr = buf_ptr.offset(4) as *mut u16;
197 let padding_mask = 0xff00u16;
198 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
199 }
200 Ok(())
201 }
202 }
203 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Time, D>>
204 fidl::encoding::Encode<DeviceSetRequest, D> for (T0,)
205 {
206 #[inline]
207 unsafe fn encode(
208 self,
209 encoder: &mut fidl::encoding::Encoder<'_, D>,
210 offset: usize,
211 depth: fidl::encoding::Depth,
212 ) -> fidl::Result<()> {
213 encoder.debug_check_bounds::<DeviceSetRequest>(offset);
214 self.0.encode(encoder, offset + 0, depth)?;
218 Ok(())
219 }
220 }
221
222 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceSetRequest {
223 #[inline(always)]
224 fn new_empty() -> Self {
225 Self { rtc: fidl::new_empty!(Time, D) }
226 }
227
228 #[inline]
229 unsafe fn decode(
230 &mut self,
231 decoder: &mut fidl::encoding::Decoder<'_, D>,
232 offset: usize,
233 _depth: fidl::encoding::Depth,
234 ) -> fidl::Result<()> {
235 decoder.debug_check_bounds::<Self>(offset);
236 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
237 let ptr = unsafe { buf_ptr.offset(4) };
239 let padval = unsafe { (ptr as *const u16).read_unaligned() };
240 let mask = 0xff00u16;
241 let maskedval = padval & mask;
242 if maskedval != 0 {
243 return Err(fidl::Error::NonZeroPadding {
244 padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
245 });
246 }
247 unsafe {
249 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
250 }
251 Ok(())
252 }
253 }
254
255 impl fidl::encoding::ValueTypeMarker for DeviceGetResponse {
256 type Borrowed<'a> = &'a Self;
257 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
258 value
259 }
260 }
261
262 unsafe impl fidl::encoding::TypeMarker for DeviceGetResponse {
263 type Owned = Self;
264
265 #[inline(always)]
266 fn inline_align(_context: fidl::encoding::Context) -> usize {
267 2
268 }
269
270 #[inline(always)]
271 fn inline_size(_context: fidl::encoding::Context) -> usize {
272 8
273 }
274 }
275
276 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceGetResponse, D>
277 for &DeviceGetResponse
278 {
279 #[inline]
280 unsafe fn encode(
281 self,
282 encoder: &mut fidl::encoding::Encoder<'_, D>,
283 offset: usize,
284 _depth: fidl::encoding::Depth,
285 ) -> fidl::Result<()> {
286 encoder.debug_check_bounds::<DeviceGetResponse>(offset);
287 unsafe {
288 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
290 (buf_ptr as *mut DeviceGetResponse)
291 .write_unaligned((self as *const DeviceGetResponse).read());
292 let padding_ptr = buf_ptr.offset(4) as *mut u16;
295 let padding_mask = 0xff00u16;
296 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
297 }
298 Ok(())
299 }
300 }
301 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Time, D>>
302 fidl::encoding::Encode<DeviceGetResponse, D> for (T0,)
303 {
304 #[inline]
305 unsafe fn encode(
306 self,
307 encoder: &mut fidl::encoding::Encoder<'_, D>,
308 offset: usize,
309 depth: fidl::encoding::Depth,
310 ) -> fidl::Result<()> {
311 encoder.debug_check_bounds::<DeviceGetResponse>(offset);
312 self.0.encode(encoder, offset + 0, depth)?;
316 Ok(())
317 }
318 }
319
320 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceGetResponse {
321 #[inline(always)]
322 fn new_empty() -> Self {
323 Self { rtc: fidl::new_empty!(Time, D) }
324 }
325
326 #[inline]
327 unsafe fn decode(
328 &mut self,
329 decoder: &mut fidl::encoding::Decoder<'_, D>,
330 offset: usize,
331 _depth: fidl::encoding::Depth,
332 ) -> fidl::Result<()> {
333 decoder.debug_check_bounds::<Self>(offset);
334 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
335 let ptr = unsafe { buf_ptr.offset(4) };
337 let padval = unsafe { (ptr as *const u16).read_unaligned() };
338 let mask = 0xff00u16;
339 let maskedval = padval & mask;
340 if maskedval != 0 {
341 return Err(fidl::Error::NonZeroPadding {
342 padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
343 });
344 }
345 unsafe {
347 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
348 }
349 Ok(())
350 }
351 }
352
353 impl fidl::encoding::ValueTypeMarker for DeviceSetResponse {
354 type Borrowed<'a> = &'a Self;
355 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
356 value
357 }
358 }
359
360 unsafe impl fidl::encoding::TypeMarker for DeviceSetResponse {
361 type Owned = Self;
362
363 #[inline(always)]
364 fn inline_align(_context: fidl::encoding::Context) -> usize {
365 4
366 }
367
368 #[inline(always)]
369 fn inline_size(_context: fidl::encoding::Context) -> usize {
370 4
371 }
372 #[inline(always)]
373 fn encode_is_copy() -> bool {
374 true
375 }
376
377 #[inline(always)]
378 fn decode_is_copy() -> bool {
379 true
380 }
381 }
382
383 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceSetResponse, D>
384 for &DeviceSetResponse
385 {
386 #[inline]
387 unsafe fn encode(
388 self,
389 encoder: &mut fidl::encoding::Encoder<'_, D>,
390 offset: usize,
391 _depth: fidl::encoding::Depth,
392 ) -> fidl::Result<()> {
393 encoder.debug_check_bounds::<DeviceSetResponse>(offset);
394 unsafe {
395 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
397 (buf_ptr as *mut DeviceSetResponse)
398 .write_unaligned((self as *const DeviceSetResponse).read());
399 }
402 Ok(())
403 }
404 }
405 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
406 fidl::encoding::Encode<DeviceSetResponse, D> for (T0,)
407 {
408 #[inline]
409 unsafe fn encode(
410 self,
411 encoder: &mut fidl::encoding::Encoder<'_, D>,
412 offset: usize,
413 depth: fidl::encoding::Depth,
414 ) -> fidl::Result<()> {
415 encoder.debug_check_bounds::<DeviceSetResponse>(offset);
416 self.0.encode(encoder, offset + 0, depth)?;
420 Ok(())
421 }
422 }
423
424 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceSetResponse {
425 #[inline(always)]
426 fn new_empty() -> Self {
427 Self { status: fidl::new_empty!(i32, D) }
428 }
429
430 #[inline]
431 unsafe fn decode(
432 &mut self,
433 decoder: &mut fidl::encoding::Decoder<'_, D>,
434 offset: usize,
435 _depth: fidl::encoding::Depth,
436 ) -> fidl::Result<()> {
437 decoder.debug_check_bounds::<Self>(offset);
438 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
439 unsafe {
442 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
443 }
444 Ok(())
445 }
446 }
447
448 impl fidl::encoding::ValueTypeMarker for Time {
449 type Borrowed<'a> = &'a Self;
450 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
451 value
452 }
453 }
454
455 unsafe impl fidl::encoding::TypeMarker for Time {
456 type Owned = Self;
457
458 #[inline(always)]
459 fn inline_align(_context: fidl::encoding::Context) -> usize {
460 2
461 }
462
463 #[inline(always)]
464 fn inline_size(_context: fidl::encoding::Context) -> usize {
465 8
466 }
467 }
468
469 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Time, D> for &Time {
470 #[inline]
471 unsafe fn encode(
472 self,
473 encoder: &mut fidl::encoding::Encoder<'_, D>,
474 offset: usize,
475 _depth: fidl::encoding::Depth,
476 ) -> fidl::Result<()> {
477 encoder.debug_check_bounds::<Time>(offset);
478 unsafe {
479 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
481 (buf_ptr as *mut Time).write_unaligned((self as *const Time).read());
482 let padding_ptr = buf_ptr.offset(4) as *mut u16;
485 let padding_mask = 0xff00u16;
486 padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
487 }
488 Ok(())
489 }
490 }
491 unsafe impl<
492 D: fidl::encoding::ResourceDialect,
493 T0: fidl::encoding::Encode<u8, D>,
494 T1: fidl::encoding::Encode<u8, D>,
495 T2: fidl::encoding::Encode<u8, D>,
496 T3: fidl::encoding::Encode<u8, D>,
497 T4: fidl::encoding::Encode<u8, D>,
498 T5: fidl::encoding::Encode<u16, D>,
499 > fidl::encoding::Encode<Time, D> for (T0, T1, T2, T3, T4, T5)
500 {
501 #[inline]
502 unsafe fn encode(
503 self,
504 encoder: &mut fidl::encoding::Encoder<'_, D>,
505 offset: usize,
506 depth: fidl::encoding::Depth,
507 ) -> fidl::Result<()> {
508 encoder.debug_check_bounds::<Time>(offset);
509 unsafe {
512 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
513 (ptr as *mut u16).write_unaligned(0);
514 }
515 self.0.encode(encoder, offset + 0, depth)?;
517 self.1.encode(encoder, offset + 1, depth)?;
518 self.2.encode(encoder, offset + 2, depth)?;
519 self.3.encode(encoder, offset + 3, depth)?;
520 self.4.encode(encoder, offset + 4, depth)?;
521 self.5.encode(encoder, offset + 6, depth)?;
522 Ok(())
523 }
524 }
525
526 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Time {
527 #[inline(always)]
528 fn new_empty() -> Self {
529 Self {
530 seconds: fidl::new_empty!(u8, D),
531 minutes: fidl::new_empty!(u8, D),
532 hours: fidl::new_empty!(u8, D),
533 day: fidl::new_empty!(u8, D),
534 month: fidl::new_empty!(u8, D),
535 year: fidl::new_empty!(u16, D),
536 }
537 }
538
539 #[inline]
540 unsafe fn decode(
541 &mut self,
542 decoder: &mut fidl::encoding::Decoder<'_, D>,
543 offset: usize,
544 _depth: fidl::encoding::Depth,
545 ) -> fidl::Result<()> {
546 decoder.debug_check_bounds::<Self>(offset);
547 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
548 let ptr = unsafe { buf_ptr.offset(4) };
550 let padval = unsafe { (ptr as *const u16).read_unaligned() };
551 let mask = 0xff00u16;
552 let maskedval = padval & mask;
553 if maskedval != 0 {
554 return Err(fidl::Error::NonZeroPadding {
555 padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
556 });
557 }
558 unsafe {
560 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
561 }
562 Ok(())
563 }
564 }
565}