1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_haptics__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18 type Proxy = DeviceProxy;
19 type RequestStream = DeviceRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DeviceSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.hardware.haptics.Device";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
26pub type DeviceStartVibrationResult = Result<(), i32>;
27pub type DevicePlayVibrationResult = Result<(), i32>;
28pub type DevicePlayEffectResult = Result<(), i32>;
29pub type DevicePlayCompositeWaveformResult = Result<(), i32>;
30pub type DeviceStopVibrationResult = Result<(), i32>;
31pub type DeviceSetAmplitudeResult = Result<(), i32>;
32pub type DeviceGetPropertiesResult =
33 Result<(f32, f32, Vec<SupportedEffect>, Vec<SupportedCompositeEffectWaveform>, u64, i64), i32>;
34
35pub trait DeviceProxyInterface: Send + Sync {
36 type StartVibrationResponseFut: std::future::Future<Output = Result<DeviceStartVibrationResult, fidl::Error>>
37 + Send;
38 fn r#start_vibration(&self) -> Self::StartVibrationResponseFut;
39 type PlayVibrationResponseFut: std::future::Future<Output = Result<DevicePlayVibrationResult, fidl::Error>>
40 + Send;
41 fn r#play_vibration(&self, duration: i64) -> Self::PlayVibrationResponseFut;
42 type PlayEffectResponseFut: std::future::Future<Output = Result<DevicePlayEffectResult, fidl::Error>>
43 + Send;
44 fn r#play_effect(
45 &self,
46 effect: Effect,
47 strength: EffectStrength,
48 ) -> Self::PlayEffectResponseFut;
49 type PlayCompositeWaveformResponseFut: std::future::Future<Output = Result<DevicePlayCompositeWaveformResult, fidl::Error>>
50 + Send;
51 fn r#play_composite_waveform(
52 &self,
53 composite_waveform: &[CompositeEffect],
54 ) -> Self::PlayCompositeWaveformResponseFut;
55 type StopVibrationResponseFut: std::future::Future<Output = Result<DeviceStopVibrationResult, fidl::Error>>
56 + Send;
57 fn r#stop_vibration(&self) -> Self::StopVibrationResponseFut;
58 type SetAmplitudeResponseFut: std::future::Future<Output = Result<DeviceSetAmplitudeResult, fidl::Error>>
59 + Send;
60 fn r#set_amplitude(&self, amplitude: f32) -> Self::SetAmplitudeResponseFut;
61 type GetPropertiesResponseFut: std::future::Future<Output = Result<DeviceGetPropertiesResult, fidl::Error>>
62 + Send;
63 fn r#get_properties(&self) -> Self::GetPropertiesResponseFut;
64}
65#[derive(Debug)]
66#[cfg(target_os = "fuchsia")]
67pub struct DeviceSynchronousProxy {
68 client: fidl::client::sync::Client,
69}
70
71#[cfg(target_os = "fuchsia")]
72impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
73 type Proxy = DeviceProxy;
74 type Protocol = DeviceMarker;
75
76 fn from_channel(inner: fidl::Channel) -> Self {
77 Self::new(inner)
78 }
79
80 fn into_channel(self) -> fidl::Channel {
81 self.client.into_channel()
82 }
83
84 fn as_channel(&self) -> &fidl::Channel {
85 self.client.as_channel()
86 }
87}
88
89#[cfg(target_os = "fuchsia")]
90impl DeviceSynchronousProxy {
91 pub fn new(channel: fidl::Channel) -> Self {
92 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
93 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
94 }
95
96 pub fn into_channel(self) -> fidl::Channel {
97 self.client.into_channel()
98 }
99
100 pub fn wait_for_event(
103 &self,
104 deadline: zx::MonotonicInstant,
105 ) -> Result<DeviceEvent, fidl::Error> {
106 DeviceEvent::decode(self.client.wait_for_event(deadline)?)
107 }
108
109 pub fn r#start_vibration(
112 &self,
113 ___deadline: zx::MonotonicInstant,
114 ) -> Result<DeviceStartVibrationResult, fidl::Error> {
115 let _response = self.client.send_query::<
116 fidl::encoding::EmptyPayload,
117 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
118 >(
119 (),
120 0x439dad11bbcca662,
121 fidl::encoding::DynamicFlags::FLEXIBLE,
122 ___deadline,
123 )?
124 .into_result::<DeviceMarker>("start_vibration")?;
125 Ok(_response.map(|x| x))
126 }
127
128 pub fn r#play_vibration(
133 &self,
134 mut duration: i64,
135 ___deadline: zx::MonotonicInstant,
136 ) -> Result<DevicePlayVibrationResult, fidl::Error> {
137 let _response = self.client.send_query::<
138 DevicePlayVibrationRequest,
139 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
140 >(
141 (duration,),
142 0x7b23b51b00917d27,
143 fidl::encoding::DynamicFlags::FLEXIBLE,
144 ___deadline,
145 )?
146 .into_result::<DeviceMarker>("play_vibration")?;
147 Ok(_response.map(|x| x))
148 }
149
150 pub fn r#play_effect(
155 &self,
156 mut effect: Effect,
157 mut strength: EffectStrength,
158 ___deadline: zx::MonotonicInstant,
159 ) -> Result<DevicePlayEffectResult, fidl::Error> {
160 let _response = self.client.send_query::<
161 DevicePlayEffectRequest,
162 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
163 >(
164 (effect, strength,),
165 0x713695448db55cd5,
166 fidl::encoding::DynamicFlags::FLEXIBLE,
167 ___deadline,
168 )?
169 .into_result::<DeviceMarker>("play_effect")?;
170 Ok(_response.map(|x| x))
171 }
172
173 pub fn r#play_composite_waveform(
178 &self,
179 mut composite_waveform: &[CompositeEffect],
180 ___deadline: zx::MonotonicInstant,
181 ) -> Result<DevicePlayCompositeWaveformResult, fidl::Error> {
182 let _response = self.client.send_query::<
183 DevicePlayCompositeWaveformRequest,
184 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
185 >(
186 (composite_waveform,),
187 0xd6fca2a36d44085,
188 fidl::encoding::DynamicFlags::FLEXIBLE,
189 ___deadline,
190 )?
191 .into_result::<DeviceMarker>("play_composite_waveform")?;
192 Ok(_response.map(|x| x))
193 }
194
195 pub fn r#stop_vibration(
201 &self,
202 ___deadline: zx::MonotonicInstant,
203 ) -> Result<DeviceStopVibrationResult, fidl::Error> {
204 let _response = self.client.send_query::<
205 fidl::encoding::EmptyPayload,
206 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
207 >(
208 (),
209 0x5861752ab352f513,
210 fidl::encoding::DynamicFlags::FLEXIBLE,
211 ___deadline,
212 )?
213 .into_result::<DeviceMarker>("stop_vibration")?;
214 Ok(_response.map(|x| x))
215 }
216
217 pub fn r#set_amplitude(
219 &self,
220 mut amplitude: f32,
221 ___deadline: zx::MonotonicInstant,
222 ) -> Result<DeviceSetAmplitudeResult, fidl::Error> {
223 let _response = self.client.send_query::<
224 DeviceSetAmplitudeRequest,
225 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
226 >(
227 (amplitude,),
228 0x1123b5c82cac1ba0,
229 fidl::encoding::DynamicFlags::FLEXIBLE,
230 ___deadline,
231 )?
232 .into_result::<DeviceMarker>("set_amplitude")?;
233 Ok(_response.map(|x| x))
234 }
235
236 pub fn r#get_properties(
238 &self,
239 ___deadline: zx::MonotonicInstant,
240 ) -> Result<DeviceGetPropertiesResult, fidl::Error> {
241 let _response = self.client.send_query::<
242 fidl::encoding::EmptyPayload,
243 fidl::encoding::FlexibleResultType<DeviceGetPropertiesResponse, i32>,
244 >(
245 (),
246 0x6482dc9bc50e8972,
247 fidl::encoding::DynamicFlags::FLEXIBLE,
248 ___deadline,
249 )?
250 .into_result::<DeviceMarker>("get_properties")?;
251 Ok(_response.map(|x| {
252 (
253 x.fundamental_resonant_frequency_hz,
254 x.quality_factor,
255 x.supported_effects,
256 x.supported_composite_effect_waveforms,
257 x.max_composite_waveform_effect_count,
258 x.max_composite_effect_delay,
259 )
260 }))
261 }
262}
263
264#[cfg(target_os = "fuchsia")]
265impl From<DeviceSynchronousProxy> for zx::NullableHandle {
266 fn from(value: DeviceSynchronousProxy) -> Self {
267 value.into_channel().into()
268 }
269}
270
271#[cfg(target_os = "fuchsia")]
272impl From<fidl::Channel> for DeviceSynchronousProxy {
273 fn from(value: fidl::Channel) -> Self {
274 Self::new(value)
275 }
276}
277
278#[cfg(target_os = "fuchsia")]
279impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
280 type Protocol = DeviceMarker;
281
282 fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
283 Self::new(value.into_channel())
284 }
285}
286
287#[derive(Debug, Clone)]
288pub struct DeviceProxy {
289 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
290}
291
292impl fidl::endpoints::Proxy for DeviceProxy {
293 type Protocol = DeviceMarker;
294
295 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
296 Self::new(inner)
297 }
298
299 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
300 self.client.into_channel().map_err(|client| Self { client })
301 }
302
303 fn as_channel(&self) -> &::fidl::AsyncChannel {
304 self.client.as_channel()
305 }
306}
307
308impl DeviceProxy {
309 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
311 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
312 Self { client: fidl::client::Client::new(channel, protocol_name) }
313 }
314
315 pub fn take_event_stream(&self) -> DeviceEventStream {
321 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
322 }
323
324 pub fn r#start_vibration(
327 &self,
328 ) -> fidl::client::QueryResponseFut<
329 DeviceStartVibrationResult,
330 fidl::encoding::DefaultFuchsiaResourceDialect,
331 > {
332 DeviceProxyInterface::r#start_vibration(self)
333 }
334
335 pub fn r#play_vibration(
340 &self,
341 mut duration: i64,
342 ) -> fidl::client::QueryResponseFut<
343 DevicePlayVibrationResult,
344 fidl::encoding::DefaultFuchsiaResourceDialect,
345 > {
346 DeviceProxyInterface::r#play_vibration(self, duration)
347 }
348
349 pub fn r#play_effect(
354 &self,
355 mut effect: Effect,
356 mut strength: EffectStrength,
357 ) -> fidl::client::QueryResponseFut<
358 DevicePlayEffectResult,
359 fidl::encoding::DefaultFuchsiaResourceDialect,
360 > {
361 DeviceProxyInterface::r#play_effect(self, effect, strength)
362 }
363
364 pub fn r#play_composite_waveform(
369 &self,
370 mut composite_waveform: &[CompositeEffect],
371 ) -> fidl::client::QueryResponseFut<
372 DevicePlayCompositeWaveformResult,
373 fidl::encoding::DefaultFuchsiaResourceDialect,
374 > {
375 DeviceProxyInterface::r#play_composite_waveform(self, composite_waveform)
376 }
377
378 pub fn r#stop_vibration(
384 &self,
385 ) -> fidl::client::QueryResponseFut<
386 DeviceStopVibrationResult,
387 fidl::encoding::DefaultFuchsiaResourceDialect,
388 > {
389 DeviceProxyInterface::r#stop_vibration(self)
390 }
391
392 pub fn r#set_amplitude(
394 &self,
395 mut amplitude: f32,
396 ) -> fidl::client::QueryResponseFut<
397 DeviceSetAmplitudeResult,
398 fidl::encoding::DefaultFuchsiaResourceDialect,
399 > {
400 DeviceProxyInterface::r#set_amplitude(self, amplitude)
401 }
402
403 pub fn r#get_properties(
405 &self,
406 ) -> fidl::client::QueryResponseFut<
407 DeviceGetPropertiesResult,
408 fidl::encoding::DefaultFuchsiaResourceDialect,
409 > {
410 DeviceProxyInterface::r#get_properties(self)
411 }
412}
413
414impl DeviceProxyInterface for DeviceProxy {
415 type StartVibrationResponseFut = fidl::client::QueryResponseFut<
416 DeviceStartVibrationResult,
417 fidl::encoding::DefaultFuchsiaResourceDialect,
418 >;
419 fn r#start_vibration(&self) -> Self::StartVibrationResponseFut {
420 fn _decode(
421 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
422 ) -> Result<DeviceStartVibrationResult, fidl::Error> {
423 let _response = fidl::client::decode_transaction_body::<
424 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
425 fidl::encoding::DefaultFuchsiaResourceDialect,
426 0x439dad11bbcca662,
427 >(_buf?)?
428 .into_result::<DeviceMarker>("start_vibration")?;
429 Ok(_response.map(|x| x))
430 }
431 self.client
432 .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceStartVibrationResult>(
433 (),
434 0x439dad11bbcca662,
435 fidl::encoding::DynamicFlags::FLEXIBLE,
436 _decode,
437 )
438 }
439
440 type PlayVibrationResponseFut = fidl::client::QueryResponseFut<
441 DevicePlayVibrationResult,
442 fidl::encoding::DefaultFuchsiaResourceDialect,
443 >;
444 fn r#play_vibration(&self, mut duration: i64) -> Self::PlayVibrationResponseFut {
445 fn _decode(
446 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
447 ) -> Result<DevicePlayVibrationResult, fidl::Error> {
448 let _response = fidl::client::decode_transaction_body::<
449 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
450 fidl::encoding::DefaultFuchsiaResourceDialect,
451 0x7b23b51b00917d27,
452 >(_buf?)?
453 .into_result::<DeviceMarker>("play_vibration")?;
454 Ok(_response.map(|x| x))
455 }
456 self.client.send_query_and_decode::<DevicePlayVibrationRequest, DevicePlayVibrationResult>(
457 (duration,),
458 0x7b23b51b00917d27,
459 fidl::encoding::DynamicFlags::FLEXIBLE,
460 _decode,
461 )
462 }
463
464 type PlayEffectResponseFut = fidl::client::QueryResponseFut<
465 DevicePlayEffectResult,
466 fidl::encoding::DefaultFuchsiaResourceDialect,
467 >;
468 fn r#play_effect(
469 &self,
470 mut effect: Effect,
471 mut strength: EffectStrength,
472 ) -> Self::PlayEffectResponseFut {
473 fn _decode(
474 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
475 ) -> Result<DevicePlayEffectResult, fidl::Error> {
476 let _response = fidl::client::decode_transaction_body::<
477 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
478 fidl::encoding::DefaultFuchsiaResourceDialect,
479 0x713695448db55cd5,
480 >(_buf?)?
481 .into_result::<DeviceMarker>("play_effect")?;
482 Ok(_response.map(|x| x))
483 }
484 self.client.send_query_and_decode::<DevicePlayEffectRequest, DevicePlayEffectResult>(
485 (effect, strength),
486 0x713695448db55cd5,
487 fidl::encoding::DynamicFlags::FLEXIBLE,
488 _decode,
489 )
490 }
491
492 type PlayCompositeWaveformResponseFut = fidl::client::QueryResponseFut<
493 DevicePlayCompositeWaveformResult,
494 fidl::encoding::DefaultFuchsiaResourceDialect,
495 >;
496 fn r#play_composite_waveform(
497 &self,
498 mut composite_waveform: &[CompositeEffect],
499 ) -> Self::PlayCompositeWaveformResponseFut {
500 fn _decode(
501 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
502 ) -> Result<DevicePlayCompositeWaveformResult, fidl::Error> {
503 let _response = fidl::client::decode_transaction_body::<
504 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
505 fidl::encoding::DefaultFuchsiaResourceDialect,
506 0xd6fca2a36d44085,
507 >(_buf?)?
508 .into_result::<DeviceMarker>("play_composite_waveform")?;
509 Ok(_response.map(|x| x))
510 }
511 self.client.send_query_and_decode::<
512 DevicePlayCompositeWaveformRequest,
513 DevicePlayCompositeWaveformResult,
514 >(
515 (composite_waveform,),
516 0xd6fca2a36d44085,
517 fidl::encoding::DynamicFlags::FLEXIBLE,
518 _decode,
519 )
520 }
521
522 type StopVibrationResponseFut = fidl::client::QueryResponseFut<
523 DeviceStopVibrationResult,
524 fidl::encoding::DefaultFuchsiaResourceDialect,
525 >;
526 fn r#stop_vibration(&self) -> Self::StopVibrationResponseFut {
527 fn _decode(
528 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
529 ) -> Result<DeviceStopVibrationResult, fidl::Error> {
530 let _response = fidl::client::decode_transaction_body::<
531 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
532 fidl::encoding::DefaultFuchsiaResourceDialect,
533 0x5861752ab352f513,
534 >(_buf?)?
535 .into_result::<DeviceMarker>("stop_vibration")?;
536 Ok(_response.map(|x| x))
537 }
538 self.client
539 .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceStopVibrationResult>(
540 (),
541 0x5861752ab352f513,
542 fidl::encoding::DynamicFlags::FLEXIBLE,
543 _decode,
544 )
545 }
546
547 type SetAmplitudeResponseFut = fidl::client::QueryResponseFut<
548 DeviceSetAmplitudeResult,
549 fidl::encoding::DefaultFuchsiaResourceDialect,
550 >;
551 fn r#set_amplitude(&self, mut amplitude: f32) -> Self::SetAmplitudeResponseFut {
552 fn _decode(
553 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
554 ) -> Result<DeviceSetAmplitudeResult, fidl::Error> {
555 let _response = fidl::client::decode_transaction_body::<
556 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
557 fidl::encoding::DefaultFuchsiaResourceDialect,
558 0x1123b5c82cac1ba0,
559 >(_buf?)?
560 .into_result::<DeviceMarker>("set_amplitude")?;
561 Ok(_response.map(|x| x))
562 }
563 self.client.send_query_and_decode::<DeviceSetAmplitudeRequest, DeviceSetAmplitudeResult>(
564 (amplitude,),
565 0x1123b5c82cac1ba0,
566 fidl::encoding::DynamicFlags::FLEXIBLE,
567 _decode,
568 )
569 }
570
571 type GetPropertiesResponseFut = fidl::client::QueryResponseFut<
572 DeviceGetPropertiesResult,
573 fidl::encoding::DefaultFuchsiaResourceDialect,
574 >;
575 fn r#get_properties(&self) -> Self::GetPropertiesResponseFut {
576 fn _decode(
577 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
578 ) -> Result<DeviceGetPropertiesResult, fidl::Error> {
579 let _response = fidl::client::decode_transaction_body::<
580 fidl::encoding::FlexibleResultType<DeviceGetPropertiesResponse, i32>,
581 fidl::encoding::DefaultFuchsiaResourceDialect,
582 0x6482dc9bc50e8972,
583 >(_buf?)?
584 .into_result::<DeviceMarker>("get_properties")?;
585 Ok(_response.map(|x| {
586 (
587 x.fundamental_resonant_frequency_hz,
588 x.quality_factor,
589 x.supported_effects,
590 x.supported_composite_effect_waveforms,
591 x.max_composite_waveform_effect_count,
592 x.max_composite_effect_delay,
593 )
594 }))
595 }
596 self.client
597 .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetPropertiesResult>(
598 (),
599 0x6482dc9bc50e8972,
600 fidl::encoding::DynamicFlags::FLEXIBLE,
601 _decode,
602 )
603 }
604}
605
606pub struct DeviceEventStream {
607 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
608}
609
610impl std::marker::Unpin for DeviceEventStream {}
611
612impl futures::stream::FusedStream for DeviceEventStream {
613 fn is_terminated(&self) -> bool {
614 self.event_receiver.is_terminated()
615 }
616}
617
618impl futures::Stream for DeviceEventStream {
619 type Item = Result<DeviceEvent, fidl::Error>;
620
621 fn poll_next(
622 mut self: std::pin::Pin<&mut Self>,
623 cx: &mut std::task::Context<'_>,
624 ) -> std::task::Poll<Option<Self::Item>> {
625 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
626 &mut self.event_receiver,
627 cx
628 )?) {
629 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
630 None => std::task::Poll::Ready(None),
631 }
632 }
633}
634
635#[derive(Debug)]
636pub enum DeviceEvent {
637 #[non_exhaustive]
638 _UnknownEvent {
639 ordinal: u64,
641 },
642}
643
644impl DeviceEvent {
645 fn decode(
647 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
648 ) -> Result<DeviceEvent, fidl::Error> {
649 let (bytes, _handles) = buf.split_mut();
650 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
651 debug_assert_eq!(tx_header.tx_id, 0);
652 match tx_header.ordinal {
653 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
654 Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
655 }
656 _ => Err(fidl::Error::UnknownOrdinal {
657 ordinal: tx_header.ordinal,
658 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
659 }),
660 }
661 }
662}
663
664pub struct DeviceRequestStream {
666 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
667 is_terminated: bool,
668}
669
670impl std::marker::Unpin for DeviceRequestStream {}
671
672impl futures::stream::FusedStream for DeviceRequestStream {
673 fn is_terminated(&self) -> bool {
674 self.is_terminated
675 }
676}
677
678impl fidl::endpoints::RequestStream for DeviceRequestStream {
679 type Protocol = DeviceMarker;
680 type ControlHandle = DeviceControlHandle;
681
682 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
683 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
684 }
685
686 fn control_handle(&self) -> Self::ControlHandle {
687 DeviceControlHandle { inner: self.inner.clone() }
688 }
689
690 fn into_inner(
691 self,
692 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
693 {
694 (self.inner, self.is_terminated)
695 }
696
697 fn from_inner(
698 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
699 is_terminated: bool,
700 ) -> Self {
701 Self { inner, is_terminated }
702 }
703}
704
705impl futures::Stream for DeviceRequestStream {
706 type Item = Result<DeviceRequest, fidl::Error>;
707
708 fn poll_next(
709 mut self: std::pin::Pin<&mut Self>,
710 cx: &mut std::task::Context<'_>,
711 ) -> std::task::Poll<Option<Self::Item>> {
712 let this = &mut *self;
713 if this.inner.check_shutdown(cx) {
714 this.is_terminated = true;
715 return std::task::Poll::Ready(None);
716 }
717 if this.is_terminated {
718 panic!("polled DeviceRequestStream after completion");
719 }
720 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
721 |bytes, handles| {
722 match this.inner.channel().read_etc(cx, bytes, handles) {
723 std::task::Poll::Ready(Ok(())) => {}
724 std::task::Poll::Pending => return std::task::Poll::Pending,
725 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
726 this.is_terminated = true;
727 return std::task::Poll::Ready(None);
728 }
729 std::task::Poll::Ready(Err(e)) => {
730 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
731 e.into(),
732 ))));
733 }
734 }
735
736 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
738
739 std::task::Poll::Ready(Some(match header.ordinal {
740 0x439dad11bbcca662 => {
741 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
742 let mut req = fidl::new_empty!(
743 fidl::encoding::EmptyPayload,
744 fidl::encoding::DefaultFuchsiaResourceDialect
745 );
746 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
747 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
748 Ok(DeviceRequest::StartVibration {
749 responder: DeviceStartVibrationResponder {
750 control_handle: std::mem::ManuallyDrop::new(control_handle),
751 tx_id: header.tx_id,
752 },
753 })
754 }
755 0x7b23b51b00917d27 => {
756 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
757 let mut req = fidl::new_empty!(
758 DevicePlayVibrationRequest,
759 fidl::encoding::DefaultFuchsiaResourceDialect
760 );
761 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePlayVibrationRequest>(&header, _body_bytes, handles, &mut req)?;
762 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
763 Ok(DeviceRequest::PlayVibration {
764 duration: req.duration,
765
766 responder: DevicePlayVibrationResponder {
767 control_handle: std::mem::ManuallyDrop::new(control_handle),
768 tx_id: header.tx_id,
769 },
770 })
771 }
772 0x713695448db55cd5 => {
773 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
774 let mut req = fidl::new_empty!(
775 DevicePlayEffectRequest,
776 fidl::encoding::DefaultFuchsiaResourceDialect
777 );
778 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePlayEffectRequest>(&header, _body_bytes, handles, &mut req)?;
779 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
780 Ok(DeviceRequest::PlayEffect {
781 effect: req.effect,
782 strength: req.strength,
783
784 responder: DevicePlayEffectResponder {
785 control_handle: std::mem::ManuallyDrop::new(control_handle),
786 tx_id: header.tx_id,
787 },
788 })
789 }
790 0xd6fca2a36d44085 => {
791 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
792 let mut req = fidl::new_empty!(
793 DevicePlayCompositeWaveformRequest,
794 fidl::encoding::DefaultFuchsiaResourceDialect
795 );
796 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevicePlayCompositeWaveformRequest>(&header, _body_bytes, handles, &mut req)?;
797 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
798 Ok(DeviceRequest::PlayCompositeWaveform {
799 composite_waveform: req.composite_waveform,
800
801 responder: DevicePlayCompositeWaveformResponder {
802 control_handle: std::mem::ManuallyDrop::new(control_handle),
803 tx_id: header.tx_id,
804 },
805 })
806 }
807 0x5861752ab352f513 => {
808 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
809 let mut req = fidl::new_empty!(
810 fidl::encoding::EmptyPayload,
811 fidl::encoding::DefaultFuchsiaResourceDialect
812 );
813 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
814 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
815 Ok(DeviceRequest::StopVibration {
816 responder: DeviceStopVibrationResponder {
817 control_handle: std::mem::ManuallyDrop::new(control_handle),
818 tx_id: header.tx_id,
819 },
820 })
821 }
822 0x1123b5c82cac1ba0 => {
823 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
824 let mut req = fidl::new_empty!(
825 DeviceSetAmplitudeRequest,
826 fidl::encoding::DefaultFuchsiaResourceDialect
827 );
828 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetAmplitudeRequest>(&header, _body_bytes, handles, &mut req)?;
829 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
830 Ok(DeviceRequest::SetAmplitude {
831 amplitude: req.amplitude,
832
833 responder: DeviceSetAmplitudeResponder {
834 control_handle: std::mem::ManuallyDrop::new(control_handle),
835 tx_id: header.tx_id,
836 },
837 })
838 }
839 0x6482dc9bc50e8972 => {
840 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
841 let mut req = fidl::new_empty!(
842 fidl::encoding::EmptyPayload,
843 fidl::encoding::DefaultFuchsiaResourceDialect
844 );
845 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
846 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
847 Ok(DeviceRequest::GetProperties {
848 responder: DeviceGetPropertiesResponder {
849 control_handle: std::mem::ManuallyDrop::new(control_handle),
850 tx_id: header.tx_id,
851 },
852 })
853 }
854 _ if header.tx_id == 0
855 && header
856 .dynamic_flags()
857 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
858 {
859 Ok(DeviceRequest::_UnknownMethod {
860 ordinal: header.ordinal,
861 control_handle: DeviceControlHandle { inner: this.inner.clone() },
862 method_type: fidl::MethodType::OneWay,
863 })
864 }
865 _ if header
866 .dynamic_flags()
867 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
868 {
869 this.inner.send_framework_err(
870 fidl::encoding::FrameworkErr::UnknownMethod,
871 header.tx_id,
872 header.ordinal,
873 header.dynamic_flags(),
874 (bytes, handles),
875 )?;
876 Ok(DeviceRequest::_UnknownMethod {
877 ordinal: header.ordinal,
878 control_handle: DeviceControlHandle { inner: this.inner.clone() },
879 method_type: fidl::MethodType::TwoWay,
880 })
881 }
882 _ => Err(fidl::Error::UnknownOrdinal {
883 ordinal: header.ordinal,
884 protocol_name:
885 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
886 }),
887 }))
888 },
889 )
890 }
891}
892
893#[derive(Debug)]
894pub enum DeviceRequest {
895 StartVibration { responder: DeviceStartVibrationResponder },
898 PlayVibration { duration: i64, responder: DevicePlayVibrationResponder },
903 PlayEffect { effect: Effect, strength: EffectStrength, responder: DevicePlayEffectResponder },
908 PlayCompositeWaveform {
913 composite_waveform: Vec<CompositeEffect>,
914 responder: DevicePlayCompositeWaveformResponder,
915 },
916 StopVibration { responder: DeviceStopVibrationResponder },
922 SetAmplitude { amplitude: f32, responder: DeviceSetAmplitudeResponder },
924 GetProperties { responder: DeviceGetPropertiesResponder },
926 #[non_exhaustive]
928 _UnknownMethod {
929 ordinal: u64,
931 control_handle: DeviceControlHandle,
932 method_type: fidl::MethodType,
933 },
934}
935
936impl DeviceRequest {
937 #[allow(irrefutable_let_patterns)]
938 pub fn into_start_vibration(self) -> Option<(DeviceStartVibrationResponder)> {
939 if let DeviceRequest::StartVibration { responder } = self {
940 Some((responder))
941 } else {
942 None
943 }
944 }
945
946 #[allow(irrefutable_let_patterns)]
947 pub fn into_play_vibration(self) -> Option<(i64, DevicePlayVibrationResponder)> {
948 if let DeviceRequest::PlayVibration { duration, responder } = self {
949 Some((duration, responder))
950 } else {
951 None
952 }
953 }
954
955 #[allow(irrefutable_let_patterns)]
956 pub fn into_play_effect(self) -> Option<(Effect, EffectStrength, DevicePlayEffectResponder)> {
957 if let DeviceRequest::PlayEffect { effect, strength, responder } = self {
958 Some((effect, strength, responder))
959 } else {
960 None
961 }
962 }
963
964 #[allow(irrefutable_let_patterns)]
965 pub fn into_play_composite_waveform(
966 self,
967 ) -> Option<(Vec<CompositeEffect>, DevicePlayCompositeWaveformResponder)> {
968 if let DeviceRequest::PlayCompositeWaveform { composite_waveform, responder } = self {
969 Some((composite_waveform, responder))
970 } else {
971 None
972 }
973 }
974
975 #[allow(irrefutable_let_patterns)]
976 pub fn into_stop_vibration(self) -> Option<(DeviceStopVibrationResponder)> {
977 if let DeviceRequest::StopVibration { responder } = self { Some((responder)) } else { None }
978 }
979
980 #[allow(irrefutable_let_patterns)]
981 pub fn into_set_amplitude(self) -> Option<(f32, DeviceSetAmplitudeResponder)> {
982 if let DeviceRequest::SetAmplitude { amplitude, responder } = self {
983 Some((amplitude, responder))
984 } else {
985 None
986 }
987 }
988
989 #[allow(irrefutable_let_patterns)]
990 pub fn into_get_properties(self) -> Option<(DeviceGetPropertiesResponder)> {
991 if let DeviceRequest::GetProperties { responder } = self { Some((responder)) } else { None }
992 }
993
994 pub fn method_name(&self) -> &'static str {
996 match *self {
997 DeviceRequest::StartVibration { .. } => "start_vibration",
998 DeviceRequest::PlayVibration { .. } => "play_vibration",
999 DeviceRequest::PlayEffect { .. } => "play_effect",
1000 DeviceRequest::PlayCompositeWaveform { .. } => "play_composite_waveform",
1001 DeviceRequest::StopVibration { .. } => "stop_vibration",
1002 DeviceRequest::SetAmplitude { .. } => "set_amplitude",
1003 DeviceRequest::GetProperties { .. } => "get_properties",
1004 DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1005 "unknown one-way method"
1006 }
1007 DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1008 "unknown two-way method"
1009 }
1010 }
1011 }
1012}
1013
1014#[derive(Debug, Clone)]
1015pub struct DeviceControlHandle {
1016 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1017}
1018
1019impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1020 fn shutdown(&self) {
1021 self.inner.shutdown()
1022 }
1023
1024 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1025 self.inner.shutdown_with_epitaph(status)
1026 }
1027
1028 fn is_closed(&self) -> bool {
1029 self.inner.channel().is_closed()
1030 }
1031 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1032 self.inner.channel().on_closed()
1033 }
1034
1035 #[cfg(target_os = "fuchsia")]
1036 fn signal_peer(
1037 &self,
1038 clear_mask: zx::Signals,
1039 set_mask: zx::Signals,
1040 ) -> Result<(), zx_status::Status> {
1041 use fidl::Peered;
1042 self.inner.channel().signal_peer(clear_mask, set_mask)
1043 }
1044}
1045
1046impl DeviceControlHandle {}
1047
1048#[must_use = "FIDL methods require a response to be sent"]
1049#[derive(Debug)]
1050pub struct DeviceStartVibrationResponder {
1051 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1052 tx_id: u32,
1053}
1054
1055impl std::ops::Drop for DeviceStartVibrationResponder {
1059 fn drop(&mut self) {
1060 self.control_handle.shutdown();
1061 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1063 }
1064}
1065
1066impl fidl::endpoints::Responder for DeviceStartVibrationResponder {
1067 type ControlHandle = DeviceControlHandle;
1068
1069 fn control_handle(&self) -> &DeviceControlHandle {
1070 &self.control_handle
1071 }
1072
1073 fn drop_without_shutdown(mut self) {
1074 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1076 std::mem::forget(self);
1078 }
1079}
1080
1081impl DeviceStartVibrationResponder {
1082 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1086 let _result = self.send_raw(result);
1087 if _result.is_err() {
1088 self.control_handle.shutdown();
1089 }
1090 self.drop_without_shutdown();
1091 _result
1092 }
1093
1094 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1096 let _result = self.send_raw(result);
1097 self.drop_without_shutdown();
1098 _result
1099 }
1100
1101 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1102 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1103 fidl::encoding::EmptyStruct,
1104 i32,
1105 >>(
1106 fidl::encoding::FlexibleResult::new(result),
1107 self.tx_id,
1108 0x439dad11bbcca662,
1109 fidl::encoding::DynamicFlags::FLEXIBLE,
1110 )
1111 }
1112}
1113
1114#[must_use = "FIDL methods require a response to be sent"]
1115#[derive(Debug)]
1116pub struct DevicePlayVibrationResponder {
1117 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1118 tx_id: u32,
1119}
1120
1121impl std::ops::Drop for DevicePlayVibrationResponder {
1125 fn drop(&mut self) {
1126 self.control_handle.shutdown();
1127 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1129 }
1130}
1131
1132impl fidl::endpoints::Responder for DevicePlayVibrationResponder {
1133 type ControlHandle = DeviceControlHandle;
1134
1135 fn control_handle(&self) -> &DeviceControlHandle {
1136 &self.control_handle
1137 }
1138
1139 fn drop_without_shutdown(mut self) {
1140 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1142 std::mem::forget(self);
1144 }
1145}
1146
1147impl DevicePlayVibrationResponder {
1148 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1152 let _result = self.send_raw(result);
1153 if _result.is_err() {
1154 self.control_handle.shutdown();
1155 }
1156 self.drop_without_shutdown();
1157 _result
1158 }
1159
1160 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1162 let _result = self.send_raw(result);
1163 self.drop_without_shutdown();
1164 _result
1165 }
1166
1167 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1168 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1169 fidl::encoding::EmptyStruct,
1170 i32,
1171 >>(
1172 fidl::encoding::FlexibleResult::new(result),
1173 self.tx_id,
1174 0x7b23b51b00917d27,
1175 fidl::encoding::DynamicFlags::FLEXIBLE,
1176 )
1177 }
1178}
1179
1180#[must_use = "FIDL methods require a response to be sent"]
1181#[derive(Debug)]
1182pub struct DevicePlayEffectResponder {
1183 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1184 tx_id: u32,
1185}
1186
1187impl std::ops::Drop for DevicePlayEffectResponder {
1191 fn drop(&mut self) {
1192 self.control_handle.shutdown();
1193 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1195 }
1196}
1197
1198impl fidl::endpoints::Responder for DevicePlayEffectResponder {
1199 type ControlHandle = DeviceControlHandle;
1200
1201 fn control_handle(&self) -> &DeviceControlHandle {
1202 &self.control_handle
1203 }
1204
1205 fn drop_without_shutdown(mut self) {
1206 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1208 std::mem::forget(self);
1210 }
1211}
1212
1213impl DevicePlayEffectResponder {
1214 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1218 let _result = self.send_raw(result);
1219 if _result.is_err() {
1220 self.control_handle.shutdown();
1221 }
1222 self.drop_without_shutdown();
1223 _result
1224 }
1225
1226 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1228 let _result = self.send_raw(result);
1229 self.drop_without_shutdown();
1230 _result
1231 }
1232
1233 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1234 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1235 fidl::encoding::EmptyStruct,
1236 i32,
1237 >>(
1238 fidl::encoding::FlexibleResult::new(result),
1239 self.tx_id,
1240 0x713695448db55cd5,
1241 fidl::encoding::DynamicFlags::FLEXIBLE,
1242 )
1243 }
1244}
1245
1246#[must_use = "FIDL methods require a response to be sent"]
1247#[derive(Debug)]
1248pub struct DevicePlayCompositeWaveformResponder {
1249 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1250 tx_id: u32,
1251}
1252
1253impl std::ops::Drop for DevicePlayCompositeWaveformResponder {
1257 fn drop(&mut self) {
1258 self.control_handle.shutdown();
1259 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1261 }
1262}
1263
1264impl fidl::endpoints::Responder for DevicePlayCompositeWaveformResponder {
1265 type ControlHandle = DeviceControlHandle;
1266
1267 fn control_handle(&self) -> &DeviceControlHandle {
1268 &self.control_handle
1269 }
1270
1271 fn drop_without_shutdown(mut self) {
1272 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1274 std::mem::forget(self);
1276 }
1277}
1278
1279impl DevicePlayCompositeWaveformResponder {
1280 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1284 let _result = self.send_raw(result);
1285 if _result.is_err() {
1286 self.control_handle.shutdown();
1287 }
1288 self.drop_without_shutdown();
1289 _result
1290 }
1291
1292 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1294 let _result = self.send_raw(result);
1295 self.drop_without_shutdown();
1296 _result
1297 }
1298
1299 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1300 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1301 fidl::encoding::EmptyStruct,
1302 i32,
1303 >>(
1304 fidl::encoding::FlexibleResult::new(result),
1305 self.tx_id,
1306 0xd6fca2a36d44085,
1307 fidl::encoding::DynamicFlags::FLEXIBLE,
1308 )
1309 }
1310}
1311
1312#[must_use = "FIDL methods require a response to be sent"]
1313#[derive(Debug)]
1314pub struct DeviceStopVibrationResponder {
1315 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1316 tx_id: u32,
1317}
1318
1319impl std::ops::Drop for DeviceStopVibrationResponder {
1323 fn drop(&mut self) {
1324 self.control_handle.shutdown();
1325 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1327 }
1328}
1329
1330impl fidl::endpoints::Responder for DeviceStopVibrationResponder {
1331 type ControlHandle = DeviceControlHandle;
1332
1333 fn control_handle(&self) -> &DeviceControlHandle {
1334 &self.control_handle
1335 }
1336
1337 fn drop_without_shutdown(mut self) {
1338 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1340 std::mem::forget(self);
1342 }
1343}
1344
1345impl DeviceStopVibrationResponder {
1346 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1350 let _result = self.send_raw(result);
1351 if _result.is_err() {
1352 self.control_handle.shutdown();
1353 }
1354 self.drop_without_shutdown();
1355 _result
1356 }
1357
1358 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1360 let _result = self.send_raw(result);
1361 self.drop_without_shutdown();
1362 _result
1363 }
1364
1365 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1366 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1367 fidl::encoding::EmptyStruct,
1368 i32,
1369 >>(
1370 fidl::encoding::FlexibleResult::new(result),
1371 self.tx_id,
1372 0x5861752ab352f513,
1373 fidl::encoding::DynamicFlags::FLEXIBLE,
1374 )
1375 }
1376}
1377
1378#[must_use = "FIDL methods require a response to be sent"]
1379#[derive(Debug)]
1380pub struct DeviceSetAmplitudeResponder {
1381 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1382 tx_id: u32,
1383}
1384
1385impl std::ops::Drop for DeviceSetAmplitudeResponder {
1389 fn drop(&mut self) {
1390 self.control_handle.shutdown();
1391 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1393 }
1394}
1395
1396impl fidl::endpoints::Responder for DeviceSetAmplitudeResponder {
1397 type ControlHandle = DeviceControlHandle;
1398
1399 fn control_handle(&self) -> &DeviceControlHandle {
1400 &self.control_handle
1401 }
1402
1403 fn drop_without_shutdown(mut self) {
1404 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1406 std::mem::forget(self);
1408 }
1409}
1410
1411impl DeviceSetAmplitudeResponder {
1412 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1416 let _result = self.send_raw(result);
1417 if _result.is_err() {
1418 self.control_handle.shutdown();
1419 }
1420 self.drop_without_shutdown();
1421 _result
1422 }
1423
1424 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1426 let _result = self.send_raw(result);
1427 self.drop_without_shutdown();
1428 _result
1429 }
1430
1431 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1432 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1433 fidl::encoding::EmptyStruct,
1434 i32,
1435 >>(
1436 fidl::encoding::FlexibleResult::new(result),
1437 self.tx_id,
1438 0x1123b5c82cac1ba0,
1439 fidl::encoding::DynamicFlags::FLEXIBLE,
1440 )
1441 }
1442}
1443
1444#[must_use = "FIDL methods require a response to be sent"]
1445#[derive(Debug)]
1446pub struct DeviceGetPropertiesResponder {
1447 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1448 tx_id: u32,
1449}
1450
1451impl std::ops::Drop for DeviceGetPropertiesResponder {
1455 fn drop(&mut self) {
1456 self.control_handle.shutdown();
1457 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1459 }
1460}
1461
1462impl fidl::endpoints::Responder for DeviceGetPropertiesResponder {
1463 type ControlHandle = DeviceControlHandle;
1464
1465 fn control_handle(&self) -> &DeviceControlHandle {
1466 &self.control_handle
1467 }
1468
1469 fn drop_without_shutdown(mut self) {
1470 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1472 std::mem::forget(self);
1474 }
1475}
1476
1477impl DeviceGetPropertiesResponder {
1478 pub fn send(
1482 self,
1483 mut result: Result<
1484 (f32, f32, &[SupportedEffect], &[SupportedCompositeEffectWaveform], u64, i64),
1485 i32,
1486 >,
1487 ) -> Result<(), fidl::Error> {
1488 let _result = self.send_raw(result);
1489 if _result.is_err() {
1490 self.control_handle.shutdown();
1491 }
1492 self.drop_without_shutdown();
1493 _result
1494 }
1495
1496 pub fn send_no_shutdown_on_err(
1498 self,
1499 mut result: Result<
1500 (f32, f32, &[SupportedEffect], &[SupportedCompositeEffectWaveform], u64, i64),
1501 i32,
1502 >,
1503 ) -> Result<(), fidl::Error> {
1504 let _result = self.send_raw(result);
1505 self.drop_without_shutdown();
1506 _result
1507 }
1508
1509 fn send_raw(
1510 &self,
1511 mut result: Result<
1512 (f32, f32, &[SupportedEffect], &[SupportedCompositeEffectWaveform], u64, i64),
1513 i32,
1514 >,
1515 ) -> Result<(), fidl::Error> {
1516 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1517 DeviceGetPropertiesResponse,
1518 i32,
1519 >>(
1520 fidl::encoding::FlexibleResult::new(result),
1521 self.tx_id,
1522 0x6482dc9bc50e8972,
1523 fidl::encoding::DynamicFlags::FLEXIBLE,
1524 )
1525 }
1526}
1527
1528#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1529pub struct ServiceMarker;
1530
1531#[cfg(target_os = "fuchsia")]
1532impl fidl::endpoints::ServiceMarker for ServiceMarker {
1533 type Proxy = ServiceProxy;
1534 type Request = ServiceRequest;
1535 const SERVICE_NAME: &'static str = "fuchsia.hardware.haptics.Service";
1536}
1537
1538#[cfg(target_os = "fuchsia")]
1541pub enum ServiceRequest {
1542 Device(DeviceRequestStream),
1543}
1544
1545#[cfg(target_os = "fuchsia")]
1546impl fidl::endpoints::ServiceRequest for ServiceRequest {
1547 type Service = ServiceMarker;
1548
1549 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1550 match name {
1551 "device" => Self::Device(
1552 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1553 ),
1554 _ => panic!("no such member protocol name for service Service"),
1555 }
1556 }
1557
1558 fn member_names() -> &'static [&'static str] {
1559 &["device"]
1560 }
1561}
1562#[cfg(target_os = "fuchsia")]
1563pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1564
1565#[cfg(target_os = "fuchsia")]
1566impl fidl::endpoints::ServiceProxy for ServiceProxy {
1567 type Service = ServiceMarker;
1568
1569 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1570 Self(opener)
1571 }
1572}
1573
1574#[cfg(target_os = "fuchsia")]
1575impl ServiceProxy {
1576 pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1577 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1578 self.connect_channel_to_device(server_end)?;
1579 Ok(proxy)
1580 }
1581
1582 pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1585 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1586 self.connect_channel_to_device(server_end)?;
1587 Ok(proxy)
1588 }
1589
1590 pub fn connect_channel_to_device(
1593 &self,
1594 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1595 ) -> Result<(), fidl::Error> {
1596 self.0.open_member("device", server_end.into_channel())
1597 }
1598
1599 pub fn instance_name(&self) -> &str {
1600 self.0.instance_name()
1601 }
1602}
1603
1604mod internal {
1605 use super::*;
1606}