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