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 Self { client: fidl::client::sync::Client::new(channel) }
77 }
78
79 pub fn into_channel(self) -> fidl::Channel {
80 self.client.into_channel()
81 }
82
83 pub fn wait_for_event(
86 &self,
87 deadline: zx::MonotonicInstant,
88 ) -> Result<DriverEvent, fidl::Error> {
89 DriverEvent::decode(self.client.wait_for_event::<DriverMarker>(deadline)?)
90 }
91
92 pub fn r#get_sensors_list(
94 &self,
95 ___deadline: zx::MonotonicInstant,
96 ) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
97 let _response = self.client.send_query::<
98 fidl::encoding::EmptyPayload,
99 fidl::encoding::FlexibleType<DriverGetSensorsListResponse>,
100 DriverMarker,
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 >, DriverMarker>(
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 >, DriverMarker>(
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 >, DriverMarker>(
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::NullableHandle {
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 { Some((event)) } else { None }
445 }
446
447 fn decode(
449 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
450 ) -> Result<DriverEvent, fidl::Error> {
451 let (bytes, _handles) = buf.split_mut();
452 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
453 debug_assert_eq!(tx_header.tx_id, 0);
454 match tx_header.ordinal {
455 0x2aaf0636bb3e1df9 => {
456 let mut out = fidl::new_empty!(
457 DriverOnSensorEventRequest,
458 fidl::encoding::DefaultFuchsiaResourceDialect
459 );
460 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverOnSensorEventRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
461 Ok((DriverEvent::OnSensorEvent { event: out.event }))
462 }
463 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
464 Ok(DriverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
465 }
466 _ => Err(fidl::Error::UnknownOrdinal {
467 ordinal: tx_header.ordinal,
468 protocol_name: <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
469 }),
470 }
471 }
472}
473
474pub struct DriverRequestStream {
476 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
477 is_terminated: bool,
478}
479
480impl std::marker::Unpin for DriverRequestStream {}
481
482impl futures::stream::FusedStream for DriverRequestStream {
483 fn is_terminated(&self) -> bool {
484 self.is_terminated
485 }
486}
487
488impl fidl::endpoints::RequestStream for DriverRequestStream {
489 type Protocol = DriverMarker;
490 type ControlHandle = DriverControlHandle;
491
492 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
493 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
494 }
495
496 fn control_handle(&self) -> Self::ControlHandle {
497 DriverControlHandle { inner: self.inner.clone() }
498 }
499
500 fn into_inner(
501 self,
502 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
503 {
504 (self.inner, self.is_terminated)
505 }
506
507 fn from_inner(
508 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
509 is_terminated: bool,
510 ) -> Self {
511 Self { inner, is_terminated }
512 }
513}
514
515impl futures::Stream for DriverRequestStream {
516 type Item = Result<DriverRequest, fidl::Error>;
517
518 fn poll_next(
519 mut self: std::pin::Pin<&mut Self>,
520 cx: &mut std::task::Context<'_>,
521 ) -> std::task::Poll<Option<Self::Item>> {
522 let this = &mut *self;
523 if this.inner.check_shutdown(cx) {
524 this.is_terminated = true;
525 return std::task::Poll::Ready(None);
526 }
527 if this.is_terminated {
528 panic!("polled DriverRequestStream after completion");
529 }
530 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
531 |bytes, handles| {
532 match this.inner.channel().read_etc(cx, bytes, handles) {
533 std::task::Poll::Ready(Ok(())) => {}
534 std::task::Poll::Pending => return std::task::Poll::Pending,
535 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
536 this.is_terminated = true;
537 return std::task::Poll::Ready(None);
538 }
539 std::task::Poll::Ready(Err(e)) => {
540 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
541 e.into(),
542 ))));
543 }
544 }
545
546 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
548
549 std::task::Poll::Ready(Some(match header.ordinal {
550 0x6a30da06929d426b => {
551 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
552 let mut req = fidl::new_empty!(
553 fidl::encoding::EmptyPayload,
554 fidl::encoding::DefaultFuchsiaResourceDialect
555 );
556 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
557 let control_handle = DriverControlHandle { inner: this.inner.clone() };
558 Ok(DriverRequest::GetSensorsList {
559 responder: DriverGetSensorsListResponder {
560 control_handle: std::mem::ManuallyDrop::new(control_handle),
561 tx_id: header.tx_id,
562 },
563 })
564 }
565 0x6ff16c620f9f3c5b => {
566 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
567 let mut req = fidl::new_empty!(
568 DriverActivateSensorRequest,
569 fidl::encoding::DefaultFuchsiaResourceDialect
570 );
571 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverActivateSensorRequest>(&header, _body_bytes, handles, &mut req)?;
572 let control_handle = DriverControlHandle { inner: this.inner.clone() };
573 Ok(DriverRequest::ActivateSensor {
574 sensor_id: req.sensor_id,
575
576 responder: DriverActivateSensorResponder {
577 control_handle: std::mem::ManuallyDrop::new(control_handle),
578 tx_id: header.tx_id,
579 },
580 })
581 }
582 0x64f003527d44ec55 => {
583 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
584 let mut req = fidl::new_empty!(
585 DriverDeactivateSensorRequest,
586 fidl::encoding::DefaultFuchsiaResourceDialect
587 );
588 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverDeactivateSensorRequest>(&header, _body_bytes, handles, &mut req)?;
589 let control_handle = DriverControlHandle { inner: this.inner.clone() };
590 Ok(DriverRequest::DeactivateSensor {
591 sensor_id: req.sensor_id,
592
593 responder: DriverDeactivateSensorResponder {
594 control_handle: std::mem::ManuallyDrop::new(control_handle),
595 tx_id: header.tx_id,
596 },
597 })
598 }
599 0x78a264bc9c645045 => {
600 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
601 let mut req = fidl::new_empty!(
602 DriverConfigureSensorRateRequest,
603 fidl::encoding::DefaultFuchsiaResourceDialect
604 );
605 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverConfigureSensorRateRequest>(&header, _body_bytes, handles, &mut req)?;
606 let control_handle = DriverControlHandle { inner: this.inner.clone() };
607 Ok(DriverRequest::ConfigureSensorRate {
608 sensor_id: req.sensor_id,
609 sensor_rate_config: req.sensor_rate_config,
610
611 responder: DriverConfigureSensorRateResponder {
612 control_handle: std::mem::ManuallyDrop::new(control_handle),
613 tx_id: header.tx_id,
614 },
615 })
616 }
617 _ if header.tx_id == 0
618 && header
619 .dynamic_flags()
620 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
621 {
622 Ok(DriverRequest::_UnknownMethod {
623 ordinal: header.ordinal,
624 control_handle: DriverControlHandle { inner: this.inner.clone() },
625 method_type: fidl::MethodType::OneWay,
626 })
627 }
628 _ if header
629 .dynamic_flags()
630 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
631 {
632 this.inner.send_framework_err(
633 fidl::encoding::FrameworkErr::UnknownMethod,
634 header.tx_id,
635 header.ordinal,
636 header.dynamic_flags(),
637 (bytes, handles),
638 )?;
639 Ok(DriverRequest::_UnknownMethod {
640 ordinal: header.ordinal,
641 control_handle: DriverControlHandle { inner: this.inner.clone() },
642 method_type: fidl::MethodType::TwoWay,
643 })
644 }
645 _ => Err(fidl::Error::UnknownOrdinal {
646 ordinal: header.ordinal,
647 protocol_name:
648 <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
649 }),
650 }))
651 },
652 )
653 }
654}
655
656#[derive(Debug)]
658pub enum DriverRequest {
659 GetSensorsList { responder: DriverGetSensorsListResponder },
661 ActivateSensor { sensor_id: i32, responder: DriverActivateSensorResponder },
663 DeactivateSensor { sensor_id: i32, responder: DriverDeactivateSensorResponder },
665 ConfigureSensorRate {
667 sensor_id: i32,
668 sensor_rate_config: fidl_fuchsia_sensors_types::SensorRateConfig,
669 responder: DriverConfigureSensorRateResponder,
670 },
671 #[non_exhaustive]
673 _UnknownMethod {
674 ordinal: u64,
676 control_handle: DriverControlHandle,
677 method_type: fidl::MethodType,
678 },
679}
680
681impl DriverRequest {
682 #[allow(irrefutable_let_patterns)]
683 pub fn into_get_sensors_list(self) -> Option<(DriverGetSensorsListResponder)> {
684 if let DriverRequest::GetSensorsList { responder } = self {
685 Some((responder))
686 } else {
687 None
688 }
689 }
690
691 #[allow(irrefutable_let_patterns)]
692 pub fn into_activate_sensor(self) -> Option<(i32, DriverActivateSensorResponder)> {
693 if let DriverRequest::ActivateSensor { sensor_id, responder } = self {
694 Some((sensor_id, responder))
695 } else {
696 None
697 }
698 }
699
700 #[allow(irrefutable_let_patterns)]
701 pub fn into_deactivate_sensor(self) -> Option<(i32, DriverDeactivateSensorResponder)> {
702 if let DriverRequest::DeactivateSensor { sensor_id, responder } = self {
703 Some((sensor_id, responder))
704 } else {
705 None
706 }
707 }
708
709 #[allow(irrefutable_let_patterns)]
710 pub fn into_configure_sensor_rate(
711 self,
712 ) -> Option<(
713 i32,
714 fidl_fuchsia_sensors_types::SensorRateConfig,
715 DriverConfigureSensorRateResponder,
716 )> {
717 if let DriverRequest::ConfigureSensorRate { sensor_id, sensor_rate_config, responder } =
718 self
719 {
720 Some((sensor_id, sensor_rate_config, responder))
721 } else {
722 None
723 }
724 }
725
726 pub fn method_name(&self) -> &'static str {
728 match *self {
729 DriverRequest::GetSensorsList { .. } => "get_sensors_list",
730 DriverRequest::ActivateSensor { .. } => "activate_sensor",
731 DriverRequest::DeactivateSensor { .. } => "deactivate_sensor",
732 DriverRequest::ConfigureSensorRate { .. } => "configure_sensor_rate",
733 DriverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
734 "unknown one-way method"
735 }
736 DriverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
737 "unknown two-way method"
738 }
739 }
740 }
741}
742
743#[derive(Debug, Clone)]
744pub struct DriverControlHandle {
745 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
746}
747
748impl DriverControlHandle {
749 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
750 self.inner.shutdown_with_epitaph(status.into())
751 }
752}
753
754impl fidl::endpoints::ControlHandle for DriverControlHandle {
755 fn shutdown(&self) {
756 self.inner.shutdown()
757 }
758
759 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
760 self.inner.shutdown_with_epitaph(status)
761 }
762
763 fn is_closed(&self) -> bool {
764 self.inner.channel().is_closed()
765 }
766 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
767 self.inner.channel().on_closed()
768 }
769
770 #[cfg(target_os = "fuchsia")]
771 fn signal_peer(
772 &self,
773 clear_mask: zx::Signals,
774 set_mask: zx::Signals,
775 ) -> Result<(), zx_status::Status> {
776 use fidl::Peered;
777 self.inner.channel().signal_peer(clear_mask, set_mask)
778 }
779}
780
781impl DriverControlHandle {
782 pub fn send_on_sensor_event(
783 &self,
784 mut event: &fidl_fuchsia_sensors_types::SensorEvent,
785 ) -> Result<(), fidl::Error> {
786 self.inner.send::<DriverOnSensorEventRequest>(
787 (event,),
788 0,
789 0x2aaf0636bb3e1df9,
790 fidl::encoding::DynamicFlags::FLEXIBLE,
791 )
792 }
793}
794
795#[must_use = "FIDL methods require a response to be sent"]
796#[derive(Debug)]
797pub struct DriverGetSensorsListResponder {
798 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
799 tx_id: u32,
800}
801
802impl std::ops::Drop for DriverGetSensorsListResponder {
806 fn drop(&mut self) {
807 self.control_handle.shutdown();
808 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
810 }
811}
812
813impl fidl::endpoints::Responder for DriverGetSensorsListResponder {
814 type ControlHandle = DriverControlHandle;
815
816 fn control_handle(&self) -> &DriverControlHandle {
817 &self.control_handle
818 }
819
820 fn drop_without_shutdown(mut self) {
821 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
823 std::mem::forget(self);
825 }
826}
827
828impl DriverGetSensorsListResponder {
829 pub fn send(
833 self,
834 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
835 ) -> Result<(), fidl::Error> {
836 let _result = self.send_raw(sensor_list);
837 if _result.is_err() {
838 self.control_handle.shutdown();
839 }
840 self.drop_without_shutdown();
841 _result
842 }
843
844 pub fn send_no_shutdown_on_err(
846 self,
847 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
848 ) -> Result<(), fidl::Error> {
849 let _result = self.send_raw(sensor_list);
850 self.drop_without_shutdown();
851 _result
852 }
853
854 fn send_raw(
855 &self,
856 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
857 ) -> Result<(), fidl::Error> {
858 self.control_handle
859 .inner
860 .send::<fidl::encoding::FlexibleType<DriverGetSensorsListResponse>>(
861 fidl::encoding::Flexible::new((sensor_list,)),
862 self.tx_id,
863 0x6a30da06929d426b,
864 fidl::encoding::DynamicFlags::FLEXIBLE,
865 )
866 }
867}
868
869#[must_use = "FIDL methods require a response to be sent"]
870#[derive(Debug)]
871pub struct DriverActivateSensorResponder {
872 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
873 tx_id: u32,
874}
875
876impl std::ops::Drop for DriverActivateSensorResponder {
880 fn drop(&mut self) {
881 self.control_handle.shutdown();
882 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
884 }
885}
886
887impl fidl::endpoints::Responder for DriverActivateSensorResponder {
888 type ControlHandle = DriverControlHandle;
889
890 fn control_handle(&self) -> &DriverControlHandle {
891 &self.control_handle
892 }
893
894 fn drop_without_shutdown(mut self) {
895 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
897 std::mem::forget(self);
899 }
900}
901
902impl DriverActivateSensorResponder {
903 pub fn send(self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
907 let _result = self.send_raw(result);
908 if _result.is_err() {
909 self.control_handle.shutdown();
910 }
911 self.drop_without_shutdown();
912 _result
913 }
914
915 pub fn send_no_shutdown_on_err(
917 self,
918 mut result: Result<(), ActivateSensorError>,
919 ) -> Result<(), fidl::Error> {
920 let _result = self.send_raw(result);
921 self.drop_without_shutdown();
922 _result
923 }
924
925 fn send_raw(&self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
926 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
927 fidl::encoding::EmptyStruct,
928 ActivateSensorError,
929 >>(
930 fidl::encoding::FlexibleResult::new(result),
931 self.tx_id,
932 0x6ff16c620f9f3c5b,
933 fidl::encoding::DynamicFlags::FLEXIBLE,
934 )
935 }
936}
937
938#[must_use = "FIDL methods require a response to be sent"]
939#[derive(Debug)]
940pub struct DriverDeactivateSensorResponder {
941 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
942 tx_id: u32,
943}
944
945impl std::ops::Drop for DriverDeactivateSensorResponder {
949 fn drop(&mut self) {
950 self.control_handle.shutdown();
951 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
953 }
954}
955
956impl fidl::endpoints::Responder for DriverDeactivateSensorResponder {
957 type ControlHandle = DriverControlHandle;
958
959 fn control_handle(&self) -> &DriverControlHandle {
960 &self.control_handle
961 }
962
963 fn drop_without_shutdown(mut self) {
964 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
966 std::mem::forget(self);
968 }
969}
970
971impl DriverDeactivateSensorResponder {
972 pub fn send(self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
976 let _result = self.send_raw(result);
977 if _result.is_err() {
978 self.control_handle.shutdown();
979 }
980 self.drop_without_shutdown();
981 _result
982 }
983
984 pub fn send_no_shutdown_on_err(
986 self,
987 mut result: Result<(), DeactivateSensorError>,
988 ) -> Result<(), fidl::Error> {
989 let _result = self.send_raw(result);
990 self.drop_without_shutdown();
991 _result
992 }
993
994 fn send_raw(&self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
995 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
996 fidl::encoding::EmptyStruct,
997 DeactivateSensorError,
998 >>(
999 fidl::encoding::FlexibleResult::new(result),
1000 self.tx_id,
1001 0x64f003527d44ec55,
1002 fidl::encoding::DynamicFlags::FLEXIBLE,
1003 )
1004 }
1005}
1006
1007#[must_use = "FIDL methods require a response to be sent"]
1008#[derive(Debug)]
1009pub struct DriverConfigureSensorRateResponder {
1010 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
1011 tx_id: u32,
1012}
1013
1014impl std::ops::Drop for DriverConfigureSensorRateResponder {
1018 fn drop(&mut self) {
1019 self.control_handle.shutdown();
1020 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1022 }
1023}
1024
1025impl fidl::endpoints::Responder for DriverConfigureSensorRateResponder {
1026 type ControlHandle = DriverControlHandle;
1027
1028 fn control_handle(&self) -> &DriverControlHandle {
1029 &self.control_handle
1030 }
1031
1032 fn drop_without_shutdown(mut self) {
1033 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1035 std::mem::forget(self);
1037 }
1038}
1039
1040impl DriverConfigureSensorRateResponder {
1041 pub fn send(self, mut result: Result<(), ConfigureSensorRateError>) -> Result<(), fidl::Error> {
1045 let _result = self.send_raw(result);
1046 if _result.is_err() {
1047 self.control_handle.shutdown();
1048 }
1049 self.drop_without_shutdown();
1050 _result
1051 }
1052
1053 pub fn send_no_shutdown_on_err(
1055 self,
1056 mut result: Result<(), ConfigureSensorRateError>,
1057 ) -> Result<(), fidl::Error> {
1058 let _result = self.send_raw(result);
1059 self.drop_without_shutdown();
1060 _result
1061 }
1062
1063 fn send_raw(
1064 &self,
1065 mut result: Result<(), ConfigureSensorRateError>,
1066 ) -> Result<(), fidl::Error> {
1067 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1068 fidl::encoding::EmptyStruct,
1069 ConfigureSensorRateError,
1070 >>(
1071 fidl::encoding::FlexibleResult::new(result),
1072 self.tx_id,
1073 0x78a264bc9c645045,
1074 fidl::encoding::DynamicFlags::FLEXIBLE,
1075 )
1076 }
1077}
1078
1079#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1080pub struct PlaybackMarker;
1081
1082impl fidl::endpoints::ProtocolMarker for PlaybackMarker {
1083 type Proxy = PlaybackProxy;
1084 type RequestStream = PlaybackRequestStream;
1085 #[cfg(target_os = "fuchsia")]
1086 type SynchronousProxy = PlaybackSynchronousProxy;
1087
1088 const DEBUG_NAME: &'static str = "fuchsia.hardware.sensors.Playback";
1089}
1090impl fidl::endpoints::DiscoverableProtocolMarker for PlaybackMarker {}
1091pub type PlaybackConfigurePlaybackResult = Result<(), ConfigurePlaybackError>;
1092
1093pub trait PlaybackProxyInterface: Send + Sync {
1094 type ConfigurePlaybackResponseFut: std::future::Future<Output = Result<PlaybackConfigurePlaybackResult, fidl::Error>>
1095 + Send;
1096 fn r#configure_playback(
1097 &self,
1098 source_config: &PlaybackSourceConfig,
1099 ) -> Self::ConfigurePlaybackResponseFut;
1100}
1101#[derive(Debug)]
1102#[cfg(target_os = "fuchsia")]
1103pub struct PlaybackSynchronousProxy {
1104 client: fidl::client::sync::Client,
1105}
1106
1107#[cfg(target_os = "fuchsia")]
1108impl fidl::endpoints::SynchronousProxy for PlaybackSynchronousProxy {
1109 type Proxy = PlaybackProxy;
1110 type Protocol = PlaybackMarker;
1111
1112 fn from_channel(inner: fidl::Channel) -> Self {
1113 Self::new(inner)
1114 }
1115
1116 fn into_channel(self) -> fidl::Channel {
1117 self.client.into_channel()
1118 }
1119
1120 fn as_channel(&self) -> &fidl::Channel {
1121 self.client.as_channel()
1122 }
1123}
1124
1125#[cfg(target_os = "fuchsia")]
1126impl PlaybackSynchronousProxy {
1127 pub fn new(channel: fidl::Channel) -> Self {
1128 Self { client: fidl::client::sync::Client::new(channel) }
1129 }
1130
1131 pub fn into_channel(self) -> fidl::Channel {
1132 self.client.into_channel()
1133 }
1134
1135 pub fn wait_for_event(
1138 &self,
1139 deadline: zx::MonotonicInstant,
1140 ) -> Result<PlaybackEvent, fidl::Error> {
1141 PlaybackEvent::decode(self.client.wait_for_event::<PlaybackMarker>(deadline)?)
1142 }
1143
1144 pub fn r#configure_playback(
1145 &self,
1146 mut source_config: &PlaybackSourceConfig,
1147 ___deadline: zx::MonotonicInstant,
1148 ) -> Result<PlaybackConfigurePlaybackResult, fidl::Error> {
1149 let _response =
1150 self.client
1151 .send_query::<PlaybackConfigurePlaybackRequest, fidl::encoding::FlexibleResultType<
1152 fidl::encoding::EmptyStruct,
1153 ConfigurePlaybackError,
1154 >, PlaybackMarker>(
1155 (source_config,),
1156 0x64327bb27c3d8742,
1157 fidl::encoding::DynamicFlags::FLEXIBLE,
1158 ___deadline,
1159 )?
1160 .into_result::<PlaybackMarker>("configure_playback")?;
1161 Ok(_response.map(|x| x))
1162 }
1163}
1164
1165#[cfg(target_os = "fuchsia")]
1166impl From<PlaybackSynchronousProxy> for zx::NullableHandle {
1167 fn from(value: PlaybackSynchronousProxy) -> Self {
1168 value.into_channel().into()
1169 }
1170}
1171
1172#[cfg(target_os = "fuchsia")]
1173impl From<fidl::Channel> for PlaybackSynchronousProxy {
1174 fn from(value: fidl::Channel) -> Self {
1175 Self::new(value)
1176 }
1177}
1178
1179#[cfg(target_os = "fuchsia")]
1180impl fidl::endpoints::FromClient for PlaybackSynchronousProxy {
1181 type Protocol = PlaybackMarker;
1182
1183 fn from_client(value: fidl::endpoints::ClientEnd<PlaybackMarker>) -> Self {
1184 Self::new(value.into_channel())
1185 }
1186}
1187
1188#[derive(Debug, Clone)]
1189pub struct PlaybackProxy {
1190 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1191}
1192
1193impl fidl::endpoints::Proxy for PlaybackProxy {
1194 type Protocol = PlaybackMarker;
1195
1196 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1197 Self::new(inner)
1198 }
1199
1200 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1201 self.client.into_channel().map_err(|client| Self { client })
1202 }
1203
1204 fn as_channel(&self) -> &::fidl::AsyncChannel {
1205 self.client.as_channel()
1206 }
1207}
1208
1209impl PlaybackProxy {
1210 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1212 let protocol_name = <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1213 Self { client: fidl::client::Client::new(channel, protocol_name) }
1214 }
1215
1216 pub fn take_event_stream(&self) -> PlaybackEventStream {
1222 PlaybackEventStream { event_receiver: self.client.take_event_receiver() }
1223 }
1224
1225 pub fn r#configure_playback(
1226 &self,
1227 mut source_config: &PlaybackSourceConfig,
1228 ) -> fidl::client::QueryResponseFut<
1229 PlaybackConfigurePlaybackResult,
1230 fidl::encoding::DefaultFuchsiaResourceDialect,
1231 > {
1232 PlaybackProxyInterface::r#configure_playback(self, source_config)
1233 }
1234}
1235
1236impl PlaybackProxyInterface for PlaybackProxy {
1237 type ConfigurePlaybackResponseFut = fidl::client::QueryResponseFut<
1238 PlaybackConfigurePlaybackResult,
1239 fidl::encoding::DefaultFuchsiaResourceDialect,
1240 >;
1241 fn r#configure_playback(
1242 &self,
1243 mut source_config: &PlaybackSourceConfig,
1244 ) -> Self::ConfigurePlaybackResponseFut {
1245 fn _decode(
1246 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1247 ) -> Result<PlaybackConfigurePlaybackResult, fidl::Error> {
1248 let _response = fidl::client::decode_transaction_body::<
1249 fidl::encoding::FlexibleResultType<
1250 fidl::encoding::EmptyStruct,
1251 ConfigurePlaybackError,
1252 >,
1253 fidl::encoding::DefaultFuchsiaResourceDialect,
1254 0x64327bb27c3d8742,
1255 >(_buf?)?
1256 .into_result::<PlaybackMarker>("configure_playback")?;
1257 Ok(_response.map(|x| x))
1258 }
1259 self.client.send_query_and_decode::<
1260 PlaybackConfigurePlaybackRequest,
1261 PlaybackConfigurePlaybackResult,
1262 >(
1263 (source_config,),
1264 0x64327bb27c3d8742,
1265 fidl::encoding::DynamicFlags::FLEXIBLE,
1266 _decode,
1267 )
1268 }
1269}
1270
1271pub struct PlaybackEventStream {
1272 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1273}
1274
1275impl std::marker::Unpin for PlaybackEventStream {}
1276
1277impl futures::stream::FusedStream for PlaybackEventStream {
1278 fn is_terminated(&self) -> bool {
1279 self.event_receiver.is_terminated()
1280 }
1281}
1282
1283impl futures::Stream for PlaybackEventStream {
1284 type Item = Result<PlaybackEvent, fidl::Error>;
1285
1286 fn poll_next(
1287 mut self: std::pin::Pin<&mut Self>,
1288 cx: &mut std::task::Context<'_>,
1289 ) -> std::task::Poll<Option<Self::Item>> {
1290 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1291 &mut self.event_receiver,
1292 cx
1293 )?) {
1294 Some(buf) => std::task::Poll::Ready(Some(PlaybackEvent::decode(buf))),
1295 None => std::task::Poll::Ready(None),
1296 }
1297 }
1298}
1299
1300#[derive(Debug)]
1301pub enum PlaybackEvent {
1302 #[non_exhaustive]
1303 _UnknownEvent {
1304 ordinal: u64,
1306 },
1307}
1308
1309impl PlaybackEvent {
1310 fn decode(
1312 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1313 ) -> Result<PlaybackEvent, fidl::Error> {
1314 let (bytes, _handles) = buf.split_mut();
1315 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1316 debug_assert_eq!(tx_header.tx_id, 0);
1317 match tx_header.ordinal {
1318 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1319 Ok(PlaybackEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1320 }
1321 _ => Err(fidl::Error::UnknownOrdinal {
1322 ordinal: tx_header.ordinal,
1323 protocol_name: <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1324 }),
1325 }
1326 }
1327}
1328
1329pub struct PlaybackRequestStream {
1331 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1332 is_terminated: bool,
1333}
1334
1335impl std::marker::Unpin for PlaybackRequestStream {}
1336
1337impl futures::stream::FusedStream for PlaybackRequestStream {
1338 fn is_terminated(&self) -> bool {
1339 self.is_terminated
1340 }
1341}
1342
1343impl fidl::endpoints::RequestStream for PlaybackRequestStream {
1344 type Protocol = PlaybackMarker;
1345 type ControlHandle = PlaybackControlHandle;
1346
1347 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1348 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1349 }
1350
1351 fn control_handle(&self) -> Self::ControlHandle {
1352 PlaybackControlHandle { inner: self.inner.clone() }
1353 }
1354
1355 fn into_inner(
1356 self,
1357 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1358 {
1359 (self.inner, self.is_terminated)
1360 }
1361
1362 fn from_inner(
1363 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1364 is_terminated: bool,
1365 ) -> Self {
1366 Self { inner, is_terminated }
1367 }
1368}
1369
1370impl futures::Stream for PlaybackRequestStream {
1371 type Item = Result<PlaybackRequest, fidl::Error>;
1372
1373 fn poll_next(
1374 mut self: std::pin::Pin<&mut Self>,
1375 cx: &mut std::task::Context<'_>,
1376 ) -> std::task::Poll<Option<Self::Item>> {
1377 let this = &mut *self;
1378 if this.inner.check_shutdown(cx) {
1379 this.is_terminated = true;
1380 return std::task::Poll::Ready(None);
1381 }
1382 if this.is_terminated {
1383 panic!("polled PlaybackRequestStream after completion");
1384 }
1385 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1386 |bytes, handles| {
1387 match this.inner.channel().read_etc(cx, bytes, handles) {
1388 std::task::Poll::Ready(Ok(())) => {}
1389 std::task::Poll::Pending => return std::task::Poll::Pending,
1390 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1391 this.is_terminated = true;
1392 return std::task::Poll::Ready(None);
1393 }
1394 std::task::Poll::Ready(Err(e)) => {
1395 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1396 e.into(),
1397 ))));
1398 }
1399 }
1400
1401 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1403
1404 std::task::Poll::Ready(Some(match header.ordinal {
1405 0x64327bb27c3d8742 => {
1406 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1407 let mut req = fidl::new_empty!(
1408 PlaybackConfigurePlaybackRequest,
1409 fidl::encoding::DefaultFuchsiaResourceDialect
1410 );
1411 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlaybackConfigurePlaybackRequest>(&header, _body_bytes, handles, &mut req)?;
1412 let control_handle = PlaybackControlHandle { inner: this.inner.clone() };
1413 Ok(PlaybackRequest::ConfigurePlayback {
1414 source_config: req.source_config,
1415
1416 responder: PlaybackConfigurePlaybackResponder {
1417 control_handle: std::mem::ManuallyDrop::new(control_handle),
1418 tx_id: header.tx_id,
1419 },
1420 })
1421 }
1422 _ if header.tx_id == 0
1423 && header
1424 .dynamic_flags()
1425 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1426 {
1427 Ok(PlaybackRequest::_UnknownMethod {
1428 ordinal: header.ordinal,
1429 control_handle: PlaybackControlHandle { inner: this.inner.clone() },
1430 method_type: fidl::MethodType::OneWay,
1431 })
1432 }
1433 _ if header
1434 .dynamic_flags()
1435 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1436 {
1437 this.inner.send_framework_err(
1438 fidl::encoding::FrameworkErr::UnknownMethod,
1439 header.tx_id,
1440 header.ordinal,
1441 header.dynamic_flags(),
1442 (bytes, handles),
1443 )?;
1444 Ok(PlaybackRequest::_UnknownMethod {
1445 ordinal: header.ordinal,
1446 control_handle: PlaybackControlHandle { inner: this.inner.clone() },
1447 method_type: fidl::MethodType::TwoWay,
1448 })
1449 }
1450 _ => Err(fidl::Error::UnknownOrdinal {
1451 ordinal: header.ordinal,
1452 protocol_name:
1453 <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1454 }),
1455 }))
1456 },
1457 )
1458 }
1459}
1460
1461#[derive(Debug)]
1467pub enum PlaybackRequest {
1468 ConfigurePlayback {
1469 source_config: PlaybackSourceConfig,
1470 responder: PlaybackConfigurePlaybackResponder,
1471 },
1472 #[non_exhaustive]
1474 _UnknownMethod {
1475 ordinal: u64,
1477 control_handle: PlaybackControlHandle,
1478 method_type: fidl::MethodType,
1479 },
1480}
1481
1482impl PlaybackRequest {
1483 #[allow(irrefutable_let_patterns)]
1484 pub fn into_configure_playback(
1485 self,
1486 ) -> Option<(PlaybackSourceConfig, PlaybackConfigurePlaybackResponder)> {
1487 if let PlaybackRequest::ConfigurePlayback { source_config, responder } = self {
1488 Some((source_config, responder))
1489 } else {
1490 None
1491 }
1492 }
1493
1494 pub fn method_name(&self) -> &'static str {
1496 match *self {
1497 PlaybackRequest::ConfigurePlayback { .. } => "configure_playback",
1498 PlaybackRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1499 "unknown one-way method"
1500 }
1501 PlaybackRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1502 "unknown two-way method"
1503 }
1504 }
1505 }
1506}
1507
1508#[derive(Debug, Clone)]
1509pub struct PlaybackControlHandle {
1510 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1511}
1512
1513impl PlaybackControlHandle {
1514 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1515 self.inner.shutdown_with_epitaph(status.into())
1516 }
1517}
1518
1519impl fidl::endpoints::ControlHandle for PlaybackControlHandle {
1520 fn shutdown(&self) {
1521 self.inner.shutdown()
1522 }
1523
1524 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1525 self.inner.shutdown_with_epitaph(status)
1526 }
1527
1528 fn is_closed(&self) -> bool {
1529 self.inner.channel().is_closed()
1530 }
1531 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1532 self.inner.channel().on_closed()
1533 }
1534
1535 #[cfg(target_os = "fuchsia")]
1536 fn signal_peer(
1537 &self,
1538 clear_mask: zx::Signals,
1539 set_mask: zx::Signals,
1540 ) -> Result<(), zx_status::Status> {
1541 use fidl::Peered;
1542 self.inner.channel().signal_peer(clear_mask, set_mask)
1543 }
1544}
1545
1546impl PlaybackControlHandle {}
1547
1548#[must_use = "FIDL methods require a response to be sent"]
1549#[derive(Debug)]
1550pub struct PlaybackConfigurePlaybackResponder {
1551 control_handle: std::mem::ManuallyDrop<PlaybackControlHandle>,
1552 tx_id: u32,
1553}
1554
1555impl std::ops::Drop for PlaybackConfigurePlaybackResponder {
1559 fn drop(&mut self) {
1560 self.control_handle.shutdown();
1561 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1563 }
1564}
1565
1566impl fidl::endpoints::Responder for PlaybackConfigurePlaybackResponder {
1567 type ControlHandle = PlaybackControlHandle;
1568
1569 fn control_handle(&self) -> &PlaybackControlHandle {
1570 &self.control_handle
1571 }
1572
1573 fn drop_without_shutdown(mut self) {
1574 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1576 std::mem::forget(self);
1578 }
1579}
1580
1581impl PlaybackConfigurePlaybackResponder {
1582 pub fn send(self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
1586 let _result = self.send_raw(result);
1587 if _result.is_err() {
1588 self.control_handle.shutdown();
1589 }
1590 self.drop_without_shutdown();
1591 _result
1592 }
1593
1594 pub fn send_no_shutdown_on_err(
1596 self,
1597 mut result: Result<(), ConfigurePlaybackError>,
1598 ) -> Result<(), fidl::Error> {
1599 let _result = self.send_raw(result);
1600 self.drop_without_shutdown();
1601 _result
1602 }
1603
1604 fn send_raw(&self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
1605 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1606 fidl::encoding::EmptyStruct,
1607 ConfigurePlaybackError,
1608 >>(
1609 fidl::encoding::FlexibleResult::new(result),
1610 self.tx_id,
1611 0x64327bb27c3d8742,
1612 fidl::encoding::DynamicFlags::FLEXIBLE,
1613 )
1614 }
1615}
1616
1617#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1618pub struct ServiceMarker;
1619
1620#[cfg(target_os = "fuchsia")]
1621impl fidl::endpoints::ServiceMarker for ServiceMarker {
1622 type Proxy = ServiceProxy;
1623 type Request = ServiceRequest;
1624 const SERVICE_NAME: &'static str = "fuchsia.hardware.sensors.Service";
1625}
1626
1627#[cfg(target_os = "fuchsia")]
1630pub enum ServiceRequest {
1631 Driver(DriverRequestStream),
1632}
1633
1634#[cfg(target_os = "fuchsia")]
1635impl fidl::endpoints::ServiceRequest for ServiceRequest {
1636 type Service = ServiceMarker;
1637
1638 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1639 match name {
1640 "driver" => Self::Driver(
1641 <DriverRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1642 ),
1643 _ => panic!("no such member protocol name for service Service"),
1644 }
1645 }
1646
1647 fn member_names() -> &'static [&'static str] {
1648 &["driver"]
1649 }
1650}
1651#[cfg(target_os = "fuchsia")]
1652pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1653
1654#[cfg(target_os = "fuchsia")]
1655impl fidl::endpoints::ServiceProxy for ServiceProxy {
1656 type Service = ServiceMarker;
1657
1658 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1659 Self(opener)
1660 }
1661}
1662
1663#[cfg(target_os = "fuchsia")]
1664impl ServiceProxy {
1665 pub fn connect_to_driver(&self) -> Result<DriverProxy, fidl::Error> {
1666 let (proxy, server_end) = fidl::endpoints::create_proxy::<DriverMarker>();
1667 self.connect_channel_to_driver(server_end)?;
1668 Ok(proxy)
1669 }
1670
1671 pub fn connect_to_driver_sync(&self) -> Result<DriverSynchronousProxy, fidl::Error> {
1674 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DriverMarker>();
1675 self.connect_channel_to_driver(server_end)?;
1676 Ok(proxy)
1677 }
1678
1679 pub fn connect_channel_to_driver(
1682 &self,
1683 server_end: fidl::endpoints::ServerEnd<DriverMarker>,
1684 ) -> Result<(), fidl::Error> {
1685 self.0.open_member("driver", server_end.into_channel())
1686 }
1687
1688 pub fn instance_name(&self) -> &str {
1689 self.0.instance_name()
1690 }
1691}
1692
1693mod internal {
1694 use super::*;
1695}