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_usb_policy_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ConfigurationMarker;
16
17impl fidl::endpoints::ProtocolMarker for ConfigurationMarker {
18 type Proxy = ConfigurationProxy;
19 type RequestStream = ConfigurationRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ConfigurationSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.usb.policy.Configuration";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ConfigurationMarker {}
26pub type ConfigurationGetConfigurationResult = Result<
27 (
28 fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
29 Vec<Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>>,
30 ),
31 i32,
32>;
33pub type ConfigurationSetConfigurationResult = Result<(), i32>;
34
35pub trait ConfigurationProxyInterface: Send + Sync {
36 type GetConfigurationResponseFut: std::future::Future<Output = Result<ConfigurationGetConfigurationResult, fidl::Error>>
37 + Send;
38 fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut;
39 type SetConfigurationResponseFut: std::future::Future<Output = Result<ConfigurationSetConfigurationResult, fidl::Error>>
40 + Send;
41 fn r#set_configuration(
42 &self,
43 device_desc: &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
44 config_descriptors: &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
45 ) -> Self::SetConfigurationResponseFut;
46}
47#[derive(Debug)]
48#[cfg(target_os = "fuchsia")]
49pub struct ConfigurationSynchronousProxy {
50 client: fidl::client::sync::Client,
51}
52
53#[cfg(target_os = "fuchsia")]
54impl fidl::endpoints::SynchronousProxy for ConfigurationSynchronousProxy {
55 type Proxy = ConfigurationProxy;
56 type Protocol = ConfigurationMarker;
57
58 fn from_channel(inner: fidl::Channel) -> Self {
59 Self::new(inner)
60 }
61
62 fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 fn as_channel(&self) -> &fidl::Channel {
67 self.client.as_channel()
68 }
69}
70
71#[cfg(target_os = "fuchsia")]
72impl ConfigurationSynchronousProxy {
73 pub fn new(channel: fidl::Channel) -> Self {
74 Self { client: fidl::client::sync::Client::new(channel) }
75 }
76
77 pub fn into_channel(self) -> fidl::Channel {
78 self.client.into_channel()
79 }
80
81 pub fn wait_for_event(
84 &self,
85 deadline: zx::MonotonicInstant,
86 ) -> Result<ConfigurationEvent, fidl::Error> {
87 ConfigurationEvent::decode(self.client.wait_for_event::<ConfigurationMarker>(deadline)?)
88 }
89
90 pub fn r#get_configuration(
97 &self,
98 ___deadline: zx::MonotonicInstant,
99 ) -> Result<ConfigurationGetConfigurationResult, fidl::Error> {
100 let _response = self.client.send_query::<
101 fidl::encoding::EmptyPayload,
102 fidl::encoding::FlexibleResultType<ConfigurationGetConfigurationResponse, i32>,
103 ConfigurationMarker,
104 >(
105 (),
106 0x451bbf2edea95fec,
107 fidl::encoding::DynamicFlags::FLEXIBLE,
108 ___deadline,
109 )?
110 .into_result::<ConfigurationMarker>("get_configuration")?;
111 Ok(_response.map(|x| (x.device_desc, x.config_descriptors)))
112 }
113
114 pub fn r#set_configuration(
128 &self,
129 mut device_desc: &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
130 mut config_descriptors: &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
131 ___deadline: zx::MonotonicInstant,
132 ) -> Result<ConfigurationSetConfigurationResult, fidl::Error> {
133 let _response = self.client.send_query::<
134 ConfigurationSetConfigurationRequest,
135 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
136 ConfigurationMarker,
137 >(
138 (device_desc, config_descriptors,),
139 0x188b98e71fce9223,
140 fidl::encoding::DynamicFlags::FLEXIBLE,
141 ___deadline,
142 )?
143 .into_result::<ConfigurationMarker>("set_configuration")?;
144 Ok(_response.map(|x| x))
145 }
146}
147
148#[cfg(target_os = "fuchsia")]
149impl From<ConfigurationSynchronousProxy> for zx::NullableHandle {
150 fn from(value: ConfigurationSynchronousProxy) -> Self {
151 value.into_channel().into()
152 }
153}
154
155#[cfg(target_os = "fuchsia")]
156impl From<fidl::Channel> for ConfigurationSynchronousProxy {
157 fn from(value: fidl::Channel) -> Self {
158 Self::new(value)
159 }
160}
161
162#[cfg(target_os = "fuchsia")]
163impl fidl::endpoints::FromClient for ConfigurationSynchronousProxy {
164 type Protocol = ConfigurationMarker;
165
166 fn from_client(value: fidl::endpoints::ClientEnd<ConfigurationMarker>) -> Self {
167 Self::new(value.into_channel())
168 }
169}
170
171#[derive(Debug, Clone)]
172pub struct ConfigurationProxy {
173 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
174}
175
176impl fidl::endpoints::Proxy for ConfigurationProxy {
177 type Protocol = ConfigurationMarker;
178
179 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
180 Self::new(inner)
181 }
182
183 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
184 self.client.into_channel().map_err(|client| Self { client })
185 }
186
187 fn as_channel(&self) -> &::fidl::AsyncChannel {
188 self.client.as_channel()
189 }
190}
191
192impl ConfigurationProxy {
193 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
195 let protocol_name = <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
196 Self { client: fidl::client::Client::new(channel, protocol_name) }
197 }
198
199 pub fn take_event_stream(&self) -> ConfigurationEventStream {
205 ConfigurationEventStream { event_receiver: self.client.take_event_receiver() }
206 }
207
208 pub fn r#get_configuration(
215 &self,
216 ) -> fidl::client::QueryResponseFut<
217 ConfigurationGetConfigurationResult,
218 fidl::encoding::DefaultFuchsiaResourceDialect,
219 > {
220 ConfigurationProxyInterface::r#get_configuration(self)
221 }
222
223 pub fn r#set_configuration(
237 &self,
238 mut device_desc: &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
239 mut config_descriptors: &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
240 ) -> fidl::client::QueryResponseFut<
241 ConfigurationSetConfigurationResult,
242 fidl::encoding::DefaultFuchsiaResourceDialect,
243 > {
244 ConfigurationProxyInterface::r#set_configuration(self, device_desc, config_descriptors)
245 }
246}
247
248impl ConfigurationProxyInterface for ConfigurationProxy {
249 type GetConfigurationResponseFut = fidl::client::QueryResponseFut<
250 ConfigurationGetConfigurationResult,
251 fidl::encoding::DefaultFuchsiaResourceDialect,
252 >;
253 fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut {
254 fn _decode(
255 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
256 ) -> Result<ConfigurationGetConfigurationResult, fidl::Error> {
257 let _response = fidl::client::decode_transaction_body::<
258 fidl::encoding::FlexibleResultType<ConfigurationGetConfigurationResponse, i32>,
259 fidl::encoding::DefaultFuchsiaResourceDialect,
260 0x451bbf2edea95fec,
261 >(_buf?)?
262 .into_result::<ConfigurationMarker>("get_configuration")?;
263 Ok(_response.map(|x| (x.device_desc, x.config_descriptors)))
264 }
265 self.client.send_query_and_decode::<
266 fidl::encoding::EmptyPayload,
267 ConfigurationGetConfigurationResult,
268 >(
269 (),
270 0x451bbf2edea95fec,
271 fidl::encoding::DynamicFlags::FLEXIBLE,
272 _decode,
273 )
274 }
275
276 type SetConfigurationResponseFut = fidl::client::QueryResponseFut<
277 ConfigurationSetConfigurationResult,
278 fidl::encoding::DefaultFuchsiaResourceDialect,
279 >;
280 fn r#set_configuration(
281 &self,
282 mut device_desc: &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
283 mut config_descriptors: &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
284 ) -> Self::SetConfigurationResponseFut {
285 fn _decode(
286 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
287 ) -> Result<ConfigurationSetConfigurationResult, fidl::Error> {
288 let _response = fidl::client::decode_transaction_body::<
289 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
290 fidl::encoding::DefaultFuchsiaResourceDialect,
291 0x188b98e71fce9223,
292 >(_buf?)?
293 .into_result::<ConfigurationMarker>("set_configuration")?;
294 Ok(_response.map(|x| x))
295 }
296 self.client.send_query_and_decode::<
297 ConfigurationSetConfigurationRequest,
298 ConfigurationSetConfigurationResult,
299 >(
300 (device_desc, config_descriptors,),
301 0x188b98e71fce9223,
302 fidl::encoding::DynamicFlags::FLEXIBLE,
303 _decode,
304 )
305 }
306}
307
308pub struct ConfigurationEventStream {
309 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
310}
311
312impl std::marker::Unpin for ConfigurationEventStream {}
313
314impl futures::stream::FusedStream for ConfigurationEventStream {
315 fn is_terminated(&self) -> bool {
316 self.event_receiver.is_terminated()
317 }
318}
319
320impl futures::Stream for ConfigurationEventStream {
321 type Item = Result<ConfigurationEvent, fidl::Error>;
322
323 fn poll_next(
324 mut self: std::pin::Pin<&mut Self>,
325 cx: &mut std::task::Context<'_>,
326 ) -> std::task::Poll<Option<Self::Item>> {
327 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
328 &mut self.event_receiver,
329 cx
330 )?) {
331 Some(buf) => std::task::Poll::Ready(Some(ConfigurationEvent::decode(buf))),
332 None => std::task::Poll::Ready(None),
333 }
334 }
335}
336
337#[derive(Debug)]
338pub enum ConfigurationEvent {
339 #[non_exhaustive]
340 _UnknownEvent {
341 ordinal: u64,
343 },
344}
345
346impl ConfigurationEvent {
347 fn decode(
349 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
350 ) -> Result<ConfigurationEvent, fidl::Error> {
351 let (bytes, _handles) = buf.split_mut();
352 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
353 debug_assert_eq!(tx_header.tx_id, 0);
354 match tx_header.ordinal {
355 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
356 Ok(ConfigurationEvent::_UnknownEvent { ordinal: tx_header.ordinal })
357 }
358 _ => Err(fidl::Error::UnknownOrdinal {
359 ordinal: tx_header.ordinal,
360 protocol_name: <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
361 }),
362 }
363 }
364}
365
366pub struct ConfigurationRequestStream {
368 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
369 is_terminated: bool,
370}
371
372impl std::marker::Unpin for ConfigurationRequestStream {}
373
374impl futures::stream::FusedStream for ConfigurationRequestStream {
375 fn is_terminated(&self) -> bool {
376 self.is_terminated
377 }
378}
379
380impl fidl::endpoints::RequestStream for ConfigurationRequestStream {
381 type Protocol = ConfigurationMarker;
382 type ControlHandle = ConfigurationControlHandle;
383
384 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
385 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
386 }
387
388 fn control_handle(&self) -> Self::ControlHandle {
389 ConfigurationControlHandle { inner: self.inner.clone() }
390 }
391
392 fn into_inner(
393 self,
394 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
395 {
396 (self.inner, self.is_terminated)
397 }
398
399 fn from_inner(
400 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
401 is_terminated: bool,
402 ) -> Self {
403 Self { inner, is_terminated }
404 }
405}
406
407impl futures::Stream for ConfigurationRequestStream {
408 type Item = Result<ConfigurationRequest, fidl::Error>;
409
410 fn poll_next(
411 mut self: std::pin::Pin<&mut Self>,
412 cx: &mut std::task::Context<'_>,
413 ) -> std::task::Poll<Option<Self::Item>> {
414 let this = &mut *self;
415 if this.inner.check_shutdown(cx) {
416 this.is_terminated = true;
417 return std::task::Poll::Ready(None);
418 }
419 if this.is_terminated {
420 panic!("polled ConfigurationRequestStream after completion");
421 }
422 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
423 |bytes, handles| {
424 match this.inner.channel().read_etc(cx, bytes, handles) {
425 std::task::Poll::Ready(Ok(())) => {}
426 std::task::Poll::Pending => return std::task::Poll::Pending,
427 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
428 this.is_terminated = true;
429 return std::task::Poll::Ready(None);
430 }
431 std::task::Poll::Ready(Err(e)) => {
432 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
433 e.into(),
434 ))));
435 }
436 }
437
438 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
440
441 std::task::Poll::Ready(Some(match header.ordinal {
442 0x451bbf2edea95fec => {
443 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
444 let mut req = fidl::new_empty!(
445 fidl::encoding::EmptyPayload,
446 fidl::encoding::DefaultFuchsiaResourceDialect
447 );
448 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
449 let control_handle =
450 ConfigurationControlHandle { inner: this.inner.clone() };
451 Ok(ConfigurationRequest::GetConfiguration {
452 responder: ConfigurationGetConfigurationResponder {
453 control_handle: std::mem::ManuallyDrop::new(control_handle),
454 tx_id: header.tx_id,
455 },
456 })
457 }
458 0x188b98e71fce9223 => {
459 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
460 let mut req = fidl::new_empty!(
461 ConfigurationSetConfigurationRequest,
462 fidl::encoding::DefaultFuchsiaResourceDialect
463 );
464 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConfigurationSetConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
465 let control_handle =
466 ConfigurationControlHandle { inner: this.inner.clone() };
467 Ok(ConfigurationRequest::SetConfiguration {
468 device_desc: req.device_desc,
469 config_descriptors: req.config_descriptors,
470
471 responder: ConfigurationSetConfigurationResponder {
472 control_handle: std::mem::ManuallyDrop::new(control_handle),
473 tx_id: header.tx_id,
474 },
475 })
476 }
477 _ if header.tx_id == 0
478 && header
479 .dynamic_flags()
480 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
481 {
482 Ok(ConfigurationRequest::_UnknownMethod {
483 ordinal: header.ordinal,
484 control_handle: ConfigurationControlHandle {
485 inner: this.inner.clone(),
486 },
487 method_type: fidl::MethodType::OneWay,
488 })
489 }
490 _ if header
491 .dynamic_flags()
492 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
493 {
494 this.inner.send_framework_err(
495 fidl::encoding::FrameworkErr::UnknownMethod,
496 header.tx_id,
497 header.ordinal,
498 header.dynamic_flags(),
499 (bytes, handles),
500 )?;
501 Ok(ConfigurationRequest::_UnknownMethod {
502 ordinal: header.ordinal,
503 control_handle: ConfigurationControlHandle {
504 inner: this.inner.clone(),
505 },
506 method_type: fidl::MethodType::TwoWay,
507 })
508 }
509 _ => Err(fidl::Error::UnknownOrdinal {
510 ordinal: header.ordinal,
511 protocol_name:
512 <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
513 }),
514 }))
515 },
516 )
517 }
518}
519
520#[derive(Debug)]
525pub enum ConfigurationRequest {
526 GetConfiguration { responder: ConfigurationGetConfigurationResponder },
533 SetConfiguration {
547 device_desc: fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
548 config_descriptors: Vec<Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>>,
549 responder: ConfigurationSetConfigurationResponder,
550 },
551 #[non_exhaustive]
553 _UnknownMethod {
554 ordinal: u64,
556 control_handle: ConfigurationControlHandle,
557 method_type: fidl::MethodType,
558 },
559}
560
561impl ConfigurationRequest {
562 #[allow(irrefutable_let_patterns)]
563 pub fn into_get_configuration(self) -> Option<(ConfigurationGetConfigurationResponder)> {
564 if let ConfigurationRequest::GetConfiguration { responder } = self {
565 Some((responder))
566 } else {
567 None
568 }
569 }
570
571 #[allow(irrefutable_let_patterns)]
572 pub fn into_set_configuration(
573 self,
574 ) -> Option<(
575 fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
576 Vec<Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>>,
577 ConfigurationSetConfigurationResponder,
578 )> {
579 if let ConfigurationRequest::SetConfiguration {
580 device_desc,
581 config_descriptors,
582 responder,
583 } = self
584 {
585 Some((device_desc, config_descriptors, responder))
586 } else {
587 None
588 }
589 }
590
591 pub fn method_name(&self) -> &'static str {
593 match *self {
594 ConfigurationRequest::GetConfiguration { .. } => "get_configuration",
595 ConfigurationRequest::SetConfiguration { .. } => "set_configuration",
596 ConfigurationRequest::_UnknownMethod {
597 method_type: fidl::MethodType::OneWay, ..
598 } => "unknown one-way method",
599 ConfigurationRequest::_UnknownMethod {
600 method_type: fidl::MethodType::TwoWay, ..
601 } => "unknown two-way method",
602 }
603 }
604}
605
606#[derive(Debug, Clone)]
607pub struct ConfigurationControlHandle {
608 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
609}
610
611impl ConfigurationControlHandle {
612 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
613 self.inner.shutdown_with_epitaph(status.into())
614 }
615}
616
617impl fidl::endpoints::ControlHandle for ConfigurationControlHandle {
618 fn shutdown(&self) {
619 self.inner.shutdown()
620 }
621
622 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
623 self.inner.shutdown_with_epitaph(status)
624 }
625
626 fn is_closed(&self) -> bool {
627 self.inner.channel().is_closed()
628 }
629 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
630 self.inner.channel().on_closed()
631 }
632
633 #[cfg(target_os = "fuchsia")]
634 fn signal_peer(
635 &self,
636 clear_mask: zx::Signals,
637 set_mask: zx::Signals,
638 ) -> Result<(), zx_status::Status> {
639 use fidl::Peered;
640 self.inner.channel().signal_peer(clear_mask, set_mask)
641 }
642}
643
644impl ConfigurationControlHandle {}
645
646#[must_use = "FIDL methods require a response to be sent"]
647#[derive(Debug)]
648pub struct ConfigurationGetConfigurationResponder {
649 control_handle: std::mem::ManuallyDrop<ConfigurationControlHandle>,
650 tx_id: u32,
651}
652
653impl std::ops::Drop for ConfigurationGetConfigurationResponder {
657 fn drop(&mut self) {
658 self.control_handle.shutdown();
659 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
661 }
662}
663
664impl fidl::endpoints::Responder for ConfigurationGetConfigurationResponder {
665 type ControlHandle = ConfigurationControlHandle;
666
667 fn control_handle(&self) -> &ConfigurationControlHandle {
668 &self.control_handle
669 }
670
671 fn drop_without_shutdown(mut self) {
672 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
674 std::mem::forget(self);
676 }
677}
678
679impl ConfigurationGetConfigurationResponder {
680 pub fn send(
684 self,
685 mut result: Result<
686 (
687 &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
688 &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
689 ),
690 i32,
691 >,
692 ) -> Result<(), fidl::Error> {
693 let _result = self.send_raw(result);
694 if _result.is_err() {
695 self.control_handle.shutdown();
696 }
697 self.drop_without_shutdown();
698 _result
699 }
700
701 pub fn send_no_shutdown_on_err(
703 self,
704 mut result: Result<
705 (
706 &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
707 &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
708 ),
709 i32,
710 >,
711 ) -> Result<(), fidl::Error> {
712 let _result = self.send_raw(result);
713 self.drop_without_shutdown();
714 _result
715 }
716
717 fn send_raw(
718 &self,
719 mut result: Result<
720 (
721 &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
722 &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
723 ),
724 i32,
725 >,
726 ) -> Result<(), fidl::Error> {
727 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
728 ConfigurationGetConfigurationResponse,
729 i32,
730 >>(
731 fidl::encoding::FlexibleResult::new(result),
732 self.tx_id,
733 0x451bbf2edea95fec,
734 fidl::encoding::DynamicFlags::FLEXIBLE,
735 )
736 }
737}
738
739#[must_use = "FIDL methods require a response to be sent"]
740#[derive(Debug)]
741pub struct ConfigurationSetConfigurationResponder {
742 control_handle: std::mem::ManuallyDrop<ConfigurationControlHandle>,
743 tx_id: u32,
744}
745
746impl std::ops::Drop for ConfigurationSetConfigurationResponder {
750 fn drop(&mut self) {
751 self.control_handle.shutdown();
752 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
754 }
755}
756
757impl fidl::endpoints::Responder for ConfigurationSetConfigurationResponder {
758 type ControlHandle = ConfigurationControlHandle;
759
760 fn control_handle(&self) -> &ConfigurationControlHandle {
761 &self.control_handle
762 }
763
764 fn drop_without_shutdown(mut self) {
765 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
767 std::mem::forget(self);
769 }
770}
771
772impl ConfigurationSetConfigurationResponder {
773 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
777 let _result = self.send_raw(result);
778 if _result.is_err() {
779 self.control_handle.shutdown();
780 }
781 self.drop_without_shutdown();
782 _result
783 }
784
785 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
787 let _result = self.send_raw(result);
788 self.drop_without_shutdown();
789 _result
790 }
791
792 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
793 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
794 fidl::encoding::EmptyStruct,
795 i32,
796 >>(
797 fidl::encoding::FlexibleResult::new(result),
798 self.tx_id,
799 0x188b98e71fce9223,
800 fidl::encoding::DynamicFlags::FLEXIBLE,
801 )
802 }
803}
804
805#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
806pub struct HealthMarker;
807
808impl fidl::endpoints::ProtocolMarker for HealthMarker {
809 type Proxy = HealthProxy;
810 type RequestStream = HealthRequestStream;
811 #[cfg(target_os = "fuchsia")]
812 type SynchronousProxy = HealthSynchronousProxy;
813
814 const DEBUG_NAME: &'static str = "fuchsia.usb.policy.Health";
815}
816impl fidl::endpoints::DiscoverableProtocolMarker for HealthMarker {}
817pub type HealthGetReportResult = Result<HealthReport, i32>;
818
819pub trait HealthProxyInterface: Send + Sync {
820 type GetReportResponseFut: std::future::Future<Output = Result<HealthGetReportResult, fidl::Error>>
821 + Send;
822 fn r#get_report(&self) -> Self::GetReportResponseFut;
823}
824#[derive(Debug)]
825#[cfg(target_os = "fuchsia")]
826pub struct HealthSynchronousProxy {
827 client: fidl::client::sync::Client,
828}
829
830#[cfg(target_os = "fuchsia")]
831impl fidl::endpoints::SynchronousProxy for HealthSynchronousProxy {
832 type Proxy = HealthProxy;
833 type Protocol = HealthMarker;
834
835 fn from_channel(inner: fidl::Channel) -> Self {
836 Self::new(inner)
837 }
838
839 fn into_channel(self) -> fidl::Channel {
840 self.client.into_channel()
841 }
842
843 fn as_channel(&self) -> &fidl::Channel {
844 self.client.as_channel()
845 }
846}
847
848#[cfg(target_os = "fuchsia")]
849impl HealthSynchronousProxy {
850 pub fn new(channel: fidl::Channel) -> Self {
851 Self { client: fidl::client::sync::Client::new(channel) }
852 }
853
854 pub fn into_channel(self) -> fidl::Channel {
855 self.client.into_channel()
856 }
857
858 pub fn wait_for_event(
861 &self,
862 deadline: zx::MonotonicInstant,
863 ) -> Result<HealthEvent, fidl::Error> {
864 HealthEvent::decode(self.client.wait_for_event::<HealthMarker>(deadline)?)
865 }
866
867 pub fn r#get_report(
869 &self,
870 ___deadline: zx::MonotonicInstant,
871 ) -> Result<HealthGetReportResult, fidl::Error> {
872 let _response = self.client.send_query::<
873 fidl::encoding::EmptyPayload,
874 fidl::encoding::FlexibleResultType<HealthReport, i32>,
875 HealthMarker,
876 >(
877 (),
878 0x45f3bc8cbb38e701,
879 fidl::encoding::DynamicFlags::FLEXIBLE,
880 ___deadline,
881 )?
882 .into_result::<HealthMarker>("get_report")?;
883 Ok(_response.map(|x| x))
884 }
885}
886
887#[cfg(target_os = "fuchsia")]
888impl From<HealthSynchronousProxy> for zx::NullableHandle {
889 fn from(value: HealthSynchronousProxy) -> Self {
890 value.into_channel().into()
891 }
892}
893
894#[cfg(target_os = "fuchsia")]
895impl From<fidl::Channel> for HealthSynchronousProxy {
896 fn from(value: fidl::Channel) -> Self {
897 Self::new(value)
898 }
899}
900
901#[cfg(target_os = "fuchsia")]
902impl fidl::endpoints::FromClient for HealthSynchronousProxy {
903 type Protocol = HealthMarker;
904
905 fn from_client(value: fidl::endpoints::ClientEnd<HealthMarker>) -> Self {
906 Self::new(value.into_channel())
907 }
908}
909
910#[derive(Debug, Clone)]
911pub struct HealthProxy {
912 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
913}
914
915impl fidl::endpoints::Proxy for HealthProxy {
916 type Protocol = HealthMarker;
917
918 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
919 Self::new(inner)
920 }
921
922 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
923 self.client.into_channel().map_err(|client| Self { client })
924 }
925
926 fn as_channel(&self) -> &::fidl::AsyncChannel {
927 self.client.as_channel()
928 }
929}
930
931impl HealthProxy {
932 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
934 let protocol_name = <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
935 Self { client: fidl::client::Client::new(channel, protocol_name) }
936 }
937
938 pub fn take_event_stream(&self) -> HealthEventStream {
944 HealthEventStream { event_receiver: self.client.take_event_receiver() }
945 }
946
947 pub fn r#get_report(
949 &self,
950 ) -> fidl::client::QueryResponseFut<
951 HealthGetReportResult,
952 fidl::encoding::DefaultFuchsiaResourceDialect,
953 > {
954 HealthProxyInterface::r#get_report(self)
955 }
956}
957
958impl HealthProxyInterface for HealthProxy {
959 type GetReportResponseFut = fidl::client::QueryResponseFut<
960 HealthGetReportResult,
961 fidl::encoding::DefaultFuchsiaResourceDialect,
962 >;
963 fn r#get_report(&self) -> Self::GetReportResponseFut {
964 fn _decode(
965 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
966 ) -> Result<HealthGetReportResult, fidl::Error> {
967 let _response = fidl::client::decode_transaction_body::<
968 fidl::encoding::FlexibleResultType<HealthReport, i32>,
969 fidl::encoding::DefaultFuchsiaResourceDialect,
970 0x45f3bc8cbb38e701,
971 >(_buf?)?
972 .into_result::<HealthMarker>("get_report")?;
973 Ok(_response.map(|x| x))
974 }
975 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HealthGetReportResult>(
976 (),
977 0x45f3bc8cbb38e701,
978 fidl::encoding::DynamicFlags::FLEXIBLE,
979 _decode,
980 )
981 }
982}
983
984pub struct HealthEventStream {
985 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
986}
987
988impl std::marker::Unpin for HealthEventStream {}
989
990impl futures::stream::FusedStream for HealthEventStream {
991 fn is_terminated(&self) -> bool {
992 self.event_receiver.is_terminated()
993 }
994}
995
996impl futures::Stream for HealthEventStream {
997 type Item = Result<HealthEvent, fidl::Error>;
998
999 fn poll_next(
1000 mut self: std::pin::Pin<&mut Self>,
1001 cx: &mut std::task::Context<'_>,
1002 ) -> std::task::Poll<Option<Self::Item>> {
1003 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1004 &mut self.event_receiver,
1005 cx
1006 )?) {
1007 Some(buf) => std::task::Poll::Ready(Some(HealthEvent::decode(buf))),
1008 None => std::task::Poll::Ready(None),
1009 }
1010 }
1011}
1012
1013#[derive(Debug)]
1014pub enum HealthEvent {
1015 #[non_exhaustive]
1016 _UnknownEvent {
1017 ordinal: u64,
1019 },
1020}
1021
1022impl HealthEvent {
1023 fn decode(
1025 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1026 ) -> Result<HealthEvent, fidl::Error> {
1027 let (bytes, _handles) = buf.split_mut();
1028 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1029 debug_assert_eq!(tx_header.tx_id, 0);
1030 match tx_header.ordinal {
1031 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1032 Ok(HealthEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1033 }
1034 _ => Err(fidl::Error::UnknownOrdinal {
1035 ordinal: tx_header.ordinal,
1036 protocol_name: <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1037 }),
1038 }
1039 }
1040}
1041
1042pub struct HealthRequestStream {
1044 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1045 is_terminated: bool,
1046}
1047
1048impl std::marker::Unpin for HealthRequestStream {}
1049
1050impl futures::stream::FusedStream for HealthRequestStream {
1051 fn is_terminated(&self) -> bool {
1052 self.is_terminated
1053 }
1054}
1055
1056impl fidl::endpoints::RequestStream for HealthRequestStream {
1057 type Protocol = HealthMarker;
1058 type ControlHandle = HealthControlHandle;
1059
1060 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1061 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1062 }
1063
1064 fn control_handle(&self) -> Self::ControlHandle {
1065 HealthControlHandle { inner: self.inner.clone() }
1066 }
1067
1068 fn into_inner(
1069 self,
1070 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1071 {
1072 (self.inner, self.is_terminated)
1073 }
1074
1075 fn from_inner(
1076 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1077 is_terminated: bool,
1078 ) -> Self {
1079 Self { inner, is_terminated }
1080 }
1081}
1082
1083impl futures::Stream for HealthRequestStream {
1084 type Item = Result<HealthRequest, fidl::Error>;
1085
1086 fn poll_next(
1087 mut self: std::pin::Pin<&mut Self>,
1088 cx: &mut std::task::Context<'_>,
1089 ) -> std::task::Poll<Option<Self::Item>> {
1090 let this = &mut *self;
1091 if this.inner.check_shutdown(cx) {
1092 this.is_terminated = true;
1093 return std::task::Poll::Ready(None);
1094 }
1095 if this.is_terminated {
1096 panic!("polled HealthRequestStream after completion");
1097 }
1098 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1099 |bytes, handles| {
1100 match this.inner.channel().read_etc(cx, bytes, handles) {
1101 std::task::Poll::Ready(Ok(())) => {}
1102 std::task::Poll::Pending => return std::task::Poll::Pending,
1103 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1104 this.is_terminated = true;
1105 return std::task::Poll::Ready(None);
1106 }
1107 std::task::Poll::Ready(Err(e)) => {
1108 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1109 e.into(),
1110 ))));
1111 }
1112 }
1113
1114 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1116
1117 std::task::Poll::Ready(Some(match header.ordinal {
1118 0x45f3bc8cbb38e701 => {
1119 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1120 let mut req = fidl::new_empty!(
1121 fidl::encoding::EmptyPayload,
1122 fidl::encoding::DefaultFuchsiaResourceDialect
1123 );
1124 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1125 let control_handle = HealthControlHandle { inner: this.inner.clone() };
1126 Ok(HealthRequest::GetReport {
1127 responder: HealthGetReportResponder {
1128 control_handle: std::mem::ManuallyDrop::new(control_handle),
1129 tx_id: header.tx_id,
1130 },
1131 })
1132 }
1133 _ if header.tx_id == 0
1134 && header
1135 .dynamic_flags()
1136 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1137 {
1138 Ok(HealthRequest::_UnknownMethod {
1139 ordinal: header.ordinal,
1140 control_handle: HealthControlHandle { inner: this.inner.clone() },
1141 method_type: fidl::MethodType::OneWay,
1142 })
1143 }
1144 _ if header
1145 .dynamic_flags()
1146 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1147 {
1148 this.inner.send_framework_err(
1149 fidl::encoding::FrameworkErr::UnknownMethod,
1150 header.tx_id,
1151 header.ordinal,
1152 header.dynamic_flags(),
1153 (bytes, handles),
1154 )?;
1155 Ok(HealthRequest::_UnknownMethod {
1156 ordinal: header.ordinal,
1157 control_handle: HealthControlHandle { inner: this.inner.clone() },
1158 method_type: fidl::MethodType::TwoWay,
1159 })
1160 }
1161 _ => Err(fidl::Error::UnknownOrdinal {
1162 ordinal: header.ordinal,
1163 protocol_name:
1164 <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1165 }),
1166 }))
1167 },
1168 )
1169 }
1170}
1171
1172#[derive(Debug)]
1174pub enum HealthRequest {
1175 GetReport { responder: HealthGetReportResponder },
1177 #[non_exhaustive]
1179 _UnknownMethod {
1180 ordinal: u64,
1182 control_handle: HealthControlHandle,
1183 method_type: fidl::MethodType,
1184 },
1185}
1186
1187impl HealthRequest {
1188 #[allow(irrefutable_let_patterns)]
1189 pub fn into_get_report(self) -> Option<(HealthGetReportResponder)> {
1190 if let HealthRequest::GetReport { responder } = self { Some((responder)) } else { None }
1191 }
1192
1193 pub fn method_name(&self) -> &'static str {
1195 match *self {
1196 HealthRequest::GetReport { .. } => "get_report",
1197 HealthRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1198 "unknown one-way method"
1199 }
1200 HealthRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1201 "unknown two-way method"
1202 }
1203 }
1204 }
1205}
1206
1207#[derive(Debug, Clone)]
1208pub struct HealthControlHandle {
1209 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1210}
1211
1212impl HealthControlHandle {
1213 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1214 self.inner.shutdown_with_epitaph(status.into())
1215 }
1216}
1217
1218impl fidl::endpoints::ControlHandle for HealthControlHandle {
1219 fn shutdown(&self) {
1220 self.inner.shutdown()
1221 }
1222
1223 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1224 self.inner.shutdown_with_epitaph(status)
1225 }
1226
1227 fn is_closed(&self) -> bool {
1228 self.inner.channel().is_closed()
1229 }
1230 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1231 self.inner.channel().on_closed()
1232 }
1233
1234 #[cfg(target_os = "fuchsia")]
1235 fn signal_peer(
1236 &self,
1237 clear_mask: zx::Signals,
1238 set_mask: zx::Signals,
1239 ) -> Result<(), zx_status::Status> {
1240 use fidl::Peered;
1241 self.inner.channel().signal_peer(clear_mask, set_mask)
1242 }
1243}
1244
1245impl HealthControlHandle {}
1246
1247#[must_use = "FIDL methods require a response to be sent"]
1248#[derive(Debug)]
1249pub struct HealthGetReportResponder {
1250 control_handle: std::mem::ManuallyDrop<HealthControlHandle>,
1251 tx_id: u32,
1252}
1253
1254impl std::ops::Drop for HealthGetReportResponder {
1258 fn drop(&mut self) {
1259 self.control_handle.shutdown();
1260 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1262 }
1263}
1264
1265impl fidl::endpoints::Responder for HealthGetReportResponder {
1266 type ControlHandle = HealthControlHandle;
1267
1268 fn control_handle(&self) -> &HealthControlHandle {
1269 &self.control_handle
1270 }
1271
1272 fn drop_without_shutdown(mut self) {
1273 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1275 std::mem::forget(self);
1277 }
1278}
1279
1280impl HealthGetReportResponder {
1281 pub fn send(self, mut result: Result<&HealthReport, i32>) -> Result<(), fidl::Error> {
1285 let _result = self.send_raw(result);
1286 if _result.is_err() {
1287 self.control_handle.shutdown();
1288 }
1289 self.drop_without_shutdown();
1290 _result
1291 }
1292
1293 pub fn send_no_shutdown_on_err(
1295 self,
1296 mut result: Result<&HealthReport, i32>,
1297 ) -> Result<(), fidl::Error> {
1298 let _result = self.send_raw(result);
1299 self.drop_without_shutdown();
1300 _result
1301 }
1302
1303 fn send_raw(&self, mut result: Result<&HealthReport, i32>) -> Result<(), fidl::Error> {
1304 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<HealthReport, i32>>(
1305 fidl::encoding::FlexibleResult::new(result),
1306 self.tx_id,
1307 0x45f3bc8cbb38e701,
1308 fidl::encoding::DynamicFlags::FLEXIBLE,
1309 )
1310 }
1311}
1312
1313#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1314pub struct PolicyProviderMarker;
1315
1316impl fidl::endpoints::ProtocolMarker for PolicyProviderMarker {
1317 type Proxy = PolicyProviderProxy;
1318 type RequestStream = PolicyProviderRequestStream;
1319 #[cfg(target_os = "fuchsia")]
1320 type SynchronousProxy = PolicyProviderSynchronousProxy;
1321
1322 const DEBUG_NAME: &'static str = "fuchsia.usb.policy.PolicyProvider";
1323}
1324impl fidl::endpoints::DiscoverableProtocolMarker for PolicyProviderMarker {}
1325
1326pub trait PolicyProviderProxyInterface: Send + Sync {
1327 type WatchDeviceStateResponseFut: std::future::Future<
1328 Output = Result<
1329 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1330 fidl::Error,
1331 >,
1332 > + Send;
1333 fn r#watch_device_state(&self) -> Self::WatchDeviceStateResponseFut;
1334}
1335#[derive(Debug)]
1336#[cfg(target_os = "fuchsia")]
1337pub struct PolicyProviderSynchronousProxy {
1338 client: fidl::client::sync::Client,
1339}
1340
1341#[cfg(target_os = "fuchsia")]
1342impl fidl::endpoints::SynchronousProxy for PolicyProviderSynchronousProxy {
1343 type Proxy = PolicyProviderProxy;
1344 type Protocol = PolicyProviderMarker;
1345
1346 fn from_channel(inner: fidl::Channel) -> Self {
1347 Self::new(inner)
1348 }
1349
1350 fn into_channel(self) -> fidl::Channel {
1351 self.client.into_channel()
1352 }
1353
1354 fn as_channel(&self) -> &fidl::Channel {
1355 self.client.as_channel()
1356 }
1357}
1358
1359#[cfg(target_os = "fuchsia")]
1360impl PolicyProviderSynchronousProxy {
1361 pub fn new(channel: fidl::Channel) -> Self {
1362 Self { client: fidl::client::sync::Client::new(channel) }
1363 }
1364
1365 pub fn into_channel(self) -> fidl::Channel {
1366 self.client.into_channel()
1367 }
1368
1369 pub fn wait_for_event(
1372 &self,
1373 deadline: zx::MonotonicInstant,
1374 ) -> Result<PolicyProviderEvent, fidl::Error> {
1375 PolicyProviderEvent::decode(self.client.wait_for_event::<PolicyProviderMarker>(deadline)?)
1376 }
1377
1378 pub fn r#watch_device_state(
1384 &self,
1385 ___deadline: zx::MonotonicInstant,
1386 ) -> Result<
1387 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1388 fidl::Error,
1389 > {
1390 let _response = self
1391 .client
1392 .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
1393 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
1394 i32,
1395 >, PolicyProviderMarker>(
1396 (),
1397 0x44628a2275753738,
1398 fidl::encoding::DynamicFlags::FLEXIBLE,
1399 ___deadline,
1400 )?
1401 .into_result::<PolicyProviderMarker>("watch_device_state")?;
1402 Ok(_response.map(|x| x))
1403 }
1404}
1405
1406#[cfg(target_os = "fuchsia")]
1407impl From<PolicyProviderSynchronousProxy> for zx::NullableHandle {
1408 fn from(value: PolicyProviderSynchronousProxy) -> Self {
1409 value.into_channel().into()
1410 }
1411}
1412
1413#[cfg(target_os = "fuchsia")]
1414impl From<fidl::Channel> for PolicyProviderSynchronousProxy {
1415 fn from(value: fidl::Channel) -> Self {
1416 Self::new(value)
1417 }
1418}
1419
1420#[cfg(target_os = "fuchsia")]
1421impl fidl::endpoints::FromClient for PolicyProviderSynchronousProxy {
1422 type Protocol = PolicyProviderMarker;
1423
1424 fn from_client(value: fidl::endpoints::ClientEnd<PolicyProviderMarker>) -> Self {
1425 Self::new(value.into_channel())
1426 }
1427}
1428
1429#[derive(Debug, Clone)]
1430pub struct PolicyProviderProxy {
1431 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1432}
1433
1434impl fidl::endpoints::Proxy for PolicyProviderProxy {
1435 type Protocol = PolicyProviderMarker;
1436
1437 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1438 Self::new(inner)
1439 }
1440
1441 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1442 self.client.into_channel().map_err(|client| Self { client })
1443 }
1444
1445 fn as_channel(&self) -> &::fidl::AsyncChannel {
1446 self.client.as_channel()
1447 }
1448}
1449
1450impl PolicyProviderProxy {
1451 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1453 let protocol_name = <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1454 Self { client: fidl::client::Client::new(channel, protocol_name) }
1455 }
1456
1457 pub fn take_event_stream(&self) -> PolicyProviderEventStream {
1463 PolicyProviderEventStream { event_receiver: self.client.take_event_receiver() }
1464 }
1465
1466 pub fn r#watch_device_state(
1472 &self,
1473 ) -> fidl::client::QueryResponseFut<
1474 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1475 fidl::encoding::DefaultFuchsiaResourceDialect,
1476 > {
1477 PolicyProviderProxyInterface::r#watch_device_state(self)
1478 }
1479}
1480
1481impl PolicyProviderProxyInterface for PolicyProviderProxy {
1482 type WatchDeviceStateResponseFut = fidl::client::QueryResponseFut<
1483 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1484 fidl::encoding::DefaultFuchsiaResourceDialect,
1485 >;
1486 fn r#watch_device_state(&self) -> Self::WatchDeviceStateResponseFut {
1487 fn _decode(
1488 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1489 ) -> Result<
1490 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1491 fidl::Error,
1492 > {
1493 let _response = fidl::client::decode_transaction_body::<
1494 fidl::encoding::FlexibleResultType<
1495 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
1496 i32,
1497 >,
1498 fidl::encoding::DefaultFuchsiaResourceDialect,
1499 0x44628a2275753738,
1500 >(_buf?)?
1501 .into_result::<PolicyProviderMarker>("watch_device_state")?;
1502 Ok(_response.map(|x| x))
1503 }
1504 self.client.send_query_and_decode::<
1505 fidl::encoding::EmptyPayload,
1506 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1507 >(
1508 (),
1509 0x44628a2275753738,
1510 fidl::encoding::DynamicFlags::FLEXIBLE,
1511 _decode,
1512 )
1513 }
1514}
1515
1516pub struct PolicyProviderEventStream {
1517 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1518}
1519
1520impl std::marker::Unpin for PolicyProviderEventStream {}
1521
1522impl futures::stream::FusedStream for PolicyProviderEventStream {
1523 fn is_terminated(&self) -> bool {
1524 self.event_receiver.is_terminated()
1525 }
1526}
1527
1528impl futures::Stream for PolicyProviderEventStream {
1529 type Item = Result<PolicyProviderEvent, fidl::Error>;
1530
1531 fn poll_next(
1532 mut self: std::pin::Pin<&mut Self>,
1533 cx: &mut std::task::Context<'_>,
1534 ) -> std::task::Poll<Option<Self::Item>> {
1535 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1536 &mut self.event_receiver,
1537 cx
1538 )?) {
1539 Some(buf) => std::task::Poll::Ready(Some(PolicyProviderEvent::decode(buf))),
1540 None => std::task::Poll::Ready(None),
1541 }
1542 }
1543}
1544
1545#[derive(Debug)]
1546pub enum PolicyProviderEvent {
1547 #[non_exhaustive]
1548 _UnknownEvent {
1549 ordinal: u64,
1551 },
1552}
1553
1554impl PolicyProviderEvent {
1555 fn decode(
1557 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1558 ) -> Result<PolicyProviderEvent, fidl::Error> {
1559 let (bytes, _handles) = buf.split_mut();
1560 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1561 debug_assert_eq!(tx_header.tx_id, 0);
1562 match tx_header.ordinal {
1563 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1564 Ok(PolicyProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1565 }
1566 _ => Err(fidl::Error::UnknownOrdinal {
1567 ordinal: tx_header.ordinal,
1568 protocol_name:
1569 <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1570 }),
1571 }
1572 }
1573}
1574
1575pub struct PolicyProviderRequestStream {
1577 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1578 is_terminated: bool,
1579}
1580
1581impl std::marker::Unpin for PolicyProviderRequestStream {}
1582
1583impl futures::stream::FusedStream for PolicyProviderRequestStream {
1584 fn is_terminated(&self) -> bool {
1585 self.is_terminated
1586 }
1587}
1588
1589impl fidl::endpoints::RequestStream for PolicyProviderRequestStream {
1590 type Protocol = PolicyProviderMarker;
1591 type ControlHandle = PolicyProviderControlHandle;
1592
1593 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1594 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1595 }
1596
1597 fn control_handle(&self) -> Self::ControlHandle {
1598 PolicyProviderControlHandle { inner: self.inner.clone() }
1599 }
1600
1601 fn into_inner(
1602 self,
1603 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1604 {
1605 (self.inner, self.is_terminated)
1606 }
1607
1608 fn from_inner(
1609 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1610 is_terminated: bool,
1611 ) -> Self {
1612 Self { inner, is_terminated }
1613 }
1614}
1615
1616impl futures::Stream for PolicyProviderRequestStream {
1617 type Item = Result<PolicyProviderRequest, fidl::Error>;
1618
1619 fn poll_next(
1620 mut self: std::pin::Pin<&mut Self>,
1621 cx: &mut std::task::Context<'_>,
1622 ) -> std::task::Poll<Option<Self::Item>> {
1623 let this = &mut *self;
1624 if this.inner.check_shutdown(cx) {
1625 this.is_terminated = true;
1626 return std::task::Poll::Ready(None);
1627 }
1628 if this.is_terminated {
1629 panic!("polled PolicyProviderRequestStream after completion");
1630 }
1631 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1632 |bytes, handles| {
1633 match this.inner.channel().read_etc(cx, bytes, handles) {
1634 std::task::Poll::Ready(Ok(())) => {}
1635 std::task::Poll::Pending => return std::task::Poll::Pending,
1636 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1637 this.is_terminated = true;
1638 return std::task::Poll::Ready(None);
1639 }
1640 std::task::Poll::Ready(Err(e)) => {
1641 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1642 e.into(),
1643 ))));
1644 }
1645 }
1646
1647 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1649
1650 std::task::Poll::Ready(Some(match header.ordinal {
1651 0x44628a2275753738 => {
1652 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1653 let mut req = fidl::new_empty!(
1654 fidl::encoding::EmptyPayload,
1655 fidl::encoding::DefaultFuchsiaResourceDialect
1656 );
1657 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1658 let control_handle =
1659 PolicyProviderControlHandle { inner: this.inner.clone() };
1660 Ok(PolicyProviderRequest::WatchDeviceState {
1661 responder: PolicyProviderWatchDeviceStateResponder {
1662 control_handle: std::mem::ManuallyDrop::new(control_handle),
1663 tx_id: header.tx_id,
1664 },
1665 })
1666 }
1667 _ if header.tx_id == 0
1668 && header
1669 .dynamic_flags()
1670 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1671 {
1672 Ok(PolicyProviderRequest::_UnknownMethod {
1673 ordinal: header.ordinal,
1674 control_handle: PolicyProviderControlHandle {
1675 inner: this.inner.clone(),
1676 },
1677 method_type: fidl::MethodType::OneWay,
1678 })
1679 }
1680 _ if header
1681 .dynamic_flags()
1682 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1683 {
1684 this.inner.send_framework_err(
1685 fidl::encoding::FrameworkErr::UnknownMethod,
1686 header.tx_id,
1687 header.ordinal,
1688 header.dynamic_flags(),
1689 (bytes, handles),
1690 )?;
1691 Ok(PolicyProviderRequest::_UnknownMethod {
1692 ordinal: header.ordinal,
1693 control_handle: PolicyProviderControlHandle {
1694 inner: this.inner.clone(),
1695 },
1696 method_type: fidl::MethodType::TwoWay,
1697 })
1698 }
1699 _ => Err(fidl::Error::UnknownOrdinal {
1700 ordinal: header.ordinal,
1701 protocol_name:
1702 <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1703 }),
1704 }))
1705 },
1706 )
1707 }
1708}
1709
1710#[derive(Debug)]
1712pub enum PolicyProviderRequest {
1713 WatchDeviceState { responder: PolicyProviderWatchDeviceStateResponder },
1719 #[non_exhaustive]
1721 _UnknownMethod {
1722 ordinal: u64,
1724 control_handle: PolicyProviderControlHandle,
1725 method_type: fidl::MethodType,
1726 },
1727}
1728
1729impl PolicyProviderRequest {
1730 #[allow(irrefutable_let_patterns)]
1731 pub fn into_watch_device_state(self) -> Option<(PolicyProviderWatchDeviceStateResponder)> {
1732 if let PolicyProviderRequest::WatchDeviceState { responder } = self {
1733 Some((responder))
1734 } else {
1735 None
1736 }
1737 }
1738
1739 pub fn method_name(&self) -> &'static str {
1741 match *self {
1742 PolicyProviderRequest::WatchDeviceState { .. } => "watch_device_state",
1743 PolicyProviderRequest::_UnknownMethod {
1744 method_type: fidl::MethodType::OneWay, ..
1745 } => "unknown one-way method",
1746 PolicyProviderRequest::_UnknownMethod {
1747 method_type: fidl::MethodType::TwoWay, ..
1748 } => "unknown two-way method",
1749 }
1750 }
1751}
1752
1753#[derive(Debug, Clone)]
1754pub struct PolicyProviderControlHandle {
1755 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1756}
1757
1758impl PolicyProviderControlHandle {
1759 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1760 self.inner.shutdown_with_epitaph(status.into())
1761 }
1762}
1763
1764impl fidl::endpoints::ControlHandle for PolicyProviderControlHandle {
1765 fn shutdown(&self) {
1766 self.inner.shutdown()
1767 }
1768
1769 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1770 self.inner.shutdown_with_epitaph(status)
1771 }
1772
1773 fn is_closed(&self) -> bool {
1774 self.inner.channel().is_closed()
1775 }
1776 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1777 self.inner.channel().on_closed()
1778 }
1779
1780 #[cfg(target_os = "fuchsia")]
1781 fn signal_peer(
1782 &self,
1783 clear_mask: zx::Signals,
1784 set_mask: zx::Signals,
1785 ) -> Result<(), zx_status::Status> {
1786 use fidl::Peered;
1787 self.inner.channel().signal_peer(clear_mask, set_mask)
1788 }
1789}
1790
1791impl PolicyProviderControlHandle {}
1792
1793#[must_use = "FIDL methods require a response to be sent"]
1794#[derive(Debug)]
1795pub struct PolicyProviderWatchDeviceStateResponder {
1796 control_handle: std::mem::ManuallyDrop<PolicyProviderControlHandle>,
1797 tx_id: u32,
1798}
1799
1800impl std::ops::Drop for PolicyProviderWatchDeviceStateResponder {
1804 fn drop(&mut self) {
1805 self.control_handle.shutdown();
1806 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1808 }
1809}
1810
1811impl fidl::endpoints::Responder for PolicyProviderWatchDeviceStateResponder {
1812 type ControlHandle = PolicyProviderControlHandle;
1813
1814 fn control_handle(&self) -> &PolicyProviderControlHandle {
1815 &self.control_handle
1816 }
1817
1818 fn drop_without_shutdown(mut self) {
1819 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1821 std::mem::forget(self);
1823 }
1824}
1825
1826impl PolicyProviderWatchDeviceStateResponder {
1827 pub fn send(
1831 self,
1832 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
1833 ) -> Result<(), fidl::Error> {
1834 let _result = self.send_raw(result);
1835 if _result.is_err() {
1836 self.control_handle.shutdown();
1837 }
1838 self.drop_without_shutdown();
1839 _result
1840 }
1841
1842 pub fn send_no_shutdown_on_err(
1844 self,
1845 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
1846 ) -> Result<(), fidl::Error> {
1847 let _result = self.send_raw(result);
1848 self.drop_without_shutdown();
1849 _result
1850 }
1851
1852 fn send_raw(
1853 &self,
1854 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
1855 ) -> Result<(), fidl::Error> {
1856 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1857 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
1858 i32,
1859 >>(
1860 fidl::encoding::FlexibleResult::new(result),
1861 self.tx_id,
1862 0x44628a2275753738,
1863 fidl::encoding::DynamicFlags::FLEXIBLE,
1864 )
1865 }
1866}
1867
1868mod internal {
1869 use super::*;
1870}