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>;
34pub type ConfigurationDisconnectCableResult = Result<(), i32>;
35pub type ConfigurationConnectCableResult = Result<(), i32>;
36
37pub trait ConfigurationProxyInterface: Send + Sync {
38 type GetConfigurationResponseFut: std::future::Future<Output = Result<ConfigurationGetConfigurationResult, fidl::Error>>
39 + Send;
40 fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut;
41 type SetConfigurationResponseFut: std::future::Future<Output = Result<ConfigurationSetConfigurationResult, fidl::Error>>
42 + Send;
43 fn r#set_configuration(
44 &self,
45 device_desc: &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
46 config_descriptors: &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
47 ) -> Self::SetConfigurationResponseFut;
48 type DisconnectCableResponseFut: std::future::Future<Output = Result<ConfigurationDisconnectCableResult, fidl::Error>>
49 + Send;
50 fn r#disconnect_cable(&self, duration: i64) -> Self::DisconnectCableResponseFut;
51 type ConnectCableResponseFut: std::future::Future<Output = Result<ConfigurationConnectCableResult, fidl::Error>>
52 + Send;
53 fn r#connect_cable(&self) -> Self::ConnectCableResponseFut;
54}
55#[derive(Debug)]
56#[cfg(target_os = "fuchsia")]
57pub struct ConfigurationSynchronousProxy {
58 client: fidl::client::sync::Client,
59}
60
61#[cfg(target_os = "fuchsia")]
62impl fidl::endpoints::SynchronousProxy for ConfigurationSynchronousProxy {
63 type Proxy = ConfigurationProxy;
64 type Protocol = ConfigurationMarker;
65
66 fn from_channel(inner: fidl::Channel) -> Self {
67 Self::new(inner)
68 }
69
70 fn into_channel(self) -> fidl::Channel {
71 self.client.into_channel()
72 }
73
74 fn as_channel(&self) -> &fidl::Channel {
75 self.client.as_channel()
76 }
77}
78
79#[cfg(target_os = "fuchsia")]
80impl ConfigurationSynchronousProxy {
81 pub fn new(channel: fidl::Channel) -> Self {
82 Self { client: fidl::client::sync::Client::new(channel) }
83 }
84
85 pub fn into_channel(self) -> fidl::Channel {
86 self.client.into_channel()
87 }
88
89 pub fn wait_for_event(
92 &self,
93 deadline: zx::MonotonicInstant,
94 ) -> Result<ConfigurationEvent, fidl::Error> {
95 ConfigurationEvent::decode(self.client.wait_for_event::<ConfigurationMarker>(deadline)?)
96 }
97
98 pub fn r#get_configuration(
105 &self,
106 ___deadline: zx::MonotonicInstant,
107 ) -> Result<ConfigurationGetConfigurationResult, fidl::Error> {
108 let _response = self.client.send_query::<
109 fidl::encoding::EmptyPayload,
110 fidl::encoding::FlexibleResultType<ConfigurationGetConfigurationResponse, i32>,
111 ConfigurationMarker,
112 >(
113 (),
114 0x451bbf2edea95fec,
115 fidl::encoding::DynamicFlags::FLEXIBLE,
116 ___deadline,
117 )?
118 .into_result::<ConfigurationMarker>("get_configuration")?;
119 Ok(_response.map(|x| (x.device_desc, x.config_descriptors)))
120 }
121
122 pub fn r#set_configuration(
136 &self,
137 mut device_desc: &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
138 mut config_descriptors: &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
139 ___deadline: zx::MonotonicInstant,
140 ) -> Result<ConfigurationSetConfigurationResult, fidl::Error> {
141 let _response = self.client.send_query::<
142 ConfigurationSetConfigurationRequest,
143 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
144 ConfigurationMarker,
145 >(
146 (device_desc, config_descriptors,),
147 0x188b98e71fce9223,
148 fidl::encoding::DynamicFlags::FLEXIBLE,
149 ___deadline,
150 )?
151 .into_result::<ConfigurationMarker>("set_configuration")?;
152 Ok(_response.map(|x| x))
153 }
154
155 pub fn r#disconnect_cable(
162 &self,
163 mut duration: i64,
164 ___deadline: zx::MonotonicInstant,
165 ) -> Result<ConfigurationDisconnectCableResult, fidl::Error> {
166 let _response = self.client.send_query::<
167 ConfigurationDisconnectCableRequest,
168 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
169 ConfigurationMarker,
170 >(
171 (duration,),
172 0x50d03f08bd3ab65,
173 fidl::encoding::DynamicFlags::FLEXIBLE,
174 ___deadline,
175 )?
176 .into_result::<ConfigurationMarker>("disconnect_cable")?;
177 Ok(_response.map(|x| x))
178 }
179
180 pub fn r#connect_cable(
184 &self,
185 ___deadline: zx::MonotonicInstant,
186 ) -> Result<ConfigurationConnectCableResult, fidl::Error> {
187 let _response = self.client.send_query::<
188 fidl::encoding::EmptyPayload,
189 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
190 ConfigurationMarker,
191 >(
192 (),
193 0x2d2227bd122b2847,
194 fidl::encoding::DynamicFlags::FLEXIBLE,
195 ___deadline,
196 )?
197 .into_result::<ConfigurationMarker>("connect_cable")?;
198 Ok(_response.map(|x| x))
199 }
200}
201
202#[cfg(target_os = "fuchsia")]
203impl From<ConfigurationSynchronousProxy> for zx::NullableHandle {
204 fn from(value: ConfigurationSynchronousProxy) -> Self {
205 value.into_channel().into()
206 }
207}
208
209#[cfg(target_os = "fuchsia")]
210impl From<fidl::Channel> for ConfigurationSynchronousProxy {
211 fn from(value: fidl::Channel) -> Self {
212 Self::new(value)
213 }
214}
215
216#[cfg(target_os = "fuchsia")]
217impl fidl::endpoints::FromClient for ConfigurationSynchronousProxy {
218 type Protocol = ConfigurationMarker;
219
220 fn from_client(value: fidl::endpoints::ClientEnd<ConfigurationMarker>) -> Self {
221 Self::new(value.into_channel())
222 }
223}
224
225#[derive(Debug, Clone)]
226pub struct ConfigurationProxy {
227 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
228}
229
230impl fidl::endpoints::Proxy for ConfigurationProxy {
231 type Protocol = ConfigurationMarker;
232
233 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
234 Self::new(inner)
235 }
236
237 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
238 self.client.into_channel().map_err(|client| Self { client })
239 }
240
241 fn as_channel(&self) -> &::fidl::AsyncChannel {
242 self.client.as_channel()
243 }
244}
245
246impl ConfigurationProxy {
247 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
249 let protocol_name = <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
250 Self { client: fidl::client::Client::new(channel, protocol_name) }
251 }
252
253 pub fn take_event_stream(&self) -> ConfigurationEventStream {
259 ConfigurationEventStream { event_receiver: self.client.take_event_receiver() }
260 }
261
262 pub fn r#get_configuration(
269 &self,
270 ) -> fidl::client::QueryResponseFut<
271 ConfigurationGetConfigurationResult,
272 fidl::encoding::DefaultFuchsiaResourceDialect,
273 > {
274 ConfigurationProxyInterface::r#get_configuration(self)
275 }
276
277 pub fn r#set_configuration(
291 &self,
292 mut device_desc: &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
293 mut config_descriptors: &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
294 ) -> fidl::client::QueryResponseFut<
295 ConfigurationSetConfigurationResult,
296 fidl::encoding::DefaultFuchsiaResourceDialect,
297 > {
298 ConfigurationProxyInterface::r#set_configuration(self, device_desc, config_descriptors)
299 }
300
301 pub fn r#disconnect_cable(
308 &self,
309 mut duration: i64,
310 ) -> fidl::client::QueryResponseFut<
311 ConfigurationDisconnectCableResult,
312 fidl::encoding::DefaultFuchsiaResourceDialect,
313 > {
314 ConfigurationProxyInterface::r#disconnect_cable(self, duration)
315 }
316
317 pub fn r#connect_cable(
321 &self,
322 ) -> fidl::client::QueryResponseFut<
323 ConfigurationConnectCableResult,
324 fidl::encoding::DefaultFuchsiaResourceDialect,
325 > {
326 ConfigurationProxyInterface::r#connect_cable(self)
327 }
328}
329
330impl ConfigurationProxyInterface for ConfigurationProxy {
331 type GetConfigurationResponseFut = fidl::client::QueryResponseFut<
332 ConfigurationGetConfigurationResult,
333 fidl::encoding::DefaultFuchsiaResourceDialect,
334 >;
335 fn r#get_configuration(&self) -> Self::GetConfigurationResponseFut {
336 fn _decode(
337 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
338 ) -> Result<ConfigurationGetConfigurationResult, fidl::Error> {
339 let _response = fidl::client::decode_transaction_body::<
340 fidl::encoding::FlexibleResultType<ConfigurationGetConfigurationResponse, i32>,
341 fidl::encoding::DefaultFuchsiaResourceDialect,
342 0x451bbf2edea95fec,
343 >(_buf?)?
344 .into_result::<ConfigurationMarker>("get_configuration")?;
345 Ok(_response.map(|x| (x.device_desc, x.config_descriptors)))
346 }
347 self.client.send_query_and_decode::<
348 fidl::encoding::EmptyPayload,
349 ConfigurationGetConfigurationResult,
350 >(
351 (),
352 0x451bbf2edea95fec,
353 fidl::encoding::DynamicFlags::FLEXIBLE,
354 _decode,
355 )
356 }
357
358 type SetConfigurationResponseFut = fidl::client::QueryResponseFut<
359 ConfigurationSetConfigurationResult,
360 fidl::encoding::DefaultFuchsiaResourceDialect,
361 >;
362 fn r#set_configuration(
363 &self,
364 mut device_desc: &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
365 mut config_descriptors: &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
366 ) -> Self::SetConfigurationResponseFut {
367 fn _decode(
368 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
369 ) -> Result<ConfigurationSetConfigurationResult, fidl::Error> {
370 let _response = fidl::client::decode_transaction_body::<
371 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
372 fidl::encoding::DefaultFuchsiaResourceDialect,
373 0x188b98e71fce9223,
374 >(_buf?)?
375 .into_result::<ConfigurationMarker>("set_configuration")?;
376 Ok(_response.map(|x| x))
377 }
378 self.client.send_query_and_decode::<
379 ConfigurationSetConfigurationRequest,
380 ConfigurationSetConfigurationResult,
381 >(
382 (device_desc, config_descriptors,),
383 0x188b98e71fce9223,
384 fidl::encoding::DynamicFlags::FLEXIBLE,
385 _decode,
386 )
387 }
388
389 type DisconnectCableResponseFut = fidl::client::QueryResponseFut<
390 ConfigurationDisconnectCableResult,
391 fidl::encoding::DefaultFuchsiaResourceDialect,
392 >;
393 fn r#disconnect_cable(&self, mut duration: i64) -> Self::DisconnectCableResponseFut {
394 fn _decode(
395 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
396 ) -> Result<ConfigurationDisconnectCableResult, fidl::Error> {
397 let _response = fidl::client::decode_transaction_body::<
398 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
399 fidl::encoding::DefaultFuchsiaResourceDialect,
400 0x50d03f08bd3ab65,
401 >(_buf?)?
402 .into_result::<ConfigurationMarker>("disconnect_cable")?;
403 Ok(_response.map(|x| x))
404 }
405 self.client.send_query_and_decode::<
406 ConfigurationDisconnectCableRequest,
407 ConfigurationDisconnectCableResult,
408 >(
409 (duration,),
410 0x50d03f08bd3ab65,
411 fidl::encoding::DynamicFlags::FLEXIBLE,
412 _decode,
413 )
414 }
415
416 type ConnectCableResponseFut = fidl::client::QueryResponseFut<
417 ConfigurationConnectCableResult,
418 fidl::encoding::DefaultFuchsiaResourceDialect,
419 >;
420 fn r#connect_cable(&self) -> Self::ConnectCableResponseFut {
421 fn _decode(
422 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
423 ) -> Result<ConfigurationConnectCableResult, fidl::Error> {
424 let _response = fidl::client::decode_transaction_body::<
425 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
426 fidl::encoding::DefaultFuchsiaResourceDialect,
427 0x2d2227bd122b2847,
428 >(_buf?)?
429 .into_result::<ConfigurationMarker>("connect_cable")?;
430 Ok(_response.map(|x| x))
431 }
432 self.client
433 .send_query_and_decode::<fidl::encoding::EmptyPayload, ConfigurationConnectCableResult>(
434 (),
435 0x2d2227bd122b2847,
436 fidl::encoding::DynamicFlags::FLEXIBLE,
437 _decode,
438 )
439 }
440}
441
442pub struct ConfigurationEventStream {
443 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
444}
445
446impl std::marker::Unpin for ConfigurationEventStream {}
447
448impl futures::stream::FusedStream for ConfigurationEventStream {
449 fn is_terminated(&self) -> bool {
450 self.event_receiver.is_terminated()
451 }
452}
453
454impl futures::Stream for ConfigurationEventStream {
455 type Item = Result<ConfigurationEvent, fidl::Error>;
456
457 fn poll_next(
458 mut self: std::pin::Pin<&mut Self>,
459 cx: &mut std::task::Context<'_>,
460 ) -> std::task::Poll<Option<Self::Item>> {
461 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
462 &mut self.event_receiver,
463 cx
464 )?) {
465 Some(buf) => std::task::Poll::Ready(Some(ConfigurationEvent::decode(buf))),
466 None => std::task::Poll::Ready(None),
467 }
468 }
469}
470
471#[derive(Debug)]
472pub enum ConfigurationEvent {
473 #[non_exhaustive]
474 _UnknownEvent {
475 ordinal: u64,
477 },
478}
479
480impl ConfigurationEvent {
481 fn decode(
483 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
484 ) -> Result<ConfigurationEvent, fidl::Error> {
485 let (bytes, _handles) = buf.split_mut();
486 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
487 debug_assert_eq!(tx_header.tx_id, 0);
488 match tx_header.ordinal {
489 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
490 Ok(ConfigurationEvent::_UnknownEvent { ordinal: tx_header.ordinal })
491 }
492 _ => Err(fidl::Error::UnknownOrdinal {
493 ordinal: tx_header.ordinal,
494 protocol_name: <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
495 }),
496 }
497 }
498}
499
500pub struct ConfigurationRequestStream {
502 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
503 is_terminated: bool,
504}
505
506impl std::marker::Unpin for ConfigurationRequestStream {}
507
508impl futures::stream::FusedStream for ConfigurationRequestStream {
509 fn is_terminated(&self) -> bool {
510 self.is_terminated
511 }
512}
513
514impl fidl::endpoints::RequestStream for ConfigurationRequestStream {
515 type Protocol = ConfigurationMarker;
516 type ControlHandle = ConfigurationControlHandle;
517
518 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
519 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
520 }
521
522 fn control_handle(&self) -> Self::ControlHandle {
523 ConfigurationControlHandle { inner: self.inner.clone() }
524 }
525
526 fn into_inner(
527 self,
528 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
529 {
530 (self.inner, self.is_terminated)
531 }
532
533 fn from_inner(
534 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
535 is_terminated: bool,
536 ) -> Self {
537 Self { inner, is_terminated }
538 }
539}
540
541impl futures::Stream for ConfigurationRequestStream {
542 type Item = Result<ConfigurationRequest, fidl::Error>;
543
544 fn poll_next(
545 mut self: std::pin::Pin<&mut Self>,
546 cx: &mut std::task::Context<'_>,
547 ) -> std::task::Poll<Option<Self::Item>> {
548 let this = &mut *self;
549 if this.inner.check_shutdown(cx) {
550 this.is_terminated = true;
551 return std::task::Poll::Ready(None);
552 }
553 if this.is_terminated {
554 panic!("polled ConfigurationRequestStream after completion");
555 }
556 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
557 |bytes, handles| {
558 match this.inner.channel().read_etc(cx, bytes, handles) {
559 std::task::Poll::Ready(Ok(())) => {}
560 std::task::Poll::Pending => return std::task::Poll::Pending,
561 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
562 this.is_terminated = true;
563 return std::task::Poll::Ready(None);
564 }
565 std::task::Poll::Ready(Err(e)) => {
566 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
567 e.into(),
568 ))));
569 }
570 }
571
572 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
574
575 std::task::Poll::Ready(Some(match header.ordinal {
576 0x451bbf2edea95fec => {
577 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
578 let mut req = fidl::new_empty!(
579 fidl::encoding::EmptyPayload,
580 fidl::encoding::DefaultFuchsiaResourceDialect
581 );
582 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
583 let control_handle =
584 ConfigurationControlHandle { inner: this.inner.clone() };
585 Ok(ConfigurationRequest::GetConfiguration {
586 responder: ConfigurationGetConfigurationResponder {
587 control_handle: std::mem::ManuallyDrop::new(control_handle),
588 tx_id: header.tx_id,
589 },
590 })
591 }
592 0x188b98e71fce9223 => {
593 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
594 let mut req = fidl::new_empty!(
595 ConfigurationSetConfigurationRequest,
596 fidl::encoding::DefaultFuchsiaResourceDialect
597 );
598 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConfigurationSetConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
599 let control_handle =
600 ConfigurationControlHandle { inner: this.inner.clone() };
601 Ok(ConfigurationRequest::SetConfiguration {
602 device_desc: req.device_desc,
603 config_descriptors: req.config_descriptors,
604
605 responder: ConfigurationSetConfigurationResponder {
606 control_handle: std::mem::ManuallyDrop::new(control_handle),
607 tx_id: header.tx_id,
608 },
609 })
610 }
611 0x50d03f08bd3ab65 => {
612 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
613 let mut req = fidl::new_empty!(
614 ConfigurationDisconnectCableRequest,
615 fidl::encoding::DefaultFuchsiaResourceDialect
616 );
617 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConfigurationDisconnectCableRequest>(&header, _body_bytes, handles, &mut req)?;
618 let control_handle =
619 ConfigurationControlHandle { inner: this.inner.clone() };
620 Ok(ConfigurationRequest::DisconnectCable {
621 duration: req.duration,
622
623 responder: ConfigurationDisconnectCableResponder {
624 control_handle: std::mem::ManuallyDrop::new(control_handle),
625 tx_id: header.tx_id,
626 },
627 })
628 }
629 0x2d2227bd122b2847 => {
630 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
631 let mut req = fidl::new_empty!(
632 fidl::encoding::EmptyPayload,
633 fidl::encoding::DefaultFuchsiaResourceDialect
634 );
635 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
636 let control_handle =
637 ConfigurationControlHandle { inner: this.inner.clone() };
638 Ok(ConfigurationRequest::ConnectCable {
639 responder: ConfigurationConnectCableResponder {
640 control_handle: std::mem::ManuallyDrop::new(control_handle),
641 tx_id: header.tx_id,
642 },
643 })
644 }
645 _ if header.tx_id == 0
646 && header
647 .dynamic_flags()
648 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
649 {
650 Ok(ConfigurationRequest::_UnknownMethod {
651 ordinal: header.ordinal,
652 control_handle: ConfigurationControlHandle {
653 inner: this.inner.clone(),
654 },
655 method_type: fidl::MethodType::OneWay,
656 })
657 }
658 _ if header
659 .dynamic_flags()
660 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
661 {
662 this.inner.send_framework_err(
663 fidl::encoding::FrameworkErr::UnknownMethod,
664 header.tx_id,
665 header.ordinal,
666 header.dynamic_flags(),
667 (bytes, handles),
668 )?;
669 Ok(ConfigurationRequest::_UnknownMethod {
670 ordinal: header.ordinal,
671 control_handle: ConfigurationControlHandle {
672 inner: this.inner.clone(),
673 },
674 method_type: fidl::MethodType::TwoWay,
675 })
676 }
677 _ => Err(fidl::Error::UnknownOrdinal {
678 ordinal: header.ordinal,
679 protocol_name:
680 <ConfigurationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
681 }),
682 }))
683 },
684 )
685 }
686}
687
688#[derive(Debug)]
693pub enum ConfigurationRequest {
694 GetConfiguration { responder: ConfigurationGetConfigurationResponder },
701 SetConfiguration {
715 device_desc: fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
716 config_descriptors: Vec<Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>>,
717 responder: ConfigurationSetConfigurationResponder,
718 },
719 DisconnectCable { duration: i64, responder: ConfigurationDisconnectCableResponder },
726 ConnectCable { responder: ConfigurationConnectCableResponder },
730 #[non_exhaustive]
732 _UnknownMethod {
733 ordinal: u64,
735 control_handle: ConfigurationControlHandle,
736 method_type: fidl::MethodType,
737 },
738}
739
740impl ConfigurationRequest {
741 #[allow(irrefutable_let_patterns)]
742 pub fn into_get_configuration(self) -> Option<(ConfigurationGetConfigurationResponder)> {
743 if let ConfigurationRequest::GetConfiguration { responder } = self {
744 Some((responder))
745 } else {
746 None
747 }
748 }
749
750 #[allow(irrefutable_let_patterns)]
751 pub fn into_set_configuration(
752 self,
753 ) -> Option<(
754 fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
755 Vec<Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>>,
756 ConfigurationSetConfigurationResponder,
757 )> {
758 if let ConfigurationRequest::SetConfiguration {
759 device_desc,
760 config_descriptors,
761 responder,
762 } = self
763 {
764 Some((device_desc, config_descriptors, responder))
765 } else {
766 None
767 }
768 }
769
770 #[allow(irrefutable_let_patterns)]
771 pub fn into_disconnect_cable(self) -> Option<(i64, ConfigurationDisconnectCableResponder)> {
772 if let ConfigurationRequest::DisconnectCable { duration, responder } = self {
773 Some((duration, responder))
774 } else {
775 None
776 }
777 }
778
779 #[allow(irrefutable_let_patterns)]
780 pub fn into_connect_cable(self) -> Option<(ConfigurationConnectCableResponder)> {
781 if let ConfigurationRequest::ConnectCable { responder } = self {
782 Some((responder))
783 } else {
784 None
785 }
786 }
787
788 pub fn method_name(&self) -> &'static str {
790 match *self {
791 ConfigurationRequest::GetConfiguration { .. } => "get_configuration",
792 ConfigurationRequest::SetConfiguration { .. } => "set_configuration",
793 ConfigurationRequest::DisconnectCable { .. } => "disconnect_cable",
794 ConfigurationRequest::ConnectCable { .. } => "connect_cable",
795 ConfigurationRequest::_UnknownMethod {
796 method_type: fidl::MethodType::OneWay, ..
797 } => "unknown one-way method",
798 ConfigurationRequest::_UnknownMethod {
799 method_type: fidl::MethodType::TwoWay, ..
800 } => "unknown two-way method",
801 }
802 }
803}
804
805#[derive(Debug, Clone)]
806pub struct ConfigurationControlHandle {
807 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
808}
809
810impl ConfigurationControlHandle {
811 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
812 self.inner.shutdown_with_epitaph(status.into())
813 }
814}
815
816impl fidl::endpoints::ControlHandle for ConfigurationControlHandle {
817 fn shutdown(&self) {
818 self.inner.shutdown()
819 }
820
821 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
822 self.inner.shutdown_with_epitaph(status)
823 }
824
825 fn is_closed(&self) -> bool {
826 self.inner.channel().is_closed()
827 }
828 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
829 self.inner.channel().on_closed()
830 }
831
832 #[cfg(target_os = "fuchsia")]
833 fn signal_peer(
834 &self,
835 clear_mask: zx::Signals,
836 set_mask: zx::Signals,
837 ) -> Result<(), zx_status::Status> {
838 use fidl::Peered;
839 self.inner.channel().signal_peer(clear_mask, set_mask)
840 }
841}
842
843impl ConfigurationControlHandle {}
844
845#[must_use = "FIDL methods require a response to be sent"]
846#[derive(Debug)]
847pub struct ConfigurationGetConfigurationResponder {
848 control_handle: std::mem::ManuallyDrop<ConfigurationControlHandle>,
849 tx_id: u32,
850}
851
852impl std::ops::Drop for ConfigurationGetConfigurationResponder {
856 fn drop(&mut self) {
857 self.control_handle.shutdown();
858 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
860 }
861}
862
863impl fidl::endpoints::Responder for ConfigurationGetConfigurationResponder {
864 type ControlHandle = ConfigurationControlHandle;
865
866 fn control_handle(&self) -> &ConfigurationControlHandle {
867 &self.control_handle
868 }
869
870 fn drop_without_shutdown(mut self) {
871 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
873 std::mem::forget(self);
875 }
876}
877
878impl ConfigurationGetConfigurationResponder {
879 pub fn send(
883 self,
884 mut result: Result<
885 (
886 &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
887 &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
888 ),
889 i32,
890 >,
891 ) -> Result<(), fidl::Error> {
892 let _result = self.send_raw(result);
893 if _result.is_err() {
894 self.control_handle.shutdown();
895 }
896 self.drop_without_shutdown();
897 _result
898 }
899
900 pub fn send_no_shutdown_on_err(
902 self,
903 mut result: Result<
904 (
905 &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
906 &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
907 ),
908 i32,
909 >,
910 ) -> Result<(), fidl::Error> {
911 let _result = self.send_raw(result);
912 self.drop_without_shutdown();
913 _result
914 }
915
916 fn send_raw(
917 &self,
918 mut result: Result<
919 (
920 &fidl_fuchsia_hardware_usb_peripheral::DeviceDescriptor,
921 &[Vec<fidl_fuchsia_hardware_usb_peripheral::FunctionDescriptor>],
922 ),
923 i32,
924 >,
925 ) -> Result<(), fidl::Error> {
926 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
927 ConfigurationGetConfigurationResponse,
928 i32,
929 >>(
930 fidl::encoding::FlexibleResult::new(result),
931 self.tx_id,
932 0x451bbf2edea95fec,
933 fidl::encoding::DynamicFlags::FLEXIBLE,
934 )
935 }
936}
937
938#[must_use = "FIDL methods require a response to be sent"]
939#[derive(Debug)]
940pub struct ConfigurationSetConfigurationResponder {
941 control_handle: std::mem::ManuallyDrop<ConfigurationControlHandle>,
942 tx_id: u32,
943}
944
945impl std::ops::Drop for ConfigurationSetConfigurationResponder {
949 fn drop(&mut self) {
950 self.control_handle.shutdown();
951 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
953 }
954}
955
956impl fidl::endpoints::Responder for ConfigurationSetConfigurationResponder {
957 type ControlHandle = ConfigurationControlHandle;
958
959 fn control_handle(&self) -> &ConfigurationControlHandle {
960 &self.control_handle
961 }
962
963 fn drop_without_shutdown(mut self) {
964 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
966 std::mem::forget(self);
968 }
969}
970
971impl ConfigurationSetConfigurationResponder {
972 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
976 let _result = self.send_raw(result);
977 if _result.is_err() {
978 self.control_handle.shutdown();
979 }
980 self.drop_without_shutdown();
981 _result
982 }
983
984 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
986 let _result = self.send_raw(result);
987 self.drop_without_shutdown();
988 _result
989 }
990
991 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
992 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
993 fidl::encoding::EmptyStruct,
994 i32,
995 >>(
996 fidl::encoding::FlexibleResult::new(result),
997 self.tx_id,
998 0x188b98e71fce9223,
999 fidl::encoding::DynamicFlags::FLEXIBLE,
1000 )
1001 }
1002}
1003
1004#[must_use = "FIDL methods require a response to be sent"]
1005#[derive(Debug)]
1006pub struct ConfigurationDisconnectCableResponder {
1007 control_handle: std::mem::ManuallyDrop<ConfigurationControlHandle>,
1008 tx_id: u32,
1009}
1010
1011impl std::ops::Drop for ConfigurationDisconnectCableResponder {
1015 fn drop(&mut self) {
1016 self.control_handle.shutdown();
1017 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1019 }
1020}
1021
1022impl fidl::endpoints::Responder for ConfigurationDisconnectCableResponder {
1023 type ControlHandle = ConfigurationControlHandle;
1024
1025 fn control_handle(&self) -> &ConfigurationControlHandle {
1026 &self.control_handle
1027 }
1028
1029 fn drop_without_shutdown(mut self) {
1030 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1032 std::mem::forget(self);
1034 }
1035}
1036
1037impl ConfigurationDisconnectCableResponder {
1038 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1042 let _result = self.send_raw(result);
1043 if _result.is_err() {
1044 self.control_handle.shutdown();
1045 }
1046 self.drop_without_shutdown();
1047 _result
1048 }
1049
1050 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1052 let _result = self.send_raw(result);
1053 self.drop_without_shutdown();
1054 _result
1055 }
1056
1057 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1058 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1059 fidl::encoding::EmptyStruct,
1060 i32,
1061 >>(
1062 fidl::encoding::FlexibleResult::new(result),
1063 self.tx_id,
1064 0x50d03f08bd3ab65,
1065 fidl::encoding::DynamicFlags::FLEXIBLE,
1066 )
1067 }
1068}
1069
1070#[must_use = "FIDL methods require a response to be sent"]
1071#[derive(Debug)]
1072pub struct ConfigurationConnectCableResponder {
1073 control_handle: std::mem::ManuallyDrop<ConfigurationControlHandle>,
1074 tx_id: u32,
1075}
1076
1077impl std::ops::Drop for ConfigurationConnectCableResponder {
1081 fn drop(&mut self) {
1082 self.control_handle.shutdown();
1083 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1085 }
1086}
1087
1088impl fidl::endpoints::Responder for ConfigurationConnectCableResponder {
1089 type ControlHandle = ConfigurationControlHandle;
1090
1091 fn control_handle(&self) -> &ConfigurationControlHandle {
1092 &self.control_handle
1093 }
1094
1095 fn drop_without_shutdown(mut self) {
1096 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1098 std::mem::forget(self);
1100 }
1101}
1102
1103impl ConfigurationConnectCableResponder {
1104 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1108 let _result = self.send_raw(result);
1109 if _result.is_err() {
1110 self.control_handle.shutdown();
1111 }
1112 self.drop_without_shutdown();
1113 _result
1114 }
1115
1116 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1118 let _result = self.send_raw(result);
1119 self.drop_without_shutdown();
1120 _result
1121 }
1122
1123 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1124 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1125 fidl::encoding::EmptyStruct,
1126 i32,
1127 >>(
1128 fidl::encoding::FlexibleResult::new(result),
1129 self.tx_id,
1130 0x2d2227bd122b2847,
1131 fidl::encoding::DynamicFlags::FLEXIBLE,
1132 )
1133 }
1134}
1135
1136#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1137pub struct HealthMarker;
1138
1139impl fidl::endpoints::ProtocolMarker for HealthMarker {
1140 type Proxy = HealthProxy;
1141 type RequestStream = HealthRequestStream;
1142 #[cfg(target_os = "fuchsia")]
1143 type SynchronousProxy = HealthSynchronousProxy;
1144
1145 const DEBUG_NAME: &'static str = "fuchsia.usb.policy.Health";
1146}
1147impl fidl::endpoints::DiscoverableProtocolMarker for HealthMarker {}
1148pub type HealthGetReportResult = Result<HealthReport, i32>;
1149
1150pub trait HealthProxyInterface: Send + Sync {
1151 type GetReportResponseFut: std::future::Future<Output = Result<HealthGetReportResult, fidl::Error>>
1152 + Send;
1153 fn r#get_report(&self) -> Self::GetReportResponseFut;
1154}
1155#[derive(Debug)]
1156#[cfg(target_os = "fuchsia")]
1157pub struct HealthSynchronousProxy {
1158 client: fidl::client::sync::Client,
1159}
1160
1161#[cfg(target_os = "fuchsia")]
1162impl fidl::endpoints::SynchronousProxy for HealthSynchronousProxy {
1163 type Proxy = HealthProxy;
1164 type Protocol = HealthMarker;
1165
1166 fn from_channel(inner: fidl::Channel) -> Self {
1167 Self::new(inner)
1168 }
1169
1170 fn into_channel(self) -> fidl::Channel {
1171 self.client.into_channel()
1172 }
1173
1174 fn as_channel(&self) -> &fidl::Channel {
1175 self.client.as_channel()
1176 }
1177}
1178
1179#[cfg(target_os = "fuchsia")]
1180impl HealthSynchronousProxy {
1181 pub fn new(channel: fidl::Channel) -> Self {
1182 Self { client: fidl::client::sync::Client::new(channel) }
1183 }
1184
1185 pub fn into_channel(self) -> fidl::Channel {
1186 self.client.into_channel()
1187 }
1188
1189 pub fn wait_for_event(
1192 &self,
1193 deadline: zx::MonotonicInstant,
1194 ) -> Result<HealthEvent, fidl::Error> {
1195 HealthEvent::decode(self.client.wait_for_event::<HealthMarker>(deadline)?)
1196 }
1197
1198 pub fn r#get_report(
1200 &self,
1201 ___deadline: zx::MonotonicInstant,
1202 ) -> Result<HealthGetReportResult, fidl::Error> {
1203 let _response = self.client.send_query::<
1204 fidl::encoding::EmptyPayload,
1205 fidl::encoding::FlexibleResultType<HealthReport, i32>,
1206 HealthMarker,
1207 >(
1208 (),
1209 0x45f3bc8cbb38e701,
1210 fidl::encoding::DynamicFlags::FLEXIBLE,
1211 ___deadline,
1212 )?
1213 .into_result::<HealthMarker>("get_report")?;
1214 Ok(_response.map(|x| x))
1215 }
1216}
1217
1218#[cfg(target_os = "fuchsia")]
1219impl From<HealthSynchronousProxy> for zx::NullableHandle {
1220 fn from(value: HealthSynchronousProxy) -> Self {
1221 value.into_channel().into()
1222 }
1223}
1224
1225#[cfg(target_os = "fuchsia")]
1226impl From<fidl::Channel> for HealthSynchronousProxy {
1227 fn from(value: fidl::Channel) -> Self {
1228 Self::new(value)
1229 }
1230}
1231
1232#[cfg(target_os = "fuchsia")]
1233impl fidl::endpoints::FromClient for HealthSynchronousProxy {
1234 type Protocol = HealthMarker;
1235
1236 fn from_client(value: fidl::endpoints::ClientEnd<HealthMarker>) -> Self {
1237 Self::new(value.into_channel())
1238 }
1239}
1240
1241#[derive(Debug, Clone)]
1242pub struct HealthProxy {
1243 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1244}
1245
1246impl fidl::endpoints::Proxy for HealthProxy {
1247 type Protocol = HealthMarker;
1248
1249 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1250 Self::new(inner)
1251 }
1252
1253 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1254 self.client.into_channel().map_err(|client| Self { client })
1255 }
1256
1257 fn as_channel(&self) -> &::fidl::AsyncChannel {
1258 self.client.as_channel()
1259 }
1260}
1261
1262impl HealthProxy {
1263 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1265 let protocol_name = <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1266 Self { client: fidl::client::Client::new(channel, protocol_name) }
1267 }
1268
1269 pub fn take_event_stream(&self) -> HealthEventStream {
1275 HealthEventStream { event_receiver: self.client.take_event_receiver() }
1276 }
1277
1278 pub fn r#get_report(
1280 &self,
1281 ) -> fidl::client::QueryResponseFut<
1282 HealthGetReportResult,
1283 fidl::encoding::DefaultFuchsiaResourceDialect,
1284 > {
1285 HealthProxyInterface::r#get_report(self)
1286 }
1287}
1288
1289impl HealthProxyInterface for HealthProxy {
1290 type GetReportResponseFut = fidl::client::QueryResponseFut<
1291 HealthGetReportResult,
1292 fidl::encoding::DefaultFuchsiaResourceDialect,
1293 >;
1294 fn r#get_report(&self) -> Self::GetReportResponseFut {
1295 fn _decode(
1296 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1297 ) -> Result<HealthGetReportResult, fidl::Error> {
1298 let _response = fidl::client::decode_transaction_body::<
1299 fidl::encoding::FlexibleResultType<HealthReport, i32>,
1300 fidl::encoding::DefaultFuchsiaResourceDialect,
1301 0x45f3bc8cbb38e701,
1302 >(_buf?)?
1303 .into_result::<HealthMarker>("get_report")?;
1304 Ok(_response.map(|x| x))
1305 }
1306 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HealthGetReportResult>(
1307 (),
1308 0x45f3bc8cbb38e701,
1309 fidl::encoding::DynamicFlags::FLEXIBLE,
1310 _decode,
1311 )
1312 }
1313}
1314
1315pub struct HealthEventStream {
1316 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1317}
1318
1319impl std::marker::Unpin for HealthEventStream {}
1320
1321impl futures::stream::FusedStream for HealthEventStream {
1322 fn is_terminated(&self) -> bool {
1323 self.event_receiver.is_terminated()
1324 }
1325}
1326
1327impl futures::Stream for HealthEventStream {
1328 type Item = Result<HealthEvent, fidl::Error>;
1329
1330 fn poll_next(
1331 mut self: std::pin::Pin<&mut Self>,
1332 cx: &mut std::task::Context<'_>,
1333 ) -> std::task::Poll<Option<Self::Item>> {
1334 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1335 &mut self.event_receiver,
1336 cx
1337 )?) {
1338 Some(buf) => std::task::Poll::Ready(Some(HealthEvent::decode(buf))),
1339 None => std::task::Poll::Ready(None),
1340 }
1341 }
1342}
1343
1344#[derive(Debug)]
1345pub enum HealthEvent {
1346 #[non_exhaustive]
1347 _UnknownEvent {
1348 ordinal: u64,
1350 },
1351}
1352
1353impl HealthEvent {
1354 fn decode(
1356 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1357 ) -> Result<HealthEvent, fidl::Error> {
1358 let (bytes, _handles) = buf.split_mut();
1359 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1360 debug_assert_eq!(tx_header.tx_id, 0);
1361 match tx_header.ordinal {
1362 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1363 Ok(HealthEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1364 }
1365 _ => Err(fidl::Error::UnknownOrdinal {
1366 ordinal: tx_header.ordinal,
1367 protocol_name: <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1368 }),
1369 }
1370 }
1371}
1372
1373pub struct HealthRequestStream {
1375 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1376 is_terminated: bool,
1377}
1378
1379impl std::marker::Unpin for HealthRequestStream {}
1380
1381impl futures::stream::FusedStream for HealthRequestStream {
1382 fn is_terminated(&self) -> bool {
1383 self.is_terminated
1384 }
1385}
1386
1387impl fidl::endpoints::RequestStream for HealthRequestStream {
1388 type Protocol = HealthMarker;
1389 type ControlHandle = HealthControlHandle;
1390
1391 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1392 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1393 }
1394
1395 fn control_handle(&self) -> Self::ControlHandle {
1396 HealthControlHandle { inner: self.inner.clone() }
1397 }
1398
1399 fn into_inner(
1400 self,
1401 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1402 {
1403 (self.inner, self.is_terminated)
1404 }
1405
1406 fn from_inner(
1407 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1408 is_terminated: bool,
1409 ) -> Self {
1410 Self { inner, is_terminated }
1411 }
1412}
1413
1414impl futures::Stream for HealthRequestStream {
1415 type Item = Result<HealthRequest, fidl::Error>;
1416
1417 fn poll_next(
1418 mut self: std::pin::Pin<&mut Self>,
1419 cx: &mut std::task::Context<'_>,
1420 ) -> std::task::Poll<Option<Self::Item>> {
1421 let this = &mut *self;
1422 if this.inner.check_shutdown(cx) {
1423 this.is_terminated = true;
1424 return std::task::Poll::Ready(None);
1425 }
1426 if this.is_terminated {
1427 panic!("polled HealthRequestStream after completion");
1428 }
1429 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1430 |bytes, handles| {
1431 match this.inner.channel().read_etc(cx, bytes, handles) {
1432 std::task::Poll::Ready(Ok(())) => {}
1433 std::task::Poll::Pending => return std::task::Poll::Pending,
1434 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1435 this.is_terminated = true;
1436 return std::task::Poll::Ready(None);
1437 }
1438 std::task::Poll::Ready(Err(e)) => {
1439 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1440 e.into(),
1441 ))));
1442 }
1443 }
1444
1445 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1447
1448 std::task::Poll::Ready(Some(match header.ordinal {
1449 0x45f3bc8cbb38e701 => {
1450 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1451 let mut req = fidl::new_empty!(
1452 fidl::encoding::EmptyPayload,
1453 fidl::encoding::DefaultFuchsiaResourceDialect
1454 );
1455 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1456 let control_handle = HealthControlHandle { inner: this.inner.clone() };
1457 Ok(HealthRequest::GetReport {
1458 responder: HealthGetReportResponder {
1459 control_handle: std::mem::ManuallyDrop::new(control_handle),
1460 tx_id: header.tx_id,
1461 },
1462 })
1463 }
1464 _ if header.tx_id == 0
1465 && header
1466 .dynamic_flags()
1467 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1468 {
1469 Ok(HealthRequest::_UnknownMethod {
1470 ordinal: header.ordinal,
1471 control_handle: HealthControlHandle { inner: this.inner.clone() },
1472 method_type: fidl::MethodType::OneWay,
1473 })
1474 }
1475 _ if header
1476 .dynamic_flags()
1477 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1478 {
1479 this.inner.send_framework_err(
1480 fidl::encoding::FrameworkErr::UnknownMethod,
1481 header.tx_id,
1482 header.ordinal,
1483 header.dynamic_flags(),
1484 (bytes, handles),
1485 )?;
1486 Ok(HealthRequest::_UnknownMethod {
1487 ordinal: header.ordinal,
1488 control_handle: HealthControlHandle { inner: this.inner.clone() },
1489 method_type: fidl::MethodType::TwoWay,
1490 })
1491 }
1492 _ => Err(fidl::Error::UnknownOrdinal {
1493 ordinal: header.ordinal,
1494 protocol_name:
1495 <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1496 }),
1497 }))
1498 },
1499 )
1500 }
1501}
1502
1503#[derive(Debug)]
1505pub enum HealthRequest {
1506 GetReport { responder: HealthGetReportResponder },
1508 #[non_exhaustive]
1510 _UnknownMethod {
1511 ordinal: u64,
1513 control_handle: HealthControlHandle,
1514 method_type: fidl::MethodType,
1515 },
1516}
1517
1518impl HealthRequest {
1519 #[allow(irrefutable_let_patterns)]
1520 pub fn into_get_report(self) -> Option<(HealthGetReportResponder)> {
1521 if let HealthRequest::GetReport { responder } = self { Some((responder)) } else { None }
1522 }
1523
1524 pub fn method_name(&self) -> &'static str {
1526 match *self {
1527 HealthRequest::GetReport { .. } => "get_report",
1528 HealthRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1529 "unknown one-way method"
1530 }
1531 HealthRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1532 "unknown two-way method"
1533 }
1534 }
1535 }
1536}
1537
1538#[derive(Debug, Clone)]
1539pub struct HealthControlHandle {
1540 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1541}
1542
1543impl HealthControlHandle {
1544 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1545 self.inner.shutdown_with_epitaph(status.into())
1546 }
1547}
1548
1549impl fidl::endpoints::ControlHandle for HealthControlHandle {
1550 fn shutdown(&self) {
1551 self.inner.shutdown()
1552 }
1553
1554 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1555 self.inner.shutdown_with_epitaph(status)
1556 }
1557
1558 fn is_closed(&self) -> bool {
1559 self.inner.channel().is_closed()
1560 }
1561 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1562 self.inner.channel().on_closed()
1563 }
1564
1565 #[cfg(target_os = "fuchsia")]
1566 fn signal_peer(
1567 &self,
1568 clear_mask: zx::Signals,
1569 set_mask: zx::Signals,
1570 ) -> Result<(), zx_status::Status> {
1571 use fidl::Peered;
1572 self.inner.channel().signal_peer(clear_mask, set_mask)
1573 }
1574}
1575
1576impl HealthControlHandle {}
1577
1578#[must_use = "FIDL methods require a response to be sent"]
1579#[derive(Debug)]
1580pub struct HealthGetReportResponder {
1581 control_handle: std::mem::ManuallyDrop<HealthControlHandle>,
1582 tx_id: u32,
1583}
1584
1585impl std::ops::Drop for HealthGetReportResponder {
1589 fn drop(&mut self) {
1590 self.control_handle.shutdown();
1591 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1593 }
1594}
1595
1596impl fidl::endpoints::Responder for HealthGetReportResponder {
1597 type ControlHandle = HealthControlHandle;
1598
1599 fn control_handle(&self) -> &HealthControlHandle {
1600 &self.control_handle
1601 }
1602
1603 fn drop_without_shutdown(mut self) {
1604 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1606 std::mem::forget(self);
1608 }
1609}
1610
1611impl HealthGetReportResponder {
1612 pub fn send(self, mut result: Result<&HealthReport, i32>) -> Result<(), fidl::Error> {
1616 let _result = self.send_raw(result);
1617 if _result.is_err() {
1618 self.control_handle.shutdown();
1619 }
1620 self.drop_without_shutdown();
1621 _result
1622 }
1623
1624 pub fn send_no_shutdown_on_err(
1626 self,
1627 mut result: Result<&HealthReport, i32>,
1628 ) -> Result<(), fidl::Error> {
1629 let _result = self.send_raw(result);
1630 self.drop_without_shutdown();
1631 _result
1632 }
1633
1634 fn send_raw(&self, mut result: Result<&HealthReport, i32>) -> Result<(), fidl::Error> {
1635 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<HealthReport, i32>>(
1636 fidl::encoding::FlexibleResult::new(result),
1637 self.tx_id,
1638 0x45f3bc8cbb38e701,
1639 fidl::encoding::DynamicFlags::FLEXIBLE,
1640 )
1641 }
1642}
1643
1644#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1645pub struct PolicyProviderMarker;
1646
1647impl fidl::endpoints::ProtocolMarker for PolicyProviderMarker {
1648 type Proxy = PolicyProviderProxy;
1649 type RequestStream = PolicyProviderRequestStream;
1650 #[cfg(target_os = "fuchsia")]
1651 type SynchronousProxy = PolicyProviderSynchronousProxy;
1652
1653 const DEBUG_NAME: &'static str = "fuchsia.usb.policy.PolicyProvider";
1654}
1655impl fidl::endpoints::DiscoverableProtocolMarker for PolicyProviderMarker {}
1656
1657pub trait PolicyProviderProxyInterface: Send + Sync {
1658 type WatchDeviceStateResponseFut: std::future::Future<
1659 Output = Result<
1660 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1661 fidl::Error,
1662 >,
1663 > + Send;
1664 fn r#watch_device_state(&self) -> Self::WatchDeviceStateResponseFut;
1665}
1666#[derive(Debug)]
1667#[cfg(target_os = "fuchsia")]
1668pub struct PolicyProviderSynchronousProxy {
1669 client: fidl::client::sync::Client,
1670}
1671
1672#[cfg(target_os = "fuchsia")]
1673impl fidl::endpoints::SynchronousProxy for PolicyProviderSynchronousProxy {
1674 type Proxy = PolicyProviderProxy;
1675 type Protocol = PolicyProviderMarker;
1676
1677 fn from_channel(inner: fidl::Channel) -> Self {
1678 Self::new(inner)
1679 }
1680
1681 fn into_channel(self) -> fidl::Channel {
1682 self.client.into_channel()
1683 }
1684
1685 fn as_channel(&self) -> &fidl::Channel {
1686 self.client.as_channel()
1687 }
1688}
1689
1690#[cfg(target_os = "fuchsia")]
1691impl PolicyProviderSynchronousProxy {
1692 pub fn new(channel: fidl::Channel) -> Self {
1693 Self { client: fidl::client::sync::Client::new(channel) }
1694 }
1695
1696 pub fn into_channel(self) -> fidl::Channel {
1697 self.client.into_channel()
1698 }
1699
1700 pub fn wait_for_event(
1703 &self,
1704 deadline: zx::MonotonicInstant,
1705 ) -> Result<PolicyProviderEvent, fidl::Error> {
1706 PolicyProviderEvent::decode(self.client.wait_for_event::<PolicyProviderMarker>(deadline)?)
1707 }
1708
1709 pub fn r#watch_device_state(
1715 &self,
1716 ___deadline: zx::MonotonicInstant,
1717 ) -> Result<
1718 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1719 fidl::Error,
1720 > {
1721 let _response = self
1722 .client
1723 .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
1724 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
1725 i32,
1726 >, PolicyProviderMarker>(
1727 (),
1728 0x44628a2275753738,
1729 fidl::encoding::DynamicFlags::FLEXIBLE,
1730 ___deadline,
1731 )?
1732 .into_result::<PolicyProviderMarker>("watch_device_state")?;
1733 Ok(_response.map(|x| x))
1734 }
1735}
1736
1737#[cfg(target_os = "fuchsia")]
1738impl From<PolicyProviderSynchronousProxy> for zx::NullableHandle {
1739 fn from(value: PolicyProviderSynchronousProxy) -> Self {
1740 value.into_channel().into()
1741 }
1742}
1743
1744#[cfg(target_os = "fuchsia")]
1745impl From<fidl::Channel> for PolicyProviderSynchronousProxy {
1746 fn from(value: fidl::Channel) -> Self {
1747 Self::new(value)
1748 }
1749}
1750
1751#[cfg(target_os = "fuchsia")]
1752impl fidl::endpoints::FromClient for PolicyProviderSynchronousProxy {
1753 type Protocol = PolicyProviderMarker;
1754
1755 fn from_client(value: fidl::endpoints::ClientEnd<PolicyProviderMarker>) -> Self {
1756 Self::new(value.into_channel())
1757 }
1758}
1759
1760#[derive(Debug, Clone)]
1761pub struct PolicyProviderProxy {
1762 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1763}
1764
1765impl fidl::endpoints::Proxy for PolicyProviderProxy {
1766 type Protocol = PolicyProviderMarker;
1767
1768 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1769 Self::new(inner)
1770 }
1771
1772 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1773 self.client.into_channel().map_err(|client| Self { client })
1774 }
1775
1776 fn as_channel(&self) -> &::fidl::AsyncChannel {
1777 self.client.as_channel()
1778 }
1779}
1780
1781impl PolicyProviderProxy {
1782 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1784 let protocol_name = <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1785 Self { client: fidl::client::Client::new(channel, protocol_name) }
1786 }
1787
1788 pub fn take_event_stream(&self) -> PolicyProviderEventStream {
1794 PolicyProviderEventStream { event_receiver: self.client.take_event_receiver() }
1795 }
1796
1797 pub fn r#watch_device_state(
1803 &self,
1804 ) -> fidl::client::QueryResponseFut<
1805 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1806 fidl::encoding::DefaultFuchsiaResourceDialect,
1807 > {
1808 PolicyProviderProxyInterface::r#watch_device_state(self)
1809 }
1810}
1811
1812impl PolicyProviderProxyInterface for PolicyProviderProxy {
1813 type WatchDeviceStateResponseFut = fidl::client::QueryResponseFut<
1814 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1815 fidl::encoding::DefaultFuchsiaResourceDialect,
1816 >;
1817 fn r#watch_device_state(&self) -> Self::WatchDeviceStateResponseFut {
1818 fn _decode(
1819 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1820 ) -> Result<
1821 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1822 fidl::Error,
1823 > {
1824 let _response = fidl::client::decode_transaction_body::<
1825 fidl::encoding::FlexibleResultType<
1826 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
1827 i32,
1828 >,
1829 fidl::encoding::DefaultFuchsiaResourceDialect,
1830 0x44628a2275753738,
1831 >(_buf?)?
1832 .into_result::<PolicyProviderMarker>("watch_device_state")?;
1833 Ok(_response.map(|x| x))
1834 }
1835 self.client.send_query_and_decode::<
1836 fidl::encoding::EmptyPayload,
1837 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
1838 >(
1839 (),
1840 0x44628a2275753738,
1841 fidl::encoding::DynamicFlags::FLEXIBLE,
1842 _decode,
1843 )
1844 }
1845}
1846
1847pub struct PolicyProviderEventStream {
1848 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1849}
1850
1851impl std::marker::Unpin for PolicyProviderEventStream {}
1852
1853impl futures::stream::FusedStream for PolicyProviderEventStream {
1854 fn is_terminated(&self) -> bool {
1855 self.event_receiver.is_terminated()
1856 }
1857}
1858
1859impl futures::Stream for PolicyProviderEventStream {
1860 type Item = Result<PolicyProviderEvent, fidl::Error>;
1861
1862 fn poll_next(
1863 mut self: std::pin::Pin<&mut Self>,
1864 cx: &mut std::task::Context<'_>,
1865 ) -> std::task::Poll<Option<Self::Item>> {
1866 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1867 &mut self.event_receiver,
1868 cx
1869 )?) {
1870 Some(buf) => std::task::Poll::Ready(Some(PolicyProviderEvent::decode(buf))),
1871 None => std::task::Poll::Ready(None),
1872 }
1873 }
1874}
1875
1876#[derive(Debug)]
1877pub enum PolicyProviderEvent {
1878 #[non_exhaustive]
1879 _UnknownEvent {
1880 ordinal: u64,
1882 },
1883}
1884
1885impl PolicyProviderEvent {
1886 fn decode(
1888 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1889 ) -> Result<PolicyProviderEvent, fidl::Error> {
1890 let (bytes, _handles) = buf.split_mut();
1891 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1892 debug_assert_eq!(tx_header.tx_id, 0);
1893 match tx_header.ordinal {
1894 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1895 Ok(PolicyProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1896 }
1897 _ => Err(fidl::Error::UnknownOrdinal {
1898 ordinal: tx_header.ordinal,
1899 protocol_name:
1900 <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1901 }),
1902 }
1903 }
1904}
1905
1906pub struct PolicyProviderRequestStream {
1908 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1909 is_terminated: bool,
1910}
1911
1912impl std::marker::Unpin for PolicyProviderRequestStream {}
1913
1914impl futures::stream::FusedStream for PolicyProviderRequestStream {
1915 fn is_terminated(&self) -> bool {
1916 self.is_terminated
1917 }
1918}
1919
1920impl fidl::endpoints::RequestStream for PolicyProviderRequestStream {
1921 type Protocol = PolicyProviderMarker;
1922 type ControlHandle = PolicyProviderControlHandle;
1923
1924 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1925 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1926 }
1927
1928 fn control_handle(&self) -> Self::ControlHandle {
1929 PolicyProviderControlHandle { inner: self.inner.clone() }
1930 }
1931
1932 fn into_inner(
1933 self,
1934 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1935 {
1936 (self.inner, self.is_terminated)
1937 }
1938
1939 fn from_inner(
1940 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1941 is_terminated: bool,
1942 ) -> Self {
1943 Self { inner, is_terminated }
1944 }
1945}
1946
1947impl futures::Stream for PolicyProviderRequestStream {
1948 type Item = Result<PolicyProviderRequest, fidl::Error>;
1949
1950 fn poll_next(
1951 mut self: std::pin::Pin<&mut Self>,
1952 cx: &mut std::task::Context<'_>,
1953 ) -> std::task::Poll<Option<Self::Item>> {
1954 let this = &mut *self;
1955 if this.inner.check_shutdown(cx) {
1956 this.is_terminated = true;
1957 return std::task::Poll::Ready(None);
1958 }
1959 if this.is_terminated {
1960 panic!("polled PolicyProviderRequestStream after completion");
1961 }
1962 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1963 |bytes, handles| {
1964 match this.inner.channel().read_etc(cx, bytes, handles) {
1965 std::task::Poll::Ready(Ok(())) => {}
1966 std::task::Poll::Pending => return std::task::Poll::Pending,
1967 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1968 this.is_terminated = true;
1969 return std::task::Poll::Ready(None);
1970 }
1971 std::task::Poll::Ready(Err(e)) => {
1972 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1973 e.into(),
1974 ))));
1975 }
1976 }
1977
1978 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1980
1981 std::task::Poll::Ready(Some(match header.ordinal {
1982 0x44628a2275753738 => {
1983 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1984 let mut req = fidl::new_empty!(
1985 fidl::encoding::EmptyPayload,
1986 fidl::encoding::DefaultFuchsiaResourceDialect
1987 );
1988 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1989 let control_handle =
1990 PolicyProviderControlHandle { inner: this.inner.clone() };
1991 Ok(PolicyProviderRequest::WatchDeviceState {
1992 responder: PolicyProviderWatchDeviceStateResponder {
1993 control_handle: std::mem::ManuallyDrop::new(control_handle),
1994 tx_id: header.tx_id,
1995 },
1996 })
1997 }
1998 _ if header.tx_id == 0
1999 && header
2000 .dynamic_flags()
2001 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2002 {
2003 Ok(PolicyProviderRequest::_UnknownMethod {
2004 ordinal: header.ordinal,
2005 control_handle: PolicyProviderControlHandle {
2006 inner: this.inner.clone(),
2007 },
2008 method_type: fidl::MethodType::OneWay,
2009 })
2010 }
2011 _ if header
2012 .dynamic_flags()
2013 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2014 {
2015 this.inner.send_framework_err(
2016 fidl::encoding::FrameworkErr::UnknownMethod,
2017 header.tx_id,
2018 header.ordinal,
2019 header.dynamic_flags(),
2020 (bytes, handles),
2021 )?;
2022 Ok(PolicyProviderRequest::_UnknownMethod {
2023 ordinal: header.ordinal,
2024 control_handle: PolicyProviderControlHandle {
2025 inner: this.inner.clone(),
2026 },
2027 method_type: fidl::MethodType::TwoWay,
2028 })
2029 }
2030 _ => Err(fidl::Error::UnknownOrdinal {
2031 ordinal: header.ordinal,
2032 protocol_name:
2033 <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2034 }),
2035 }))
2036 },
2037 )
2038 }
2039}
2040
2041#[derive(Debug)]
2043pub enum PolicyProviderRequest {
2044 WatchDeviceState { responder: PolicyProviderWatchDeviceStateResponder },
2050 #[non_exhaustive]
2052 _UnknownMethod {
2053 ordinal: u64,
2055 control_handle: PolicyProviderControlHandle,
2056 method_type: fidl::MethodType,
2057 },
2058}
2059
2060impl PolicyProviderRequest {
2061 #[allow(irrefutable_let_patterns)]
2062 pub fn into_watch_device_state(self) -> Option<(PolicyProviderWatchDeviceStateResponder)> {
2063 if let PolicyProviderRequest::WatchDeviceState { responder } = self {
2064 Some((responder))
2065 } else {
2066 None
2067 }
2068 }
2069
2070 pub fn method_name(&self) -> &'static str {
2072 match *self {
2073 PolicyProviderRequest::WatchDeviceState { .. } => "watch_device_state",
2074 PolicyProviderRequest::_UnknownMethod {
2075 method_type: fidl::MethodType::OneWay, ..
2076 } => "unknown one-way method",
2077 PolicyProviderRequest::_UnknownMethod {
2078 method_type: fidl::MethodType::TwoWay, ..
2079 } => "unknown two-way method",
2080 }
2081 }
2082}
2083
2084#[derive(Debug, Clone)]
2085pub struct PolicyProviderControlHandle {
2086 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2087}
2088
2089impl PolicyProviderControlHandle {
2090 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2091 self.inner.shutdown_with_epitaph(status.into())
2092 }
2093}
2094
2095impl fidl::endpoints::ControlHandle for PolicyProviderControlHandle {
2096 fn shutdown(&self) {
2097 self.inner.shutdown()
2098 }
2099
2100 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2101 self.inner.shutdown_with_epitaph(status)
2102 }
2103
2104 fn is_closed(&self) -> bool {
2105 self.inner.channel().is_closed()
2106 }
2107 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2108 self.inner.channel().on_closed()
2109 }
2110
2111 #[cfg(target_os = "fuchsia")]
2112 fn signal_peer(
2113 &self,
2114 clear_mask: zx::Signals,
2115 set_mask: zx::Signals,
2116 ) -> Result<(), zx_status::Status> {
2117 use fidl::Peered;
2118 self.inner.channel().signal_peer(clear_mask, set_mask)
2119 }
2120}
2121
2122impl PolicyProviderControlHandle {}
2123
2124#[must_use = "FIDL methods require a response to be sent"]
2125#[derive(Debug)]
2126pub struct PolicyProviderWatchDeviceStateResponder {
2127 control_handle: std::mem::ManuallyDrop<PolicyProviderControlHandle>,
2128 tx_id: u32,
2129}
2130
2131impl std::ops::Drop for PolicyProviderWatchDeviceStateResponder {
2135 fn drop(&mut self) {
2136 self.control_handle.shutdown();
2137 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2139 }
2140}
2141
2142impl fidl::endpoints::Responder for PolicyProviderWatchDeviceStateResponder {
2143 type ControlHandle = PolicyProviderControlHandle;
2144
2145 fn control_handle(&self) -> &PolicyProviderControlHandle {
2146 &self.control_handle
2147 }
2148
2149 fn drop_without_shutdown(mut self) {
2150 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2152 std::mem::forget(self);
2154 }
2155}
2156
2157impl PolicyProviderWatchDeviceStateResponder {
2158 pub fn send(
2162 self,
2163 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
2164 ) -> Result<(), fidl::Error> {
2165 let _result = self.send_raw(result);
2166 if _result.is_err() {
2167 self.control_handle.shutdown();
2168 }
2169 self.drop_without_shutdown();
2170 _result
2171 }
2172
2173 pub fn send_no_shutdown_on_err(
2175 self,
2176 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
2177 ) -> Result<(), fidl::Error> {
2178 let _result = self.send_raw(result);
2179 self.drop_without_shutdown();
2180 _result
2181 }
2182
2183 fn send_raw(
2184 &self,
2185 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
2186 ) -> Result<(), fidl::Error> {
2187 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2188 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
2189 i32,
2190 >>(
2191 fidl::encoding::FlexibleResult::new(result),
2192 self.tx_id,
2193 0x44628a2275753738,
2194 fidl::encoding::DynamicFlags::FLEXIBLE,
2195 )
2196 }
2197}
2198
2199mod internal {
2200 use super::*;
2201}