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> = 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 Box<DeviceGetHardwareIdResponse> {
68 type EncodedOption = ::fidl_next::WireBox<WireDeviceGetHardwareIdResponse>;
69}
70
71unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<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 Box<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::TakeFrom<WireDeviceGetHardwareIdResponse> for DeviceGetHardwareIdResponse {
116 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
117 ::fidl_next::CopyOptimization::enable_if(
118 true && <u32 as ::fidl_next::Encodable>::COPY_OPTIMIZATION.is_enabled(),
119 )
120 };
121
122 #[inline]
123 fn take_from(from: &WireDeviceGetHardwareIdResponse) -> Self {
124 Self { response: ::fidl_next::TakeFrom::take_from(&from.response) }
125 }
126}
127
128#[derive(Clone, Debug)]
130#[repr(C)]
131pub struct WireDeviceGetHardwareIdResponse {
132 pub response: ::fidl_next::WireU32,
133}
134
135unsafe impl ::fidl_next::ZeroPadding for WireDeviceGetHardwareIdResponse {
136 #[inline]
137 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
138}
139
140unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceGetHardwareIdResponse
141where
142 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
143{
144 fn decode(
145 slot: ::fidl_next::Slot<'_, Self>,
146 decoder: &mut ___D,
147 ) -> Result<(), ::fidl_next::DecodeError> {
148 ::fidl_next::munge! {
149 let Self {
150 mut response,
151
152 } = slot;
153 }
154
155 ::fidl_next::Decode::decode(response.as_mut(), decoder)?;
156
157 Ok(())
158 }
159}
160
161#[derive(Debug)]
162#[repr(C)]
163pub struct DeviceGetEventResponse {
164 pub event: ::fidl_next::fuchsia::zx::Handle,
165}
166
167impl ::fidl_next::Encodable for DeviceGetEventResponse {
168 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
169 ::fidl_next::CopyOptimization::enable_if(
170 true && <::fidl_next::fuchsia::zx::Handle as ::fidl_next::Encodable>::COPY_OPTIMIZATION
171 .is_enabled(),
172 )
173 };
174
175 type Encoded = WireDeviceGetEventResponse;
176}
177
178unsafe impl<___E> ::fidl_next::Encode<___E> for DeviceGetEventResponse
179where
180 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
181
182 ___E: ::fidl_next::fuchsia::HandleEncoder,
183{
184 #[inline]
185 fn encode(
186 self,
187 encoder: &mut ___E,
188 out: &mut ::core::mem::MaybeUninit<Self::Encoded>,
189 ) -> Result<(), ::fidl_next::EncodeError> {
190 ::fidl_next::munge! {
191 let Self::Encoded {
192 event,
193
194 } = out;
195 }
196
197 ::fidl_next::Encode::encode(self.event, encoder, event)?;
198
199 Ok(())
200 }
201}
202
203impl ::fidl_next::EncodableOption for Box<DeviceGetEventResponse> {
204 type EncodedOption = ::fidl_next::WireBox<WireDeviceGetEventResponse>;
205}
206
207unsafe impl<___E> ::fidl_next::EncodeOption<___E> for Box<DeviceGetEventResponse>
208where
209 ___E: ::fidl_next::Encoder + ?Sized,
210 DeviceGetEventResponse: ::fidl_next::Encode<___E>,
211{
212 #[inline]
213 fn encode_option(
214 this: Option<Self>,
215 encoder: &mut ___E,
216 out: &mut ::core::mem::MaybeUninit<Self::EncodedOption>,
217 ) -> Result<(), ::fidl_next::EncodeError> {
218 if let Some(inner) = this {
219 ::fidl_next::EncoderExt::encode_next(encoder, *inner)?;
220 ::fidl_next::WireBox::encode_present(out);
221 } else {
222 ::fidl_next::WireBox::encode_absent(out);
223 }
224
225 Ok(())
226 }
227}
228
229impl ::fidl_next::TakeFrom<WireDeviceGetEventResponse> for DeviceGetEventResponse {
230 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<Self> = unsafe {
231 ::fidl_next::CopyOptimization::enable_if(
232 true && <::fidl_next::fuchsia::zx::Handle as ::fidl_next::Encodable>::COPY_OPTIMIZATION
233 .is_enabled(),
234 )
235 };
236
237 #[inline]
238 fn take_from(from: &WireDeviceGetEventResponse) -> Self {
239 Self { event: ::fidl_next::TakeFrom::take_from(&from.event) }
240 }
241}
242
243#[derive(Debug)]
245#[repr(C)]
246pub struct WireDeviceGetEventResponse {
247 pub event: ::fidl_next::fuchsia::WireHandle,
248}
249
250unsafe impl ::fidl_next::ZeroPadding for WireDeviceGetEventResponse {
251 #[inline]
252 fn zero_padding(out: &mut ::core::mem::MaybeUninit<Self>) {}
253}
254
255unsafe impl<___D> ::fidl_next::Decode<___D> for WireDeviceGetEventResponse
256where
257 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
258
259 ___D: ::fidl_next::fuchsia::HandleDecoder,
260{
261 fn decode(
262 slot: ::fidl_next::Slot<'_, Self>,
263 decoder: &mut ___D,
264 ) -> Result<(), ::fidl_next::DecodeError> {
265 ::fidl_next::munge! {
266 let Self {
267 mut event,
268
269 } = slot;
270 }
271
272 ::fidl_next::Decode::decode(event.as_mut(), decoder)?;
273
274 Ok(())
275 }
276}
277
278#[doc = " The protocol provides access to functions of the driver.\n"]
280#[derive(Debug)]
281pub struct Device;
282
283pub mod device {
284 pub mod prelude {
285 pub use crate::{
286 device, Device, DeviceClientHandler, DeviceClientSender, DeviceServerHandler,
287 DeviceServerSender,
288 };
289
290 pub use crate::DeviceGetEventResponse;
291
292 pub use crate::DeviceGetHardwareIdResponse;
293 }
294
295 pub struct GetHardwareId;
296
297 impl ::fidl_next::Method for GetHardwareId {
298 const ORDINAL: u64 = 7952116938191896180;
299
300 type Protocol = crate::Device;
301
302 type Request = ();
303
304 type Response =
305 ::fidl_next::WireResult<crate::WireDeviceGetHardwareIdResponse, ::fidl_next::WireI32>;
306 }
307
308 pub struct GetEvent;
309
310 impl ::fidl_next::Method for GetEvent {
311 const ORDINAL: u64 = 6100331669860404750;
312
313 type Protocol = crate::Device;
314
315 type Request = ();
316
317 type Response = crate::WireDeviceGetEventResponse;
318 }
319}
320
321pub trait DeviceClientSender {
323 type Transport: ::fidl_next::Transport;
324
325 #[doc = " Returns a unique identifier for this device.\n"]
326 fn get_hardware_id(
327 &self,
328 ) -> Result<
329 ::fidl_next::ResponseFuture<'_, Self::Transport, device::GetHardwareId>,
330 ::fidl_next::EncodeError,
331 >;
332
333 #[doc = " Returns a zircon event object handle!\n"]
334 fn get_event(
335 &self,
336 ) -> Result<
337 ::fidl_next::ResponseFuture<'_, Self::Transport, device::GetEvent>,
338 ::fidl_next::EncodeError,
339 >;
340}
341
342impl<___T> DeviceClientSender for ::fidl_next::ClientSender<___T, Device>
343where
344 ___T: ::fidl_next::Transport,
345{
346 type Transport = ___T;
347
348 #[doc = " Returns a unique identifier for this device.\n"]
349 fn get_hardware_id(
350 &self,
351 ) -> Result<
352 ::fidl_next::ResponseFuture<'_, Self::Transport, device::GetHardwareId>,
353 ::fidl_next::EncodeError,
354 > {
355 self.as_untyped()
356 .send_two_way(7952116938191896180, ())
357 .map(::fidl_next::ResponseFuture::from_untyped)
358 }
359
360 #[doc = " Returns a zircon event object handle!\n"]
361 fn get_event(
362 &self,
363 ) -> Result<
364 ::fidl_next::ResponseFuture<'_, Self::Transport, device::GetEvent>,
365 ::fidl_next::EncodeError,
366 > {
367 self.as_untyped()
368 .send_two_way(6100331669860404750, ())
369 .map(::fidl_next::ResponseFuture::from_untyped)
370 }
371}
372
373pub trait DeviceClientHandler<___T: ::fidl_next::Transport> {}
377
378impl<___T, ___H> ::fidl_next::ClientProtocol<___T, ___H> for Device
379where
380 ___T: ::fidl_next::Transport,
381 ___H: DeviceClientHandler<___T>,
382
383 <device::GetHardwareId as ::fidl_next::Method>::Response:
384 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
385
386 <device::GetEvent as ::fidl_next::Method>::Response:
387 ::fidl_next::Decode<<___T as ::fidl_next::Transport>::RecvBuffer>,
388{
389 fn on_event(
390 handler: &mut ___H,
391 sender: &::fidl_next::ClientSender<___T, Self>,
392 ordinal: u64,
393 buffer: ___T::RecvBuffer,
394 ) {
395 match ordinal {
396 ordinal => {
397 sender.close();
398 }
399 }
400 }
401}
402
403pub trait DeviceServerSender {
405 type Transport: ::fidl_next::Transport;
406}
407
408impl<___T> DeviceServerSender for ::fidl_next::ServerSender<___T, Device>
409where
410 ___T: ::fidl_next::Transport,
411{
412 type Transport = ___T;
413}
414
415pub trait DeviceServerHandler<___T: ::fidl_next::Transport> {
419 #[doc = " Returns a unique identifier for this device.\n"]
420 fn get_hardware_id(
421 &mut self,
422 sender: &::fidl_next::ServerSender<___T, Device>,
423
424 responder: ::fidl_next::Responder<device::GetHardwareId>,
425 );
426
427 #[doc = " Returns a zircon event object handle!\n"]
428 fn get_event(
429 &mut self,
430 sender: &::fidl_next::ServerSender<___T, Device>,
431
432 responder: ::fidl_next::Responder<device::GetEvent>,
433 );
434}
435
436impl<___T, ___H> ::fidl_next::ServerProtocol<___T, ___H> for Device
437where
438 ___T: ::fidl_next::Transport,
439 ___H: DeviceServerHandler<___T>,
440{
441 fn on_one_way(
442 handler: &mut ___H,
443 sender: &::fidl_next::ServerSender<___T, Self>,
444 ordinal: u64,
445 buffer: ___T::RecvBuffer,
446 ) {
447 match ordinal {
448 ordinal => {
449 sender.close();
450 }
451 }
452 }
453
454 fn on_two_way(
455 handler: &mut ___H,
456 sender: &::fidl_next::ServerSender<___T, Self>,
457 ordinal: u64,
458 buffer: ___T::RecvBuffer,
459 responder: ::fidl_next::protocol::Responder,
460 ) {
461 match ordinal {
462 7952116938191896180 => {
463 let responder = ::fidl_next::Responder::from_untyped(responder);
464
465 handler.get_hardware_id(sender, responder);
466 }
467
468 6100331669860404750 => {
469 let responder = ::fidl_next::Responder::from_untyped(responder);
470
471 handler.get_event(sender, responder);
472 }
473
474 ordinal => {
475 sender.close();
476 }
477 }
478 }
479}
480
481pub mod compat {
483
484 #[cfg(feature = "driver")]
485 impl ::fidl_next::TakeFrom<crate::WireDeviceGetHardwareIdResponse>
486 for ::fidl_fuchsia_examples_gizmo::DeviceGetHardwareIdResponse
487 {
488 #[inline]
489 fn take_from(from: &crate::WireDeviceGetHardwareIdResponse) -> Self {
490 Self { response: ::fidl_next::TakeFrom::take_from(&from.response) }
491 }
492 }
493
494 #[cfg(feature = "driver")]
495 impl ::fidl_next::TakeFrom<crate::WireDeviceGetEventResponse>
496 for ::fidl_fuchsia_examples_gizmo::DeviceGetEventResponse
497 {
498 #[inline]
499 fn take_from(from: &crate::WireDeviceGetEventResponse) -> Self {
500 Self { event: ::fidl_next::TakeFrom::take_from(&from.event) }
501 }
502 }
503
504 #[cfg(target_os = "fuchsia")]
505 pub type DeviceProxy =
508 ::fidl_next::ClientSender<::fidl_next::fuchsia::zx::Channel, crate::Device>;
509
510 #[cfg(feature = "driver")]
511 impl ::fidl_next::TakeFrom<crate::Device> for ::fidl_fuchsia_examples_gizmo::DeviceMarker {
512 #[inline]
513 fn take_from(from: &crate::Device) -> Self {
514 Self
515 }
516 }
517}