1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_sensors__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DriverMarker;
16
17impl fidl::endpoints::ProtocolMarker for DriverMarker {
18 type Proxy = DriverProxy;
19 type RequestStream = DriverRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DriverSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.hardware.sensors.Driver";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DriverMarker {}
26pub type DriverActivateSensorResult = Result<(), ActivateSensorError>;
27pub type DriverDeactivateSensorResult = Result<(), DeactivateSensorError>;
28pub type DriverConfigureSensorRateResult = Result<(), ConfigureSensorRateError>;
29
30pub trait DriverProxyInterface: Send + Sync {
31 type GetSensorsListResponseFut: std::future::Future<
32 Output = Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error>,
33 > + Send;
34 fn r#get_sensors_list(&self) -> Self::GetSensorsListResponseFut;
35 type ActivateSensorResponseFut: std::future::Future<Output = Result<DriverActivateSensorResult, fidl::Error>>
36 + Send;
37 fn r#activate_sensor(&self, sensor_id: i32) -> Self::ActivateSensorResponseFut;
38 type DeactivateSensorResponseFut: std::future::Future<Output = Result<DriverDeactivateSensorResult, fidl::Error>>
39 + Send;
40 fn r#deactivate_sensor(&self, sensor_id: i32) -> Self::DeactivateSensorResponseFut;
41 type ConfigureSensorRateResponseFut: std::future::Future<Output = Result<DriverConfigureSensorRateResult, fidl::Error>>
42 + Send;
43 fn r#configure_sensor_rate(
44 &self,
45 sensor_id: i32,
46 sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
47 ) -> Self::ConfigureSensorRateResponseFut;
48}
49#[derive(Debug)]
50#[cfg(target_os = "fuchsia")]
51pub struct DriverSynchronousProxy {
52 client: fidl::client::sync::Client,
53}
54
55#[cfg(target_os = "fuchsia")]
56impl fidl::endpoints::SynchronousProxy for DriverSynchronousProxy {
57 type Proxy = DriverProxy;
58 type Protocol = DriverMarker;
59
60 fn from_channel(inner: fidl::Channel) -> Self {
61 Self::new(inner)
62 }
63
64 fn into_channel(self) -> fidl::Channel {
65 self.client.into_channel()
66 }
67
68 fn as_channel(&self) -> &fidl::Channel {
69 self.client.as_channel()
70 }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl DriverSynchronousProxy {
75 pub fn new(channel: fidl::Channel) -> Self {
76 let protocol_name = <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
77 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
78 }
79
80 pub fn into_channel(self) -> fidl::Channel {
81 self.client.into_channel()
82 }
83
84 pub fn wait_for_event(
87 &self,
88 deadline: zx::MonotonicInstant,
89 ) -> Result<DriverEvent, fidl::Error> {
90 DriverEvent::decode(self.client.wait_for_event(deadline)?)
91 }
92
93 pub fn r#get_sensors_list(
95 &self,
96 ___deadline: zx::MonotonicInstant,
97 ) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
98 let _response = self.client.send_query::<
99 fidl::encoding::EmptyPayload,
100 fidl::encoding::FlexibleType<DriverGetSensorsListResponse>,
101 >(
102 (),
103 0x6a30da06929d426b,
104 fidl::encoding::DynamicFlags::FLEXIBLE,
105 ___deadline,
106 )?
107 .into_result::<DriverMarker>("get_sensors_list")?;
108 Ok(_response.sensor_list)
109 }
110
111 pub fn r#activate_sensor(
113 &self,
114 mut sensor_id: i32,
115 ___deadline: zx::MonotonicInstant,
116 ) -> Result<DriverActivateSensorResult, fidl::Error> {
117 let _response =
118 self.client
119 .send_query::<DriverActivateSensorRequest, fidl::encoding::FlexibleResultType<
120 fidl::encoding::EmptyStruct,
121 ActivateSensorError,
122 >>(
123 (sensor_id,),
124 0x6ff16c620f9f3c5b,
125 fidl::encoding::DynamicFlags::FLEXIBLE,
126 ___deadline,
127 )?
128 .into_result::<DriverMarker>("activate_sensor")?;
129 Ok(_response.map(|x| x))
130 }
131
132 pub fn r#deactivate_sensor(
134 &self,
135 mut sensor_id: i32,
136 ___deadline: zx::MonotonicInstant,
137 ) -> Result<DriverDeactivateSensorResult, fidl::Error> {
138 let _response =
139 self.client
140 .send_query::<DriverDeactivateSensorRequest, fidl::encoding::FlexibleResultType<
141 fidl::encoding::EmptyStruct,
142 DeactivateSensorError,
143 >>(
144 (sensor_id,),
145 0x64f003527d44ec55,
146 fidl::encoding::DynamicFlags::FLEXIBLE,
147 ___deadline,
148 )?
149 .into_result::<DriverMarker>("deactivate_sensor")?;
150 Ok(_response.map(|x| x))
151 }
152
153 pub fn r#configure_sensor_rate(
155 &self,
156 mut sensor_id: i32,
157 mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
158 ___deadline: zx::MonotonicInstant,
159 ) -> Result<DriverConfigureSensorRateResult, fidl::Error> {
160 let _response = self
161 .client
162 .send_query::<DriverConfigureSensorRateRequest, fidl::encoding::FlexibleResultType<
163 fidl::encoding::EmptyStruct,
164 ConfigureSensorRateError,
165 >>(
166 (sensor_id, sensor_rate_config),
167 0x78a264bc9c645045,
168 fidl::encoding::DynamicFlags::FLEXIBLE,
169 ___deadline,
170 )?
171 .into_result::<DriverMarker>("configure_sensor_rate")?;
172 Ok(_response.map(|x| x))
173 }
174}
175
176#[cfg(target_os = "fuchsia")]
177impl From<DriverSynchronousProxy> for zx::Handle {
178 fn from(value: DriverSynchronousProxy) -> Self {
179 value.into_channel().into()
180 }
181}
182
183#[cfg(target_os = "fuchsia")]
184impl From<fidl::Channel> for DriverSynchronousProxy {
185 fn from(value: fidl::Channel) -> Self {
186 Self::new(value)
187 }
188}
189
190#[cfg(target_os = "fuchsia")]
191impl fidl::endpoints::FromClient for DriverSynchronousProxy {
192 type Protocol = DriverMarker;
193
194 fn from_client(value: fidl::endpoints::ClientEnd<DriverMarker>) -> Self {
195 Self::new(value.into_channel())
196 }
197}
198
199#[derive(Debug, Clone)]
200pub struct DriverProxy {
201 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
202}
203
204impl fidl::endpoints::Proxy for DriverProxy {
205 type Protocol = DriverMarker;
206
207 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
208 Self::new(inner)
209 }
210
211 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
212 self.client.into_channel().map_err(|client| Self { client })
213 }
214
215 fn as_channel(&self) -> &::fidl::AsyncChannel {
216 self.client.as_channel()
217 }
218}
219
220impl DriverProxy {
221 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
223 let protocol_name = <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
224 Self { client: fidl::client::Client::new(channel, protocol_name) }
225 }
226
227 pub fn take_event_stream(&self) -> DriverEventStream {
233 DriverEventStream { event_receiver: self.client.take_event_receiver() }
234 }
235
236 pub fn r#get_sensors_list(
238 &self,
239 ) -> fidl::client::QueryResponseFut<
240 Vec<fidl_fuchsia_sensors_types::SensorInfo>,
241 fidl::encoding::DefaultFuchsiaResourceDialect,
242 > {
243 DriverProxyInterface::r#get_sensors_list(self)
244 }
245
246 pub fn r#activate_sensor(
248 &self,
249 mut sensor_id: i32,
250 ) -> fidl::client::QueryResponseFut<
251 DriverActivateSensorResult,
252 fidl::encoding::DefaultFuchsiaResourceDialect,
253 > {
254 DriverProxyInterface::r#activate_sensor(self, sensor_id)
255 }
256
257 pub fn r#deactivate_sensor(
259 &self,
260 mut sensor_id: i32,
261 ) -> fidl::client::QueryResponseFut<
262 DriverDeactivateSensorResult,
263 fidl::encoding::DefaultFuchsiaResourceDialect,
264 > {
265 DriverProxyInterface::r#deactivate_sensor(self, sensor_id)
266 }
267
268 pub fn r#configure_sensor_rate(
270 &self,
271 mut sensor_id: i32,
272 mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
273 ) -> fidl::client::QueryResponseFut<
274 DriverConfigureSensorRateResult,
275 fidl::encoding::DefaultFuchsiaResourceDialect,
276 > {
277 DriverProxyInterface::r#configure_sensor_rate(self, sensor_id, sensor_rate_config)
278 }
279}
280
281impl DriverProxyInterface for DriverProxy {
282 type GetSensorsListResponseFut = fidl::client::QueryResponseFut<
283 Vec<fidl_fuchsia_sensors_types::SensorInfo>,
284 fidl::encoding::DefaultFuchsiaResourceDialect,
285 >;
286 fn r#get_sensors_list(&self) -> Self::GetSensorsListResponseFut {
287 fn _decode(
288 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
289 ) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
290 let _response = fidl::client::decode_transaction_body::<
291 fidl::encoding::FlexibleType<DriverGetSensorsListResponse>,
292 fidl::encoding::DefaultFuchsiaResourceDialect,
293 0x6a30da06929d426b,
294 >(_buf?)?
295 .into_result::<DriverMarker>("get_sensors_list")?;
296 Ok(_response.sensor_list)
297 }
298 self.client.send_query_and_decode::<
299 fidl::encoding::EmptyPayload,
300 Vec<fidl_fuchsia_sensors_types::SensorInfo>,
301 >(
302 (),
303 0x6a30da06929d426b,
304 fidl::encoding::DynamicFlags::FLEXIBLE,
305 _decode,
306 )
307 }
308
309 type ActivateSensorResponseFut = fidl::client::QueryResponseFut<
310 DriverActivateSensorResult,
311 fidl::encoding::DefaultFuchsiaResourceDialect,
312 >;
313 fn r#activate_sensor(&self, mut sensor_id: i32) -> Self::ActivateSensorResponseFut {
314 fn _decode(
315 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
316 ) -> Result<DriverActivateSensorResult, fidl::Error> {
317 let _response = fidl::client::decode_transaction_body::<
318 fidl::encoding::FlexibleResultType<
319 fidl::encoding::EmptyStruct,
320 ActivateSensorError,
321 >,
322 fidl::encoding::DefaultFuchsiaResourceDialect,
323 0x6ff16c620f9f3c5b,
324 >(_buf?)?
325 .into_result::<DriverMarker>("activate_sensor")?;
326 Ok(_response.map(|x| x))
327 }
328 self.client
329 .send_query_and_decode::<DriverActivateSensorRequest, DriverActivateSensorResult>(
330 (sensor_id,),
331 0x6ff16c620f9f3c5b,
332 fidl::encoding::DynamicFlags::FLEXIBLE,
333 _decode,
334 )
335 }
336
337 type DeactivateSensorResponseFut = fidl::client::QueryResponseFut<
338 DriverDeactivateSensorResult,
339 fidl::encoding::DefaultFuchsiaResourceDialect,
340 >;
341 fn r#deactivate_sensor(&self, mut sensor_id: i32) -> Self::DeactivateSensorResponseFut {
342 fn _decode(
343 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
344 ) -> Result<DriverDeactivateSensorResult, fidl::Error> {
345 let _response = fidl::client::decode_transaction_body::<
346 fidl::encoding::FlexibleResultType<
347 fidl::encoding::EmptyStruct,
348 DeactivateSensorError,
349 >,
350 fidl::encoding::DefaultFuchsiaResourceDialect,
351 0x64f003527d44ec55,
352 >(_buf?)?
353 .into_result::<DriverMarker>("deactivate_sensor")?;
354 Ok(_response.map(|x| x))
355 }
356 self.client
357 .send_query_and_decode::<DriverDeactivateSensorRequest, DriverDeactivateSensorResult>(
358 (sensor_id,),
359 0x64f003527d44ec55,
360 fidl::encoding::DynamicFlags::FLEXIBLE,
361 _decode,
362 )
363 }
364
365 type ConfigureSensorRateResponseFut = fidl::client::QueryResponseFut<
366 DriverConfigureSensorRateResult,
367 fidl::encoding::DefaultFuchsiaResourceDialect,
368 >;
369 fn r#configure_sensor_rate(
370 &self,
371 mut sensor_id: i32,
372 mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
373 ) -> Self::ConfigureSensorRateResponseFut {
374 fn _decode(
375 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
376 ) -> Result<DriverConfigureSensorRateResult, fidl::Error> {
377 let _response = fidl::client::decode_transaction_body::<
378 fidl::encoding::FlexibleResultType<
379 fidl::encoding::EmptyStruct,
380 ConfigureSensorRateError,
381 >,
382 fidl::encoding::DefaultFuchsiaResourceDialect,
383 0x78a264bc9c645045,
384 >(_buf?)?
385 .into_result::<DriverMarker>("configure_sensor_rate")?;
386 Ok(_response.map(|x| x))
387 }
388 self.client.send_query_and_decode::<
389 DriverConfigureSensorRateRequest,
390 DriverConfigureSensorRateResult,
391 >(
392 (sensor_id, sensor_rate_config,),
393 0x78a264bc9c645045,
394 fidl::encoding::DynamicFlags::FLEXIBLE,
395 _decode,
396 )
397 }
398}
399
400pub struct DriverEventStream {
401 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
402}
403
404impl std::marker::Unpin for DriverEventStream {}
405
406impl futures::stream::FusedStream for DriverEventStream {
407 fn is_terminated(&self) -> bool {
408 self.event_receiver.is_terminated()
409 }
410}
411
412impl futures::Stream for DriverEventStream {
413 type Item = Result<DriverEvent, fidl::Error>;
414
415 fn poll_next(
416 mut self: std::pin::Pin<&mut Self>,
417 cx: &mut std::task::Context<'_>,
418 ) -> std::task::Poll<Option<Self::Item>> {
419 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
420 &mut self.event_receiver,
421 cx
422 )?) {
423 Some(buf) => std::task::Poll::Ready(Some(DriverEvent::decode(buf))),
424 None => std::task::Poll::Ready(None),
425 }
426 }
427}
428
429#[derive(Debug)]
430pub enum DriverEvent {
431 OnSensorEvent {
432 event: fidl_fuchsia_sensors_types::SensorEvent,
433 },
434 #[non_exhaustive]
435 _UnknownEvent {
436 ordinal: u64,
438 },
439}
440
441impl DriverEvent {
442 #[allow(irrefutable_let_patterns)]
443 pub fn into_on_sensor_event(self) -> Option<fidl_fuchsia_sensors_types::SensorEvent> {
444 if let DriverEvent::OnSensorEvent { event } = self { 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 fidl::endpoints::ControlHandle for DriverControlHandle {
749 fn shutdown(&self) {
750 self.inner.shutdown()
751 }
752 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
753 self.inner.shutdown_with_epitaph(status)
754 }
755
756 fn is_closed(&self) -> bool {
757 self.inner.channel().is_closed()
758 }
759 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
760 self.inner.channel().on_closed()
761 }
762
763 #[cfg(target_os = "fuchsia")]
764 fn signal_peer(
765 &self,
766 clear_mask: zx::Signals,
767 set_mask: zx::Signals,
768 ) -> Result<(), zx_status::Status> {
769 use fidl::Peered;
770 self.inner.channel().signal_peer(clear_mask, set_mask)
771 }
772}
773
774impl DriverControlHandle {
775 pub fn send_on_sensor_event(
776 &self,
777 mut event: &fidl_fuchsia_sensors_types::SensorEvent,
778 ) -> Result<(), fidl::Error> {
779 self.inner.send::<DriverOnSensorEventRequest>(
780 (event,),
781 0,
782 0x2aaf0636bb3e1df9,
783 fidl::encoding::DynamicFlags::FLEXIBLE,
784 )
785 }
786}
787
788#[must_use = "FIDL methods require a response to be sent"]
789#[derive(Debug)]
790pub struct DriverGetSensorsListResponder {
791 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
792 tx_id: u32,
793}
794
795impl std::ops::Drop for DriverGetSensorsListResponder {
799 fn drop(&mut self) {
800 self.control_handle.shutdown();
801 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
803 }
804}
805
806impl fidl::endpoints::Responder for DriverGetSensorsListResponder {
807 type ControlHandle = DriverControlHandle;
808
809 fn control_handle(&self) -> &DriverControlHandle {
810 &self.control_handle
811 }
812
813 fn drop_without_shutdown(mut self) {
814 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
816 std::mem::forget(self);
818 }
819}
820
821impl DriverGetSensorsListResponder {
822 pub fn send(
826 self,
827 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
828 ) -> Result<(), fidl::Error> {
829 let _result = self.send_raw(sensor_list);
830 if _result.is_err() {
831 self.control_handle.shutdown();
832 }
833 self.drop_without_shutdown();
834 _result
835 }
836
837 pub fn send_no_shutdown_on_err(
839 self,
840 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
841 ) -> Result<(), fidl::Error> {
842 let _result = self.send_raw(sensor_list);
843 self.drop_without_shutdown();
844 _result
845 }
846
847 fn send_raw(
848 &self,
849 mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
850 ) -> Result<(), fidl::Error> {
851 self.control_handle
852 .inner
853 .send::<fidl::encoding::FlexibleType<DriverGetSensorsListResponse>>(
854 fidl::encoding::Flexible::new((sensor_list,)),
855 self.tx_id,
856 0x6a30da06929d426b,
857 fidl::encoding::DynamicFlags::FLEXIBLE,
858 )
859 }
860}
861
862#[must_use = "FIDL methods require a response to be sent"]
863#[derive(Debug)]
864pub struct DriverActivateSensorResponder {
865 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
866 tx_id: u32,
867}
868
869impl std::ops::Drop for DriverActivateSensorResponder {
873 fn drop(&mut self) {
874 self.control_handle.shutdown();
875 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877 }
878}
879
880impl fidl::endpoints::Responder for DriverActivateSensorResponder {
881 type ControlHandle = DriverControlHandle;
882
883 fn control_handle(&self) -> &DriverControlHandle {
884 &self.control_handle
885 }
886
887 fn drop_without_shutdown(mut self) {
888 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
890 std::mem::forget(self);
892 }
893}
894
895impl DriverActivateSensorResponder {
896 pub fn send(self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
900 let _result = self.send_raw(result);
901 if _result.is_err() {
902 self.control_handle.shutdown();
903 }
904 self.drop_without_shutdown();
905 _result
906 }
907
908 pub fn send_no_shutdown_on_err(
910 self,
911 mut result: Result<(), ActivateSensorError>,
912 ) -> Result<(), fidl::Error> {
913 let _result = self.send_raw(result);
914 self.drop_without_shutdown();
915 _result
916 }
917
918 fn send_raw(&self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
919 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
920 fidl::encoding::EmptyStruct,
921 ActivateSensorError,
922 >>(
923 fidl::encoding::FlexibleResult::new(result),
924 self.tx_id,
925 0x6ff16c620f9f3c5b,
926 fidl::encoding::DynamicFlags::FLEXIBLE,
927 )
928 }
929}
930
931#[must_use = "FIDL methods require a response to be sent"]
932#[derive(Debug)]
933pub struct DriverDeactivateSensorResponder {
934 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
935 tx_id: u32,
936}
937
938impl std::ops::Drop for DriverDeactivateSensorResponder {
942 fn drop(&mut self) {
943 self.control_handle.shutdown();
944 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
946 }
947}
948
949impl fidl::endpoints::Responder for DriverDeactivateSensorResponder {
950 type ControlHandle = DriverControlHandle;
951
952 fn control_handle(&self) -> &DriverControlHandle {
953 &self.control_handle
954 }
955
956 fn drop_without_shutdown(mut self) {
957 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
959 std::mem::forget(self);
961 }
962}
963
964impl DriverDeactivateSensorResponder {
965 pub fn send(self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
969 let _result = self.send_raw(result);
970 if _result.is_err() {
971 self.control_handle.shutdown();
972 }
973 self.drop_without_shutdown();
974 _result
975 }
976
977 pub fn send_no_shutdown_on_err(
979 self,
980 mut result: Result<(), DeactivateSensorError>,
981 ) -> Result<(), fidl::Error> {
982 let _result = self.send_raw(result);
983 self.drop_without_shutdown();
984 _result
985 }
986
987 fn send_raw(&self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
988 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
989 fidl::encoding::EmptyStruct,
990 DeactivateSensorError,
991 >>(
992 fidl::encoding::FlexibleResult::new(result),
993 self.tx_id,
994 0x64f003527d44ec55,
995 fidl::encoding::DynamicFlags::FLEXIBLE,
996 )
997 }
998}
999
1000#[must_use = "FIDL methods require a response to be sent"]
1001#[derive(Debug)]
1002pub struct DriverConfigureSensorRateResponder {
1003 control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
1004 tx_id: u32,
1005}
1006
1007impl std::ops::Drop for DriverConfigureSensorRateResponder {
1011 fn drop(&mut self) {
1012 self.control_handle.shutdown();
1013 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1015 }
1016}
1017
1018impl fidl::endpoints::Responder for DriverConfigureSensorRateResponder {
1019 type ControlHandle = DriverControlHandle;
1020
1021 fn control_handle(&self) -> &DriverControlHandle {
1022 &self.control_handle
1023 }
1024
1025 fn drop_without_shutdown(mut self) {
1026 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1028 std::mem::forget(self);
1030 }
1031}
1032
1033impl DriverConfigureSensorRateResponder {
1034 pub fn send(self, mut result: Result<(), ConfigureSensorRateError>) -> Result<(), fidl::Error> {
1038 let _result = self.send_raw(result);
1039 if _result.is_err() {
1040 self.control_handle.shutdown();
1041 }
1042 self.drop_without_shutdown();
1043 _result
1044 }
1045
1046 pub fn send_no_shutdown_on_err(
1048 self,
1049 mut result: Result<(), ConfigureSensorRateError>,
1050 ) -> Result<(), fidl::Error> {
1051 let _result = self.send_raw(result);
1052 self.drop_without_shutdown();
1053 _result
1054 }
1055
1056 fn send_raw(
1057 &self,
1058 mut result: Result<(), ConfigureSensorRateError>,
1059 ) -> Result<(), fidl::Error> {
1060 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1061 fidl::encoding::EmptyStruct,
1062 ConfigureSensorRateError,
1063 >>(
1064 fidl::encoding::FlexibleResult::new(result),
1065 self.tx_id,
1066 0x78a264bc9c645045,
1067 fidl::encoding::DynamicFlags::FLEXIBLE,
1068 )
1069 }
1070}
1071
1072#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1073pub struct PlaybackMarker;
1074
1075impl fidl::endpoints::ProtocolMarker for PlaybackMarker {
1076 type Proxy = PlaybackProxy;
1077 type RequestStream = PlaybackRequestStream;
1078 #[cfg(target_os = "fuchsia")]
1079 type SynchronousProxy = PlaybackSynchronousProxy;
1080
1081 const DEBUG_NAME: &'static str = "fuchsia.hardware.sensors.Playback";
1082}
1083impl fidl::endpoints::DiscoverableProtocolMarker for PlaybackMarker {}
1084pub type PlaybackConfigurePlaybackResult = Result<(), ConfigurePlaybackError>;
1085
1086pub trait PlaybackProxyInterface: Send + Sync {
1087 type ConfigurePlaybackResponseFut: std::future::Future<Output = Result<PlaybackConfigurePlaybackResult, fidl::Error>>
1088 + Send;
1089 fn r#configure_playback(
1090 &self,
1091 source_config: &PlaybackSourceConfig,
1092 ) -> Self::ConfigurePlaybackResponseFut;
1093}
1094#[derive(Debug)]
1095#[cfg(target_os = "fuchsia")]
1096pub struct PlaybackSynchronousProxy {
1097 client: fidl::client::sync::Client,
1098}
1099
1100#[cfg(target_os = "fuchsia")]
1101impl fidl::endpoints::SynchronousProxy for PlaybackSynchronousProxy {
1102 type Proxy = PlaybackProxy;
1103 type Protocol = PlaybackMarker;
1104
1105 fn from_channel(inner: fidl::Channel) -> Self {
1106 Self::new(inner)
1107 }
1108
1109 fn into_channel(self) -> fidl::Channel {
1110 self.client.into_channel()
1111 }
1112
1113 fn as_channel(&self) -> &fidl::Channel {
1114 self.client.as_channel()
1115 }
1116}
1117
1118#[cfg(target_os = "fuchsia")]
1119impl PlaybackSynchronousProxy {
1120 pub fn new(channel: fidl::Channel) -> Self {
1121 let protocol_name = <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1122 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1123 }
1124
1125 pub fn into_channel(self) -> fidl::Channel {
1126 self.client.into_channel()
1127 }
1128
1129 pub fn wait_for_event(
1132 &self,
1133 deadline: zx::MonotonicInstant,
1134 ) -> Result<PlaybackEvent, fidl::Error> {
1135 PlaybackEvent::decode(self.client.wait_for_event(deadline)?)
1136 }
1137
1138 pub fn r#configure_playback(
1139 &self,
1140 mut source_config: &PlaybackSourceConfig,
1141 ___deadline: zx::MonotonicInstant,
1142 ) -> Result<PlaybackConfigurePlaybackResult, fidl::Error> {
1143 let _response =
1144 self.client
1145 .send_query::<PlaybackConfigurePlaybackRequest, fidl::encoding::FlexibleResultType<
1146 fidl::encoding::EmptyStruct,
1147 ConfigurePlaybackError,
1148 >>(
1149 (source_config,),
1150 0x64327bb27c3d8742,
1151 fidl::encoding::DynamicFlags::FLEXIBLE,
1152 ___deadline,
1153 )?
1154 .into_result::<PlaybackMarker>("configure_playback")?;
1155 Ok(_response.map(|x| x))
1156 }
1157}
1158
1159#[cfg(target_os = "fuchsia")]
1160impl From<PlaybackSynchronousProxy> for zx::Handle {
1161 fn from(value: PlaybackSynchronousProxy) -> Self {
1162 value.into_channel().into()
1163 }
1164}
1165
1166#[cfg(target_os = "fuchsia")]
1167impl From<fidl::Channel> for PlaybackSynchronousProxy {
1168 fn from(value: fidl::Channel) -> Self {
1169 Self::new(value)
1170 }
1171}
1172
1173#[cfg(target_os = "fuchsia")]
1174impl fidl::endpoints::FromClient for PlaybackSynchronousProxy {
1175 type Protocol = PlaybackMarker;
1176
1177 fn from_client(value: fidl::endpoints::ClientEnd<PlaybackMarker>) -> Self {
1178 Self::new(value.into_channel())
1179 }
1180}
1181
1182#[derive(Debug, Clone)]
1183pub struct PlaybackProxy {
1184 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1185}
1186
1187impl fidl::endpoints::Proxy for PlaybackProxy {
1188 type Protocol = PlaybackMarker;
1189
1190 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1191 Self::new(inner)
1192 }
1193
1194 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1195 self.client.into_channel().map_err(|client| Self { client })
1196 }
1197
1198 fn as_channel(&self) -> &::fidl::AsyncChannel {
1199 self.client.as_channel()
1200 }
1201}
1202
1203impl PlaybackProxy {
1204 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1206 let protocol_name = <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1207 Self { client: fidl::client::Client::new(channel, protocol_name) }
1208 }
1209
1210 pub fn take_event_stream(&self) -> PlaybackEventStream {
1216 PlaybackEventStream { event_receiver: self.client.take_event_receiver() }
1217 }
1218
1219 pub fn r#configure_playback(
1220 &self,
1221 mut source_config: &PlaybackSourceConfig,
1222 ) -> fidl::client::QueryResponseFut<
1223 PlaybackConfigurePlaybackResult,
1224 fidl::encoding::DefaultFuchsiaResourceDialect,
1225 > {
1226 PlaybackProxyInterface::r#configure_playback(self, source_config)
1227 }
1228}
1229
1230impl PlaybackProxyInterface for PlaybackProxy {
1231 type ConfigurePlaybackResponseFut = fidl::client::QueryResponseFut<
1232 PlaybackConfigurePlaybackResult,
1233 fidl::encoding::DefaultFuchsiaResourceDialect,
1234 >;
1235 fn r#configure_playback(
1236 &self,
1237 mut source_config: &PlaybackSourceConfig,
1238 ) -> Self::ConfigurePlaybackResponseFut {
1239 fn _decode(
1240 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1241 ) -> Result<PlaybackConfigurePlaybackResult, fidl::Error> {
1242 let _response = fidl::client::decode_transaction_body::<
1243 fidl::encoding::FlexibleResultType<
1244 fidl::encoding::EmptyStruct,
1245 ConfigurePlaybackError,
1246 >,
1247 fidl::encoding::DefaultFuchsiaResourceDialect,
1248 0x64327bb27c3d8742,
1249 >(_buf?)?
1250 .into_result::<PlaybackMarker>("configure_playback")?;
1251 Ok(_response.map(|x| x))
1252 }
1253 self.client.send_query_and_decode::<
1254 PlaybackConfigurePlaybackRequest,
1255 PlaybackConfigurePlaybackResult,
1256 >(
1257 (source_config,),
1258 0x64327bb27c3d8742,
1259 fidl::encoding::DynamicFlags::FLEXIBLE,
1260 _decode,
1261 )
1262 }
1263}
1264
1265pub struct PlaybackEventStream {
1266 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1267}
1268
1269impl std::marker::Unpin for PlaybackEventStream {}
1270
1271impl futures::stream::FusedStream for PlaybackEventStream {
1272 fn is_terminated(&self) -> bool {
1273 self.event_receiver.is_terminated()
1274 }
1275}
1276
1277impl futures::Stream for PlaybackEventStream {
1278 type Item = Result<PlaybackEvent, fidl::Error>;
1279
1280 fn poll_next(
1281 mut self: std::pin::Pin<&mut Self>,
1282 cx: &mut std::task::Context<'_>,
1283 ) -> std::task::Poll<Option<Self::Item>> {
1284 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1285 &mut self.event_receiver,
1286 cx
1287 )?) {
1288 Some(buf) => std::task::Poll::Ready(Some(PlaybackEvent::decode(buf))),
1289 None => std::task::Poll::Ready(None),
1290 }
1291 }
1292}
1293
1294#[derive(Debug)]
1295pub enum PlaybackEvent {
1296 #[non_exhaustive]
1297 _UnknownEvent {
1298 ordinal: u64,
1300 },
1301}
1302
1303impl PlaybackEvent {
1304 fn decode(
1306 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1307 ) -> Result<PlaybackEvent, fidl::Error> {
1308 let (bytes, _handles) = buf.split_mut();
1309 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1310 debug_assert_eq!(tx_header.tx_id, 0);
1311 match tx_header.ordinal {
1312 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1313 Ok(PlaybackEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1314 }
1315 _ => Err(fidl::Error::UnknownOrdinal {
1316 ordinal: tx_header.ordinal,
1317 protocol_name: <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1318 }),
1319 }
1320 }
1321}
1322
1323pub struct PlaybackRequestStream {
1325 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1326 is_terminated: bool,
1327}
1328
1329impl std::marker::Unpin for PlaybackRequestStream {}
1330
1331impl futures::stream::FusedStream for PlaybackRequestStream {
1332 fn is_terminated(&self) -> bool {
1333 self.is_terminated
1334 }
1335}
1336
1337impl fidl::endpoints::RequestStream for PlaybackRequestStream {
1338 type Protocol = PlaybackMarker;
1339 type ControlHandle = PlaybackControlHandle;
1340
1341 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1342 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1343 }
1344
1345 fn control_handle(&self) -> Self::ControlHandle {
1346 PlaybackControlHandle { inner: self.inner.clone() }
1347 }
1348
1349 fn into_inner(
1350 self,
1351 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1352 {
1353 (self.inner, self.is_terminated)
1354 }
1355
1356 fn from_inner(
1357 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1358 is_terminated: bool,
1359 ) -> Self {
1360 Self { inner, is_terminated }
1361 }
1362}
1363
1364impl futures::Stream for PlaybackRequestStream {
1365 type Item = Result<PlaybackRequest, fidl::Error>;
1366
1367 fn poll_next(
1368 mut self: std::pin::Pin<&mut Self>,
1369 cx: &mut std::task::Context<'_>,
1370 ) -> std::task::Poll<Option<Self::Item>> {
1371 let this = &mut *self;
1372 if this.inner.check_shutdown(cx) {
1373 this.is_terminated = true;
1374 return std::task::Poll::Ready(None);
1375 }
1376 if this.is_terminated {
1377 panic!("polled PlaybackRequestStream after completion");
1378 }
1379 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1380 |bytes, handles| {
1381 match this.inner.channel().read_etc(cx, bytes, handles) {
1382 std::task::Poll::Ready(Ok(())) => {}
1383 std::task::Poll::Pending => return std::task::Poll::Pending,
1384 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1385 this.is_terminated = true;
1386 return std::task::Poll::Ready(None);
1387 }
1388 std::task::Poll::Ready(Err(e)) => {
1389 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1390 e.into(),
1391 ))));
1392 }
1393 }
1394
1395 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1397
1398 std::task::Poll::Ready(Some(match header.ordinal {
1399 0x64327bb27c3d8742 => {
1400 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1401 let mut req = fidl::new_empty!(
1402 PlaybackConfigurePlaybackRequest,
1403 fidl::encoding::DefaultFuchsiaResourceDialect
1404 );
1405 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlaybackConfigurePlaybackRequest>(&header, _body_bytes, handles, &mut req)?;
1406 let control_handle = PlaybackControlHandle { inner: this.inner.clone() };
1407 Ok(PlaybackRequest::ConfigurePlayback {
1408 source_config: req.source_config,
1409
1410 responder: PlaybackConfigurePlaybackResponder {
1411 control_handle: std::mem::ManuallyDrop::new(control_handle),
1412 tx_id: header.tx_id,
1413 },
1414 })
1415 }
1416 _ if header.tx_id == 0
1417 && header
1418 .dynamic_flags()
1419 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1420 {
1421 Ok(PlaybackRequest::_UnknownMethod {
1422 ordinal: header.ordinal,
1423 control_handle: PlaybackControlHandle { inner: this.inner.clone() },
1424 method_type: fidl::MethodType::OneWay,
1425 })
1426 }
1427 _ if header
1428 .dynamic_flags()
1429 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1430 {
1431 this.inner.send_framework_err(
1432 fidl::encoding::FrameworkErr::UnknownMethod,
1433 header.tx_id,
1434 header.ordinal,
1435 header.dynamic_flags(),
1436 (bytes, handles),
1437 )?;
1438 Ok(PlaybackRequest::_UnknownMethod {
1439 ordinal: header.ordinal,
1440 control_handle: PlaybackControlHandle { inner: this.inner.clone() },
1441 method_type: fidl::MethodType::TwoWay,
1442 })
1443 }
1444 _ => Err(fidl::Error::UnknownOrdinal {
1445 ordinal: header.ordinal,
1446 protocol_name:
1447 <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1448 }),
1449 }))
1450 },
1451 )
1452 }
1453}
1454
1455#[derive(Debug)]
1461pub enum PlaybackRequest {
1462 ConfigurePlayback {
1463 source_config: PlaybackSourceConfig,
1464 responder: PlaybackConfigurePlaybackResponder,
1465 },
1466 #[non_exhaustive]
1468 _UnknownMethod {
1469 ordinal: u64,
1471 control_handle: PlaybackControlHandle,
1472 method_type: fidl::MethodType,
1473 },
1474}
1475
1476impl PlaybackRequest {
1477 #[allow(irrefutable_let_patterns)]
1478 pub fn into_configure_playback(
1479 self,
1480 ) -> Option<(PlaybackSourceConfig, PlaybackConfigurePlaybackResponder)> {
1481 if let PlaybackRequest::ConfigurePlayback { source_config, responder } = self {
1482 Some((source_config, responder))
1483 } else {
1484 None
1485 }
1486 }
1487
1488 pub fn method_name(&self) -> &'static str {
1490 match *self {
1491 PlaybackRequest::ConfigurePlayback { .. } => "configure_playback",
1492 PlaybackRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1493 "unknown one-way method"
1494 }
1495 PlaybackRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1496 "unknown two-way method"
1497 }
1498 }
1499 }
1500}
1501
1502#[derive(Debug, Clone)]
1503pub struct PlaybackControlHandle {
1504 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1505}
1506
1507impl fidl::endpoints::ControlHandle for PlaybackControlHandle {
1508 fn shutdown(&self) {
1509 self.inner.shutdown()
1510 }
1511 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1512 self.inner.shutdown_with_epitaph(status)
1513 }
1514
1515 fn is_closed(&self) -> bool {
1516 self.inner.channel().is_closed()
1517 }
1518 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1519 self.inner.channel().on_closed()
1520 }
1521
1522 #[cfg(target_os = "fuchsia")]
1523 fn signal_peer(
1524 &self,
1525 clear_mask: zx::Signals,
1526 set_mask: zx::Signals,
1527 ) -> Result<(), zx_status::Status> {
1528 use fidl::Peered;
1529 self.inner.channel().signal_peer(clear_mask, set_mask)
1530 }
1531}
1532
1533impl PlaybackControlHandle {}
1534
1535#[must_use = "FIDL methods require a response to be sent"]
1536#[derive(Debug)]
1537pub struct PlaybackConfigurePlaybackResponder {
1538 control_handle: std::mem::ManuallyDrop<PlaybackControlHandle>,
1539 tx_id: u32,
1540}
1541
1542impl std::ops::Drop for PlaybackConfigurePlaybackResponder {
1546 fn drop(&mut self) {
1547 self.control_handle.shutdown();
1548 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1550 }
1551}
1552
1553impl fidl::endpoints::Responder for PlaybackConfigurePlaybackResponder {
1554 type ControlHandle = PlaybackControlHandle;
1555
1556 fn control_handle(&self) -> &PlaybackControlHandle {
1557 &self.control_handle
1558 }
1559
1560 fn drop_without_shutdown(mut self) {
1561 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1563 std::mem::forget(self);
1565 }
1566}
1567
1568impl PlaybackConfigurePlaybackResponder {
1569 pub fn send(self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
1573 let _result = self.send_raw(result);
1574 if _result.is_err() {
1575 self.control_handle.shutdown();
1576 }
1577 self.drop_without_shutdown();
1578 _result
1579 }
1580
1581 pub fn send_no_shutdown_on_err(
1583 self,
1584 mut result: Result<(), ConfigurePlaybackError>,
1585 ) -> Result<(), fidl::Error> {
1586 let _result = self.send_raw(result);
1587 self.drop_without_shutdown();
1588 _result
1589 }
1590
1591 fn send_raw(&self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
1592 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1593 fidl::encoding::EmptyStruct,
1594 ConfigurePlaybackError,
1595 >>(
1596 fidl::encoding::FlexibleResult::new(result),
1597 self.tx_id,
1598 0x64327bb27c3d8742,
1599 fidl::encoding::DynamicFlags::FLEXIBLE,
1600 )
1601 }
1602}
1603
1604#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1605pub struct ServiceMarker;
1606
1607#[cfg(target_os = "fuchsia")]
1608impl fidl::endpoints::ServiceMarker for ServiceMarker {
1609 type Proxy = ServiceProxy;
1610 type Request = ServiceRequest;
1611 const SERVICE_NAME: &'static str = "fuchsia.hardware.sensors.Service";
1612}
1613
1614#[cfg(target_os = "fuchsia")]
1617pub enum ServiceRequest {
1618 Driver(DriverRequestStream),
1619}
1620
1621#[cfg(target_os = "fuchsia")]
1622impl fidl::endpoints::ServiceRequest for ServiceRequest {
1623 type Service = ServiceMarker;
1624
1625 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1626 match name {
1627 "driver" => Self::Driver(
1628 <DriverRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1629 ),
1630 _ => panic!("no such member protocol name for service Service"),
1631 }
1632 }
1633
1634 fn member_names() -> &'static [&'static str] {
1635 &["driver"]
1636 }
1637}
1638#[cfg(target_os = "fuchsia")]
1639pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1640
1641#[cfg(target_os = "fuchsia")]
1642impl fidl::endpoints::ServiceProxy for ServiceProxy {
1643 type Service = ServiceMarker;
1644
1645 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1646 Self(opener)
1647 }
1648}
1649
1650#[cfg(target_os = "fuchsia")]
1651impl ServiceProxy {
1652 pub fn connect_to_driver(&self) -> Result<DriverProxy, fidl::Error> {
1653 let (proxy, server_end) = fidl::endpoints::create_proxy::<DriverMarker>();
1654 self.connect_channel_to_driver(server_end)?;
1655 Ok(proxy)
1656 }
1657
1658 pub fn connect_to_driver_sync(&self) -> Result<DriverSynchronousProxy, fidl::Error> {
1661 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DriverMarker>();
1662 self.connect_channel_to_driver(server_end)?;
1663 Ok(proxy)
1664 }
1665
1666 pub fn connect_channel_to_driver(
1669 &self,
1670 server_end: fidl::endpoints::ServerEnd<DriverMarker>,
1671 ) -> Result<(), fidl::Error> {
1672 self.0.open_member("driver", server_end.into_channel())
1673 }
1674
1675 pub fn instance_name(&self) -> &str {
1676 self.0.instance_name()
1677 }
1678}
1679
1680mod internal {
1681 use super::*;
1682}