fidl_next_fuchsia_examples_gizmo/
fidl_next_fuchsia_examples_gizmo.rs1#![warn(clippy::all)]
3#![allow(unused_parens, unused_variables, unused_mut, unused_imports, unreachable_code)]
4
5#[derive(Clone, Debug)]
6#[repr(C)]
7pub struct DeviceGetHardwareIdResponse {
8 pub response: u32,
9}
10
11impl ::fidl_next::Encodable for DeviceGetHardwareIdResponse {
12 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireDeviceGetHardwareIdResponse> = unsafe {
13 ::fidl_next::CopyOptimization::enable_if(
14 true && <u32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
15 )
16 };
17
18 type Encoded = WireDeviceGetHardwareIdResponse;
19}
20
21unsafe impl<___E> ::fidl_next::Encode<___E> for DeviceGetHardwareIdResponse
22where
23 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
24{
25 #[inline]
26 fn encode(
27 self,
28 encoder: &mut ___E,
29 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
30 ) -> Result<(), ::fidl_next::EncodeError> {
31 ::fidl_next::munge! {
32 let Self::Encoded {
33 response,
34
35 } = out;
36 }
37
38 ::fidl_next::Encode::encode(self.response, encoder, response)?;
39
40 Ok(())
41 }
42}
43
44unsafe impl<___E> ::fidl_next::EncodeRef<___E> for DeviceGetHardwareIdResponse
45where
46 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
47{
48 #[inline]
49 fn encode_ref(
50 &self,
51 encoder: &mut ___E,
52 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
53 ) -> Result<(), ::fidl_next::EncodeError> {
54 ::fidl_next::munge! {
55 let Self::Encoded {
56 response,
57
58 } = out;
59 }
60
61 ::fidl_next::EncodeRef::encode_ref(&self.response, encoder, response)?;
62
63 Ok(())
64 }
65}
66
67impl ::fidl_next::EncodableOption for DeviceGetHardwareIdResponse {
68 type EncodedOption = ::fidl_next::WireBox<'static, WireDeviceGetHardwareIdResponse>;
69}
70
71unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DeviceGetHardwareIdResponse
72where
73 ___E: ::fidl_next::Encoder + ?Sized,
74 DeviceGetHardwareIdResponse: ::fidl_next::Encode<___E>,
75{
76 #[inline]
77 fn encode_option(
78 this: Option<Self>,
79 encoder: &mut ___E,
80 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
81 ) -> Result<(), ::fidl_next::EncodeError> {
82 if let Some(inner) = this {
83 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
84 ::fidl_next::WireBox::encode_present(out);
85 } else {
86 ::fidl_next::WireBox::encode_absent(out);
87 }
88
89 Ok(())
90 }
91}
92
93unsafe impl<___E> ::fidl_next::EncodeOptionRef<___E> for DeviceGetHardwareIdResponse
94where
95 ___E: ::fidl_next::Encoder + ?Sized,
96 DeviceGetHardwareIdResponse: ::fidl_next::EncodeRef<___E>,
97{
98 #[inline]
99 fn encode_option_ref(
100 this: Option<&Self>,
101 encoder: &mut ___E,
102 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
103 ) -> Result<(), ::fidl_next::EncodeError> {
104 if let Some(inner) = this {
105 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
106 ::fidl_next::WireBox::encode_present(out);
107 } else {
108 ::fidl_next::WireBox::encode_absent(out);
109 }
110
111 Ok(())
112 }
113}
114
115impl ::fidl_next::FromWire<WireDeviceGetHardwareIdResponse> for DeviceGetHardwareIdResponse {
116 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireDeviceGetHardwareIdResponse, Self> = unsafe {
117 ::fidl_next::CopyOptimization::enable_if(
118 true && <u32 as ::fidl_next::FromWire<::fidl_next::WireU32>>::COPY_OPTIMIZATION
119 .is_enabled(),
120 )
121 };
122
123 #[inline]
124 fn from_wire(wire: WireDeviceGetHardwareIdResponse) -> Self {
125 Self { response: ::fidl_next::FromWire::from_wire(wire.response) }
126 }
127}
128
129impl ::fidl_next::FromWireRef<WireDeviceGetHardwareIdResponse> for DeviceGetHardwareIdResponse {
130 #[inline]
131 fn from_wire_ref(wire: &WireDeviceGetHardwareIdResponse) -> Self {
132 Self { response: ::fidl_next::FromWireRef::from_wire_ref(&wire.response) }
133 }
134}
135
136#[derive(Clone, Debug)]
138#[repr(C)]
139pub struct WireDeviceGetHardwareIdResponse {
140 pub response: ::fidl_next::WireU32,
141}
142
143unsafe impl ::fidl_next::Wire for WireDeviceGetHardwareIdResponse {
144 type Decoded<'de> = WireDeviceGetHardwareIdResponse;
145
146 #[inline]
147 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
148}
149
150unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceGetHardwareIdResponse
151where
152 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
153{
154 fn decode(
155 slot: ::fidl_next::Slot<'_, Self>,
156 decoder: &mut ___D,
157 ) -> Result<(), ::fidl_next::DecodeError> {
158 ::fidl_next::munge! {
159 let Self {
160 mut response,
161
162 } = slot;
163 }
164
165 ::fidl_next::Decode::decode(response.as_mut(), decoder)?;
166
167 Ok(())
168 }
169}
170
171#[derive(Debug)]
172#[repr(C)]
173pub struct DeviceGetEventResponse {
174 pub event: ::fidl_next::fuchsia::zx::Handle,
175}
176
177impl ::fidl_next::Encodable for DeviceGetEventResponse {
178 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self, WireDeviceGetEventResponse> = unsafe {
179 ::fidl_next::CopyOptimization::enable_if(
180 true && <::fidl_next::fuchsia::zx::Handle as ::fidl_next::Encodable>::COPY_OPTIMIZATION
181 .is_enabled(),
182 )
183 };
184
185 type Encoded = WireDeviceGetEventResponse;
186}
187
188unsafe impl<___E> ::fidl_next::Encode<___E> for DeviceGetEventResponse
189where
190 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
191
192 ___E: ::fidl_next::fuchsia::HandleEncoder,
193{
194 #[inline]
195 fn encode(
196 self,
197 encoder: &mut ___E,
198 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
199 ) -> Result<(), ::fidl_next::EncodeError> {
200 ::fidl_next::munge! {
201 let Self::Encoded {
202 event,
203
204 } = out;
205 }
206
207 ::fidl_next::Encode::encode(self.event, encoder, event)?;
208
209 Ok(())
210 }
211}
212
213impl ::fidl_next::EncodableOption for DeviceGetEventResponse {
214 type EncodedOption = ::fidl_next::WireBox<'static, WireDeviceGetEventResponse>;
215}
216
217unsafe impl<___E> ::fidl_next::EncodeOption<___E> for DeviceGetEventResponse
218where
219 ___E: ::fidl_next::Encoder + ?Sized,
220 DeviceGetEventResponse: ::fidl_next::Encode<___E>,
221{
222 #[inline]
223 fn encode_option(
224 this: Option<Self>,
225 encoder: &mut ___E,
226 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
227 ) -> Result<(), ::fidl_next::EncodeError> {
228 if let Some(inner) = this {
229 ::fidl_next::EncoderExt::encode_next(encoder, inner)?;
230 ::fidl_next::WireBox::encode_present(out);
231 } else {
232 ::fidl_next::WireBox::encode_absent(out);
233 }
234
235 Ok(())
236 }
237}
238
239impl ::fidl_next::FromWire<WireDeviceGetEventResponse> for DeviceGetEventResponse {
240 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<WireDeviceGetEventResponse, Self> = unsafe {
241 ::fidl_next::CopyOptimization::enable_if(
242 true && <::fidl_next::fuchsia::zx::Handle as ::fidl_next::FromWire<
243 ::fidl_next::fuchsia::WireHandle,
244 >>::COPY_OPTIMIZATION
245 .is_enabled(),
246 )
247 };
248
249 #[inline]
250 fn from_wire(wire: WireDeviceGetEventResponse) -> Self {
251 Self { event: ::fidl_next::FromWire::from_wire(wire.event) }
252 }
253}
254
255#[derive(Debug)]
257#[repr(C)]
258pub struct WireDeviceGetEventResponse {
259 pub event: ::fidl_next::fuchsia::WireHandle,
260}
261
262unsafe impl ::fidl_next::Wire for WireDeviceGetEventResponse {
263 type Decoded<'de> = WireDeviceGetEventResponse;
264
265 #[inline]
266 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
267}
268
269unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceGetEventResponse
270where
271 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
272
273 ___D: ::fidl_next::fuchsia::HandleDecoder,
274{
275 fn decode(
276 slot: ::fidl_next::Slot<'_, Self>,
277 decoder: &mut ___D,
278 ) -> Result<(), ::fidl_next::DecodeError> {
279 ::fidl_next::munge! {
280 let Self {
281 mut event,
282
283 } = slot;
284 }
285
286 ::fidl_next::Decode::decode(event.as_mut(), decoder)?;
287
288 Ok(())
289 }
290}
291
292#[doc = " The protocol provides access to functions of the driver.\n"]
294#[derive(Debug)]
295pub struct Device;
296
297pub mod device {
298 pub mod prelude {
299 pub use crate::{
300 device, Device, DeviceClientHandler, DeviceClientSender, DeviceServerHandler,
301 DeviceServerSender,
302 };
303
304 pub use crate::DeviceGetEventResponse;
305
306 pub use crate::DeviceGetHardwareIdResponse;
307 }
308
309 pub struct GetHardwareId;
310
311 impl ::fidl_next::Method for GetHardwareId {
312 const ORDINAL: u64 = 7952116938191896180;
313
314 type Protocol = crate::Device;
315
316 type Request = ();
317
318 type Response = ::fidl_next::WireResult<
319 'static,
320 crate::WireDeviceGetHardwareIdResponse,
321 ::fidl_next::WireI32,
322 >;
323 }
324
325 pub struct GetEvent;
326
327 impl ::fidl_next::Method for GetEvent {
328 const ORDINAL: u64 = 6100331669860404750;
329
330 type Protocol = crate::Device;
331
332 type Request = ();
333
334 type Response = crate::WireDeviceGetEventResponse;
335 }
336}
337
338pub trait DeviceClientSender {
340 type Transport: ::fidl_next::Transport;
341
342 #[doc = " Returns a unique identifier for this device.\n"]
343 fn get_hardware_id(
344 &self,
345 ) -> Result<
346 ::fidl_next::ResponseFuture<'_, Self::Transport, device::GetHardwareId>,
347 ::fidl_next::EncodeError,
348 >;
349
350 #[doc = " Returns a zircon event object handle!\n"]
351 fn get_event(
352 &self,
353 ) -> Result<
354 ::fidl_next::ResponseFuture<'_, Self::Transport, device::GetEvent>,
355 ::fidl_next::EncodeError,
356 >;
357}
358
359impl<___T> DeviceClientSender for ::fidl_next::ClientSender<___T, Device>
360where
361 ___T: ::fidl_next::Transport,
362{
363 type Transport = ___T;
364
365 #[doc = " Returns a unique identifier for this device.\n"]
366 fn get_hardware_id(
367 &self,
368 ) -> Result<
369 ::fidl_next::ResponseFuture<'_, Self::Transport, device::GetHardwareId>,
370 ::fidl_next::EncodeError,
371 > {
372 self.as_untyped()
373 .send_two_way(7952116938191896180, ())
374 .map(::fidl_next::ResponseFuture::from_untyped)
375 }
376
377 #[doc = " Returns a zircon event object handle!\n"]
378 fn get_event(
379 &self,
380 ) -> Result<
381 ::fidl_next::ResponseFuture<'_, Self::Transport, device::GetEvent>,
382 ::fidl_next::EncodeError,
383 > {
384 self.as_untyped()
385 .send_two_way(6100331669860404750, ())
386 .map(::fidl_next::ResponseFuture::from_untyped)
387 }
388}
389
390pub trait DeviceClientHandler<___T: ::fidl_next::Transport> {}
394
395impl<___T, ___H> ::fidl_next::ClientProtocol<___T, ___H> for Device
396where
397 ___T: ::fidl_next::Transport,
398 ___H: DeviceClientHandler<___T>,
399
400 <device::GetHardwareId as ::fidl_next::Method>::Response:
401 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
402
403 <device::GetEvent as ::fidl_next::Method>::Response:
404 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
405{
406 fn on_event(
407 handler: &mut ___H,
408 sender: &::fidl_next::ClientSender<___T, Self>,
409 ordinal: u64,
410 buffer: ___T::RecvBuffer,
411 ) {
412 match ordinal {
413 ordinal => {
414 sender.close();
415 }
416 }
417 }
418}
419
420pub trait DeviceServerSender {
422 type Transport: ::fidl_next::Transport;
423}
424
425impl<___T> DeviceServerSender for ::fidl_next::ServerSender<___T, Device>
426where
427 ___T: ::fidl_next::Transport,
428{
429 type Transport = ___T;
430}
431
432pub trait DeviceServerHandler<___T: ::fidl_next::Transport> {
436 #[doc = " Returns a unique identifier for this device.\n"]
437 fn get_hardware_id(
438 &mut self,
439 sender: &::fidl_next::ServerSender<___T, Device>,
440
441 responder: ::fidl_next::Responder<device::GetHardwareId>,
442 );
443
444 #[doc = " Returns a zircon event object handle!\n"]
445 fn get_event(
446 &mut self,
447 sender: &::fidl_next::ServerSender<___T, Device>,
448
449 responder: ::fidl_next::Responder<device::GetEvent>,
450 );
451}
452
453impl<___T, ___H> ::fidl_next::ServerProtocol<___T, ___H> for Device
454where
455 ___T: ::fidl_next::Transport,
456 ___H: DeviceServerHandler<___T>,
457{
458 fn on_one_way(
459 handler: &mut ___H,
460 sender: &::fidl_next::ServerSender<___T, Self>,
461 ordinal: u64,
462 buffer: ___T::RecvBuffer,
463 ) {
464 match ordinal {
465 ordinal => {
466 sender.close();
467 }
468 }
469 }
470
471 fn on_two_way(
472 handler: &mut ___H,
473 sender: &::fidl_next::ServerSender<___T, Self>,
474 ordinal: u64,
475 buffer: ___T::RecvBuffer,
476 responder: ::fidl_next::protocol::Responder,
477 ) {
478 match ordinal {
479 7952116938191896180 => {
480 let responder = ::fidl_next::Responder::from_untyped(responder);
481
482 handler.get_hardware_id(sender, responder);
483 }
484
485 6100331669860404750 => {
486 let responder = ::fidl_next::Responder::from_untyped(responder);
487
488 handler.get_event(sender, responder);
489 }
490
491 ordinal => {
492 sender.close();
493 }
494 }
495 }
496}
497
498pub mod compat {
500
501 #[cfg(target_os = "fuchsia")]
502 pub type DeviceProxy =
505 ::fidl_next::ClientSender<::fidl_next::fuchsia::zx::Channel, crate::Device>;
506
507 #[cfg(feature = "driver")]
508 impl ::core::convert::From<crate::Device> for ::fidl_fuchsia_examples_gizmo::DeviceMarker {
509 #[inline]
510 fn from(_: crate::Device) -> Self {
511 Self
512 }
513 }
514}