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
5pub mod natural {
6
7 pub use fidl_next_common_fuchsia_examples_gizmo::natural::*;
8
9 #[derive(PartialEq, Debug)]
10 #[repr(C)]
11 pub struct DeviceGetEventResponse {
12 pub event: ::fidl_next::fuchsia::zx::Event,
13 }
14
15 unsafe impl<___E> ::fidl_next::Encode<crate::wire::DeviceGetEventResponse, ___E>
16 for DeviceGetEventResponse
17 where
18 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
19 ___E: ::fidl_next::fuchsia::HandleEncoder,
20 {
21 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
22 Self,
23 crate::wire::DeviceGetEventResponse,
24 > = unsafe {
25 ::fidl_next::CopyOptimization::enable_if(
26 true && <::fidl_next::fuchsia::zx::Event as ::fidl_next::Encode<
27 ::fidl_next::fuchsia::WireEvent,
28 ___E,
29 >>::COPY_OPTIMIZATION
30 .is_enabled(),
31 )
32 };
33
34 #[inline]
35 fn encode(
36 self,
37 encoder_: &mut ___E,
38 out_: &mut ::core::mem::MaybeUninit<crate::wire::DeviceGetEventResponse>,
39 _: (),
40 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
41 ::fidl_next::munge! {
42 let crate::wire::DeviceGetEventResponse {
43 event,
44
45 } = out_;
46 }
47
48 ::fidl_next::Encode::encode(self.event, encoder_, event, ())?;
49
50 let mut _field = unsafe { ::fidl_next::Slot::new_unchecked(event.as_mut_ptr()) };
51
52 Ok(())
53 }
54 }
55
56 unsafe impl<___E>
57 ::fidl_next::EncodeOption<
58 ::fidl_next::WireBox<'static, crate::wire::DeviceGetEventResponse>,
59 ___E,
60 > for DeviceGetEventResponse
61 where
62 ___E: ::fidl_next::Encoder + ?Sized,
63 DeviceGetEventResponse: ::fidl_next::Encode<crate::wire::DeviceGetEventResponse, ___E>,
64 {
65 #[inline]
66 fn encode_option(
67 this: ::core::option::Option<Self>,
68 encoder: &mut ___E,
69 out: &mut ::core::mem::MaybeUninit<
70 ::fidl_next::WireBox<'static, crate::wire::DeviceGetEventResponse>,
71 >,
72 _: (),
73 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
74 if let Some(inner) = this {
75 ::fidl_next::EncoderExt::encode_next(encoder, inner, ())?;
76 ::fidl_next::WireBox::encode_present(out);
77 } else {
78 ::fidl_next::WireBox::encode_absent(out);
79 }
80
81 Ok(())
82 }
83 }
84
85 impl ::fidl_next::FromWire<crate::wire::DeviceGetEventResponse> for DeviceGetEventResponse {
86 const COPY_OPTIMIZATION: ::fidl_next::CopyOptimization<
87 crate::wire::DeviceGetEventResponse,
88 Self,
89 > = unsafe {
90 ::fidl_next::CopyOptimization::enable_if(
91 true && <::fidl_next::fuchsia::zx::Event as ::fidl_next::FromWire<
92 ::fidl_next::fuchsia::WireEvent,
93 >>::COPY_OPTIMIZATION
94 .is_enabled(),
95 )
96 };
97
98 #[inline]
99 fn from_wire(wire: crate::wire::DeviceGetEventResponse) -> Self {
100 Self { event: ::fidl_next::FromWire::from_wire(wire.event) }
101 }
102 }
103}
104
105pub mod wire {
106
107 pub use fidl_next_common_fuchsia_examples_gizmo::wire::*;
108
109 #[derive(Debug)]
111 #[repr(C)]
112 pub struct DeviceGetEventResponse {
113 pub event: ::fidl_next::fuchsia::WireEvent,
114 }
115
116 static_assertions::const_assert_eq!(std::mem::size_of::<DeviceGetEventResponse>(), 4);
117 static_assertions::const_assert_eq!(std::mem::align_of::<DeviceGetEventResponse>(), 4);
118
119 static_assertions::const_assert_eq!(std::mem::offset_of!(DeviceGetEventResponse, event), 0);
120
121 unsafe impl ::fidl_next::Wire for DeviceGetEventResponse {
122 type Owned<'de> = DeviceGetEventResponse;
123
124 #[inline]
125 fn zero_padding(out_: &mut ::core::mem::MaybeUninit<Self>) {
126 ::fidl_next::munge! {
127 let Self {
128
129 event,
130
131 } = &mut *out_;
132 }
133
134 ::fidl_next::Wire::zero_padding(event);
135 }
136 }
137
138 unsafe impl<___D> ::fidl_next::Decode<___D> for DeviceGetEventResponse
139 where
140 ___D: ::fidl_next::decoder::InternalHandleDecoder + ?Sized,
141 ___D: ::fidl_next::fuchsia::HandleDecoder,
142 {
143 fn decode(
144 slot_: ::fidl_next::Slot<'_, Self>,
145 decoder_: &mut ___D,
146 _: (),
147 ) -> ::core::result::Result<(), ::fidl_next::DecodeError> {
148 ::fidl_next::munge! {
149 let Self {
150
151 mut event,
152
153 } = slot_;
154 }
155
156 let _field = event.as_mut();
157
158 ::fidl_next::Decode::decode(event.as_mut(), decoder_, ())?;
159
160 Ok(())
161 }
162 }
163
164 impl ::fidl_next::IntoNatural for DeviceGetEventResponse {
165 type Natural = crate::natural::DeviceGetEventResponse;
166 }
167
168 impl ::fidl_next::Unconstrained for DeviceGetEventResponse {}
169}
170
171pub mod wire_optional {
172
173 pub use fidl_next_common_fuchsia_examples_gizmo::wire_optional::*;
174}
175
176pub mod generic {
177
178 pub use fidl_next_common_fuchsia_examples_gizmo::generic::*;
179
180 pub struct DeviceGetEventResponse<T0> {
181 pub event: T0,
182 }
183
184 unsafe impl<___E, T0> ::fidl_next::Encode<crate::wire::DeviceGetEventResponse, ___E>
185 for DeviceGetEventResponse<T0>
186 where
187 ___E: ::fidl_next::encoder::InternalHandleEncoder + ?Sized,
188 ___E: ::fidl_next::fuchsia::HandleEncoder,
189 T0: ::fidl_next::Encode<::fidl_next::fuchsia::WireEvent, ___E>,
190 {
191 #[inline]
192 fn encode(
193 self,
194 encoder_: &mut ___E,
195 out_: &mut ::core::mem::MaybeUninit<crate::wire::DeviceGetEventResponse>,
196 _: (),
197 ) -> ::core::result::Result<(), ::fidl_next::EncodeError> {
198 ::fidl_next::munge! {
199 let crate::wire::DeviceGetEventResponse {
200
201 event,
202
203 } = out_;
204 }
205
206 ::fidl_next::Encode::encode(self.event, encoder_, event, ())?;
207
208 Ok(())
209 }
210 }
211}
212
213pub use self::natural::*;
214
215#[doc = " The protocol provides access to functions of the driver.\n"]
217#[derive(PartialEq, Debug)]
218pub struct Device;
219
220#[cfg(feature = "driver")]
221impl ::fidl_next::HasTransport for Device {
222 type Transport = ::fdf_fidl::DriverChannel;
223}
224
225pub mod device {
226 pub mod prelude {
227 pub use crate::{Device, DeviceClientHandler, DeviceServerHandler, device};
228
229 pub use crate::natural::DeviceGetEventResponse;
230
231 pub use crate::natural::DeviceGetHardwareIdResponse;
232 }
233
234 pub struct GetHardwareId;
235
236 impl ::fidl_next::Method for GetHardwareId {
237 const ORDINAL: u64 = 7952116938191896180;
238 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
239 ::fidl_next::protocol::Flexibility::Strict;
240
241 type Protocol = crate::Device;
242
243 type Request = ();
244 }
245
246 impl ::fidl_next::TwoWayMethod for GetHardwareId {
247 type Response = ::fidl_next::WireResult<
248 'static,
249 crate::wire::DeviceGetHardwareIdResponse,
250 ::fidl_next::WireI32,
251 >;
252 }
253
254 impl<___R> ::fidl_next::Respond<___R> for GetHardwareId {
255 type Output = ::core::result::Result<
256 crate::generic::DeviceGetHardwareIdResponse<___R>,
257 ::fidl_next::util::Never,
258 >;
259
260 fn respond(response: ___R) -> Self::Output {
261 ::core::result::Result::Ok(crate::generic::DeviceGetHardwareIdResponse {
262 response: response,
263 })
264 }
265 }
266
267 impl<___R> ::fidl_next::RespondErr<___R> for GetHardwareId {
268 type Output = ::core::result::Result<::fidl_next::util::Never, ___R>;
269
270 fn respond_err(response: ___R) -> Self::Output {
271 ::core::result::Result::Err(response)
272 }
273 }
274
275 pub struct GetEvent;
276
277 impl ::fidl_next::Method for GetEvent {
278 const ORDINAL: u64 = 6100331669860404750;
279 const FLEXIBILITY: ::fidl_next::protocol::Flexibility =
280 ::fidl_next::protocol::Flexibility::Strict;
281
282 type Protocol = crate::Device;
283
284 type Request = ();
285 }
286
287 impl ::fidl_next::TwoWayMethod for GetEvent {
288 type Response = crate::wire::DeviceGetEventResponse;
289 }
290
291 impl<___R> ::fidl_next::Respond<___R> for GetEvent {
292 type Output = crate::generic::DeviceGetEventResponse<___R>;
293
294 fn respond(response: ___R) -> Self::Output {
295 crate::generic::DeviceGetEventResponse { event: response }
296 }
297 }
298
299 mod ___detail {
300 unsafe impl<___T> ::fidl_next::HasConnectionHandles<___T> for crate::Device
301 where
302 ___T: ::fidl_next::Transport,
303 {
304 type Client = DeviceClient<___T>;
305 type Server = DeviceServer<___T>;
306 }
307
308 #[repr(transparent)]
310 pub struct DeviceClient<___T: ::fidl_next::Transport> {
311 #[allow(dead_code)]
312 client: ::fidl_next::protocol::Client<___T>,
313 }
314
315 impl<___T> DeviceClient<___T>
316 where
317 ___T: ::fidl_next::Transport,
318 {
319 #[doc = " Returns a unique identifier for this device.\n"]
320 pub fn get_hardware_id(
321 &self,
322 ) -> ::fidl_next::TwoWayFuture<'_, super::GetHardwareId, ___T> {
323 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
324 7952116938191896180,
325 <super::GetHardwareId as ::fidl_next::Method>::FLEXIBILITY,
326 (),
327 ))
328 }
329
330 #[doc = " Returns a zircon event object handle!\n"]
331 pub fn get_event(&self) -> ::fidl_next::TwoWayFuture<'_, super::GetEvent, ___T> {
332 ::fidl_next::TwoWayFuture::from_untyped(self.client.send_two_way(
333 6100331669860404750,
334 <super::GetEvent as ::fidl_next::Method>::FLEXIBILITY,
335 (),
336 ))
337 }
338 }
339
340 #[repr(transparent)]
342 pub struct DeviceServer<___T: ::fidl_next::Transport> {
343 server: ::fidl_next::protocol::Server<___T>,
344 }
345
346 impl<___T> DeviceServer<___T> where ___T: ::fidl_next::Transport {}
347 }
348}
349
350pub trait DeviceClientHandler<
354 #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
355 #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
356>
357{
358}
359
360impl<___T> DeviceClientHandler<___T> for ::fidl_next::IgnoreEvents where ___T: ::fidl_next::Transport
361{}
362
363impl<___H, ___T> ::fidl_next::DispatchClientMessage<___H, ___T> for Device
364where
365 ___H: DeviceClientHandler<___T> + ::core::marker::Send,
366 ___T: ::fidl_next::Transport,
367{
368 async fn on_event(
369 handler: &mut ___H,
370 ordinal: u64,
371 flexibility: ::fidl_next::protocol::Flexibility,
372 buffer: ___T::RecvBuffer,
373 ) -> ::core::result::Result<(), ::fidl_next::ProtocolError<___T::Error>> {
374 match ordinal {
375 ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
376 }
377 }
378}
379
380pub trait DeviceServerHandler<
384 #[cfg(feature = "driver")] ___T: ::fidl_next::Transport = ::fdf_fidl::DriverChannel,
385 #[cfg(not(feature = "driver"))] ___T: ::fidl_next::Transport,
386>
387{
388 #[doc = " Returns a unique identifier for this device.\n"]
389 fn get_hardware_id(
390 &mut self,
391
392 responder: ::fidl_next::Responder<device::GetHardwareId, ___T>,
393 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
394
395 #[doc = " Returns a zircon event object handle!\n"]
396 fn get_event(
397 &mut self,
398
399 responder: ::fidl_next::Responder<device::GetEvent, ___T>,
400 ) -> impl ::core::future::Future<Output = ()> + ::core::marker::Send;
401}
402
403impl<___H, ___T> ::fidl_next::DispatchServerMessage<___H, ___T> for Device
404where
405 ___H: DeviceServerHandler<___T> + ::core::marker::Send,
406 ___T: ::fidl_next::Transport,
407{
408 async fn on_one_way(
409 handler: &mut ___H,
410 ordinal: u64,
411 flexibility: ::fidl_next::protocol::Flexibility,
412 buffer: ___T::RecvBuffer,
413 ) -> ::core::result::Result<
414 (),
415 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
416 > {
417 match ordinal {
418 ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
419 }
420 }
421
422 async fn on_two_way(
423 handler: &mut ___H,
424 ordinal: u64,
425 flexibility: ::fidl_next::protocol::Flexibility,
426 buffer: ___T::RecvBuffer,
427 responder: ::fidl_next::protocol::Responder<___T>,
428 ) -> ::core::result::Result<
429 (),
430 ::fidl_next::ProtocolError<<___T as ::fidl_next::Transport>::Error>,
431 > {
432 match ordinal {
433 7952116938191896180 => {
434 let responder = ::fidl_next::Responder::from_untyped(responder);
435
436 handler.get_hardware_id(responder).await;
437 Ok(())
438 }
439
440 6100331669860404750 => {
441 let responder = ::fidl_next::Responder::from_untyped(responder);
442
443 handler.get_event(responder).await;
444 Ok(())
445 }
446
447 ordinal => Err(::fidl_next::ProtocolError::UnknownOrdinal(ordinal)),
448 }
449 }
450}
451
452pub use fidl_next_common_fuchsia_examples_gizmo::*;
453
454pub mod compat {
456
457 pub use fidl_next_common_fuchsia_examples_gizmo::compat::*;
458
459 #[cfg(feature = "driver")]
460 impl ::fidl_next::CompatFrom<crate::DeviceGetEventResponse>
461 for ::fidl_fuchsia_examples_gizmo::DeviceGetEventResponse
462 {
463 #[inline]
464 fn compat_from(value: crate::DeviceGetEventResponse) -> Self {
465 Self { event: ::fidl_next::CompatFrom::compat_from(value.event) }
466 }
467 }
468
469 #[cfg(feature = "driver")]
470 impl ::fidl_next::CompatFrom<::fidl_fuchsia_examples_gizmo::DeviceGetEventResponse>
471 for crate::DeviceGetEventResponse
472 {
473 #[inline]
474 fn compat_from(value: ::fidl_fuchsia_examples_gizmo::DeviceGetEventResponse) -> Self {
475 Self { event: ::fidl_next::CompatFrom::compat_from(value.event) }
476 }
477 }
478
479 #[cfg(target_os = "fuchsia")]
480 pub type DeviceProxy = ::fidl_next::Client<crate::Device>;
483
484 #[cfg(feature = "driver")]
485 impl ::fidl_next::CompatFrom<crate::Device> for ::fidl_fuchsia_examples_gizmo::DeviceMarker {
486 fn compat_from(_: crate::Device) -> Self {
487 Self
488 }
489 }
490
491 #[cfg(feature = "driver")]
492 impl ::fidl_next::CompatFrom<::fidl_fuchsia_examples_gizmo::DeviceMarker> for crate::Device {
493 fn compat_from(_: ::fidl_fuchsia_examples_gizmo::DeviceMarker) -> Self {
494 Self
495 }
496 }
497}