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 DeviceControlHandle {
1026 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1027 self.inner.shutdown_with_epitaph(status.into())
1028 }
1029}
1030
1031impl fidl::endpoints::ControlHandle for DeviceControlHandle {
1032 fn shutdown(&self) {
1033 self.inner.shutdown()
1034 }
1035
1036 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1037 self.inner.shutdown_with_epitaph(status)
1038 }
1039
1040 fn is_closed(&self) -> bool {
1041 self.inner.channel().is_closed()
1042 }
1043 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1044 self.inner.channel().on_closed()
1045 }
1046
1047 #[cfg(target_os = "fuchsia")]
1048 fn signal_peer(
1049 &self,
1050 clear_mask: zx::Signals,
1051 set_mask: zx::Signals,
1052 ) -> Result<(), zx_status::Status> {
1053 use fidl::Peered;
1054 self.inner.channel().signal_peer(clear_mask, set_mask)
1055 }
1056}
1057
1058impl DeviceControlHandle {}
1059
1060#[must_use = "FIDL methods require a response to be sent"]
1061#[derive(Debug)]
1062pub struct DeviceStartVibrationResponder {
1063 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1064 tx_id: u32,
1065}
1066
1067impl std::ops::Drop for DeviceStartVibrationResponder {
1071 fn drop(&mut self) {
1072 self.control_handle.shutdown();
1073 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1075 }
1076}
1077
1078impl fidl::endpoints::Responder for DeviceStartVibrationResponder {
1079 type ControlHandle = DeviceControlHandle;
1080
1081 fn control_handle(&self) -> &DeviceControlHandle {
1082 &self.control_handle
1083 }
1084
1085 fn drop_without_shutdown(mut self) {
1086 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1088 std::mem::forget(self);
1090 }
1091}
1092
1093impl DeviceStartVibrationResponder {
1094 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1098 let _result = self.send_raw(result);
1099 if _result.is_err() {
1100 self.control_handle.shutdown();
1101 }
1102 self.drop_without_shutdown();
1103 _result
1104 }
1105
1106 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1108 let _result = self.send_raw(result);
1109 self.drop_without_shutdown();
1110 _result
1111 }
1112
1113 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1114 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1115 fidl::encoding::EmptyStruct,
1116 i32,
1117 >>(
1118 fidl::encoding::FlexibleResult::new(result),
1119 self.tx_id,
1120 0x439dad11bbcca662,
1121 fidl::encoding::DynamicFlags::FLEXIBLE,
1122 )
1123 }
1124}
1125
1126#[must_use = "FIDL methods require a response to be sent"]
1127#[derive(Debug)]
1128pub struct DevicePlayVibrationResponder {
1129 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1130 tx_id: u32,
1131}
1132
1133impl std::ops::Drop for DevicePlayVibrationResponder {
1137 fn drop(&mut self) {
1138 self.control_handle.shutdown();
1139 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1141 }
1142}
1143
1144impl fidl::endpoints::Responder for DevicePlayVibrationResponder {
1145 type ControlHandle = DeviceControlHandle;
1146
1147 fn control_handle(&self) -> &DeviceControlHandle {
1148 &self.control_handle
1149 }
1150
1151 fn drop_without_shutdown(mut self) {
1152 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1154 std::mem::forget(self);
1156 }
1157}
1158
1159impl DevicePlayVibrationResponder {
1160 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1164 let _result = self.send_raw(result);
1165 if _result.is_err() {
1166 self.control_handle.shutdown();
1167 }
1168 self.drop_without_shutdown();
1169 _result
1170 }
1171
1172 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1174 let _result = self.send_raw(result);
1175 self.drop_without_shutdown();
1176 _result
1177 }
1178
1179 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1180 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1181 fidl::encoding::EmptyStruct,
1182 i32,
1183 >>(
1184 fidl::encoding::FlexibleResult::new(result),
1185 self.tx_id,
1186 0x7b23b51b00917d27,
1187 fidl::encoding::DynamicFlags::FLEXIBLE,
1188 )
1189 }
1190}
1191
1192#[must_use = "FIDL methods require a response to be sent"]
1193#[derive(Debug)]
1194pub struct DevicePlayEffectResponder {
1195 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1196 tx_id: u32,
1197}
1198
1199impl std::ops::Drop for DevicePlayEffectResponder {
1203 fn drop(&mut self) {
1204 self.control_handle.shutdown();
1205 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1207 }
1208}
1209
1210impl fidl::endpoints::Responder for DevicePlayEffectResponder {
1211 type ControlHandle = DeviceControlHandle;
1212
1213 fn control_handle(&self) -> &DeviceControlHandle {
1214 &self.control_handle
1215 }
1216
1217 fn drop_without_shutdown(mut self) {
1218 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1220 std::mem::forget(self);
1222 }
1223}
1224
1225impl DevicePlayEffectResponder {
1226 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1230 let _result = self.send_raw(result);
1231 if _result.is_err() {
1232 self.control_handle.shutdown();
1233 }
1234 self.drop_without_shutdown();
1235 _result
1236 }
1237
1238 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1240 let _result = self.send_raw(result);
1241 self.drop_without_shutdown();
1242 _result
1243 }
1244
1245 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1246 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1247 fidl::encoding::EmptyStruct,
1248 i32,
1249 >>(
1250 fidl::encoding::FlexibleResult::new(result),
1251 self.tx_id,
1252 0x713695448db55cd5,
1253 fidl::encoding::DynamicFlags::FLEXIBLE,
1254 )
1255 }
1256}
1257
1258#[must_use = "FIDL methods require a response to be sent"]
1259#[derive(Debug)]
1260pub struct DevicePlayCompositeWaveformResponder {
1261 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1262 tx_id: u32,
1263}
1264
1265impl std::ops::Drop for DevicePlayCompositeWaveformResponder {
1269 fn drop(&mut self) {
1270 self.control_handle.shutdown();
1271 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1273 }
1274}
1275
1276impl fidl::endpoints::Responder for DevicePlayCompositeWaveformResponder {
1277 type ControlHandle = DeviceControlHandle;
1278
1279 fn control_handle(&self) -> &DeviceControlHandle {
1280 &self.control_handle
1281 }
1282
1283 fn drop_without_shutdown(mut self) {
1284 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1286 std::mem::forget(self);
1288 }
1289}
1290
1291impl DevicePlayCompositeWaveformResponder {
1292 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1296 let _result = self.send_raw(result);
1297 if _result.is_err() {
1298 self.control_handle.shutdown();
1299 }
1300 self.drop_without_shutdown();
1301 _result
1302 }
1303
1304 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1306 let _result = self.send_raw(result);
1307 self.drop_without_shutdown();
1308 _result
1309 }
1310
1311 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1312 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1313 fidl::encoding::EmptyStruct,
1314 i32,
1315 >>(
1316 fidl::encoding::FlexibleResult::new(result),
1317 self.tx_id,
1318 0xd6fca2a36d44085,
1319 fidl::encoding::DynamicFlags::FLEXIBLE,
1320 )
1321 }
1322}
1323
1324#[must_use = "FIDL methods require a response to be sent"]
1325#[derive(Debug)]
1326pub struct DeviceStopVibrationResponder {
1327 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1328 tx_id: u32,
1329}
1330
1331impl std::ops::Drop for DeviceStopVibrationResponder {
1335 fn drop(&mut self) {
1336 self.control_handle.shutdown();
1337 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1339 }
1340}
1341
1342impl fidl::endpoints::Responder for DeviceStopVibrationResponder {
1343 type ControlHandle = DeviceControlHandle;
1344
1345 fn control_handle(&self) -> &DeviceControlHandle {
1346 &self.control_handle
1347 }
1348
1349 fn drop_without_shutdown(mut self) {
1350 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1352 std::mem::forget(self);
1354 }
1355}
1356
1357impl DeviceStopVibrationResponder {
1358 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1362 let _result = self.send_raw(result);
1363 if _result.is_err() {
1364 self.control_handle.shutdown();
1365 }
1366 self.drop_without_shutdown();
1367 _result
1368 }
1369
1370 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1372 let _result = self.send_raw(result);
1373 self.drop_without_shutdown();
1374 _result
1375 }
1376
1377 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1378 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1379 fidl::encoding::EmptyStruct,
1380 i32,
1381 >>(
1382 fidl::encoding::FlexibleResult::new(result),
1383 self.tx_id,
1384 0x5861752ab352f513,
1385 fidl::encoding::DynamicFlags::FLEXIBLE,
1386 )
1387 }
1388}
1389
1390#[must_use = "FIDL methods require a response to be sent"]
1391#[derive(Debug)]
1392pub struct DeviceSetAmplitudeResponder {
1393 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1394 tx_id: u32,
1395}
1396
1397impl std::ops::Drop for DeviceSetAmplitudeResponder {
1401 fn drop(&mut self) {
1402 self.control_handle.shutdown();
1403 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1405 }
1406}
1407
1408impl fidl::endpoints::Responder for DeviceSetAmplitudeResponder {
1409 type ControlHandle = DeviceControlHandle;
1410
1411 fn control_handle(&self) -> &DeviceControlHandle {
1412 &self.control_handle
1413 }
1414
1415 fn drop_without_shutdown(mut self) {
1416 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1418 std::mem::forget(self);
1420 }
1421}
1422
1423impl DeviceSetAmplitudeResponder {
1424 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1428 let _result = self.send_raw(result);
1429 if _result.is_err() {
1430 self.control_handle.shutdown();
1431 }
1432 self.drop_without_shutdown();
1433 _result
1434 }
1435
1436 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1438 let _result = self.send_raw(result);
1439 self.drop_without_shutdown();
1440 _result
1441 }
1442
1443 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1444 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1445 fidl::encoding::EmptyStruct,
1446 i32,
1447 >>(
1448 fidl::encoding::FlexibleResult::new(result),
1449 self.tx_id,
1450 0x1123b5c82cac1ba0,
1451 fidl::encoding::DynamicFlags::FLEXIBLE,
1452 )
1453 }
1454}
1455
1456#[must_use = "FIDL methods require a response to be sent"]
1457#[derive(Debug)]
1458pub struct DeviceGetPropertiesResponder {
1459 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1460 tx_id: u32,
1461}
1462
1463impl std::ops::Drop for DeviceGetPropertiesResponder {
1467 fn drop(&mut self) {
1468 self.control_handle.shutdown();
1469 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1471 }
1472}
1473
1474impl fidl::endpoints::Responder for DeviceGetPropertiesResponder {
1475 type ControlHandle = DeviceControlHandle;
1476
1477 fn control_handle(&self) -> &DeviceControlHandle {
1478 &self.control_handle
1479 }
1480
1481 fn drop_without_shutdown(mut self) {
1482 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1484 std::mem::forget(self);
1486 }
1487}
1488
1489impl DeviceGetPropertiesResponder {
1490 pub fn send(
1494 self,
1495 mut result: Result<
1496 (f32, f32, &[SupportedEffect], &[SupportedCompositeEffectWaveform], u64, i64),
1497 i32,
1498 >,
1499 ) -> Result<(), fidl::Error> {
1500 let _result = self.send_raw(result);
1501 if _result.is_err() {
1502 self.control_handle.shutdown();
1503 }
1504 self.drop_without_shutdown();
1505 _result
1506 }
1507
1508 pub fn send_no_shutdown_on_err(
1510 self,
1511 mut result: Result<
1512 (f32, f32, &[SupportedEffect], &[SupportedCompositeEffectWaveform], u64, i64),
1513 i32,
1514 >,
1515 ) -> Result<(), fidl::Error> {
1516 let _result = self.send_raw(result);
1517 self.drop_without_shutdown();
1518 _result
1519 }
1520
1521 fn send_raw(
1522 &self,
1523 mut result: Result<
1524 (f32, f32, &[SupportedEffect], &[SupportedCompositeEffectWaveform], u64, i64),
1525 i32,
1526 >,
1527 ) -> Result<(), fidl::Error> {
1528 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1529 DeviceGetPropertiesResponse,
1530 i32,
1531 >>(
1532 fidl::encoding::FlexibleResult::new(result),
1533 self.tx_id,
1534 0x6482dc9bc50e8972,
1535 fidl::encoding::DynamicFlags::FLEXIBLE,
1536 )
1537 }
1538}
1539
1540#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1541pub struct ServiceMarker;
1542
1543#[cfg(target_os = "fuchsia")]
1544impl fidl::endpoints::ServiceMarker for ServiceMarker {
1545 type Proxy = ServiceProxy;
1546 type Request = ServiceRequest;
1547 const SERVICE_NAME: &'static str = "fuchsia.hardware.haptics.Service";
1548}
1549
1550#[cfg(target_os = "fuchsia")]
1553pub enum ServiceRequest {
1554 Device(DeviceRequestStream),
1555}
1556
1557#[cfg(target_os = "fuchsia")]
1558impl fidl::endpoints::ServiceRequest for ServiceRequest {
1559 type Service = ServiceMarker;
1560
1561 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1562 match name {
1563 "device" => Self::Device(
1564 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1565 ),
1566 _ => panic!("no such member protocol name for service Service"),
1567 }
1568 }
1569
1570 fn member_names() -> &'static [&'static str] {
1571 &["device"]
1572 }
1573}
1574#[cfg(target_os = "fuchsia")]
1575pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1576
1577#[cfg(target_os = "fuchsia")]
1578impl fidl::endpoints::ServiceProxy for ServiceProxy {
1579 type Service = ServiceMarker;
1580
1581 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1582 Self(opener)
1583 }
1584}
1585
1586#[cfg(target_os = "fuchsia")]
1587impl ServiceProxy {
1588 pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
1589 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1590 self.connect_channel_to_device(server_end)?;
1591 Ok(proxy)
1592 }
1593
1594 pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1597 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1598 self.connect_channel_to_device(server_end)?;
1599 Ok(proxy)
1600 }
1601
1602 pub fn connect_channel_to_device(
1605 &self,
1606 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1607 ) -> Result<(), fidl::Error> {
1608 self.0.open_member("device", server_end.into_channel())
1609 }
1610
1611 pub fn instance_name(&self) -> &str {
1612 self.0.instance_name()
1613 }
1614}
1615
1616mod internal {
1617 use super::*;
1618}