fidl_test_coding/
fidl_test_coding.rs1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14#[repr(C)]
15pub struct Foo {
16 pub byte: u8,
17}
18
19impl fidl::Persistable for Foo {}
20
21mod internal {
22 use super::*;
23
24 impl fidl::encoding::ValueTypeMarker for Foo {
25 type Borrowed<'a> = &'a Self;
26 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
27 value
28 }
29 }
30
31 unsafe impl fidl::encoding::TypeMarker for Foo {
32 type Owned = Self;
33
34 #[inline(always)]
35 fn inline_align(_context: fidl::encoding::Context) -> usize {
36 1
37 }
38
39 #[inline(always)]
40 fn inline_size(_context: fidl::encoding::Context) -> usize {
41 1
42 }
43 #[inline(always)]
44 fn encode_is_copy() -> bool {
45 true
46 }
47
48 #[inline(always)]
49 fn decode_is_copy() -> bool {
50 true
51 }
52 }
53
54 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Foo, D> for &Foo {
55 #[inline]
56 unsafe fn encode(
57 self,
58 encoder: &mut fidl::encoding::Encoder<'_, D>,
59 offset: usize,
60 _depth: fidl::encoding::Depth,
61 ) -> fidl::Result<()> {
62 encoder.debug_check_bounds::<Foo>(offset);
63 unsafe {
64 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
66 (buf_ptr as *mut Foo).write_unaligned((self as *const Foo).read());
67 }
70 Ok(())
71 }
72 }
73 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u8, D>>
74 fidl::encoding::Encode<Foo, D> for (T0,)
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::<Foo>(offset);
84 self.0.encode(encoder, offset + 0, depth)?;
88 Ok(())
89 }
90 }
91
92 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Foo {
93 #[inline(always)]
94 fn new_empty() -> Self {
95 Self { byte: fidl::new_empty!(u8, D) }
96 }
97
98 #[inline]
99 unsafe fn decode(
100 &mut self,
101 decoder: &mut fidl::encoding::Decoder<'_, D>,
102 offset: usize,
103 _depth: fidl::encoding::Depth,
104 ) -> fidl::Result<()> {
105 decoder.debug_check_bounds::<Self>(offset);
106 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
107 unsafe {
110 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
111 }
112 Ok(())
113 }
114 }
115}