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_virtualaudio_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ControlAddDeviceRequest {
16 pub config: Configuration,
17 pub server: fidl::endpoints::ServerEnd<DeviceMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ControlAddDeviceRequest {}
21
22#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
23pub struct DeviceOnBufferCreatedRequest {
24 pub ring_buffer: fidl::Vmo,
25 pub num_ring_buffer_frames: u32,
26 pub notifications_per_ring: u32,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30 for DeviceOnBufferCreatedRequest
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct DeviceGetBufferResponse {
36 pub ring_buffer: fidl::Vmo,
37 pub num_ring_buffer_frames: u32,
38 pub notifications_per_ring: u32,
39}
40
41impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetBufferResponse {}
42
43#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
44pub struct ControlMarker;
45
46impl fidl::endpoints::ProtocolMarker for ControlMarker {
47 type Proxy = ControlProxy;
48 type RequestStream = ControlRequestStream;
49 #[cfg(target_os = "fuchsia")]
50 type SynchronousProxy = ControlSynchronousProxy;
51
52 const DEBUG_NAME: &'static str = "(anonymous) Control";
53}
54pub type ControlGetDefaultConfigurationResult = Result<Configuration, Error>;
55pub type ControlAddDeviceResult = Result<(), Error>;
56
57pub trait ControlProxyInterface: Send + Sync {
58 type GetDefaultConfigurationResponseFut: std::future::Future<Output = Result<ControlGetDefaultConfigurationResult, fidl::Error>>
59 + Send;
60 fn r#get_default_configuration(
61 &self,
62 type_: DeviceType,
63 direction: &Direction,
64 ) -> Self::GetDefaultConfigurationResponseFut;
65 type AddDeviceResponseFut: std::future::Future<Output = Result<ControlAddDeviceResult, fidl::Error>>
66 + Send;
67 fn r#add_device(
68 &self,
69 config: &Configuration,
70 server: fidl::endpoints::ServerEnd<DeviceMarker>,
71 ) -> Self::AddDeviceResponseFut;
72 type GetNumDevicesResponseFut: std::future::Future<Output = Result<(u32, u32, u32), fidl::Error>>
73 + Send;
74 fn r#get_num_devices(&self) -> Self::GetNumDevicesResponseFut;
75 type RemoveAllResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
76 fn r#remove_all(&self) -> Self::RemoveAllResponseFut;
77}
78#[derive(Debug)]
79#[cfg(target_os = "fuchsia")]
80pub struct ControlSynchronousProxy {
81 client: fidl::client::sync::Client,
82}
83
84#[cfg(target_os = "fuchsia")]
85impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
86 type Proxy = ControlProxy;
87 type Protocol = ControlMarker;
88
89 fn from_channel(inner: fidl::Channel) -> Self {
90 Self::new(inner)
91 }
92
93 fn into_channel(self) -> fidl::Channel {
94 self.client.into_channel()
95 }
96
97 fn as_channel(&self) -> &fidl::Channel {
98 self.client.as_channel()
99 }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl ControlSynchronousProxy {
104 pub fn new(channel: fidl::Channel) -> Self {
105 let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
106 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
107 }
108
109 pub fn into_channel(self) -> fidl::Channel {
110 self.client.into_channel()
111 }
112
113 pub fn wait_for_event(
116 &self,
117 deadline: zx::MonotonicInstant,
118 ) -> Result<ControlEvent, fidl::Error> {
119 ControlEvent::decode(self.client.wait_for_event(deadline)?)
120 }
121
122 pub fn r#get_default_configuration(
124 &self,
125 mut type_: DeviceType,
126 mut direction: &Direction,
127 ___deadline: zx::MonotonicInstant,
128 ) -> Result<ControlGetDefaultConfigurationResult, fidl::Error> {
129 let _response = self.client.send_query::<
130 ControlGetDefaultConfigurationRequest,
131 fidl::encoding::ResultType<ControlGetDefaultConfigurationResponse, Error>,
132 >(
133 (type_, direction,),
134 0x18fbd1298daa19e9,
135 fidl::encoding::DynamicFlags::empty(),
136 ___deadline,
137 )?;
138 Ok(_response.map(|x| x.config))
139 }
140
141 pub fn r#add_device(
144 &self,
145 mut config: &Configuration,
146 mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
147 ___deadline: zx::MonotonicInstant,
148 ) -> Result<ControlAddDeviceResult, fidl::Error> {
149 let _response = self.client.send_query::<
150 ControlAddDeviceRequest,
151 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
152 >(
153 (config, server,),
154 0x6b5fff2f3ed7ce9,
155 fidl::encoding::DynamicFlags::empty(),
156 ___deadline,
157 )?;
158 Ok(_response.map(|x| x))
159 }
160
161 pub fn r#get_num_devices(
164 &self,
165 ___deadline: zx::MonotonicInstant,
166 ) -> Result<(u32, u32, u32), fidl::Error> {
167 let _response =
168 self.client.send_query::<fidl::encoding::EmptyPayload, ControlGetNumDevicesResponse>(
169 (),
170 0x256704ce2f8097af,
171 fidl::encoding::DynamicFlags::empty(),
172 ___deadline,
173 )?;
174 Ok((
175 _response.num_input_devices,
176 _response.num_output_devices,
177 _response.num_unspecified_direction_devices,
178 ))
179 }
180
181 pub fn r#remove_all(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
183 let _response =
184 self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
185 (),
186 0x7904287969087c4b,
187 fidl::encoding::DynamicFlags::empty(),
188 ___deadline,
189 )?;
190 Ok(_response)
191 }
192}
193
194#[cfg(target_os = "fuchsia")]
195impl From<ControlSynchronousProxy> for zx::Handle {
196 fn from(value: ControlSynchronousProxy) -> Self {
197 value.into_channel().into()
198 }
199}
200
201#[cfg(target_os = "fuchsia")]
202impl From<fidl::Channel> for ControlSynchronousProxy {
203 fn from(value: fidl::Channel) -> Self {
204 Self::new(value)
205 }
206}
207
208#[derive(Debug, Clone)]
209pub struct ControlProxy {
210 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
211}
212
213impl fidl::endpoints::Proxy for ControlProxy {
214 type Protocol = ControlMarker;
215
216 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
217 Self::new(inner)
218 }
219
220 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
221 self.client.into_channel().map_err(|client| Self { client })
222 }
223
224 fn as_channel(&self) -> &::fidl::AsyncChannel {
225 self.client.as_channel()
226 }
227}
228
229impl ControlProxy {
230 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
232 let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
233 Self { client: fidl::client::Client::new(channel, protocol_name) }
234 }
235
236 pub fn take_event_stream(&self) -> ControlEventStream {
242 ControlEventStream { event_receiver: self.client.take_event_receiver() }
243 }
244
245 pub fn r#get_default_configuration(
247 &self,
248 mut type_: DeviceType,
249 mut direction: &Direction,
250 ) -> fidl::client::QueryResponseFut<
251 ControlGetDefaultConfigurationResult,
252 fidl::encoding::DefaultFuchsiaResourceDialect,
253 > {
254 ControlProxyInterface::r#get_default_configuration(self, type_, direction)
255 }
256
257 pub fn r#add_device(
260 &self,
261 mut config: &Configuration,
262 mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
263 ) -> fidl::client::QueryResponseFut<
264 ControlAddDeviceResult,
265 fidl::encoding::DefaultFuchsiaResourceDialect,
266 > {
267 ControlProxyInterface::r#add_device(self, config, server)
268 }
269
270 pub fn r#get_num_devices(
273 &self,
274 ) -> fidl::client::QueryResponseFut<
275 (u32, u32, u32),
276 fidl::encoding::DefaultFuchsiaResourceDialect,
277 > {
278 ControlProxyInterface::r#get_num_devices(self)
279 }
280
281 pub fn r#remove_all(
283 &self,
284 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
285 ControlProxyInterface::r#remove_all(self)
286 }
287}
288
289impl ControlProxyInterface for ControlProxy {
290 type GetDefaultConfigurationResponseFut = fidl::client::QueryResponseFut<
291 ControlGetDefaultConfigurationResult,
292 fidl::encoding::DefaultFuchsiaResourceDialect,
293 >;
294 fn r#get_default_configuration(
295 &self,
296 mut type_: DeviceType,
297 mut direction: &Direction,
298 ) -> Self::GetDefaultConfigurationResponseFut {
299 fn _decode(
300 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
301 ) -> Result<ControlGetDefaultConfigurationResult, fidl::Error> {
302 let _response = fidl::client::decode_transaction_body::<
303 fidl::encoding::ResultType<ControlGetDefaultConfigurationResponse, Error>,
304 fidl::encoding::DefaultFuchsiaResourceDialect,
305 0x18fbd1298daa19e9,
306 >(_buf?)?;
307 Ok(_response.map(|x| x.config))
308 }
309 self.client.send_query_and_decode::<
310 ControlGetDefaultConfigurationRequest,
311 ControlGetDefaultConfigurationResult,
312 >(
313 (type_, direction,),
314 0x18fbd1298daa19e9,
315 fidl::encoding::DynamicFlags::empty(),
316 _decode,
317 )
318 }
319
320 type AddDeviceResponseFut = fidl::client::QueryResponseFut<
321 ControlAddDeviceResult,
322 fidl::encoding::DefaultFuchsiaResourceDialect,
323 >;
324 fn r#add_device(
325 &self,
326 mut config: &Configuration,
327 mut server: fidl::endpoints::ServerEnd<DeviceMarker>,
328 ) -> Self::AddDeviceResponseFut {
329 fn _decode(
330 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
331 ) -> Result<ControlAddDeviceResult, fidl::Error> {
332 let _response = fidl::client::decode_transaction_body::<
333 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
334 fidl::encoding::DefaultFuchsiaResourceDialect,
335 0x6b5fff2f3ed7ce9,
336 >(_buf?)?;
337 Ok(_response.map(|x| x))
338 }
339 self.client.send_query_and_decode::<ControlAddDeviceRequest, ControlAddDeviceResult>(
340 (config, server),
341 0x6b5fff2f3ed7ce9,
342 fidl::encoding::DynamicFlags::empty(),
343 _decode,
344 )
345 }
346
347 type GetNumDevicesResponseFut = fidl::client::QueryResponseFut<
348 (u32, u32, u32),
349 fidl::encoding::DefaultFuchsiaResourceDialect,
350 >;
351 fn r#get_num_devices(&self) -> Self::GetNumDevicesResponseFut {
352 fn _decode(
353 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
354 ) -> Result<(u32, u32, u32), fidl::Error> {
355 let _response = fidl::client::decode_transaction_body::<
356 ControlGetNumDevicesResponse,
357 fidl::encoding::DefaultFuchsiaResourceDialect,
358 0x256704ce2f8097af,
359 >(_buf?)?;
360 Ok((
361 _response.num_input_devices,
362 _response.num_output_devices,
363 _response.num_unspecified_direction_devices,
364 ))
365 }
366 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (u32, u32, u32)>(
367 (),
368 0x256704ce2f8097af,
369 fidl::encoding::DynamicFlags::empty(),
370 _decode,
371 )
372 }
373
374 type RemoveAllResponseFut =
375 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
376 fn r#remove_all(&self) -> Self::RemoveAllResponseFut {
377 fn _decode(
378 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
379 ) -> Result<(), fidl::Error> {
380 let _response = fidl::client::decode_transaction_body::<
381 fidl::encoding::EmptyPayload,
382 fidl::encoding::DefaultFuchsiaResourceDialect,
383 0x7904287969087c4b,
384 >(_buf?)?;
385 Ok(_response)
386 }
387 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
388 (),
389 0x7904287969087c4b,
390 fidl::encoding::DynamicFlags::empty(),
391 _decode,
392 )
393 }
394}
395
396pub struct ControlEventStream {
397 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
398}
399
400impl std::marker::Unpin for ControlEventStream {}
401
402impl futures::stream::FusedStream for ControlEventStream {
403 fn is_terminated(&self) -> bool {
404 self.event_receiver.is_terminated()
405 }
406}
407
408impl futures::Stream for ControlEventStream {
409 type Item = Result<ControlEvent, fidl::Error>;
410
411 fn poll_next(
412 mut self: std::pin::Pin<&mut Self>,
413 cx: &mut std::task::Context<'_>,
414 ) -> std::task::Poll<Option<Self::Item>> {
415 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
416 &mut self.event_receiver,
417 cx
418 )?) {
419 Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
420 None => std::task::Poll::Ready(None),
421 }
422 }
423}
424
425#[derive(Debug)]
426pub enum ControlEvent {}
427
428impl ControlEvent {
429 fn decode(
431 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
432 ) -> Result<ControlEvent, fidl::Error> {
433 let (bytes, _handles) = buf.split_mut();
434 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
435 debug_assert_eq!(tx_header.tx_id, 0);
436 match tx_header.ordinal {
437 _ => Err(fidl::Error::UnknownOrdinal {
438 ordinal: tx_header.ordinal,
439 protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
440 }),
441 }
442 }
443}
444
445pub struct ControlRequestStream {
447 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
448 is_terminated: bool,
449}
450
451impl std::marker::Unpin for ControlRequestStream {}
452
453impl futures::stream::FusedStream for ControlRequestStream {
454 fn is_terminated(&self) -> bool {
455 self.is_terminated
456 }
457}
458
459impl fidl::endpoints::RequestStream for ControlRequestStream {
460 type Protocol = ControlMarker;
461 type ControlHandle = ControlControlHandle;
462
463 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
464 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
465 }
466
467 fn control_handle(&self) -> Self::ControlHandle {
468 ControlControlHandle { inner: self.inner.clone() }
469 }
470
471 fn into_inner(
472 self,
473 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
474 {
475 (self.inner, self.is_terminated)
476 }
477
478 fn from_inner(
479 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
480 is_terminated: bool,
481 ) -> Self {
482 Self { inner, is_terminated }
483 }
484}
485
486impl futures::Stream for ControlRequestStream {
487 type Item = Result<ControlRequest, fidl::Error>;
488
489 fn poll_next(
490 mut self: std::pin::Pin<&mut Self>,
491 cx: &mut std::task::Context<'_>,
492 ) -> std::task::Poll<Option<Self::Item>> {
493 let this = &mut *self;
494 if this.inner.check_shutdown(cx) {
495 this.is_terminated = true;
496 return std::task::Poll::Ready(None);
497 }
498 if this.is_terminated {
499 panic!("polled ControlRequestStream after completion");
500 }
501 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
502 |bytes, handles| {
503 match this.inner.channel().read_etc(cx, bytes, handles) {
504 std::task::Poll::Ready(Ok(())) => {}
505 std::task::Poll::Pending => return std::task::Poll::Pending,
506 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
507 this.is_terminated = true;
508 return std::task::Poll::Ready(None);
509 }
510 std::task::Poll::Ready(Err(e)) => {
511 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
512 e.into(),
513 ))))
514 }
515 }
516
517 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
519
520 std::task::Poll::Ready(Some(match header.ordinal {
521 0x18fbd1298daa19e9 => {
522 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
523 let mut req = fidl::new_empty!(
524 ControlGetDefaultConfigurationRequest,
525 fidl::encoding::DefaultFuchsiaResourceDialect
526 );
527 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlGetDefaultConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
528 let control_handle = ControlControlHandle { inner: this.inner.clone() };
529 Ok(ControlRequest::GetDefaultConfiguration {
530 type_: req.type_,
531 direction: req.direction,
532
533 responder: ControlGetDefaultConfigurationResponder {
534 control_handle: std::mem::ManuallyDrop::new(control_handle),
535 tx_id: header.tx_id,
536 },
537 })
538 }
539 0x6b5fff2f3ed7ce9 => {
540 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
541 let mut req = fidl::new_empty!(
542 ControlAddDeviceRequest,
543 fidl::encoding::DefaultFuchsiaResourceDialect
544 );
545 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlAddDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
546 let control_handle = ControlControlHandle { inner: this.inner.clone() };
547 Ok(ControlRequest::AddDevice {
548 config: req.config,
549 server: req.server,
550
551 responder: ControlAddDeviceResponder {
552 control_handle: std::mem::ManuallyDrop::new(control_handle),
553 tx_id: header.tx_id,
554 },
555 })
556 }
557 0x256704ce2f8097af => {
558 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
559 let mut req = fidl::new_empty!(
560 fidl::encoding::EmptyPayload,
561 fidl::encoding::DefaultFuchsiaResourceDialect
562 );
563 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
564 let control_handle = ControlControlHandle { inner: this.inner.clone() };
565 Ok(ControlRequest::GetNumDevices {
566 responder: ControlGetNumDevicesResponder {
567 control_handle: std::mem::ManuallyDrop::new(control_handle),
568 tx_id: header.tx_id,
569 },
570 })
571 }
572 0x7904287969087c4b => {
573 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
574 let mut req = fidl::new_empty!(
575 fidl::encoding::EmptyPayload,
576 fidl::encoding::DefaultFuchsiaResourceDialect
577 );
578 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
579 let control_handle = ControlControlHandle { inner: this.inner.clone() };
580 Ok(ControlRequest::RemoveAll {
581 responder: ControlRemoveAllResponder {
582 control_handle: std::mem::ManuallyDrop::new(control_handle),
583 tx_id: header.tx_id,
584 },
585 })
586 }
587 _ => Err(fidl::Error::UnknownOrdinal {
588 ordinal: header.ordinal,
589 protocol_name:
590 <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
591 }),
592 }))
593 },
594 )
595 }
596}
597
598#[derive(Debug)]
602pub enum ControlRequest {
603 GetDefaultConfiguration {
605 type_: DeviceType,
606 direction: Direction,
607 responder: ControlGetDefaultConfigurationResponder,
608 },
609 AddDevice {
612 config: Configuration,
613 server: fidl::endpoints::ServerEnd<DeviceMarker>,
614 responder: ControlAddDeviceResponder,
615 },
616 GetNumDevices { responder: ControlGetNumDevicesResponder },
619 RemoveAll { responder: ControlRemoveAllResponder },
621}
622
623impl ControlRequest {
624 #[allow(irrefutable_let_patterns)]
625 pub fn into_get_default_configuration(
626 self,
627 ) -> Option<(DeviceType, Direction, ControlGetDefaultConfigurationResponder)> {
628 if let ControlRequest::GetDefaultConfiguration { type_, direction, responder } = self {
629 Some((type_, direction, responder))
630 } else {
631 None
632 }
633 }
634
635 #[allow(irrefutable_let_patterns)]
636 pub fn into_add_device(
637 self,
638 ) -> Option<(Configuration, fidl::endpoints::ServerEnd<DeviceMarker>, ControlAddDeviceResponder)>
639 {
640 if let ControlRequest::AddDevice { config, server, responder } = self {
641 Some((config, server, responder))
642 } else {
643 None
644 }
645 }
646
647 #[allow(irrefutable_let_patterns)]
648 pub fn into_get_num_devices(self) -> Option<(ControlGetNumDevicesResponder)> {
649 if let ControlRequest::GetNumDevices { responder } = self {
650 Some((responder))
651 } else {
652 None
653 }
654 }
655
656 #[allow(irrefutable_let_patterns)]
657 pub fn into_remove_all(self) -> Option<(ControlRemoveAllResponder)> {
658 if let ControlRequest::RemoveAll { responder } = self {
659 Some((responder))
660 } else {
661 None
662 }
663 }
664
665 pub fn method_name(&self) -> &'static str {
667 match *self {
668 ControlRequest::GetDefaultConfiguration { .. } => "get_default_configuration",
669 ControlRequest::AddDevice { .. } => "add_device",
670 ControlRequest::GetNumDevices { .. } => "get_num_devices",
671 ControlRequest::RemoveAll { .. } => "remove_all",
672 }
673 }
674}
675
676#[derive(Debug, Clone)]
677pub struct ControlControlHandle {
678 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
679}
680
681impl fidl::endpoints::ControlHandle for ControlControlHandle {
682 fn shutdown(&self) {
683 self.inner.shutdown()
684 }
685 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
686 self.inner.shutdown_with_epitaph(status)
687 }
688
689 fn is_closed(&self) -> bool {
690 self.inner.channel().is_closed()
691 }
692 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
693 self.inner.channel().on_closed()
694 }
695
696 #[cfg(target_os = "fuchsia")]
697 fn signal_peer(
698 &self,
699 clear_mask: zx::Signals,
700 set_mask: zx::Signals,
701 ) -> Result<(), zx_status::Status> {
702 use fidl::Peered;
703 self.inner.channel().signal_peer(clear_mask, set_mask)
704 }
705}
706
707impl ControlControlHandle {}
708
709#[must_use = "FIDL methods require a response to be sent"]
710#[derive(Debug)]
711pub struct ControlGetDefaultConfigurationResponder {
712 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
713 tx_id: u32,
714}
715
716impl std::ops::Drop for ControlGetDefaultConfigurationResponder {
720 fn drop(&mut self) {
721 self.control_handle.shutdown();
722 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
724 }
725}
726
727impl fidl::endpoints::Responder for ControlGetDefaultConfigurationResponder {
728 type ControlHandle = ControlControlHandle;
729
730 fn control_handle(&self) -> &ControlControlHandle {
731 &self.control_handle
732 }
733
734 fn drop_without_shutdown(mut self) {
735 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
737 std::mem::forget(self);
739 }
740}
741
742impl ControlGetDefaultConfigurationResponder {
743 pub fn send(self, mut result: Result<&Configuration, Error>) -> Result<(), fidl::Error> {
747 let _result = self.send_raw(result);
748 if _result.is_err() {
749 self.control_handle.shutdown();
750 }
751 self.drop_without_shutdown();
752 _result
753 }
754
755 pub fn send_no_shutdown_on_err(
757 self,
758 mut result: Result<&Configuration, Error>,
759 ) -> Result<(), fidl::Error> {
760 let _result = self.send_raw(result);
761 self.drop_without_shutdown();
762 _result
763 }
764
765 fn send_raw(&self, mut result: Result<&Configuration, Error>) -> Result<(), fidl::Error> {
766 self.control_handle.inner.send::<fidl::encoding::ResultType<
767 ControlGetDefaultConfigurationResponse,
768 Error,
769 >>(
770 result.map(|config| (config,)),
771 self.tx_id,
772 0x18fbd1298daa19e9,
773 fidl::encoding::DynamicFlags::empty(),
774 )
775 }
776}
777
778#[must_use = "FIDL methods require a response to be sent"]
779#[derive(Debug)]
780pub struct ControlAddDeviceResponder {
781 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
782 tx_id: u32,
783}
784
785impl std::ops::Drop for ControlAddDeviceResponder {
789 fn drop(&mut self) {
790 self.control_handle.shutdown();
791 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
793 }
794}
795
796impl fidl::endpoints::Responder for ControlAddDeviceResponder {
797 type ControlHandle = ControlControlHandle;
798
799 fn control_handle(&self) -> &ControlControlHandle {
800 &self.control_handle
801 }
802
803 fn drop_without_shutdown(mut self) {
804 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
806 std::mem::forget(self);
808 }
809}
810
811impl ControlAddDeviceResponder {
812 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
816 let _result = self.send_raw(result);
817 if _result.is_err() {
818 self.control_handle.shutdown();
819 }
820 self.drop_without_shutdown();
821 _result
822 }
823
824 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
826 let _result = self.send_raw(result);
827 self.drop_without_shutdown();
828 _result
829 }
830
831 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
832 self.control_handle
833 .inner
834 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
835 result,
836 self.tx_id,
837 0x6b5fff2f3ed7ce9,
838 fidl::encoding::DynamicFlags::empty(),
839 )
840 }
841}
842
843#[must_use = "FIDL methods require a response to be sent"]
844#[derive(Debug)]
845pub struct ControlGetNumDevicesResponder {
846 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
847 tx_id: u32,
848}
849
850impl std::ops::Drop for ControlGetNumDevicesResponder {
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 ControlGetNumDevicesResponder {
862 type ControlHandle = ControlControlHandle;
863
864 fn control_handle(&self) -> &ControlControlHandle {
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 ControlGetNumDevicesResponder {
877 pub fn send(
881 self,
882 mut num_input_devices: u32,
883 mut num_output_devices: u32,
884 mut num_unspecified_direction_devices: u32,
885 ) -> Result<(), fidl::Error> {
886 let _result =
887 self.send_raw(num_input_devices, num_output_devices, num_unspecified_direction_devices);
888 if _result.is_err() {
889 self.control_handle.shutdown();
890 }
891 self.drop_without_shutdown();
892 _result
893 }
894
895 pub fn send_no_shutdown_on_err(
897 self,
898 mut num_input_devices: u32,
899 mut num_output_devices: u32,
900 mut num_unspecified_direction_devices: u32,
901 ) -> Result<(), fidl::Error> {
902 let _result =
903 self.send_raw(num_input_devices, num_output_devices, num_unspecified_direction_devices);
904 self.drop_without_shutdown();
905 _result
906 }
907
908 fn send_raw(
909 &self,
910 mut num_input_devices: u32,
911 mut num_output_devices: u32,
912 mut num_unspecified_direction_devices: u32,
913 ) -> Result<(), fidl::Error> {
914 self.control_handle.inner.send::<ControlGetNumDevicesResponse>(
915 (num_input_devices, num_output_devices, num_unspecified_direction_devices),
916 self.tx_id,
917 0x256704ce2f8097af,
918 fidl::encoding::DynamicFlags::empty(),
919 )
920 }
921}
922
923#[must_use = "FIDL methods require a response to be sent"]
924#[derive(Debug)]
925pub struct ControlRemoveAllResponder {
926 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
927 tx_id: u32,
928}
929
930impl std::ops::Drop for ControlRemoveAllResponder {
934 fn drop(&mut self) {
935 self.control_handle.shutdown();
936 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
938 }
939}
940
941impl fidl::endpoints::Responder for ControlRemoveAllResponder {
942 type ControlHandle = ControlControlHandle;
943
944 fn control_handle(&self) -> &ControlControlHandle {
945 &self.control_handle
946 }
947
948 fn drop_without_shutdown(mut self) {
949 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
951 std::mem::forget(self);
953 }
954}
955
956impl ControlRemoveAllResponder {
957 pub fn send(self) -> Result<(), fidl::Error> {
961 let _result = self.send_raw();
962 if _result.is_err() {
963 self.control_handle.shutdown();
964 }
965 self.drop_without_shutdown();
966 _result
967 }
968
969 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
971 let _result = self.send_raw();
972 self.drop_without_shutdown();
973 _result
974 }
975
976 fn send_raw(&self) -> Result<(), fidl::Error> {
977 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
978 (),
979 self.tx_id,
980 0x7904287969087c4b,
981 fidl::encoding::DynamicFlags::empty(),
982 )
983 }
984}
985
986#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
987pub struct DeviceMarker;
988
989impl fidl::endpoints::ProtocolMarker for DeviceMarker {
990 type Proxy = DeviceProxy;
991 type RequestStream = DeviceRequestStream;
992 #[cfg(target_os = "fuchsia")]
993 type SynchronousProxy = DeviceSynchronousProxy;
994
995 const DEBUG_NAME: &'static str = "(anonymous) Device";
996}
997pub type DeviceGetFormatResult = Result<(u32, u32, u32, i64), Error>;
998pub type DeviceGetGainResult = Result<(bool, bool, f32), Error>;
999pub type DeviceGetBufferResult = Result<(fidl::Vmo, u32, u32), Error>;
1000pub type DeviceSetNotificationFrequencyResult = Result<(), Error>;
1001pub type DeviceGetPositionResult = Result<(i64, u32), Error>;
1002pub type DeviceChangePlugStateResult = Result<(), Error>;
1003pub type DeviceAdjustClockRateResult = Result<(), Error>;
1004
1005pub trait DeviceProxyInterface: Send + Sync {
1006 type GetFormatResponseFut: std::future::Future<Output = Result<DeviceGetFormatResult, fidl::Error>>
1007 + Send;
1008 fn r#get_format(&self) -> Self::GetFormatResponseFut;
1009 type GetGainResponseFut: std::future::Future<Output = Result<DeviceGetGainResult, fidl::Error>>
1010 + Send;
1011 fn r#get_gain(&self) -> Self::GetGainResponseFut;
1012 type GetBufferResponseFut: std::future::Future<Output = Result<DeviceGetBufferResult, fidl::Error>>
1013 + Send;
1014 fn r#get_buffer(&self) -> Self::GetBufferResponseFut;
1015 type SetNotificationFrequencyResponseFut: std::future::Future<Output = Result<DeviceSetNotificationFrequencyResult, fidl::Error>>
1016 + Send;
1017 fn r#set_notification_frequency(
1018 &self,
1019 notifications_per_ring: u32,
1020 ) -> Self::SetNotificationFrequencyResponseFut;
1021 type GetPositionResponseFut: std::future::Future<Output = Result<DeviceGetPositionResult, fidl::Error>>
1022 + Send;
1023 fn r#get_position(&self) -> Self::GetPositionResponseFut;
1024 type ChangePlugStateResponseFut: std::future::Future<Output = Result<DeviceChangePlugStateResult, fidl::Error>>
1025 + Send;
1026 fn r#change_plug_state(
1027 &self,
1028 plug_change_time: i64,
1029 plugged: bool,
1030 ) -> Self::ChangePlugStateResponseFut;
1031 type AdjustClockRateResponseFut: std::future::Future<Output = Result<DeviceAdjustClockRateResult, fidl::Error>>
1032 + Send;
1033 fn r#adjust_clock_rate(&self, ppm_from_monotonic: i32) -> Self::AdjustClockRateResponseFut;
1034}
1035#[derive(Debug)]
1036#[cfg(target_os = "fuchsia")]
1037pub struct DeviceSynchronousProxy {
1038 client: fidl::client::sync::Client,
1039}
1040
1041#[cfg(target_os = "fuchsia")]
1042impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
1043 type Proxy = DeviceProxy;
1044 type Protocol = DeviceMarker;
1045
1046 fn from_channel(inner: fidl::Channel) -> Self {
1047 Self::new(inner)
1048 }
1049
1050 fn into_channel(self) -> fidl::Channel {
1051 self.client.into_channel()
1052 }
1053
1054 fn as_channel(&self) -> &fidl::Channel {
1055 self.client.as_channel()
1056 }
1057}
1058
1059#[cfg(target_os = "fuchsia")]
1060impl DeviceSynchronousProxy {
1061 pub fn new(channel: fidl::Channel) -> Self {
1062 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1063 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1064 }
1065
1066 pub fn into_channel(self) -> fidl::Channel {
1067 self.client.into_channel()
1068 }
1069
1070 pub fn wait_for_event(
1073 &self,
1074 deadline: zx::MonotonicInstant,
1075 ) -> Result<DeviceEvent, fidl::Error> {
1076 DeviceEvent::decode(self.client.wait_for_event(deadline)?)
1077 }
1078
1079 pub fn r#get_format(
1082 &self,
1083 ___deadline: zx::MonotonicInstant,
1084 ) -> Result<DeviceGetFormatResult, fidl::Error> {
1085 let _response = self.client.send_query::<
1086 fidl::encoding::EmptyPayload,
1087 fidl::encoding::ResultType<DeviceGetFormatResponse, Error>,
1088 >(
1089 (),
1090 0x6107d32083bacc1b,
1091 fidl::encoding::DynamicFlags::empty(),
1092 ___deadline,
1093 )?;
1094 Ok(_response
1095 .map(|x| (x.frames_per_second, x.sample_format, x.num_channels, x.external_delay)))
1096 }
1097
1098 pub fn r#get_gain(
1100 &self,
1101 ___deadline: zx::MonotonicInstant,
1102 ) -> Result<DeviceGetGainResult, fidl::Error> {
1103 let _response = self.client.send_query::<
1104 fidl::encoding::EmptyPayload,
1105 fidl::encoding::ResultType<DeviceGetGainResponse, Error>,
1106 >(
1107 (),
1108 0x6d85d82b49fb28e9,
1109 fidl::encoding::DynamicFlags::empty(),
1110 ___deadline,
1111 )?;
1112 Ok(_response.map(|x| (x.current_mute, x.current_agc, x.current_gain_db)))
1113 }
1114
1115 pub fn r#get_buffer(
1118 &self,
1119 ___deadline: zx::MonotonicInstant,
1120 ) -> Result<DeviceGetBufferResult, fidl::Error> {
1121 let _response = self.client.send_query::<
1122 fidl::encoding::EmptyPayload,
1123 fidl::encoding::ResultType<DeviceGetBufferResponse, Error>,
1124 >(
1125 (),
1126 0x38e202be0db060d0,
1127 fidl::encoding::DynamicFlags::empty(),
1128 ___deadline,
1129 )?;
1130 Ok(_response.map(|x| (x.ring_buffer, x.num_ring_buffer_frames, x.notifications_per_ring)))
1131 }
1132
1133 pub fn r#set_notification_frequency(
1138 &self,
1139 mut notifications_per_ring: u32,
1140 ___deadline: zx::MonotonicInstant,
1141 ) -> Result<DeviceSetNotificationFrequencyResult, fidl::Error> {
1142 let _response = self.client.send_query::<
1143 DeviceSetNotificationFrequencyRequest,
1144 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1145 >(
1146 (notifications_per_ring,),
1147 0x45789b88ca9185b8,
1148 fidl::encoding::DynamicFlags::empty(),
1149 ___deadline,
1150 )?;
1151 Ok(_response.map(|x| x))
1152 }
1153
1154 pub fn r#get_position(
1159 &self,
1160 ___deadline: zx::MonotonicInstant,
1161 ) -> Result<DeviceGetPositionResult, fidl::Error> {
1162 let _response = self.client.send_query::<
1163 fidl::encoding::EmptyPayload,
1164 fidl::encoding::ResultType<DeviceGetPositionResponse, Error>,
1165 >(
1166 (),
1167 0x6fe5bbf9065258e8,
1168 fidl::encoding::DynamicFlags::empty(),
1169 ___deadline,
1170 )?;
1171 Ok(_response.map(|x| (x.monotonic_time, x.ring_position)))
1172 }
1173
1174 pub fn r#change_plug_state(
1177 &self,
1178 mut plug_change_time: i64,
1179 mut plugged: bool,
1180 ___deadline: zx::MonotonicInstant,
1181 ) -> Result<DeviceChangePlugStateResult, fidl::Error> {
1182 let _response = self.client.send_query::<
1183 DeviceChangePlugStateRequest,
1184 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1185 >(
1186 (plug_change_time, plugged,),
1187 0x61aa2d370caaf8f0,
1188 fidl::encoding::DynamicFlags::empty(),
1189 ___deadline,
1190 )?;
1191 Ok(_response.map(|x| x))
1192 }
1193
1194 pub fn r#adjust_clock_rate(
1199 &self,
1200 mut ppm_from_monotonic: i32,
1201 ___deadline: zx::MonotonicInstant,
1202 ) -> Result<DeviceAdjustClockRateResult, fidl::Error> {
1203 let _response = self.client.send_query::<
1204 DeviceAdjustClockRateRequest,
1205 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1206 >(
1207 (ppm_from_monotonic,),
1208 0x754661f655350134,
1209 fidl::encoding::DynamicFlags::empty(),
1210 ___deadline,
1211 )?;
1212 Ok(_response.map(|x| x))
1213 }
1214}
1215
1216#[cfg(target_os = "fuchsia")]
1217impl From<DeviceSynchronousProxy> for zx::Handle {
1218 fn from(value: DeviceSynchronousProxy) -> Self {
1219 value.into_channel().into()
1220 }
1221}
1222
1223#[cfg(target_os = "fuchsia")]
1224impl From<fidl::Channel> for DeviceSynchronousProxy {
1225 fn from(value: fidl::Channel) -> Self {
1226 Self::new(value)
1227 }
1228}
1229
1230#[derive(Debug, Clone)]
1231pub struct DeviceProxy {
1232 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1233}
1234
1235impl fidl::endpoints::Proxy for DeviceProxy {
1236 type Protocol = DeviceMarker;
1237
1238 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1239 Self::new(inner)
1240 }
1241
1242 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1243 self.client.into_channel().map_err(|client| Self { client })
1244 }
1245
1246 fn as_channel(&self) -> &::fidl::AsyncChannel {
1247 self.client.as_channel()
1248 }
1249}
1250
1251impl DeviceProxy {
1252 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1254 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1255 Self { client: fidl::client::Client::new(channel, protocol_name) }
1256 }
1257
1258 pub fn take_event_stream(&self) -> DeviceEventStream {
1264 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
1265 }
1266
1267 pub fn r#get_format(
1270 &self,
1271 ) -> fidl::client::QueryResponseFut<
1272 DeviceGetFormatResult,
1273 fidl::encoding::DefaultFuchsiaResourceDialect,
1274 > {
1275 DeviceProxyInterface::r#get_format(self)
1276 }
1277
1278 pub fn r#get_gain(
1280 &self,
1281 ) -> fidl::client::QueryResponseFut<
1282 DeviceGetGainResult,
1283 fidl::encoding::DefaultFuchsiaResourceDialect,
1284 > {
1285 DeviceProxyInterface::r#get_gain(self)
1286 }
1287
1288 pub fn r#get_buffer(
1291 &self,
1292 ) -> fidl::client::QueryResponseFut<
1293 DeviceGetBufferResult,
1294 fidl::encoding::DefaultFuchsiaResourceDialect,
1295 > {
1296 DeviceProxyInterface::r#get_buffer(self)
1297 }
1298
1299 pub fn r#set_notification_frequency(
1304 &self,
1305 mut notifications_per_ring: u32,
1306 ) -> fidl::client::QueryResponseFut<
1307 DeviceSetNotificationFrequencyResult,
1308 fidl::encoding::DefaultFuchsiaResourceDialect,
1309 > {
1310 DeviceProxyInterface::r#set_notification_frequency(self, notifications_per_ring)
1311 }
1312
1313 pub fn r#get_position(
1318 &self,
1319 ) -> fidl::client::QueryResponseFut<
1320 DeviceGetPositionResult,
1321 fidl::encoding::DefaultFuchsiaResourceDialect,
1322 > {
1323 DeviceProxyInterface::r#get_position(self)
1324 }
1325
1326 pub fn r#change_plug_state(
1329 &self,
1330 mut plug_change_time: i64,
1331 mut plugged: bool,
1332 ) -> fidl::client::QueryResponseFut<
1333 DeviceChangePlugStateResult,
1334 fidl::encoding::DefaultFuchsiaResourceDialect,
1335 > {
1336 DeviceProxyInterface::r#change_plug_state(self, plug_change_time, plugged)
1337 }
1338
1339 pub fn r#adjust_clock_rate(
1344 &self,
1345 mut ppm_from_monotonic: i32,
1346 ) -> fidl::client::QueryResponseFut<
1347 DeviceAdjustClockRateResult,
1348 fidl::encoding::DefaultFuchsiaResourceDialect,
1349 > {
1350 DeviceProxyInterface::r#adjust_clock_rate(self, ppm_from_monotonic)
1351 }
1352}
1353
1354impl DeviceProxyInterface for DeviceProxy {
1355 type GetFormatResponseFut = fidl::client::QueryResponseFut<
1356 DeviceGetFormatResult,
1357 fidl::encoding::DefaultFuchsiaResourceDialect,
1358 >;
1359 fn r#get_format(&self) -> Self::GetFormatResponseFut {
1360 fn _decode(
1361 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1362 ) -> Result<DeviceGetFormatResult, fidl::Error> {
1363 let _response = fidl::client::decode_transaction_body::<
1364 fidl::encoding::ResultType<DeviceGetFormatResponse, Error>,
1365 fidl::encoding::DefaultFuchsiaResourceDialect,
1366 0x6107d32083bacc1b,
1367 >(_buf?)?;
1368 Ok(_response
1369 .map(|x| (x.frames_per_second, x.sample_format, x.num_channels, x.external_delay)))
1370 }
1371 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetFormatResult>(
1372 (),
1373 0x6107d32083bacc1b,
1374 fidl::encoding::DynamicFlags::empty(),
1375 _decode,
1376 )
1377 }
1378
1379 type GetGainResponseFut = fidl::client::QueryResponseFut<
1380 DeviceGetGainResult,
1381 fidl::encoding::DefaultFuchsiaResourceDialect,
1382 >;
1383 fn r#get_gain(&self) -> Self::GetGainResponseFut {
1384 fn _decode(
1385 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1386 ) -> Result<DeviceGetGainResult, fidl::Error> {
1387 let _response = fidl::client::decode_transaction_body::<
1388 fidl::encoding::ResultType<DeviceGetGainResponse, Error>,
1389 fidl::encoding::DefaultFuchsiaResourceDialect,
1390 0x6d85d82b49fb28e9,
1391 >(_buf?)?;
1392 Ok(_response.map(|x| (x.current_mute, x.current_agc, x.current_gain_db)))
1393 }
1394 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetGainResult>(
1395 (),
1396 0x6d85d82b49fb28e9,
1397 fidl::encoding::DynamicFlags::empty(),
1398 _decode,
1399 )
1400 }
1401
1402 type GetBufferResponseFut = fidl::client::QueryResponseFut<
1403 DeviceGetBufferResult,
1404 fidl::encoding::DefaultFuchsiaResourceDialect,
1405 >;
1406 fn r#get_buffer(&self) -> Self::GetBufferResponseFut {
1407 fn _decode(
1408 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1409 ) -> Result<DeviceGetBufferResult, fidl::Error> {
1410 let _response = fidl::client::decode_transaction_body::<
1411 fidl::encoding::ResultType<DeviceGetBufferResponse, Error>,
1412 fidl::encoding::DefaultFuchsiaResourceDialect,
1413 0x38e202be0db060d0,
1414 >(_buf?)?;
1415 Ok(_response
1416 .map(|x| (x.ring_buffer, x.num_ring_buffer_frames, x.notifications_per_ring)))
1417 }
1418 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetBufferResult>(
1419 (),
1420 0x38e202be0db060d0,
1421 fidl::encoding::DynamicFlags::empty(),
1422 _decode,
1423 )
1424 }
1425
1426 type SetNotificationFrequencyResponseFut = fidl::client::QueryResponseFut<
1427 DeviceSetNotificationFrequencyResult,
1428 fidl::encoding::DefaultFuchsiaResourceDialect,
1429 >;
1430 fn r#set_notification_frequency(
1431 &self,
1432 mut notifications_per_ring: u32,
1433 ) -> Self::SetNotificationFrequencyResponseFut {
1434 fn _decode(
1435 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1436 ) -> Result<DeviceSetNotificationFrequencyResult, fidl::Error> {
1437 let _response = fidl::client::decode_transaction_body::<
1438 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1439 fidl::encoding::DefaultFuchsiaResourceDialect,
1440 0x45789b88ca9185b8,
1441 >(_buf?)?;
1442 Ok(_response.map(|x| x))
1443 }
1444 self.client.send_query_and_decode::<
1445 DeviceSetNotificationFrequencyRequest,
1446 DeviceSetNotificationFrequencyResult,
1447 >(
1448 (notifications_per_ring,),
1449 0x45789b88ca9185b8,
1450 fidl::encoding::DynamicFlags::empty(),
1451 _decode,
1452 )
1453 }
1454
1455 type GetPositionResponseFut = fidl::client::QueryResponseFut<
1456 DeviceGetPositionResult,
1457 fidl::encoding::DefaultFuchsiaResourceDialect,
1458 >;
1459 fn r#get_position(&self) -> Self::GetPositionResponseFut {
1460 fn _decode(
1461 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1462 ) -> Result<DeviceGetPositionResult, fidl::Error> {
1463 let _response = fidl::client::decode_transaction_body::<
1464 fidl::encoding::ResultType<DeviceGetPositionResponse, Error>,
1465 fidl::encoding::DefaultFuchsiaResourceDialect,
1466 0x6fe5bbf9065258e8,
1467 >(_buf?)?;
1468 Ok(_response.map(|x| (x.monotonic_time, x.ring_position)))
1469 }
1470 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetPositionResult>(
1471 (),
1472 0x6fe5bbf9065258e8,
1473 fidl::encoding::DynamicFlags::empty(),
1474 _decode,
1475 )
1476 }
1477
1478 type ChangePlugStateResponseFut = fidl::client::QueryResponseFut<
1479 DeviceChangePlugStateResult,
1480 fidl::encoding::DefaultFuchsiaResourceDialect,
1481 >;
1482 fn r#change_plug_state(
1483 &self,
1484 mut plug_change_time: i64,
1485 mut plugged: bool,
1486 ) -> Self::ChangePlugStateResponseFut {
1487 fn _decode(
1488 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1489 ) -> Result<DeviceChangePlugStateResult, fidl::Error> {
1490 let _response = fidl::client::decode_transaction_body::<
1491 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1492 fidl::encoding::DefaultFuchsiaResourceDialect,
1493 0x61aa2d370caaf8f0,
1494 >(_buf?)?;
1495 Ok(_response.map(|x| x))
1496 }
1497 self.client
1498 .send_query_and_decode::<DeviceChangePlugStateRequest, DeviceChangePlugStateResult>(
1499 (plug_change_time, plugged),
1500 0x61aa2d370caaf8f0,
1501 fidl::encoding::DynamicFlags::empty(),
1502 _decode,
1503 )
1504 }
1505
1506 type AdjustClockRateResponseFut = fidl::client::QueryResponseFut<
1507 DeviceAdjustClockRateResult,
1508 fidl::encoding::DefaultFuchsiaResourceDialect,
1509 >;
1510 fn r#adjust_clock_rate(&self, mut ppm_from_monotonic: i32) -> Self::AdjustClockRateResponseFut {
1511 fn _decode(
1512 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1513 ) -> Result<DeviceAdjustClockRateResult, fidl::Error> {
1514 let _response = fidl::client::decode_transaction_body::<
1515 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
1516 fidl::encoding::DefaultFuchsiaResourceDialect,
1517 0x754661f655350134,
1518 >(_buf?)?;
1519 Ok(_response.map(|x| x))
1520 }
1521 self.client
1522 .send_query_and_decode::<DeviceAdjustClockRateRequest, DeviceAdjustClockRateResult>(
1523 (ppm_from_monotonic,),
1524 0x754661f655350134,
1525 fidl::encoding::DynamicFlags::empty(),
1526 _decode,
1527 )
1528 }
1529}
1530
1531pub struct DeviceEventStream {
1532 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1533}
1534
1535impl std::marker::Unpin for DeviceEventStream {}
1536
1537impl futures::stream::FusedStream for DeviceEventStream {
1538 fn is_terminated(&self) -> bool {
1539 self.event_receiver.is_terminated()
1540 }
1541}
1542
1543impl futures::Stream for DeviceEventStream {
1544 type Item = Result<DeviceEvent, fidl::Error>;
1545
1546 fn poll_next(
1547 mut self: std::pin::Pin<&mut Self>,
1548 cx: &mut std::task::Context<'_>,
1549 ) -> std::task::Poll<Option<Self::Item>> {
1550 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1551 &mut self.event_receiver,
1552 cx
1553 )?) {
1554 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
1555 None => std::task::Poll::Ready(None),
1556 }
1557 }
1558}
1559
1560#[derive(Debug)]
1561pub enum DeviceEvent {
1562 OnSetFormat {
1563 frames_per_second: u32,
1564 sample_format: u32,
1565 num_channels: u32,
1566 external_delay: i64,
1567 },
1568 OnSetGain {
1569 current_mute: bool,
1570 current_agc: bool,
1571 current_gain_db: f32,
1572 },
1573 OnBufferCreated {
1574 ring_buffer: fidl::Vmo,
1575 num_ring_buffer_frames: u32,
1576 notifications_per_ring: u32,
1577 },
1578 OnStart {
1579 start_time: i64,
1580 },
1581 OnStop {
1582 stop_time: i64,
1583 ring_position: u32,
1584 },
1585 OnPositionNotify {
1586 monotonic_time: i64,
1587 ring_position: u32,
1588 },
1589}
1590
1591impl DeviceEvent {
1592 #[allow(irrefutable_let_patterns)]
1593 pub fn into_on_set_format(self) -> Option<(u32, u32, u32, i64)> {
1594 if let DeviceEvent::OnSetFormat {
1595 frames_per_second,
1596 sample_format,
1597 num_channels,
1598 external_delay,
1599 } = self
1600 {
1601 Some((frames_per_second, sample_format, num_channels, external_delay))
1602 } else {
1603 None
1604 }
1605 }
1606 #[allow(irrefutable_let_patterns)]
1607 pub fn into_on_set_gain(self) -> Option<(bool, bool, f32)> {
1608 if let DeviceEvent::OnSetGain { current_mute, current_agc, current_gain_db } = self {
1609 Some((current_mute, current_agc, current_gain_db))
1610 } else {
1611 None
1612 }
1613 }
1614 #[allow(irrefutable_let_patterns)]
1615 pub fn into_on_buffer_created(self) -> Option<(fidl::Vmo, u32, u32)> {
1616 if let DeviceEvent::OnBufferCreated {
1617 ring_buffer,
1618 num_ring_buffer_frames,
1619 notifications_per_ring,
1620 } = self
1621 {
1622 Some((ring_buffer, num_ring_buffer_frames, notifications_per_ring))
1623 } else {
1624 None
1625 }
1626 }
1627 #[allow(irrefutable_let_patterns)]
1628 pub fn into_on_start(self) -> Option<i64> {
1629 if let DeviceEvent::OnStart { start_time } = self {
1630 Some((start_time))
1631 } else {
1632 None
1633 }
1634 }
1635 #[allow(irrefutable_let_patterns)]
1636 pub fn into_on_stop(self) -> Option<(i64, u32)> {
1637 if let DeviceEvent::OnStop { stop_time, ring_position } = self {
1638 Some((stop_time, ring_position))
1639 } else {
1640 None
1641 }
1642 }
1643 #[allow(irrefutable_let_patterns)]
1644 pub fn into_on_position_notify(self) -> Option<(i64, u32)> {
1645 if let DeviceEvent::OnPositionNotify { monotonic_time, ring_position } = self {
1646 Some((monotonic_time, ring_position))
1647 } else {
1648 None
1649 }
1650 }
1651
1652 fn decode(
1654 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1655 ) -> Result<DeviceEvent, fidl::Error> {
1656 let (bytes, _handles) = buf.split_mut();
1657 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1658 debug_assert_eq!(tx_header.tx_id, 0);
1659 match tx_header.ordinal {
1660 0x2a547759ab3678b2 => {
1661 let mut out = fidl::new_empty!(
1662 DeviceOnSetFormatRequest,
1663 fidl::encoding::DefaultFuchsiaResourceDialect
1664 );
1665 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnSetFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1666 Ok((DeviceEvent::OnSetFormat {
1667 frames_per_second: out.frames_per_second,
1668 sample_format: out.sample_format,
1669 num_channels: out.num_channels,
1670 external_delay: out.external_delay,
1671 }))
1672 }
1673 0x31fffec81b3a9393 => {
1674 let mut out = fidl::new_empty!(
1675 DeviceOnSetGainRequest,
1676 fidl::encoding::DefaultFuchsiaResourceDialect
1677 );
1678 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnSetGainRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1679 Ok((DeviceEvent::OnSetGain {
1680 current_mute: out.current_mute,
1681 current_agc: out.current_agc,
1682 current_gain_db: out.current_gain_db,
1683 }))
1684 }
1685 0x5c2eb72e264afefd => {
1686 let mut out = fidl::new_empty!(
1687 DeviceOnBufferCreatedRequest,
1688 fidl::encoding::DefaultFuchsiaResourceDialect
1689 );
1690 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnBufferCreatedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1691 Ok((DeviceEvent::OnBufferCreated {
1692 ring_buffer: out.ring_buffer,
1693 num_ring_buffer_frames: out.num_ring_buffer_frames,
1694 notifications_per_ring: out.notifications_per_ring,
1695 }))
1696 }
1697 0x498f0b7e64d7ca58 => {
1698 let mut out = fidl::new_empty!(
1699 DeviceOnStartRequest,
1700 fidl::encoding::DefaultFuchsiaResourceDialect
1701 );
1702 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnStartRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1703 Ok((DeviceEvent::OnStart { start_time: out.start_time }))
1704 }
1705 0x6f5d4d2fe223ae5b => {
1706 let mut out = fidl::new_empty!(
1707 DeviceOnStopRequest,
1708 fidl::encoding::DefaultFuchsiaResourceDialect
1709 );
1710 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnStopRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1711 Ok((DeviceEvent::OnStop {
1712 stop_time: out.stop_time,
1713 ring_position: out.ring_position,
1714 }))
1715 }
1716 0x79274c4de9013585 => {
1717 let mut out = fidl::new_empty!(
1718 DeviceOnPositionNotifyRequest,
1719 fidl::encoding::DefaultFuchsiaResourceDialect
1720 );
1721 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceOnPositionNotifyRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1722 Ok((DeviceEvent::OnPositionNotify {
1723 monotonic_time: out.monotonic_time,
1724 ring_position: out.ring_position,
1725 }))
1726 }
1727 _ => Err(fidl::Error::UnknownOrdinal {
1728 ordinal: tx_header.ordinal,
1729 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1730 }),
1731 }
1732 }
1733}
1734
1735pub struct DeviceRequestStream {
1737 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1738 is_terminated: bool,
1739}
1740
1741impl std::marker::Unpin for DeviceRequestStream {}
1742
1743impl futures::stream::FusedStream for DeviceRequestStream {
1744 fn is_terminated(&self) -> bool {
1745 self.is_terminated
1746 }
1747}
1748
1749impl fidl::endpoints::RequestStream for DeviceRequestStream {
1750 type Protocol = DeviceMarker;
1751 type ControlHandle = DeviceControlHandle;
1752
1753 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1754 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1755 }
1756
1757 fn control_handle(&self) -> Self::ControlHandle {
1758 DeviceControlHandle { inner: self.inner.clone() }
1759 }
1760
1761 fn into_inner(
1762 self,
1763 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1764 {
1765 (self.inner, self.is_terminated)
1766 }
1767
1768 fn from_inner(
1769 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1770 is_terminated: bool,
1771 ) -> Self {
1772 Self { inner, is_terminated }
1773 }
1774}
1775
1776impl futures::Stream for DeviceRequestStream {
1777 type Item = Result<DeviceRequest, fidl::Error>;
1778
1779 fn poll_next(
1780 mut self: std::pin::Pin<&mut Self>,
1781 cx: &mut std::task::Context<'_>,
1782 ) -> std::task::Poll<Option<Self::Item>> {
1783 let this = &mut *self;
1784 if this.inner.check_shutdown(cx) {
1785 this.is_terminated = true;
1786 return std::task::Poll::Ready(None);
1787 }
1788 if this.is_terminated {
1789 panic!("polled DeviceRequestStream after completion");
1790 }
1791 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1792 |bytes, handles| {
1793 match this.inner.channel().read_etc(cx, bytes, handles) {
1794 std::task::Poll::Ready(Ok(())) => {}
1795 std::task::Poll::Pending => return std::task::Poll::Pending,
1796 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1797 this.is_terminated = true;
1798 return std::task::Poll::Ready(None);
1799 }
1800 std::task::Poll::Ready(Err(e)) => {
1801 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1802 e.into(),
1803 ))))
1804 }
1805 }
1806
1807 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1809
1810 std::task::Poll::Ready(Some(match header.ordinal {
1811 0x6107d32083bacc1b => {
1812 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1813 let mut req = fidl::new_empty!(
1814 fidl::encoding::EmptyPayload,
1815 fidl::encoding::DefaultFuchsiaResourceDialect
1816 );
1817 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1818 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1819 Ok(DeviceRequest::GetFormat {
1820 responder: DeviceGetFormatResponder {
1821 control_handle: std::mem::ManuallyDrop::new(control_handle),
1822 tx_id: header.tx_id,
1823 },
1824 })
1825 }
1826 0x6d85d82b49fb28e9 => {
1827 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1828 let mut req = fidl::new_empty!(
1829 fidl::encoding::EmptyPayload,
1830 fidl::encoding::DefaultFuchsiaResourceDialect
1831 );
1832 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1833 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1834 Ok(DeviceRequest::GetGain {
1835 responder: DeviceGetGainResponder {
1836 control_handle: std::mem::ManuallyDrop::new(control_handle),
1837 tx_id: header.tx_id,
1838 },
1839 })
1840 }
1841 0x38e202be0db060d0 => {
1842 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1843 let mut req = fidl::new_empty!(
1844 fidl::encoding::EmptyPayload,
1845 fidl::encoding::DefaultFuchsiaResourceDialect
1846 );
1847 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1848 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1849 Ok(DeviceRequest::GetBuffer {
1850 responder: DeviceGetBufferResponder {
1851 control_handle: std::mem::ManuallyDrop::new(control_handle),
1852 tx_id: header.tx_id,
1853 },
1854 })
1855 }
1856 0x45789b88ca9185b8 => {
1857 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1858 let mut req = fidl::new_empty!(
1859 DeviceSetNotificationFrequencyRequest,
1860 fidl::encoding::DefaultFuchsiaResourceDialect
1861 );
1862 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetNotificationFrequencyRequest>(&header, _body_bytes, handles, &mut req)?;
1863 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1864 Ok(DeviceRequest::SetNotificationFrequency {
1865 notifications_per_ring: req.notifications_per_ring,
1866
1867 responder: DeviceSetNotificationFrequencyResponder {
1868 control_handle: std::mem::ManuallyDrop::new(control_handle),
1869 tx_id: header.tx_id,
1870 },
1871 })
1872 }
1873 0x6fe5bbf9065258e8 => {
1874 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1875 let mut req = fidl::new_empty!(
1876 fidl::encoding::EmptyPayload,
1877 fidl::encoding::DefaultFuchsiaResourceDialect
1878 );
1879 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1880 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1881 Ok(DeviceRequest::GetPosition {
1882 responder: DeviceGetPositionResponder {
1883 control_handle: std::mem::ManuallyDrop::new(control_handle),
1884 tx_id: header.tx_id,
1885 },
1886 })
1887 }
1888 0x61aa2d370caaf8f0 => {
1889 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1890 let mut req = fidl::new_empty!(
1891 DeviceChangePlugStateRequest,
1892 fidl::encoding::DefaultFuchsiaResourceDialect
1893 );
1894 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceChangePlugStateRequest>(&header, _body_bytes, handles, &mut req)?;
1895 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1896 Ok(DeviceRequest::ChangePlugState {
1897 plug_change_time: req.plug_change_time,
1898 plugged: req.plugged,
1899
1900 responder: DeviceChangePlugStateResponder {
1901 control_handle: std::mem::ManuallyDrop::new(control_handle),
1902 tx_id: header.tx_id,
1903 },
1904 })
1905 }
1906 0x754661f655350134 => {
1907 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1908 let mut req = fidl::new_empty!(
1909 DeviceAdjustClockRateRequest,
1910 fidl::encoding::DefaultFuchsiaResourceDialect
1911 );
1912 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceAdjustClockRateRequest>(&header, _body_bytes, handles, &mut req)?;
1913 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
1914 Ok(DeviceRequest::AdjustClockRate {
1915 ppm_from_monotonic: req.ppm_from_monotonic,
1916
1917 responder: DeviceAdjustClockRateResponder {
1918 control_handle: std::mem::ManuallyDrop::new(control_handle),
1919 tx_id: header.tx_id,
1920 },
1921 })
1922 }
1923 _ => Err(fidl::Error::UnknownOrdinal {
1924 ordinal: header.ordinal,
1925 protocol_name:
1926 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1927 }),
1928 }))
1929 },
1930 )
1931 }
1932}
1933
1934#[derive(Debug)]
1938pub enum DeviceRequest {
1939 GetFormat { responder: DeviceGetFormatResponder },
1942 GetGain { responder: DeviceGetGainResponder },
1944 GetBuffer { responder: DeviceGetBufferResponder },
1947 SetNotificationFrequency {
1952 notifications_per_ring: u32,
1953 responder: DeviceSetNotificationFrequencyResponder,
1954 },
1955 GetPosition { responder: DeviceGetPositionResponder },
1960 ChangePlugState {
1963 plug_change_time: i64,
1964 plugged: bool,
1965 responder: DeviceChangePlugStateResponder,
1966 },
1967 AdjustClockRate { ppm_from_monotonic: i32, responder: DeviceAdjustClockRateResponder },
1972}
1973
1974impl DeviceRequest {
1975 #[allow(irrefutable_let_patterns)]
1976 pub fn into_get_format(self) -> Option<(DeviceGetFormatResponder)> {
1977 if let DeviceRequest::GetFormat { responder } = self {
1978 Some((responder))
1979 } else {
1980 None
1981 }
1982 }
1983
1984 #[allow(irrefutable_let_patterns)]
1985 pub fn into_get_gain(self) -> Option<(DeviceGetGainResponder)> {
1986 if let DeviceRequest::GetGain { responder } = self {
1987 Some((responder))
1988 } else {
1989 None
1990 }
1991 }
1992
1993 #[allow(irrefutable_let_patterns)]
1994 pub fn into_get_buffer(self) -> Option<(DeviceGetBufferResponder)> {
1995 if let DeviceRequest::GetBuffer { responder } = self {
1996 Some((responder))
1997 } else {
1998 None
1999 }
2000 }
2001
2002 #[allow(irrefutable_let_patterns)]
2003 pub fn into_set_notification_frequency(
2004 self,
2005 ) -> Option<(u32, DeviceSetNotificationFrequencyResponder)> {
2006 if let DeviceRequest::SetNotificationFrequency { notifications_per_ring, responder } = self
2007 {
2008 Some((notifications_per_ring, responder))
2009 } else {
2010 None
2011 }
2012 }
2013
2014 #[allow(irrefutable_let_patterns)]
2015 pub fn into_get_position(self) -> Option<(DeviceGetPositionResponder)> {
2016 if let DeviceRequest::GetPosition { responder } = self {
2017 Some((responder))
2018 } else {
2019 None
2020 }
2021 }
2022
2023 #[allow(irrefutable_let_patterns)]
2024 pub fn into_change_plug_state(self) -> Option<(i64, bool, DeviceChangePlugStateResponder)> {
2025 if let DeviceRequest::ChangePlugState { plug_change_time, plugged, responder } = self {
2026 Some((plug_change_time, plugged, responder))
2027 } else {
2028 None
2029 }
2030 }
2031
2032 #[allow(irrefutable_let_patterns)]
2033 pub fn into_adjust_clock_rate(self) -> Option<(i32, DeviceAdjustClockRateResponder)> {
2034 if let DeviceRequest::AdjustClockRate { ppm_from_monotonic, responder } = self {
2035 Some((ppm_from_monotonic, responder))
2036 } else {
2037 None
2038 }
2039 }
2040
2041 pub fn method_name(&self) -> &'static str {
2043 match *self {
2044 DeviceRequest::GetFormat { .. } => "get_format",
2045 DeviceRequest::GetGain { .. } => "get_gain",
2046 DeviceRequest::GetBuffer { .. } => "get_buffer",
2047 DeviceRequest::SetNotificationFrequency { .. } => "set_notification_frequency",
2048 DeviceRequest::GetPosition { .. } => "get_position",
2049 DeviceRequest::ChangePlugState { .. } => "change_plug_state",
2050 DeviceRequest::AdjustClockRate { .. } => "adjust_clock_rate",
2051 }
2052 }
2053}
2054
2055#[derive(Debug, Clone)]
2056pub struct DeviceControlHandle {
2057 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2058}
2059
2060impl fidl::endpoints::ControlHandle for DeviceControlHandle {
2061 fn shutdown(&self) {
2062 self.inner.shutdown()
2063 }
2064 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2065 self.inner.shutdown_with_epitaph(status)
2066 }
2067
2068 fn is_closed(&self) -> bool {
2069 self.inner.channel().is_closed()
2070 }
2071 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2072 self.inner.channel().on_closed()
2073 }
2074
2075 #[cfg(target_os = "fuchsia")]
2076 fn signal_peer(
2077 &self,
2078 clear_mask: zx::Signals,
2079 set_mask: zx::Signals,
2080 ) -> Result<(), zx_status::Status> {
2081 use fidl::Peered;
2082 self.inner.channel().signal_peer(clear_mask, set_mask)
2083 }
2084}
2085
2086impl DeviceControlHandle {
2087 pub fn send_on_set_format(
2088 &self,
2089 mut frames_per_second: u32,
2090 mut sample_format: u32,
2091 mut num_channels: u32,
2092 mut external_delay: i64,
2093 ) -> Result<(), fidl::Error> {
2094 self.inner.send::<DeviceOnSetFormatRequest>(
2095 (frames_per_second, sample_format, num_channels, external_delay),
2096 0,
2097 0x2a547759ab3678b2,
2098 fidl::encoding::DynamicFlags::empty(),
2099 )
2100 }
2101
2102 pub fn send_on_set_gain(
2103 &self,
2104 mut current_mute: bool,
2105 mut current_agc: bool,
2106 mut current_gain_db: f32,
2107 ) -> Result<(), fidl::Error> {
2108 self.inner.send::<DeviceOnSetGainRequest>(
2109 (current_mute, current_agc, current_gain_db),
2110 0,
2111 0x31fffec81b3a9393,
2112 fidl::encoding::DynamicFlags::empty(),
2113 )
2114 }
2115
2116 pub fn send_on_buffer_created(
2117 &self,
2118 mut ring_buffer: fidl::Vmo,
2119 mut num_ring_buffer_frames: u32,
2120 mut notifications_per_ring: u32,
2121 ) -> Result<(), fidl::Error> {
2122 self.inner.send::<DeviceOnBufferCreatedRequest>(
2123 (ring_buffer, num_ring_buffer_frames, notifications_per_ring),
2124 0,
2125 0x5c2eb72e264afefd,
2126 fidl::encoding::DynamicFlags::empty(),
2127 )
2128 }
2129
2130 pub fn send_on_start(&self, mut start_time: i64) -> Result<(), fidl::Error> {
2131 self.inner.send::<DeviceOnStartRequest>(
2132 (start_time,),
2133 0,
2134 0x498f0b7e64d7ca58,
2135 fidl::encoding::DynamicFlags::empty(),
2136 )
2137 }
2138
2139 pub fn send_on_stop(
2140 &self,
2141 mut stop_time: i64,
2142 mut ring_position: u32,
2143 ) -> Result<(), fidl::Error> {
2144 self.inner.send::<DeviceOnStopRequest>(
2145 (stop_time, ring_position),
2146 0,
2147 0x6f5d4d2fe223ae5b,
2148 fidl::encoding::DynamicFlags::empty(),
2149 )
2150 }
2151
2152 pub fn send_on_position_notify(
2153 &self,
2154 mut monotonic_time: i64,
2155 mut ring_position: u32,
2156 ) -> Result<(), fidl::Error> {
2157 self.inner.send::<DeviceOnPositionNotifyRequest>(
2158 (monotonic_time, ring_position),
2159 0,
2160 0x79274c4de9013585,
2161 fidl::encoding::DynamicFlags::empty(),
2162 )
2163 }
2164}
2165
2166#[must_use = "FIDL methods require a response to be sent"]
2167#[derive(Debug)]
2168pub struct DeviceGetFormatResponder {
2169 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2170 tx_id: u32,
2171}
2172
2173impl std::ops::Drop for DeviceGetFormatResponder {
2177 fn drop(&mut self) {
2178 self.control_handle.shutdown();
2179 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2181 }
2182}
2183
2184impl fidl::endpoints::Responder for DeviceGetFormatResponder {
2185 type ControlHandle = DeviceControlHandle;
2186
2187 fn control_handle(&self) -> &DeviceControlHandle {
2188 &self.control_handle
2189 }
2190
2191 fn drop_without_shutdown(mut self) {
2192 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2194 std::mem::forget(self);
2196 }
2197}
2198
2199impl DeviceGetFormatResponder {
2200 pub fn send(self, mut result: Result<(u32, u32, u32, i64), Error>) -> Result<(), fidl::Error> {
2204 let _result = self.send_raw(result);
2205 if _result.is_err() {
2206 self.control_handle.shutdown();
2207 }
2208 self.drop_without_shutdown();
2209 _result
2210 }
2211
2212 pub fn send_no_shutdown_on_err(
2214 self,
2215 mut result: Result<(u32, u32, u32, i64), Error>,
2216 ) -> Result<(), fidl::Error> {
2217 let _result = self.send_raw(result);
2218 self.drop_without_shutdown();
2219 _result
2220 }
2221
2222 fn send_raw(&self, mut result: Result<(u32, u32, u32, i64), Error>) -> Result<(), fidl::Error> {
2223 self.control_handle
2224 .inner
2225 .send::<fidl::encoding::ResultType<DeviceGetFormatResponse, Error>>(
2226 result,
2227 self.tx_id,
2228 0x6107d32083bacc1b,
2229 fidl::encoding::DynamicFlags::empty(),
2230 )
2231 }
2232}
2233
2234#[must_use = "FIDL methods require a response to be sent"]
2235#[derive(Debug)]
2236pub struct DeviceGetGainResponder {
2237 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2238 tx_id: u32,
2239}
2240
2241impl std::ops::Drop for DeviceGetGainResponder {
2245 fn drop(&mut self) {
2246 self.control_handle.shutdown();
2247 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2249 }
2250}
2251
2252impl fidl::endpoints::Responder for DeviceGetGainResponder {
2253 type ControlHandle = DeviceControlHandle;
2254
2255 fn control_handle(&self) -> &DeviceControlHandle {
2256 &self.control_handle
2257 }
2258
2259 fn drop_without_shutdown(mut self) {
2260 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2262 std::mem::forget(self);
2264 }
2265}
2266
2267impl DeviceGetGainResponder {
2268 pub fn send(self, mut result: Result<(bool, bool, f32), Error>) -> Result<(), fidl::Error> {
2272 let _result = self.send_raw(result);
2273 if _result.is_err() {
2274 self.control_handle.shutdown();
2275 }
2276 self.drop_without_shutdown();
2277 _result
2278 }
2279
2280 pub fn send_no_shutdown_on_err(
2282 self,
2283 mut result: Result<(bool, bool, f32), Error>,
2284 ) -> Result<(), fidl::Error> {
2285 let _result = self.send_raw(result);
2286 self.drop_without_shutdown();
2287 _result
2288 }
2289
2290 fn send_raw(&self, mut result: Result<(bool, bool, f32), Error>) -> Result<(), fidl::Error> {
2291 self.control_handle.inner.send::<fidl::encoding::ResultType<DeviceGetGainResponse, Error>>(
2292 result,
2293 self.tx_id,
2294 0x6d85d82b49fb28e9,
2295 fidl::encoding::DynamicFlags::empty(),
2296 )
2297 }
2298}
2299
2300#[must_use = "FIDL methods require a response to be sent"]
2301#[derive(Debug)]
2302pub struct DeviceGetBufferResponder {
2303 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2304 tx_id: u32,
2305}
2306
2307impl std::ops::Drop for DeviceGetBufferResponder {
2311 fn drop(&mut self) {
2312 self.control_handle.shutdown();
2313 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2315 }
2316}
2317
2318impl fidl::endpoints::Responder for DeviceGetBufferResponder {
2319 type ControlHandle = DeviceControlHandle;
2320
2321 fn control_handle(&self) -> &DeviceControlHandle {
2322 &self.control_handle
2323 }
2324
2325 fn drop_without_shutdown(mut self) {
2326 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2328 std::mem::forget(self);
2330 }
2331}
2332
2333impl DeviceGetBufferResponder {
2334 pub fn send(self, mut result: Result<(fidl::Vmo, u32, u32), Error>) -> Result<(), fidl::Error> {
2338 let _result = self.send_raw(result);
2339 if _result.is_err() {
2340 self.control_handle.shutdown();
2341 }
2342 self.drop_without_shutdown();
2343 _result
2344 }
2345
2346 pub fn send_no_shutdown_on_err(
2348 self,
2349 mut result: Result<(fidl::Vmo, u32, u32), Error>,
2350 ) -> Result<(), fidl::Error> {
2351 let _result = self.send_raw(result);
2352 self.drop_without_shutdown();
2353 _result
2354 }
2355
2356 fn send_raw(
2357 &self,
2358 mut result: Result<(fidl::Vmo, u32, u32), Error>,
2359 ) -> Result<(), fidl::Error> {
2360 self.control_handle
2361 .inner
2362 .send::<fidl::encoding::ResultType<DeviceGetBufferResponse, Error>>(
2363 result,
2364 self.tx_id,
2365 0x38e202be0db060d0,
2366 fidl::encoding::DynamicFlags::empty(),
2367 )
2368 }
2369}
2370
2371#[must_use = "FIDL methods require a response to be sent"]
2372#[derive(Debug)]
2373pub struct DeviceSetNotificationFrequencyResponder {
2374 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2375 tx_id: u32,
2376}
2377
2378impl std::ops::Drop for DeviceSetNotificationFrequencyResponder {
2382 fn drop(&mut self) {
2383 self.control_handle.shutdown();
2384 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2386 }
2387}
2388
2389impl fidl::endpoints::Responder for DeviceSetNotificationFrequencyResponder {
2390 type ControlHandle = DeviceControlHandle;
2391
2392 fn control_handle(&self) -> &DeviceControlHandle {
2393 &self.control_handle
2394 }
2395
2396 fn drop_without_shutdown(mut self) {
2397 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2399 std::mem::forget(self);
2401 }
2402}
2403
2404impl DeviceSetNotificationFrequencyResponder {
2405 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2409 let _result = self.send_raw(result);
2410 if _result.is_err() {
2411 self.control_handle.shutdown();
2412 }
2413 self.drop_without_shutdown();
2414 _result
2415 }
2416
2417 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2419 let _result = self.send_raw(result);
2420 self.drop_without_shutdown();
2421 _result
2422 }
2423
2424 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2425 self.control_handle
2426 .inner
2427 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2428 result,
2429 self.tx_id,
2430 0x45789b88ca9185b8,
2431 fidl::encoding::DynamicFlags::empty(),
2432 )
2433 }
2434}
2435
2436#[must_use = "FIDL methods require a response to be sent"]
2437#[derive(Debug)]
2438pub struct DeviceGetPositionResponder {
2439 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2440 tx_id: u32,
2441}
2442
2443impl std::ops::Drop for DeviceGetPositionResponder {
2447 fn drop(&mut self) {
2448 self.control_handle.shutdown();
2449 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2451 }
2452}
2453
2454impl fidl::endpoints::Responder for DeviceGetPositionResponder {
2455 type ControlHandle = DeviceControlHandle;
2456
2457 fn control_handle(&self) -> &DeviceControlHandle {
2458 &self.control_handle
2459 }
2460
2461 fn drop_without_shutdown(mut self) {
2462 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2464 std::mem::forget(self);
2466 }
2467}
2468
2469impl DeviceGetPositionResponder {
2470 pub fn send(self, mut result: Result<(i64, u32), Error>) -> Result<(), fidl::Error> {
2474 let _result = self.send_raw(result);
2475 if _result.is_err() {
2476 self.control_handle.shutdown();
2477 }
2478 self.drop_without_shutdown();
2479 _result
2480 }
2481
2482 pub fn send_no_shutdown_on_err(
2484 self,
2485 mut result: Result<(i64, u32), Error>,
2486 ) -> Result<(), fidl::Error> {
2487 let _result = self.send_raw(result);
2488 self.drop_without_shutdown();
2489 _result
2490 }
2491
2492 fn send_raw(&self, mut result: Result<(i64, u32), Error>) -> Result<(), fidl::Error> {
2493 self.control_handle
2494 .inner
2495 .send::<fidl::encoding::ResultType<DeviceGetPositionResponse, Error>>(
2496 result,
2497 self.tx_id,
2498 0x6fe5bbf9065258e8,
2499 fidl::encoding::DynamicFlags::empty(),
2500 )
2501 }
2502}
2503
2504#[must_use = "FIDL methods require a response to be sent"]
2505#[derive(Debug)]
2506pub struct DeviceChangePlugStateResponder {
2507 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2508 tx_id: u32,
2509}
2510
2511impl std::ops::Drop for DeviceChangePlugStateResponder {
2515 fn drop(&mut self) {
2516 self.control_handle.shutdown();
2517 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2519 }
2520}
2521
2522impl fidl::endpoints::Responder for DeviceChangePlugStateResponder {
2523 type ControlHandle = DeviceControlHandle;
2524
2525 fn control_handle(&self) -> &DeviceControlHandle {
2526 &self.control_handle
2527 }
2528
2529 fn drop_without_shutdown(mut self) {
2530 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2532 std::mem::forget(self);
2534 }
2535}
2536
2537impl DeviceChangePlugStateResponder {
2538 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2542 let _result = self.send_raw(result);
2543 if _result.is_err() {
2544 self.control_handle.shutdown();
2545 }
2546 self.drop_without_shutdown();
2547 _result
2548 }
2549
2550 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2552 let _result = self.send_raw(result);
2553 self.drop_without_shutdown();
2554 _result
2555 }
2556
2557 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2558 self.control_handle
2559 .inner
2560 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2561 result,
2562 self.tx_id,
2563 0x61aa2d370caaf8f0,
2564 fidl::encoding::DynamicFlags::empty(),
2565 )
2566 }
2567}
2568
2569#[must_use = "FIDL methods require a response to be sent"]
2570#[derive(Debug)]
2571pub struct DeviceAdjustClockRateResponder {
2572 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
2573 tx_id: u32,
2574}
2575
2576impl std::ops::Drop for DeviceAdjustClockRateResponder {
2580 fn drop(&mut self) {
2581 self.control_handle.shutdown();
2582 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2584 }
2585}
2586
2587impl fidl::endpoints::Responder for DeviceAdjustClockRateResponder {
2588 type ControlHandle = DeviceControlHandle;
2589
2590 fn control_handle(&self) -> &DeviceControlHandle {
2591 &self.control_handle
2592 }
2593
2594 fn drop_without_shutdown(mut self) {
2595 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2597 std::mem::forget(self);
2599 }
2600}
2601
2602impl DeviceAdjustClockRateResponder {
2603 pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2607 let _result = self.send_raw(result);
2608 if _result.is_err() {
2609 self.control_handle.shutdown();
2610 }
2611 self.drop_without_shutdown();
2612 _result
2613 }
2614
2615 pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2617 let _result = self.send_raw(result);
2618 self.drop_without_shutdown();
2619 _result
2620 }
2621
2622 fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
2623 self.control_handle
2624 .inner
2625 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
2626 result,
2627 self.tx_id,
2628 0x754661f655350134,
2629 fidl::encoding::DynamicFlags::empty(),
2630 )
2631 }
2632}
2633
2634mod internal {
2635 use super::*;
2636
2637 impl fidl::encoding::ResourceTypeMarker for ControlAddDeviceRequest {
2638 type Borrowed<'a> = &'a mut Self;
2639 fn take_or_borrow<'a>(
2640 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2641 ) -> Self::Borrowed<'a> {
2642 value
2643 }
2644 }
2645
2646 unsafe impl fidl::encoding::TypeMarker for ControlAddDeviceRequest {
2647 type Owned = Self;
2648
2649 #[inline(always)]
2650 fn inline_align(_context: fidl::encoding::Context) -> usize {
2651 8
2652 }
2653
2654 #[inline(always)]
2655 fn inline_size(_context: fidl::encoding::Context) -> usize {
2656 24
2657 }
2658 }
2659
2660 unsafe impl
2661 fidl::encoding::Encode<
2662 ControlAddDeviceRequest,
2663 fidl::encoding::DefaultFuchsiaResourceDialect,
2664 > for &mut ControlAddDeviceRequest
2665 {
2666 #[inline]
2667 unsafe fn encode(
2668 self,
2669 encoder: &mut fidl::encoding::Encoder<
2670 '_,
2671 fidl::encoding::DefaultFuchsiaResourceDialect,
2672 >,
2673 offset: usize,
2674 _depth: fidl::encoding::Depth,
2675 ) -> fidl::Result<()> {
2676 encoder.debug_check_bounds::<ControlAddDeviceRequest>(offset);
2677 fidl::encoding::Encode::<ControlAddDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2679 (
2680 <Configuration as fidl::encoding::ValueTypeMarker>::borrow(&self.config),
2681 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server),
2682 ),
2683 encoder, offset, _depth
2684 )
2685 }
2686 }
2687 unsafe impl<
2688 T0: fidl::encoding::Encode<Configuration, fidl::encoding::DefaultFuchsiaResourceDialect>,
2689 T1: fidl::encoding::Encode<
2690 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2691 fidl::encoding::DefaultFuchsiaResourceDialect,
2692 >,
2693 >
2694 fidl::encoding::Encode<
2695 ControlAddDeviceRequest,
2696 fidl::encoding::DefaultFuchsiaResourceDialect,
2697 > for (T0, T1)
2698 {
2699 #[inline]
2700 unsafe fn encode(
2701 self,
2702 encoder: &mut fidl::encoding::Encoder<
2703 '_,
2704 fidl::encoding::DefaultFuchsiaResourceDialect,
2705 >,
2706 offset: usize,
2707 depth: fidl::encoding::Depth,
2708 ) -> fidl::Result<()> {
2709 encoder.debug_check_bounds::<ControlAddDeviceRequest>(offset);
2710 unsafe {
2713 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2714 (ptr as *mut u64).write_unaligned(0);
2715 }
2716 self.0.encode(encoder, offset + 0, depth)?;
2718 self.1.encode(encoder, offset + 16, depth)?;
2719 Ok(())
2720 }
2721 }
2722
2723 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2724 for ControlAddDeviceRequest
2725 {
2726 #[inline(always)]
2727 fn new_empty() -> Self {
2728 Self {
2729 config: fidl::new_empty!(
2730 Configuration,
2731 fidl::encoding::DefaultFuchsiaResourceDialect
2732 ),
2733 server: fidl::new_empty!(
2734 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2735 fidl::encoding::DefaultFuchsiaResourceDialect
2736 ),
2737 }
2738 }
2739
2740 #[inline]
2741 unsafe fn decode(
2742 &mut self,
2743 decoder: &mut fidl::encoding::Decoder<
2744 '_,
2745 fidl::encoding::DefaultFuchsiaResourceDialect,
2746 >,
2747 offset: usize,
2748 _depth: fidl::encoding::Depth,
2749 ) -> fidl::Result<()> {
2750 decoder.debug_check_bounds::<Self>(offset);
2751 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2753 let padval = unsafe { (ptr as *const u64).read_unaligned() };
2754 let mask = 0xffffffff00000000u64;
2755 let maskedval = padval & mask;
2756 if maskedval != 0 {
2757 return Err(fidl::Error::NonZeroPadding {
2758 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2759 });
2760 }
2761 fidl::decode!(
2762 Configuration,
2763 fidl::encoding::DefaultFuchsiaResourceDialect,
2764 &mut self.config,
2765 decoder,
2766 offset + 0,
2767 _depth
2768 )?;
2769 fidl::decode!(
2770 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DeviceMarker>>,
2771 fidl::encoding::DefaultFuchsiaResourceDialect,
2772 &mut self.server,
2773 decoder,
2774 offset + 16,
2775 _depth
2776 )?;
2777 Ok(())
2778 }
2779 }
2780
2781 impl fidl::encoding::ResourceTypeMarker for DeviceOnBufferCreatedRequest {
2782 type Borrowed<'a> = &'a mut Self;
2783 fn take_or_borrow<'a>(
2784 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2785 ) -> Self::Borrowed<'a> {
2786 value
2787 }
2788 }
2789
2790 unsafe impl fidl::encoding::TypeMarker for DeviceOnBufferCreatedRequest {
2791 type Owned = Self;
2792
2793 #[inline(always)]
2794 fn inline_align(_context: fidl::encoding::Context) -> usize {
2795 4
2796 }
2797
2798 #[inline(always)]
2799 fn inline_size(_context: fidl::encoding::Context) -> usize {
2800 12
2801 }
2802 }
2803
2804 unsafe impl
2805 fidl::encoding::Encode<
2806 DeviceOnBufferCreatedRequest,
2807 fidl::encoding::DefaultFuchsiaResourceDialect,
2808 > for &mut DeviceOnBufferCreatedRequest
2809 {
2810 #[inline]
2811 unsafe fn encode(
2812 self,
2813 encoder: &mut fidl::encoding::Encoder<
2814 '_,
2815 fidl::encoding::DefaultFuchsiaResourceDialect,
2816 >,
2817 offset: usize,
2818 _depth: fidl::encoding::Depth,
2819 ) -> fidl::Result<()> {
2820 encoder.debug_check_bounds::<DeviceOnBufferCreatedRequest>(offset);
2821 fidl::encoding::Encode::<
2823 DeviceOnBufferCreatedRequest,
2824 fidl::encoding::DefaultFuchsiaResourceDialect,
2825 >::encode(
2826 (
2827 <fidl::encoding::HandleType<
2828 fidl::Vmo,
2829 { fidl::ObjectType::VMO.into_raw() },
2830 2147483648,
2831 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2832 &mut self.ring_buffer
2833 ),
2834 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_ring_buffer_frames),
2835 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.notifications_per_ring),
2836 ),
2837 encoder,
2838 offset,
2839 _depth,
2840 )
2841 }
2842 }
2843 unsafe impl<
2844 T0: fidl::encoding::Encode<
2845 fidl::encoding::HandleType<
2846 fidl::Vmo,
2847 { fidl::ObjectType::VMO.into_raw() },
2848 2147483648,
2849 >,
2850 fidl::encoding::DefaultFuchsiaResourceDialect,
2851 >,
2852 T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2853 T2: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2854 >
2855 fidl::encoding::Encode<
2856 DeviceOnBufferCreatedRequest,
2857 fidl::encoding::DefaultFuchsiaResourceDialect,
2858 > for (T0, T1, T2)
2859 {
2860 #[inline]
2861 unsafe fn encode(
2862 self,
2863 encoder: &mut fidl::encoding::Encoder<
2864 '_,
2865 fidl::encoding::DefaultFuchsiaResourceDialect,
2866 >,
2867 offset: usize,
2868 depth: fidl::encoding::Depth,
2869 ) -> fidl::Result<()> {
2870 encoder.debug_check_bounds::<DeviceOnBufferCreatedRequest>(offset);
2871 self.0.encode(encoder, offset + 0, depth)?;
2875 self.1.encode(encoder, offset + 4, depth)?;
2876 self.2.encode(encoder, offset + 8, depth)?;
2877 Ok(())
2878 }
2879 }
2880
2881 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2882 for DeviceOnBufferCreatedRequest
2883 {
2884 #[inline(always)]
2885 fn new_empty() -> Self {
2886 Self {
2887 ring_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2888 num_ring_buffer_frames: fidl::new_empty!(
2889 u32,
2890 fidl::encoding::DefaultFuchsiaResourceDialect
2891 ),
2892 notifications_per_ring: fidl::new_empty!(
2893 u32,
2894 fidl::encoding::DefaultFuchsiaResourceDialect
2895 ),
2896 }
2897 }
2898
2899 #[inline]
2900 unsafe fn decode(
2901 &mut self,
2902 decoder: &mut fidl::encoding::Decoder<
2903 '_,
2904 fidl::encoding::DefaultFuchsiaResourceDialect,
2905 >,
2906 offset: usize,
2907 _depth: fidl::encoding::Depth,
2908 ) -> fidl::Result<()> {
2909 decoder.debug_check_bounds::<Self>(offset);
2910 fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.ring_buffer, decoder, offset + 0, _depth)?;
2912 fidl::decode!(
2913 u32,
2914 fidl::encoding::DefaultFuchsiaResourceDialect,
2915 &mut self.num_ring_buffer_frames,
2916 decoder,
2917 offset + 4,
2918 _depth
2919 )?;
2920 fidl::decode!(
2921 u32,
2922 fidl::encoding::DefaultFuchsiaResourceDialect,
2923 &mut self.notifications_per_ring,
2924 decoder,
2925 offset + 8,
2926 _depth
2927 )?;
2928 Ok(())
2929 }
2930 }
2931
2932 impl fidl::encoding::ResourceTypeMarker for DeviceGetBufferResponse {
2933 type Borrowed<'a> = &'a mut Self;
2934 fn take_or_borrow<'a>(
2935 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2936 ) -> Self::Borrowed<'a> {
2937 value
2938 }
2939 }
2940
2941 unsafe impl fidl::encoding::TypeMarker for DeviceGetBufferResponse {
2942 type Owned = Self;
2943
2944 #[inline(always)]
2945 fn inline_align(_context: fidl::encoding::Context) -> usize {
2946 4
2947 }
2948
2949 #[inline(always)]
2950 fn inline_size(_context: fidl::encoding::Context) -> usize {
2951 12
2952 }
2953 }
2954
2955 unsafe impl
2956 fidl::encoding::Encode<
2957 DeviceGetBufferResponse,
2958 fidl::encoding::DefaultFuchsiaResourceDialect,
2959 > for &mut DeviceGetBufferResponse
2960 {
2961 #[inline]
2962 unsafe fn encode(
2963 self,
2964 encoder: &mut fidl::encoding::Encoder<
2965 '_,
2966 fidl::encoding::DefaultFuchsiaResourceDialect,
2967 >,
2968 offset: usize,
2969 _depth: fidl::encoding::Depth,
2970 ) -> fidl::Result<()> {
2971 encoder.debug_check_bounds::<DeviceGetBufferResponse>(offset);
2972 fidl::encoding::Encode::<
2974 DeviceGetBufferResponse,
2975 fidl::encoding::DefaultFuchsiaResourceDialect,
2976 >::encode(
2977 (
2978 <fidl::encoding::HandleType<
2979 fidl::Vmo,
2980 { fidl::ObjectType::VMO.into_raw() },
2981 2147483648,
2982 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2983 &mut self.ring_buffer
2984 ),
2985 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_ring_buffer_frames),
2986 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.notifications_per_ring),
2987 ),
2988 encoder,
2989 offset,
2990 _depth,
2991 )
2992 }
2993 }
2994 unsafe impl<
2995 T0: fidl::encoding::Encode<
2996 fidl::encoding::HandleType<
2997 fidl::Vmo,
2998 { fidl::ObjectType::VMO.into_raw() },
2999 2147483648,
3000 >,
3001 fidl::encoding::DefaultFuchsiaResourceDialect,
3002 >,
3003 T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
3004 T2: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
3005 >
3006 fidl::encoding::Encode<
3007 DeviceGetBufferResponse,
3008 fidl::encoding::DefaultFuchsiaResourceDialect,
3009 > for (T0, T1, T2)
3010 {
3011 #[inline]
3012 unsafe fn encode(
3013 self,
3014 encoder: &mut fidl::encoding::Encoder<
3015 '_,
3016 fidl::encoding::DefaultFuchsiaResourceDialect,
3017 >,
3018 offset: usize,
3019 depth: fidl::encoding::Depth,
3020 ) -> fidl::Result<()> {
3021 encoder.debug_check_bounds::<DeviceGetBufferResponse>(offset);
3022 self.0.encode(encoder, offset + 0, depth)?;
3026 self.1.encode(encoder, offset + 4, depth)?;
3027 self.2.encode(encoder, offset + 8, depth)?;
3028 Ok(())
3029 }
3030 }
3031
3032 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3033 for DeviceGetBufferResponse
3034 {
3035 #[inline(always)]
3036 fn new_empty() -> Self {
3037 Self {
3038 ring_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3039 num_ring_buffer_frames: fidl::new_empty!(
3040 u32,
3041 fidl::encoding::DefaultFuchsiaResourceDialect
3042 ),
3043 notifications_per_ring: fidl::new_empty!(
3044 u32,
3045 fidl::encoding::DefaultFuchsiaResourceDialect
3046 ),
3047 }
3048 }
3049
3050 #[inline]
3051 unsafe fn decode(
3052 &mut self,
3053 decoder: &mut fidl::encoding::Decoder<
3054 '_,
3055 fidl::encoding::DefaultFuchsiaResourceDialect,
3056 >,
3057 offset: usize,
3058 _depth: fidl::encoding::Depth,
3059 ) -> fidl::Result<()> {
3060 decoder.debug_check_bounds::<Self>(offset);
3061 fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.ring_buffer, decoder, offset + 0, _depth)?;
3063 fidl::decode!(
3064 u32,
3065 fidl::encoding::DefaultFuchsiaResourceDialect,
3066 &mut self.num_ring_buffer_frames,
3067 decoder,
3068 offset + 4,
3069 _depth
3070 )?;
3071 fidl::decode!(
3072 u32,
3073 fidl::encoding::DefaultFuchsiaResourceDialect,
3074 &mut self.notifications_per_ring,
3075 decoder,
3076 offset + 8,
3077 _depth
3078 )?;
3079 Ok(())
3080 }
3081 }
3082}