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::{device, Device, DeviceClientHandler, DeviceServerHandler};
300
301 pub use crate::DeviceGetEventResponse;
302
303 pub use crate::DeviceGetHardwareIdResponse;
304 }
305
306 pub struct GetHardwareId;
307
308 impl ::fidl_next::Method for GetHardwareId {
309 const ORDINAL: u64 = 7952116938191896180;
310
311 type Protocol = crate::Device;
312
313 type Request = ();
314
315 type Response = ::fidl_next::WireResult<
316 'static,
317 crate::WireDeviceGetHardwareIdResponse,
318 ::fidl_next::WireI32,
319 >;
320 }
321
322 pub struct GetEvent;
323
324 impl ::fidl_next::Method for GetEvent {
325 const ORDINAL: u64 = 6100331669860404750;
326
327 type Protocol = crate::Device;
328
329 type Request = ();
330
331 type Response = crate::WireDeviceGetEventResponse;
332 }
333
334 mod ___detail {
335
336 unsafe impl<___T> ::fidl_next::Protocol<___T> for crate::Device
337 where
338 ___T: ::fidl_next::Transport,
339 {
340 type ClientSender = DeviceClientSender<___T>;
341 type ServerSender = DeviceServerSender<___T>;
342 }
343
344 pub struct DeviceClientSender<___T: ::fidl_next::Transport> {
346 #[allow(dead_code)]
347 sender: ::fidl_next::protocol::ClientSender<___T>,
348 }
349
350 impl<___T> DeviceClientSender<___T>
351 where
352 ___T: ::fidl_next::Transport,
353 {
354 #[doc = " Returns a unique identifier for this device.\n"]
355 pub fn get_hardware_id(
356 &self,
357 ) -> Result<
358 ::fidl_next::ResponseFuture<'_, super::GetHardwareId, ___T>,
359 ::fidl_next::EncodeError,
360 > {
361 self.sender
362 .send_two_way(7952116938191896180, ())
363 .map(::fidl_next::ResponseFuture::from_untyped)
364 }
365
366 #[doc = " Returns a zircon event object handle!\n"]
367 pub fn get_event(
368 &self,
369 ) -> Result<
370 ::fidl_next::ResponseFuture<'_, super::GetEvent, ___T>,
371 ::fidl_next::EncodeError,
372 > {
373 self.sender
374 .send_two_way(6100331669860404750, ())
375 .map(::fidl_next::ResponseFuture::from_untyped)
376 }
377 }
378
379 #[repr(transparent)]
381 pub struct DeviceServerSender<___T: ::fidl_next::Transport> {
382 sender: ::fidl_next::protocol::ServerSender<___T>,
383 }
384
385 impl<___T> DeviceServerSender<___T> where ___T: ::fidl_next::Transport {}
386 }
387}
388
389pub trait DeviceClientHandler<___T: ::fidl_next::Transport> {}
393
394impl<___H, ___T> ::fidl_next::ClientProtocol<___H, ___T> for Device
395where
396 ___H: DeviceClientHandler<___T> + Send,
397 ___T: ::fidl_next::Transport,
398
399 <device::GetHardwareId as ::fidl_next::Method>::Response:
400 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
401
402 <device::GetEvent as ::fidl_next::Method>::Response:
403 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
404{
405 async fn on_event(
406 handler: &mut ___H,
407 sender: &::fidl_next::ClientSender<Self, ___T>,
408 ordinal: u64,
409 buffer: ___T::RecvBuffer,
410 ) {
411 match ordinal {
412 ordinal => {
413 sender.close();
414 }
415 }
416 }
417}
418
419pub trait DeviceServerHandler<___T: ::fidl_next::Transport> {
423 #[doc = " Returns a unique identifier for this device.\n"]
424 fn get_hardware_id(
425 &mut self,
426 sender: &::fidl_next::ServerSender<Device, ___T>,
427
428 responder: ::fidl_next::Responder<device::GetHardwareId>,
429 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
430
431 #[doc = " Returns a zircon event object handle!\n"]
432 fn get_event(
433 &mut self,
434 sender: &::fidl_next::ServerSender<Device, ___T>,
435
436 responder: ::fidl_next::Responder<device::GetEvent>,
437 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
438}
439
440impl<___H, ___T> ::fidl_next::ServerProtocol<___H, ___T> for Device
441where
442 ___H: DeviceServerHandler<___T> + Send,
443 ___T: ::fidl_next::Transport,
444{
445 async fn on_one_way(
446 handler: &mut ___H,
447 sender: &::fidl_next::ServerSender<Self, ___T>,
448 ordinal: u64,
449 buffer: ___T::RecvBuffer,
450 ) {
451 match ordinal {
452 ordinal => {
453 sender.close();
454 }
455 }
456 }
457
458 async fn on_two_way(
459 handler: &mut ___H,
460 sender: &::fidl_next::ServerSender<Self, ___T>,
461 ordinal: u64,
462 buffer: ___T::RecvBuffer,
463 responder: ::fidl_next::protocol::Responder,
464 ) {
465 match ordinal {
466 7952116938191896180 => {
467 let responder = ::fidl_next::Responder::from_untyped(responder);
468
469 handler.get_hardware_id(sender, responder).await;
470 }
471
472 6100331669860404750 => {
473 let responder = ::fidl_next::Responder::from_untyped(responder);
474
475 handler.get_event(sender, responder).await;
476 }
477
478 ordinal => {
479 sender.close();
480 }
481 }
482 }
483}
484
485pub mod compat {
487
488 #[cfg(target_os = "fuchsia")]
489 pub type DeviceProxy =
492 ::fidl_next::ClientSender<::fidl_next::fuchsia::zx::Channel, crate::Device>;
493
494 #[cfg(feature = "driver")]
495 impl ::core::convert::From<crate::Device> for ::fidl_fuchsia_examples_gizmo::DeviceMarker {
496 #[inline]
497 fn from(_: crate::Device) -> Self {
498 Self
499 }
500 }
501}