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