fidl_examples_canvas_clientrequesteddraw__common/
fidl_examples_canvas_clientrequesteddraw__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 type Line = [Point; 2];
13
14#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
18#[repr(C)]
19pub struct BoundingBox {
20 pub top_left: Point,
21 pub bottom_right: Point,
22}
23
24impl fidl::Persistable for BoundingBox {}
25
26#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27pub struct InstanceAddLinesRequest {
28 pub lines: Vec<[Point; 2]>,
29}
30
31impl fidl::Persistable for InstanceAddLinesRequest {}
32
33#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35#[repr(C)]
36pub struct Point {
37 pub x: i64,
38 pub y: i64,
39}
40
41impl fidl::Persistable for Point {}
42
43pub mod instance_ordinals {
44 pub const ADD_LINES: u64 = 0x5a82f0b30f970bd6;
45 pub const READY: u64 = 0x3458d7a668873150;
46 pub const ON_DRAWN: u64 = 0x25e6d8494623419a;
47}
48
49mod internal {
50 use super::*;
51
52 impl fidl::encoding::ValueTypeMarker for BoundingBox {
53 type Borrowed<'a> = &'a Self;
54 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
55 value
56 }
57 }
58
59 unsafe impl fidl::encoding::TypeMarker for BoundingBox {
60 type Owned = Self;
61
62 #[inline(always)]
63 fn inline_align(_context: fidl::encoding::Context) -> usize {
64 8
65 }
66
67 #[inline(always)]
68 fn inline_size(_context: fidl::encoding::Context) -> usize {
69 32
70 }
71 #[inline(always)]
72 fn encode_is_copy() -> bool {
73 true
74 }
75
76 #[inline(always)]
77 fn decode_is_copy() -> bool {
78 true
79 }
80 }
81
82 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BoundingBox, D>
83 for &BoundingBox
84 {
85 #[inline]
86 unsafe fn encode(
87 self,
88 encoder: &mut fidl::encoding::Encoder<'_, D>,
89 offset: usize,
90 _depth: fidl::encoding::Depth,
91 ) -> fidl::Result<()> {
92 encoder.debug_check_bounds::<BoundingBox>(offset);
93 unsafe {
94 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
96 (buf_ptr as *mut BoundingBox).write_unaligned((self as *const BoundingBox).read());
97 }
100 Ok(())
101 }
102 }
103 unsafe impl<
104 D: fidl::encoding::ResourceDialect,
105 T0: fidl::encoding::Encode<Point, D>,
106 T1: fidl::encoding::Encode<Point, D>,
107 > fidl::encoding::Encode<BoundingBox, D> for (T0, T1)
108 {
109 #[inline]
110 unsafe fn encode(
111 self,
112 encoder: &mut fidl::encoding::Encoder<'_, D>,
113 offset: usize,
114 depth: fidl::encoding::Depth,
115 ) -> fidl::Result<()> {
116 encoder.debug_check_bounds::<BoundingBox>(offset);
117 self.0.encode(encoder, offset + 0, depth)?;
121 self.1.encode(encoder, offset + 16, depth)?;
122 Ok(())
123 }
124 }
125
126 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BoundingBox {
127 #[inline(always)]
128 fn new_empty() -> Self {
129 Self { top_left: fidl::new_empty!(Point, D), bottom_right: fidl::new_empty!(Point, D) }
130 }
131
132 #[inline]
133 unsafe fn decode(
134 &mut self,
135 decoder: &mut fidl::encoding::Decoder<'_, D>,
136 offset: usize,
137 _depth: fidl::encoding::Depth,
138 ) -> fidl::Result<()> {
139 decoder.debug_check_bounds::<Self>(offset);
140 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
141 unsafe {
144 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 32);
145 }
146 Ok(())
147 }
148 }
149
150 impl fidl::encoding::ValueTypeMarker for InstanceAddLinesRequest {
151 type Borrowed<'a> = &'a Self;
152 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
153 value
154 }
155 }
156
157 unsafe impl fidl::encoding::TypeMarker for InstanceAddLinesRequest {
158 type Owned = Self;
159
160 #[inline(always)]
161 fn inline_align(_context: fidl::encoding::Context) -> usize {
162 8
163 }
164
165 #[inline(always)]
166 fn inline_size(_context: fidl::encoding::Context) -> usize {
167 16
168 }
169 }
170
171 unsafe impl<D: fidl::encoding::ResourceDialect>
172 fidl::encoding::Encode<InstanceAddLinesRequest, D> for &InstanceAddLinesRequest
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::<InstanceAddLinesRequest>(offset);
182 fidl::encoding::Encode::<InstanceAddLinesRequest, D>::encode(
184 (
185 <fidl::encoding::UnboundedVector<fidl::encoding::Array<Point, 2>> as fidl::encoding::ValueTypeMarker>::borrow(&self.lines),
186 ),
187 encoder, offset, _depth
188 )
189 }
190 }
191 unsafe impl<
192 D: fidl::encoding::ResourceDialect,
193 T0: fidl::encoding::Encode<
194 fidl::encoding::UnboundedVector<fidl::encoding::Array<Point, 2>>,
195 D,
196 >,
197 > fidl::encoding::Encode<InstanceAddLinesRequest, D> for (T0,)
198 {
199 #[inline]
200 unsafe fn encode(
201 self,
202 encoder: &mut fidl::encoding::Encoder<'_, D>,
203 offset: usize,
204 depth: fidl::encoding::Depth,
205 ) -> fidl::Result<()> {
206 encoder.debug_check_bounds::<InstanceAddLinesRequest>(offset);
207 self.0.encode(encoder, offset + 0, depth)?;
211 Ok(())
212 }
213 }
214
215 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
216 for InstanceAddLinesRequest
217 {
218 #[inline(always)]
219 fn new_empty() -> Self {
220 Self {
221 lines: fidl::new_empty!(
222 fidl::encoding::UnboundedVector<fidl::encoding::Array<Point, 2>>,
223 D
224 ),
225 }
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 fidl::decode!(
238 fidl::encoding::UnboundedVector<fidl::encoding::Array<Point, 2>>,
239 D,
240 &mut self.lines,
241 decoder,
242 offset + 0,
243 _depth
244 )?;
245 Ok(())
246 }
247 }
248
249 impl fidl::encoding::ValueTypeMarker for Point {
250 type Borrowed<'a> = &'a Self;
251 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
252 value
253 }
254 }
255
256 unsafe impl fidl::encoding::TypeMarker for Point {
257 type Owned = Self;
258
259 #[inline(always)]
260 fn inline_align(_context: fidl::encoding::Context) -> usize {
261 8
262 }
263
264 #[inline(always)]
265 fn inline_size(_context: fidl::encoding::Context) -> usize {
266 16
267 }
268 #[inline(always)]
269 fn encode_is_copy() -> bool {
270 true
271 }
272
273 #[inline(always)]
274 fn decode_is_copy() -> bool {
275 true
276 }
277 }
278
279 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Point, D> for &Point {
280 #[inline]
281 unsafe fn encode(
282 self,
283 encoder: &mut fidl::encoding::Encoder<'_, D>,
284 offset: usize,
285 _depth: fidl::encoding::Depth,
286 ) -> fidl::Result<()> {
287 encoder.debug_check_bounds::<Point>(offset);
288 unsafe {
289 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
291 (buf_ptr as *mut Point).write_unaligned((self as *const Point).read());
292 }
295 Ok(())
296 }
297 }
298 unsafe impl<
299 D: fidl::encoding::ResourceDialect,
300 T0: fidl::encoding::Encode<i64, D>,
301 T1: fidl::encoding::Encode<i64, D>,
302 > fidl::encoding::Encode<Point, D> for (T0, T1)
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::<Point>(offset);
312 self.0.encode(encoder, offset + 0, depth)?;
316 self.1.encode(encoder, offset + 8, depth)?;
317 Ok(())
318 }
319 }
320
321 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Point {
322 #[inline(always)]
323 fn new_empty() -> Self {
324 Self { x: fidl::new_empty!(i64, D), y: fidl::new_empty!(i64, D) }
325 }
326
327 #[inline]
328 unsafe fn decode(
329 &mut self,
330 decoder: &mut fidl::encoding::Decoder<'_, D>,
331 offset: usize,
332 _depth: fidl::encoding::Depth,
333 ) -> fidl::Result<()> {
334 decoder.debug_check_bounds::<Self>(offset);
335 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
336 unsafe {
339 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
340 }
341 Ok(())
342 }
343 }
344}