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_sensors__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DriverMarker;
16
17impl fidl::endpoints::ProtocolMarker for DriverMarker {
18 type Proxy = DriverProxy;
19 type RequestStream = DriverRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DriverSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.hardware.sensors.Driver";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DriverMarker {}
26pub type DriverActivateSensorResult = Result<(), ActivateSensorError>;
27pub type DriverDeactivateSensorResult = Result<(), DeactivateSensorError>;
28pub type DriverConfigureSensorRateResult = Result<(), ConfigureSensorRateError>;
29
30pub trait DriverProxyInterface: Send + Sync {
31 type GetSensorsListResponseFut: std::future::Future<
32 Output = Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error>,
33 > + Send;
34 fn r#get_sensors_list(&self) -> Self::GetSensorsListResponseFut;
35 type ActivateSensorResponseFut: std::future::Future<Output = Result<DriverActivateSensorResult, fidl::Error>>
36 + Send;
37 fn r#activate_sensor(&self, sensor_id: i32) -> Self::ActivateSensorResponseFut;
38 type DeactivateSensorResponseFut: std::future::Future<Output = Result<DriverDeactivateSensorResult, fidl::Error>>
39 + Send;
40 fn r#deactivate_sensor(&self, sensor_id: i32) -> Self::DeactivateSensorResponseFut;
41 type ConfigureSensorRateResponseFut: std::future::Future<Output = Result<DriverConfigureSensorRateResult, fidl::Error>>
42 + Send;
43 fn r#configure_sensor_rate(
44 &self,
45 sensor_id: i32,
46 sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
47 ) -> Self::ConfigureSensorRateResponseFut;
48}
49#[derive(Debug)]
50#[cfg(target_os = "fuchsia")]
51pub struct DriverSynchronousProxy {
52 client: fidl::client::sync::Client,
53}
54
55#[cfg(target_os = "fuchsia")]
56impl fidl::endpoints::SynchronousProxy for DriverSynchronousProxy {
57 type Proxy = DriverProxy;
58 type Protocol = DriverMarker;
59
60 fn from_channel(inner: fidl::Channel) -> Self {
61 Self::new(inner)
62 }
63
64 fn into_channel(self) -> fidl::Channel {
65 self.client.into_channel()
66 }
67
68 fn as_channel(&self) -> &fidl::Channel {
69 self.client.as_channel()
70 }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl DriverSynchronousProxy {
75 pub fn new(channel: fidl::Channel) -> Self {
76 let protocol_name = <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
77 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
78 }
79
80 pub fn into_channel(self) -> fidl::Channel {
81 self.client.into_channel()
82 }
83
84 pub fn wait_for_event(
87 &self,
88 deadline: zx::MonotonicInstant,
89 ) -> Result<DriverEvent, fidl::Error> {
90 DriverEvent::decode(self.client.wait_for_event(deadline)?)
91 }
92
93 pub fn r#get_sensors_list(
95 &self,
96 ___deadline: zx::MonotonicInstant,
97 ) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
98 let _response = self.client.send_query::<
99 fidl::encoding::EmptyPayload,
100 fidl::encoding::FlexibleType<DriverGetSensorsListResponse>,
101 >(
102 (),
103 0x6a30da06929d426b,
104 fidl::encoding::DynamicFlags::FLEXIBLE,
105 ___deadline,
106 )?
107 .into_result::<DriverMarker>("get_sensors_list")?;
108 Ok(_response.sensor_list)
109 }
110
111 pub fn r#activate_sensor(
113 &self,
114 mut sensor_id: i32,
115 ___deadline: zx::MonotonicInstant,
116 ) -> Result<DriverActivateSensorResult, fidl::Error> {
117 let _response =
118 self.client
119 .send_query::<DriverActivateSensorRequest, fidl::encoding::FlexibleResultType<
120 fidl::encoding::EmptyStruct,
121 ActivateSensorError,
122 >>(
123 (sensor_id,),
124 0x6ff16c620f9f3c5b,
125 fidl::encoding::DynamicFlags::FLEXIBLE,
126 ___deadline,
127 )?
128 .into_result::<DriverMarker>("activate_sensor")?;
129 Ok(_response.map(|x| x))
130 }
131
132 pub fn r#deactivate_sensor(
134 &self,
135 mut sensor_id: i32,
136 ___deadline: zx::MonotonicInstant,
137 ) -> Result<DriverDeactivateSensorResult, fidl::Error> {
138 let _response =
139 self.client
140 .send_query::<DriverDeactivateSensorRequest, fidl::encoding::FlexibleResultType<
141 fidl::encoding::EmptyStruct,
142 DeactivateSensorError,
143 >>(
144 (sensor_id,),
145 0x64f003527d44ec55,
146 fidl::encoding::DynamicFlags::FLEXIBLE,
147 ___deadline,
148 )?
149 .into_result::<DriverMarker>("deactivate_sensor")?;
150 Ok(_response.map(|x| x))
151 }
152
153 pub fn r#configure_sensor_rate(
155 &self,
156 mut sensor_id: i32,
157 mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
158 ___deadline: zx::MonotonicInstant,
159 ) -> Result<DriverConfigureSensorRateResult, fidl::Error> {
160 let _response = self
161 .client
162 .send_query::<DriverConfigureSensorRateRequest, fidl::encoding::FlexibleResultType<
163 fidl::encoding::EmptyStruct,
164 ConfigureSensorRateError,
165 >>(
166 (sensor_id, sensor_rate_config),
167 0x78a264bc9c645045,
168 fidl::encoding::DynamicFlags::FLEXIBLE,
169 ___deadline,
170 )?
171 .into_result::<DriverMarker>("configure_sensor_rate")?;
172 Ok(_response.map(|x| x))
173 }
174}
175
176#[cfg(target_os = "fuchsia")]
177impl From<DriverSynchronousProxy> for zx::Handle {
178 fn from(value: DriverSynchronousProxy) -> Self {
179 value.into_channel().into()
180 }
181}
182
183#[cfg(target_os = "fuchsia")]
184impl From<fidl::Channel> for DriverSynchronousProxy {
185 fn from(value: fidl::Channel) -> Self {
186 Self::new(value)
187 }
188}
189
190#[cfg(target_os = "fuchsia")]
191impl fidl::endpoints::FromClient for DriverSynchronousProxy {
192 type Protocol = DriverMarker;
193
194 fn from_client(value: fidl::endpoints::ClientEnd<DriverMarker>) -> Self {
195 Self::new(value.into_channel())
196 }
197}
198
199#[derive(Debug, Clone)]
200pub struct DriverProxy {
201 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
202}
203
204impl fidl::endpoints::Proxy for DriverProxy {
205 type Protocol = DriverMarker;
206
207 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
208 Self::new(inner)
209 }
210
211 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
212 self.client.into_channel().map_err(|client| Self { client })
213 }
214
215 fn as_channel(&self) -> &::fidl::AsyncChannel {
216 self.client.as_channel()
217 }
218}
219
220impl DriverProxy {
221 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
223 let protocol_name = <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
224 Self { client: fidl::client::Client::new(channel, protocol_name) }
225 }
226
227 pub fn take_event_stream(&self) -> DriverEventStream {
233 DriverEventStream { event_receiver: self.client.take_event_receiver() }
234 }
235
236 pub fn r#get_sensors_list(
238 &self,
239 ) -> fidl::client::QueryResponseFut<
240 Vec<fidl_fuchsia_sensors_types::SensorInfo>,
241 fidl::encoding::DefaultFuchsiaResourceDialect,
242 > {
243 DriverProxyInterface::r#get_sensors_list(self)
244 }
245
246 pub fn r#activate_sensor(
248 &self,
249 mut sensor_id: i32,
250 ) -> fidl::client::QueryResponseFut<
251 DriverActivateSensorResult,
252 fidl::encoding::DefaultFuchsiaResourceDialect,
253 > {
254 DriverProxyInterface::r#activate_sensor(self, sensor_id)
255 }
256
257 pub fn r#deactivate_sensor(
259 &self,
260 mut sensor_id: i32,
261 ) -> fidl::client::QueryResponseFut<
262 DriverDeactivateSensorResult,
263 fidl::encoding::DefaultFuchsiaResourceDialect,
264 > {
265 DriverProxyInterface::r#deactivate_sensor(self, sensor_id)
266 }
267
268 pub fn r#configure_sensor_rate(
270 &self,
271 mut sensor_id: i32,
272 mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
273 ) -> fidl::client::QueryResponseFut<
274 DriverConfigureSensorRateResult,
275 fidl::encoding::DefaultFuchsiaResourceDialect,
276 > {
277 DriverProxyInterface::r#configure_sensor_rate(self, sensor_id, sensor_rate_config)
278 }
279}
280
281impl DriverProxyInterface for DriverProxy {
282 type GetSensorsListResponseFut = fidl::client::QueryResponseFut<
283 Vec<fidl_fuchsia_sensors_types::SensorInfo>,
284 fidl::encoding::DefaultFuchsiaResourceDialect,
285 >;
286 fn r#get_sensors_list(&self) -> Self::GetSensorsListResponseFut {
287 fn _decode(
288 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
289 ) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
290 let _response = fidl::client::decode_transaction_body::<
291 fidl::encoding::FlexibleType<DriverGetSensorsListResponse>,
292 fidl::encoding::DefaultFuchsiaResourceDialect,
293 0x6a30da06929d426b,
294 >(_buf?)?
295 .into_result::<DriverMarker>("get_sensors_list")?;
296 Ok(_response.sensor_list)
297 }
298 self.client.send_query_and_decode::<
299 fidl::encoding::EmptyPayload,
300 Vec<fidl_fuchsia_sensors_types::SensorInfo>,
301 >(
302 (),
303 0x6a30da06929d426b,
304 fidl::encoding::DynamicFlags::FLEXIBLE,
305 _decode,
306 )
307 }
308
309 type ActivateSensorResponseFut = fidl::client::QueryResponseFut<
310 DriverActivateSensorResult,
311 fidl::encoding::DefaultFuchsiaResourceDialect,
312 >;
313 fn r#activate_sensor(&self, mut sensor_id: i32) -> Self::ActivateSensorResponseFut {
314 fn _decode(
315 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
316 ) -> Result<DriverActivateSensorResult, fidl::Error> {
317 let _response = fidl::client::decode_transaction_body::<
318 fidl::encoding::FlexibleResultType<
319 fidl::encoding::EmptyStruct,
320 ActivateSensorError,
321 >,
322 fidl::encoding::DefaultFuchsiaResourceDialect,
323 0x6ff16c620f9f3c5b,
324 >(_buf?)?
325 .into_result::<DriverMarker>("activate_sensor")?;
326 Ok(_response.map(|x| x))
327 }
328 self.client
329 .send_query_and_decode::<DriverActivateSensorRequest, DriverActivateSensorResult>(
330 (sensor_id,),
331 0x6ff16c620f9f3c5b,
332 fidl::encoding::DynamicFlags::FLEXIBLE,
333 _decode,
334 )
335 }
336
337 type DeactivateSensorResponseFut = fidl::client::QueryResponseFut<
338 DriverDeactivateSensorResult,
339 fidl::encoding::DefaultFuchsiaResourceDialect,
340 >;
341 fn r#deactivate_sensor(&self, mut sensor_id: i32) -> Self::DeactivateSensorResponseFut {
342 fn _decode(
343 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
344 ) -> Result<DriverDeactivateSensorResult, fidl::Error> {
345 let _response = fidl::client::decode_transaction_body::<
346 fidl::encoding::FlexibleResultType<
347 fidl::encoding::EmptyStruct,
348 DeactivateSensorError,
349 >,
350 fidl::encoding::DefaultFuchsiaResourceDialect,
351 0x64f003527d44ec55,
352 >(_buf?)?
353 .into_result::<DriverMarker>("deactivate_sensor")?;
354 Ok(_response.map(|x| x))
355 }
356 self.client
357 .send_query_and_decode::<DriverDeactivateSensorRequest, DriverDeactivateSensorResult>(
358 (sensor_id,),
359 0x64f003527d44ec55,
360 fidl::encoding::DynamicFlags::FLEXIBLE,
361 _decode,
362 )
363 }
364
365 type ConfigureSensorRateResponseFut = fidl::client::QueryResponseFut<
366 DriverConfigureSensorRateResult,
367 fidl::encoding::DefaultFuchsiaResourceDialect,
368 >;
369 fn r#configure_sensor_rate(
370 &self,
371 mut sensor_id: i32,
372 mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
373 ) -> Self::ConfigureSensorRateResponseFut {
374 fn _decode(
375 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
376 ) -> Result<DriverConfigureSensorRateResult, fidl::Error> {
377 let _response = fidl::client::decode_transaction_body::<
378 fidl::encoding::FlexibleResultType<
379 fidl::encoding::EmptyStruct,
380 ConfigureSensorRateError,
381 >,
382 fidl::encoding::DefaultFuchsiaResourceDialect,
383 0x78a264bc9c645045,
384 >(_buf?)?
385 .into_result::<DriverMarker>("configure_sensor_rate")?;
386 Ok(_response.map(|x| x))
387 }
388 self.client.send_query_and_decode::<
389 DriverConfigureSensorRateRequest,
390 DriverConfigureSensorRateResult,
391 >(
392 (sensor_id, sensor_rate_config,),
393 0x78a264bc9c645045,
394 fidl::encoding::DynamicFlags::FLEXIBLE,
395 _decode,
396 )
397 }
398}
399
400pub struct DriverEventStream {
401 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
402}
403
404impl std::marker::Unpin for DriverEventStream {}
405
406impl futures::stream::FusedStream for DriverEventStream {
407 fn is_terminated(&self) -> bool {
408 self.event_receiver.is_terminated()
409 }
410}
411
412impl futures::Stream for DriverEventStream {
413 type Item = Result<DriverEvent, fidl::Error>;
414
415 fn poll_next(
416 mut self: std::pin::Pin<&mut Self>,
417 cx: &mut std::task::Context<'_>,
418 ) -> std::task::Poll<Option<Self::Item>> {
419 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
420 &mut self.event_receiver,
421 cx
422 )?) {
423 Some(buf) => std::task::Poll::Ready(Some(DriverEvent::decode(buf))),
424 None => std::task::Poll::Ready(None),
425 }
426 }
427}
428
429#[derive(Debug)]
430pub enum DriverEvent {
431 OnSensorEvent {
432 event: fidl_fuchsia_sensors_types::SensorEvent,
433 },
434 #[non_exhaustive]
435 _UnknownEvent {
436 ordinal: u64,
438 },
439}
440
441impl DriverEvent {
442 #[allow(irrefutable_let_patterns)]
443 pub fn into_on_sensor_event(self) -> Option<fidl_fuchsia_sensors_types::SensorEvent> {
444 if let DriverEvent::OnSensorEvent { event } = self {
445 Some((event))
446 } else {
447 None
448 }
449 }
450
451 fn decode(
453 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
454 ) -> Result<DriverEvent, fidl::Error> {
455 let (bytes, _handles) = buf.split_mut();
456 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
457 debug_assert_eq!(tx_header.tx_id, 0);
458 match tx_header.ordinal {
459 0x2aaf0636bb3e1df9 => {
460 let mut out = fidl::new_empty!(
461 DriverOnSensorEventRequest,
462 fidl::encoding::DefaultFuchsiaResourceDialect
463 );
464 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverOnSensorEventRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
465 Ok((DriverEvent::OnSensorEvent { event: out.event }))
466 }
467 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
468 Ok(DriverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
469 }
470 _ => Err(fidl::Error::UnknownOrdinal {
471 ordinal: tx_header.ordinal,
472 protocol_name: <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
473 }),
474 }
475 }
476}
477
478pub struct DriverRequestStream {
480 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
481 is_terminated: bool,
482}
483
484impl std::marker::Unpin for DriverRequestStream {}
485
486impl futures::stream::FusedStream for DriverRequestStream {
487 fn is_terminated(&self) -> bool {
488 self.is_terminated
489 }
490}
491
492impl fidl::endpoints::RequestStream for DriverRequestStream {
493 type Protocol = DriverMarker;
494 type ControlHandle = DriverControlHandle;
495
496 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
497 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
498 }
499
500 fn control_handle(&self) -> Self::ControlHandle {
501 DriverControlHandle { inner: self.inner.clone() }
502 }
503
504 fn into_inner(
505 self,
506 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
507 {
508 (self.inner, self.is_terminated)
509 }
510
511 fn from_inner(
512 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
513 is_terminated: bool,
514 ) -> Self {
515 Self { inner, is_terminated }
516 }
517}
518
519impl futures::Stream for DriverRequestStream {
520 type Item = Result<DriverRequest, fidl::Error>;
521
522 fn poll_next(
523 mut self: std::pin::Pin<&mut Self>,
524 cx: &mut std::task::Context<'_>,
525 ) -> std::task::Poll<Option<Self::Item>> {
526 let this = &mut *self;
527 if this.inner.check_shutdown(cx) {
528 this.is_terminated = true;
529 return std::task::Poll::Ready(None);
530 }
531 if this.is_terminated {
532 panic!("polled DriverRequestStream after completion");
533 }
534 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
535 |bytes, handles| {
536 match this.inner.channel().read_etc(cx, bytes, handles) {
537 std::task::Poll::Ready(Ok(())) => {}
538 std::task::Poll::Pending => return std::task::Poll::Pending,
539 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
540 this.is_terminated = true;
541 return std::task::Poll::Ready(None);
542 }
543 std::task::Poll::Ready(Err(e)) => {
544 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
545 e.into(),
546 ))))
547 }
548 }
549
550 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
552
553 std::task::Poll::Ready(Some(match header.ordinal {
554 0x6a30da06929d426b => {
555 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
556 let mut req = fidl::new_empty!(
557 fidl::encoding::EmptyPayload,
558 fidl::encoding::DefaultFuchsiaResourceDialect
559 );
560 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
561 let control_handle = DriverControlHandle { inner: this.inner.clone() };
562 Ok(DriverRequest::GetSensorsList {
563 responder: DriverGetSensorsListResponder {
564 control_handle: std::mem::ManuallyDrop::new(control_handle),
565 tx_id: header.tx_id,
566 },
567 })
568 }
569 0x6ff16c620f9f3c5b => {
570 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
571 let mut req = fidl::new_empty!(
572 DriverActivateSensorRequest,
573 fidl::encoding::DefaultFuchsiaResourceDialect
574 );
575 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverActivateSensorRequest>(&header, _body_bytes, handles, &mut req)?;
576 let control_handle = DriverControlHandle { inner: this.inner.clone() };
577 Ok(DriverRequest::ActivateSensor {
578 sensor_id: req.sensor_id,
579
580 responder: DriverActivateSensorResponder {
581 control_handle: std::mem::ManuallyDrop::new(control_handle),
582 tx_id: header.tx_id,
583 },
584 })
585 }
586 0x64f003527d44ec55 => {
587 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
588 let mut req = fidl::new_empty!(
589 DriverDeactivateSensorRequest,
590 fidl::encoding::DefaultFuchsiaResourceDialect
591 );
592 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverDeactivateSensorRequest>(&header, _body_bytes, handles, &mut req)?;
593 let control_handle = DriverControlHandle { inner: this.inner.clone() };
594 Ok(DriverRequest::DeactivateSensor {
595 sensor_id: req.sensor_id,
596
597 responder: DriverDeactivateSensorResponder {
598 control_handle: std::mem::ManuallyDrop::new(control_handle),
599 tx_id: header.tx_id,
600 },
601 })
602 }
603 0x78a264bc9c645045 => {
604 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
605 let mut req = fidl::new_empty!(
606 DriverConfigureSensorRateRequest,
607 fidl::encoding::DefaultFuchsiaResourceDialect
608 );
609 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverConfigureSensorRateRequest>(&header, _body_bytes, handles, &mut req)?;
610 let control_handle = DriverControlHandle { inner: this.inner.clone() };
611 Ok(DriverRequest::ConfigureSensorRate {
612 sensor_id: req.sensor_id,
613 sensor_rate_config: req.sensor_rate_config,
614
615 responder: DriverConfigureSensorRateResponder {
616 control_handle: std::mem::ManuallyDrop::new(control_handle),
617 tx_id: header.tx_id,
618 },
619 })
620 }
621 _ if header.tx_id == 0
622 && header
623 .dynamic_flags()
624 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
625 {
626 Ok(DriverRequest::_UnknownMethod {
627 ordinal: header.ordinal,
628 control_handle: DriverControlHandle { inner: this.inner.clone() },
629 method_type: fidl::MethodType::OneWay,
630 })
631 }
632 _ if header
633 .dynamic_flags()
634 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
635 {
636 this.inner.send_framework_err(
637 fidl::encoding::FrameworkErr::UnknownMethod,
638 header.tx_id,
639 header.ordinal,
640 header.dynamic_flags(),
641 (bytes, handles),
642 )?;
643 Ok(DriverRequest::_UnknownMethod {
644 ordinal: header.ordinal,
645 control_handle: DriverControlHandle { inner: this.inner.clone() },
646 method_type: fidl::MethodType::TwoWay,
647 })
648 }
649 _ => Err(fidl::Error::UnknownOrdinal {
650 ordinal: header.ordinal,
651 protocol_name:
652 <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
653 }),
654 }))
655 },
656 )
657 }
658}
659
660#[derive(Debug)]
662pub enum DriverRequest {
663 GetSensorsList { responder: DriverGetSensorsListResponder },
665 ActivateSensor { sensor_id: i32, responder: DriverActivateSensorResponder },
667 DeactivateSensor { sensor_id: i32, responder: DriverDeactivateSensorResponder },
669 ConfigureSensorRate {
671 sensor_id: i32,
672 sensor_rate_config: fidl_fuchsia_sensors_types::SensorRateConfig,
673 responder: DriverConfigureSensorRateResponder,
674 },
675 #[non_exhaustive]
677 _UnknownMethod {
678 ordinal: u64,
680 control_handle: DriverControlHandle,
681 method_type: fidl::MethodType,
682 },
683}
684
685impl DriverRequest {
686 #[allow(irrefutable_let_patterns)]
687 pub fn into_get_sensors_list(self) -> Option<(DriverGetSensorsListResponder)> {
688 if let DriverRequest::GetSensorsList { responder } = self {
689 Some((responder))
690 } else {
691 None
692 }
693 }
694
695 #[allow(irrefutable_let_patterns)]
696 pub fn into_activate_sensor(self) -> Option<(i32, DriverActivateSensorResponder)> {
697 if let DriverRequest::ActivateSensor { sensor_id, responder } = self {
698 Some((sensor_id, responder))
699 } else {
700 None
701 }
702 }
703
704 #[allow(irrefutable_let_patterns)]
705 pub fn into_deactivate_sensor(self) -> Option<(i32, DriverDeactivateSensorResponder)> {
706 if let DriverRequest::DeactivateSensor { sensor_id, responder } = self {
707 Some((sensor_id, responder))
708 } else {
709 None
710 }
711 }
712
713 #[allow(irrefutable_let_patterns)]
714 pub fn into_configure_sensor_rate(
715 self,
716 ) -> Option<(
717 i32,
718 fidl_fuchsia_sensors_types::SensorRateConfig,
719 DriverConfigureSensorRateResponder,
720 )> {
721 if let DriverRequest::ConfigureSensorRate { sensor_id, sensor_rate_config, responder } =
722 self
723 {
724 Some((sensor_id, sensor_rate_config, responder))
725 } else {
726 None
727 }
728 }
729
730 pub fn method_name(&self) -> &'static str {
732 match *self {
733 DriverRequest::GetSensorsList { .. } => "get_sensors_list",
734 DriverRequest::ActivateSensor { .. } => "activate_sensor",
735 DriverRequest::DeactivateSensor { .. } => "deactivate_sensor",
736 DriverRequest::ConfigureSensorRate { .. } => "configure_sensor_rate",
737 DriverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
738 "unknown one-way method"
739 }
740 DriverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
741 "unknown two-way method"
742 }
743 }
744 }
745}
746
747#[derive(Debug, Clone)]
748pub struct DriverControlHandle {
749 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
750}
751
752impl fidl::endpoints::ControlHandle for DriverControlHandle {
753 fn shutdown(&self) {
754 self.inner.shutdown()
755 }
756 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
757 self.inner.shutdown_with_epitaph(status)
758 }
759
760 fn is_closed(&self) -> bool {
761 self.inner.channel().is_closed()
762 }
763 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
764 self.inner.channel().on_closed()
765 }
766
767 #[cfg(target_os = "fuchsia")]
768 fn signal_peer(
769 &self,
770 clear_mask: zx::Signals,
771 set_mask: zx::Signals,
772 ) -> Result<(), zx_status::Status> {
773 use fidl::Peered;
774 self.inner.channel().signal_peer(clear_mask, set_mask)
775 }
776}
777
778impl DriverControlHandle {
779 pub fn send_on_sensor_event(
780 &self,
781 mut event: &fidl_fuchsia_sensors_types::SensorEvent,
782 ) -> Result<(), fidl::Error> {
783 self.inner.send::<DriverOnSensorEventRequest>(
784 (event,),
785 0,
786 0x2aaf0636bb3e1df9,
787 fidl::encoding::DynamicFlags::FLEXIBLE,
788 )
789 }
790}
791
792#[must_use = "FIDL methods require a response to be sent"]
793#[derive(Debug)]
794pub struct DriverGetSensorsListResponder {
795 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
796 tx_id: u32,
797}
798
799impl std::ops::Drop for DriverGetSensorsListResponder {
803 fn drop(&mut self) {
804 self.control_handle.shutdown();
805 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
807 }
808}
809
810impl fidl::endpoints::Responder for DriverGetSensorsListResponder {
811 type ControlHandle = DriverControlHandle;
812
813 fn control_handle(&self) -> &DriverControlHandle {
814 &self.control_handle
815 }
816
817 fn drop_without_shutdown(mut self) {
818 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
820 std::mem::forget(self);
822 }
823}
824
825impl DriverGetSensorsListResponder {
826 pub fn send(
830 self,
831 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
832 ) -> Result<(), fidl::Error> {
833 let _result = self.send_raw(sensor_list);
834 if _result.is_err() {
835 self.control_handle.shutdown();
836 }
837 self.drop_without_shutdown();
838 _result
839 }
840
841 pub fn send_no_shutdown_on_err(
843 self,
844 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
845 ) -> Result<(), fidl::Error> {
846 let _result = self.send_raw(sensor_list);
847 self.drop_without_shutdown();
848 _result
849 }
850
851 fn send_raw(
852 &self,
853 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
854 ) -> Result<(), fidl::Error> {
855 self.control_handle
856 .inner
857 .send::<fidl::encoding::FlexibleType<DriverGetSensorsListResponse>>(
858 fidl::encoding::Flexible::new((sensor_list,)),
859 self.tx_id,
860 0x6a30da06929d426b,
861 fidl::encoding::DynamicFlags::FLEXIBLE,
862 )
863 }
864}
865
866#[must_use = "FIDL methods require a response to be sent"]
867#[derive(Debug)]
868pub struct DriverActivateSensorResponder {
869 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
870 tx_id: u32,
871}
872
873impl std::ops::Drop for DriverActivateSensorResponder {
877 fn drop(&mut self) {
878 self.control_handle.shutdown();
879 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
881 }
882}
883
884impl fidl::endpoints::Responder for DriverActivateSensorResponder {
885 type ControlHandle = DriverControlHandle;
886
887 fn control_handle(&self) -> &DriverControlHandle {
888 &self.control_handle
889 }
890
891 fn drop_without_shutdown(mut self) {
892 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
894 std::mem::forget(self);
896 }
897}
898
899impl DriverActivateSensorResponder {
900 pub fn send(self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
904 let _result = self.send_raw(result);
905 if _result.is_err() {
906 self.control_handle.shutdown();
907 }
908 self.drop_without_shutdown();
909 _result
910 }
911
912 pub fn send_no_shutdown_on_err(
914 self,
915 mut result: Result<(), ActivateSensorError>,
916 ) -> Result<(), fidl::Error> {
917 let _result = self.send_raw(result);
918 self.drop_without_shutdown();
919 _result
920 }
921
922 fn send_raw(&self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
923 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
924 fidl::encoding::EmptyStruct,
925 ActivateSensorError,
926 >>(
927 fidl::encoding::FlexibleResult::new(result),
928 self.tx_id,
929 0x6ff16c620f9f3c5b,
930 fidl::encoding::DynamicFlags::FLEXIBLE,
931 )
932 }
933}
934
935#[must_use = "FIDL methods require a response to be sent"]
936#[derive(Debug)]
937pub struct DriverDeactivateSensorResponder {
938 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
939 tx_id: u32,
940}
941
942impl std::ops::Drop for DriverDeactivateSensorResponder {
946 fn drop(&mut self) {
947 self.control_handle.shutdown();
948 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
950 }
951}
952
953impl fidl::endpoints::Responder for DriverDeactivateSensorResponder {
954 type ControlHandle = DriverControlHandle;
955
956 fn control_handle(&self) -> &DriverControlHandle {
957 &self.control_handle
958 }
959
960 fn drop_without_shutdown(mut self) {
961 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
963 std::mem::forget(self);
965 }
966}
967
968impl DriverDeactivateSensorResponder {
969 pub fn send(self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
973 let _result = self.send_raw(result);
974 if _result.is_err() {
975 self.control_handle.shutdown();
976 }
977 self.drop_without_shutdown();
978 _result
979 }
980
981 pub fn send_no_shutdown_on_err(
983 self,
984 mut result: Result<(), DeactivateSensorError>,
985 ) -> Result<(), fidl::Error> {
986 let _result = self.send_raw(result);
987 self.drop_without_shutdown();
988 _result
989 }
990
991 fn send_raw(&self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
992 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
993 fidl::encoding::EmptyStruct,
994 DeactivateSensorError,
995 >>(
996 fidl::encoding::FlexibleResult::new(result),
997 self.tx_id,
998 0x64f003527d44ec55,
999 fidl::encoding::DynamicFlags::FLEXIBLE,
1000 )
1001 }
1002}
1003
1004#[must_use = "FIDL methods require a response to be sent"]
1005#[derive(Debug)]
1006pub struct DriverConfigureSensorRateResponder {
1007 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
1008 tx_id: u32,
1009}
1010
1011impl std::ops::Drop for DriverConfigureSensorRateResponder {
1015 fn drop(&mut self) {
1016 self.control_handle.shutdown();
1017 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1019 }
1020}
1021
1022impl fidl::endpoints::Responder for DriverConfigureSensorRateResponder {
1023 type ControlHandle = DriverControlHandle;
1024
1025 fn control_handle(&self) -> &DriverControlHandle {
1026 &self.control_handle
1027 }
1028
1029 fn drop_without_shutdown(mut self) {
1030 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1032 std::mem::forget(self);
1034 }
1035}
1036
1037impl DriverConfigureSensorRateResponder {
1038 pub fn send(self, mut result: Result<(), ConfigureSensorRateError>) -> Result<(), fidl::Error> {
1042 let _result = self.send_raw(result);
1043 if _result.is_err() {
1044 self.control_handle.shutdown();
1045 }
1046 self.drop_without_shutdown();
1047 _result
1048 }
1049
1050 pub fn send_no_shutdown_on_err(
1052 self,
1053 mut result: Result<(), ConfigureSensorRateError>,
1054 ) -> Result<(), fidl::Error> {
1055 let _result = self.send_raw(result);
1056 self.drop_without_shutdown();
1057 _result
1058 }
1059
1060 fn send_raw(
1061 &self,
1062 mut result: Result<(), ConfigureSensorRateError>,
1063 ) -> Result<(), fidl::Error> {
1064 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1065 fidl::encoding::EmptyStruct,
1066 ConfigureSensorRateError,
1067 >>(
1068 fidl::encoding::FlexibleResult::new(result),
1069 self.tx_id,
1070 0x78a264bc9c645045,
1071 fidl::encoding::DynamicFlags::FLEXIBLE,
1072 )
1073 }
1074}
1075
1076#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1077pub struct PlaybackMarker;
1078
1079impl fidl::endpoints::ProtocolMarker for PlaybackMarker {
1080 type Proxy = PlaybackProxy;
1081 type RequestStream = PlaybackRequestStream;
1082 #[cfg(target_os = "fuchsia")]
1083 type SynchronousProxy = PlaybackSynchronousProxy;
1084
1085 const DEBUG_NAME: &'static str = "fuchsia.hardware.sensors.Playback";
1086}
1087impl fidl::endpoints::DiscoverableProtocolMarker for PlaybackMarker {}
1088pub type PlaybackConfigurePlaybackResult = Result<(), ConfigurePlaybackError>;
1089
1090pub trait PlaybackProxyInterface: Send + Sync {
1091 type ConfigurePlaybackResponseFut: std::future::Future<Output = Result<PlaybackConfigurePlaybackResult, fidl::Error>>
1092 + Send;
1093 fn r#configure_playback(
1094 &self,
1095 source_config: &PlaybackSourceConfig,
1096 ) -> Self::ConfigurePlaybackResponseFut;
1097}
1098#[derive(Debug)]
1099#[cfg(target_os = "fuchsia")]
1100pub struct PlaybackSynchronousProxy {
1101 client: fidl::client::sync::Client,
1102}
1103
1104#[cfg(target_os = "fuchsia")]
1105impl fidl::endpoints::SynchronousProxy for PlaybackSynchronousProxy {
1106 type Proxy = PlaybackProxy;
1107 type Protocol = PlaybackMarker;
1108
1109 fn from_channel(inner: fidl::Channel) -> Self {
1110 Self::new(inner)
1111 }
1112
1113 fn into_channel(self) -> fidl::Channel {
1114 self.client.into_channel()
1115 }
1116
1117 fn as_channel(&self) -> &fidl::Channel {
1118 self.client.as_channel()
1119 }
1120}
1121
1122#[cfg(target_os = "fuchsia")]
1123impl PlaybackSynchronousProxy {
1124 pub fn new(channel: fidl::Channel) -> Self {
1125 let protocol_name = <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1126 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1127 }
1128
1129 pub fn into_channel(self) -> fidl::Channel {
1130 self.client.into_channel()
1131 }
1132
1133 pub fn wait_for_event(
1136 &self,
1137 deadline: zx::MonotonicInstant,
1138 ) -> Result<PlaybackEvent, fidl::Error> {
1139 PlaybackEvent::decode(self.client.wait_for_event(deadline)?)
1140 }
1141
1142 pub fn r#configure_playback(
1143 &self,
1144 mut source_config: &PlaybackSourceConfig,
1145 ___deadline: zx::MonotonicInstant,
1146 ) -> Result<PlaybackConfigurePlaybackResult, fidl::Error> {
1147 let _response =
1148 self.client
1149 .send_query::<PlaybackConfigurePlaybackRequest, fidl::encoding::FlexibleResultType<
1150 fidl::encoding::EmptyStruct,
1151 ConfigurePlaybackError,
1152 >>(
1153 (source_config,),
1154 0x64327bb27c3d8742,
1155 fidl::encoding::DynamicFlags::FLEXIBLE,
1156 ___deadline,
1157 )?
1158 .into_result::<PlaybackMarker>("configure_playback")?;
1159 Ok(_response.map(|x| x))
1160 }
1161}
1162
1163#[cfg(target_os = "fuchsia")]
1164impl From<PlaybackSynchronousProxy> for zx::Handle {
1165 fn from(value: PlaybackSynchronousProxy) -> Self {
1166 value.into_channel().into()
1167 }
1168}
1169
1170#[cfg(target_os = "fuchsia")]
1171impl From<fidl::Channel> for PlaybackSynchronousProxy {
1172 fn from(value: fidl::Channel) -> Self {
1173 Self::new(value)
1174 }
1175}
1176
1177#[cfg(target_os = "fuchsia")]
1178impl fidl::endpoints::FromClient for PlaybackSynchronousProxy {
1179 type Protocol = PlaybackMarker;
1180
1181 fn from_client(value: fidl::endpoints::ClientEnd<PlaybackMarker>) -> Self {
1182 Self::new(value.into_channel())
1183 }
1184}
1185
1186#[derive(Debug, Clone)]
1187pub struct PlaybackProxy {
1188 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1189}
1190
1191impl fidl::endpoints::Proxy for PlaybackProxy {
1192 type Protocol = PlaybackMarker;
1193
1194 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1195 Self::new(inner)
1196 }
1197
1198 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1199 self.client.into_channel().map_err(|client| Self { client })
1200 }
1201
1202 fn as_channel(&self) -> &::fidl::AsyncChannel {
1203 self.client.as_channel()
1204 }
1205}
1206
1207impl PlaybackProxy {
1208 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1210 let protocol_name = <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1211 Self { client: fidl::client::Client::new(channel, protocol_name) }
1212 }
1213
1214 pub fn take_event_stream(&self) -> PlaybackEventStream {
1220 PlaybackEventStream { event_receiver: self.client.take_event_receiver() }
1221 }
1222
1223 pub fn r#configure_playback(
1224 &self,
1225 mut source_config: &PlaybackSourceConfig,
1226 ) -> fidl::client::QueryResponseFut<
1227 PlaybackConfigurePlaybackResult,
1228 fidl::encoding::DefaultFuchsiaResourceDialect,
1229 > {
1230 PlaybackProxyInterface::r#configure_playback(self, source_config)
1231 }
1232}
1233
1234impl PlaybackProxyInterface for PlaybackProxy {
1235 type ConfigurePlaybackResponseFut = fidl::client::QueryResponseFut<
1236 PlaybackConfigurePlaybackResult,
1237 fidl::encoding::DefaultFuchsiaResourceDialect,
1238 >;
1239 fn r#configure_playback(
1240 &self,
1241 mut source_config: &PlaybackSourceConfig,
1242 ) -> Self::ConfigurePlaybackResponseFut {
1243 fn _decode(
1244 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1245 ) -> Result<PlaybackConfigurePlaybackResult, fidl::Error> {
1246 let _response = fidl::client::decode_transaction_body::<
1247 fidl::encoding::FlexibleResultType<
1248 fidl::encoding::EmptyStruct,
1249 ConfigurePlaybackError,
1250 >,
1251 fidl::encoding::DefaultFuchsiaResourceDialect,
1252 0x64327bb27c3d8742,
1253 >(_buf?)?
1254 .into_result::<PlaybackMarker>("configure_playback")?;
1255 Ok(_response.map(|x| x))
1256 }
1257 self.client.send_query_and_decode::<
1258 PlaybackConfigurePlaybackRequest,
1259 PlaybackConfigurePlaybackResult,
1260 >(
1261 (source_config,),
1262 0x64327bb27c3d8742,
1263 fidl::encoding::DynamicFlags::FLEXIBLE,
1264 _decode,
1265 )
1266 }
1267}
1268
1269pub struct PlaybackEventStream {
1270 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1271}
1272
1273impl std::marker::Unpin for PlaybackEventStream {}
1274
1275impl futures::stream::FusedStream for PlaybackEventStream {
1276 fn is_terminated(&self) -> bool {
1277 self.event_receiver.is_terminated()
1278 }
1279}
1280
1281impl futures::Stream for PlaybackEventStream {
1282 type Item = Result<PlaybackEvent, fidl::Error>;
1283
1284 fn poll_next(
1285 mut self: std::pin::Pin<&mut Self>,
1286 cx: &mut std::task::Context<'_>,
1287 ) -> std::task::Poll<Option<Self::Item>> {
1288 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1289 &mut self.event_receiver,
1290 cx
1291 )?) {
1292 Some(buf) => std::task::Poll::Ready(Some(PlaybackEvent::decode(buf))),
1293 None => std::task::Poll::Ready(None),
1294 }
1295 }
1296}
1297
1298#[derive(Debug)]
1299pub enum PlaybackEvent {
1300 #[non_exhaustive]
1301 _UnknownEvent {
1302 ordinal: u64,
1304 },
1305}
1306
1307impl PlaybackEvent {
1308 fn decode(
1310 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1311 ) -> Result<PlaybackEvent, fidl::Error> {
1312 let (bytes, _handles) = buf.split_mut();
1313 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1314 debug_assert_eq!(tx_header.tx_id, 0);
1315 match tx_header.ordinal {
1316 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1317 Ok(PlaybackEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1318 }
1319 _ => Err(fidl::Error::UnknownOrdinal {
1320 ordinal: tx_header.ordinal,
1321 protocol_name: <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1322 }),
1323 }
1324 }
1325}
1326
1327pub struct PlaybackRequestStream {
1329 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1330 is_terminated: bool,
1331}
1332
1333impl std::marker::Unpin for PlaybackRequestStream {}
1334
1335impl futures::stream::FusedStream for PlaybackRequestStream {
1336 fn is_terminated(&self) -> bool {
1337 self.is_terminated
1338 }
1339}
1340
1341impl fidl::endpoints::RequestStream for PlaybackRequestStream {
1342 type Protocol = PlaybackMarker;
1343 type ControlHandle = PlaybackControlHandle;
1344
1345 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1346 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1347 }
1348
1349 fn control_handle(&self) -> Self::ControlHandle {
1350 PlaybackControlHandle { inner: self.inner.clone() }
1351 }
1352
1353 fn into_inner(
1354 self,
1355 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1356 {
1357 (self.inner, self.is_terminated)
1358 }
1359
1360 fn from_inner(
1361 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1362 is_terminated: bool,
1363 ) -> Self {
1364 Self { inner, is_terminated }
1365 }
1366}
1367
1368impl futures::Stream for PlaybackRequestStream {
1369 type Item = Result<PlaybackRequest, fidl::Error>;
1370
1371 fn poll_next(
1372 mut self: std::pin::Pin<&mut Self>,
1373 cx: &mut std::task::Context<'_>,
1374 ) -> std::task::Poll<Option<Self::Item>> {
1375 let this = &mut *self;
1376 if this.inner.check_shutdown(cx) {
1377 this.is_terminated = true;
1378 return std::task::Poll::Ready(None);
1379 }
1380 if this.is_terminated {
1381 panic!("polled PlaybackRequestStream after completion");
1382 }
1383 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1384 |bytes, handles| {
1385 match this.inner.channel().read_etc(cx, bytes, handles) {
1386 std::task::Poll::Ready(Ok(())) => {}
1387 std::task::Poll::Pending => return std::task::Poll::Pending,
1388 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1389 this.is_terminated = true;
1390 return std::task::Poll::Ready(None);
1391 }
1392 std::task::Poll::Ready(Err(e)) => {
1393 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1394 e.into(),
1395 ))))
1396 }
1397 }
1398
1399 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1401
1402 std::task::Poll::Ready(Some(match header.ordinal {
1403 0x64327bb27c3d8742 => {
1404 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1405 let mut req = fidl::new_empty!(
1406 PlaybackConfigurePlaybackRequest,
1407 fidl::encoding::DefaultFuchsiaResourceDialect
1408 );
1409 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlaybackConfigurePlaybackRequest>(&header, _body_bytes, handles, &mut req)?;
1410 let control_handle = PlaybackControlHandle { inner: this.inner.clone() };
1411 Ok(PlaybackRequest::ConfigurePlayback {
1412 source_config: req.source_config,
1413
1414 responder: PlaybackConfigurePlaybackResponder {
1415 control_handle: std::mem::ManuallyDrop::new(control_handle),
1416 tx_id: header.tx_id,
1417 },
1418 })
1419 }
1420 _ if header.tx_id == 0
1421 && header
1422 .dynamic_flags()
1423 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1424 {
1425 Ok(PlaybackRequest::_UnknownMethod {
1426 ordinal: header.ordinal,
1427 control_handle: PlaybackControlHandle { inner: this.inner.clone() },
1428 method_type: fidl::MethodType::OneWay,
1429 })
1430 }
1431 _ if header
1432 .dynamic_flags()
1433 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1434 {
1435 this.inner.send_framework_err(
1436 fidl::encoding::FrameworkErr::UnknownMethod,
1437 header.tx_id,
1438 header.ordinal,
1439 header.dynamic_flags(),
1440 (bytes, handles),
1441 )?;
1442 Ok(PlaybackRequest::_UnknownMethod {
1443 ordinal: header.ordinal,
1444 control_handle: PlaybackControlHandle { inner: this.inner.clone() },
1445 method_type: fidl::MethodType::TwoWay,
1446 })
1447 }
1448 _ => Err(fidl::Error::UnknownOrdinal {
1449 ordinal: header.ordinal,
1450 protocol_name:
1451 <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1452 }),
1453 }))
1454 },
1455 )
1456 }
1457}
1458
1459#[derive(Debug)]
1465pub enum PlaybackRequest {
1466 ConfigurePlayback {
1467 source_config: PlaybackSourceConfig,
1468 responder: PlaybackConfigurePlaybackResponder,
1469 },
1470 #[non_exhaustive]
1472 _UnknownMethod {
1473 ordinal: u64,
1475 control_handle: PlaybackControlHandle,
1476 method_type: fidl::MethodType,
1477 },
1478}
1479
1480impl PlaybackRequest {
1481 #[allow(irrefutable_let_patterns)]
1482 pub fn into_configure_playback(
1483 self,
1484 ) -> Option<(PlaybackSourceConfig, PlaybackConfigurePlaybackResponder)> {
1485 if let PlaybackRequest::ConfigurePlayback { source_config, responder } = self {
1486 Some((source_config, responder))
1487 } else {
1488 None
1489 }
1490 }
1491
1492 pub fn method_name(&self) -> &'static str {
1494 match *self {
1495 PlaybackRequest::ConfigurePlayback { .. } => "configure_playback",
1496 PlaybackRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1497 "unknown one-way method"
1498 }
1499 PlaybackRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1500 "unknown two-way method"
1501 }
1502 }
1503 }
1504}
1505
1506#[derive(Debug, Clone)]
1507pub struct PlaybackControlHandle {
1508 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1509}
1510
1511impl fidl::endpoints::ControlHandle for PlaybackControlHandle {
1512 fn shutdown(&self) {
1513 self.inner.shutdown()
1514 }
1515 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1516 self.inner.shutdown_with_epitaph(status)
1517 }
1518
1519 fn is_closed(&self) -> bool {
1520 self.inner.channel().is_closed()
1521 }
1522 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1523 self.inner.channel().on_closed()
1524 }
1525
1526 #[cfg(target_os = "fuchsia")]
1527 fn signal_peer(
1528 &self,
1529 clear_mask: zx::Signals,
1530 set_mask: zx::Signals,
1531 ) -> Result<(), zx_status::Status> {
1532 use fidl::Peered;
1533 self.inner.channel().signal_peer(clear_mask, set_mask)
1534 }
1535}
1536
1537impl PlaybackControlHandle {}
1538
1539#[must_use = "FIDL methods require a response to be sent"]
1540#[derive(Debug)]
1541pub struct PlaybackConfigurePlaybackResponder {
1542 control_handle: std::mem::ManuallyDrop<PlaybackControlHandle>,
1543 tx_id: u32,
1544}
1545
1546impl std::ops::Drop for PlaybackConfigurePlaybackResponder {
1550 fn drop(&mut self) {
1551 self.control_handle.shutdown();
1552 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1554 }
1555}
1556
1557impl fidl::endpoints::Responder for PlaybackConfigurePlaybackResponder {
1558 type ControlHandle = PlaybackControlHandle;
1559
1560 fn control_handle(&self) -> &PlaybackControlHandle {
1561 &self.control_handle
1562 }
1563
1564 fn drop_without_shutdown(mut self) {
1565 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1567 std::mem::forget(self);
1569 }
1570}
1571
1572impl PlaybackConfigurePlaybackResponder {
1573 pub fn send(self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
1577 let _result = self.send_raw(result);
1578 if _result.is_err() {
1579 self.control_handle.shutdown();
1580 }
1581 self.drop_without_shutdown();
1582 _result
1583 }
1584
1585 pub fn send_no_shutdown_on_err(
1587 self,
1588 mut result: Result<(), ConfigurePlaybackError>,
1589 ) -> Result<(), fidl::Error> {
1590 let _result = self.send_raw(result);
1591 self.drop_without_shutdown();
1592 _result
1593 }
1594
1595 fn send_raw(&self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
1596 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1597 fidl::encoding::EmptyStruct,
1598 ConfigurePlaybackError,
1599 >>(
1600 fidl::encoding::FlexibleResult::new(result),
1601 self.tx_id,
1602 0x64327bb27c3d8742,
1603 fidl::encoding::DynamicFlags::FLEXIBLE,
1604 )
1605 }
1606}
1607
1608#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1609pub struct ServiceMarker;
1610
1611#[cfg(target_os = "fuchsia")]
1612impl fidl::endpoints::ServiceMarker for ServiceMarker {
1613 type Proxy = ServiceProxy;
1614 type Request = ServiceRequest;
1615 const SERVICE_NAME: &'static str = "fuchsia.hardware.sensors.Service";
1616}
1617
1618#[cfg(target_os = "fuchsia")]
1621pub enum ServiceRequest {
1622 Driver(DriverRequestStream),
1623}
1624
1625#[cfg(target_os = "fuchsia")]
1626impl fidl::endpoints::ServiceRequest for ServiceRequest {
1627 type Service = ServiceMarker;
1628
1629 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1630 match name {
1631 "driver" => Self::Driver(
1632 <DriverRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1633 ),
1634 _ => panic!("no such member protocol name for service Service"),
1635 }
1636 }
1637
1638 fn member_names() -> &'static [&'static str] {
1639 &["driver"]
1640 }
1641}
1642#[cfg(target_os = "fuchsia")]
1643pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1644
1645#[cfg(target_os = "fuchsia")]
1646impl fidl::endpoints::ServiceProxy for ServiceProxy {
1647 type Service = ServiceMarker;
1648
1649 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1650 Self(opener)
1651 }
1652}
1653
1654#[cfg(target_os = "fuchsia")]
1655impl ServiceProxy {
1656 pub fn connect_to_driver(&self) -> Result<DriverProxy, fidl::Error> {
1657 let (proxy, server_end) = fidl::endpoints::create_proxy::<DriverMarker>();
1658 self.connect_channel_to_driver(server_end)?;
1659 Ok(proxy)
1660 }
1661
1662 pub fn connect_to_driver_sync(&self) -> Result<DriverSynchronousProxy, fidl::Error> {
1665 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DriverMarker>();
1666 self.connect_channel_to_driver(server_end)?;
1667 Ok(proxy)
1668 }
1669
1670 pub fn connect_channel_to_driver(
1673 &self,
1674 server_end: fidl::endpoints::ServerEnd<DriverMarker>,
1675 ) -> Result<(), fidl::Error> {
1676 self.0.open_member("driver", server_end.into_channel())
1677 }
1678
1679 pub fn instance_name(&self) -> &str {
1680 self.0.instance_name()
1681 }
1682}
1683
1684mod internal {
1685 use super::*;
1686}