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