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