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 HealthMarker;
16
17impl fidl::endpoints::ProtocolMarker for HealthMarker {
18 type Proxy = HealthProxy;
19 type RequestStream = HealthRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = HealthSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.usb.policy.Health";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for HealthMarker {}
26pub type HealthGetReportResult = Result<HealthReport, i32>;
27
28pub trait HealthProxyInterface: Send + Sync {
29 type GetReportResponseFut: std::future::Future<Output = Result<HealthGetReportResult, fidl::Error>>
30 + Send;
31 fn r#get_report(&self) -> Self::GetReportResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct HealthSynchronousProxy {
36 client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for HealthSynchronousProxy {
41 type Proxy = HealthProxy;
42 type Protocol = HealthMarker;
43
44 fn from_channel(inner: fidl::Channel) -> Self {
45 Self::new(inner)
46 }
47
48 fn into_channel(self) -> fidl::Channel {
49 self.client.into_channel()
50 }
51
52 fn as_channel(&self) -> &fidl::Channel {
53 self.client.as_channel()
54 }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl HealthSynchronousProxy {
59 pub fn new(channel: fidl::Channel) -> Self {
60 Self { client: fidl::client::sync::Client::new(channel) }
61 }
62
63 pub fn into_channel(self) -> fidl::Channel {
64 self.client.into_channel()
65 }
66
67 pub fn wait_for_event(
70 &self,
71 deadline: zx::MonotonicInstant,
72 ) -> Result<HealthEvent, fidl::Error> {
73 HealthEvent::decode(self.client.wait_for_event::<HealthMarker>(deadline)?)
74 }
75
76 pub fn r#get_report(
78 &self,
79 ___deadline: zx::MonotonicInstant,
80 ) -> Result<HealthGetReportResult, fidl::Error> {
81 let _response = self.client.send_query::<
82 fidl::encoding::EmptyPayload,
83 fidl::encoding::FlexibleResultType<HealthReport, i32>,
84 HealthMarker,
85 >(
86 (),
87 0x45f3bc8cbb38e701,
88 fidl::encoding::DynamicFlags::FLEXIBLE,
89 ___deadline,
90 )?
91 .into_result::<HealthMarker>("get_report")?;
92 Ok(_response.map(|x| x))
93 }
94}
95
96#[cfg(target_os = "fuchsia")]
97impl From<HealthSynchronousProxy> for zx::NullableHandle {
98 fn from(value: HealthSynchronousProxy) -> Self {
99 value.into_channel().into()
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<fidl::Channel> for HealthSynchronousProxy {
105 fn from(value: fidl::Channel) -> Self {
106 Self::new(value)
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl fidl::endpoints::FromClient for HealthSynchronousProxy {
112 type Protocol = HealthMarker;
113
114 fn from_client(value: fidl::endpoints::ClientEnd<HealthMarker>) -> Self {
115 Self::new(value.into_channel())
116 }
117}
118
119#[derive(Debug, Clone)]
120pub struct HealthProxy {
121 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
122}
123
124impl fidl::endpoints::Proxy for HealthProxy {
125 type Protocol = HealthMarker;
126
127 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
128 Self::new(inner)
129 }
130
131 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
132 self.client.into_channel().map_err(|client| Self { client })
133 }
134
135 fn as_channel(&self) -> &::fidl::AsyncChannel {
136 self.client.as_channel()
137 }
138}
139
140impl HealthProxy {
141 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
143 let protocol_name = <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
144 Self { client: fidl::client::Client::new(channel, protocol_name) }
145 }
146
147 pub fn take_event_stream(&self) -> HealthEventStream {
153 HealthEventStream { event_receiver: self.client.take_event_receiver() }
154 }
155
156 pub fn r#get_report(
158 &self,
159 ) -> fidl::client::QueryResponseFut<
160 HealthGetReportResult,
161 fidl::encoding::DefaultFuchsiaResourceDialect,
162 > {
163 HealthProxyInterface::r#get_report(self)
164 }
165}
166
167impl HealthProxyInterface for HealthProxy {
168 type GetReportResponseFut = fidl::client::QueryResponseFut<
169 HealthGetReportResult,
170 fidl::encoding::DefaultFuchsiaResourceDialect,
171 >;
172 fn r#get_report(&self) -> Self::GetReportResponseFut {
173 fn _decode(
174 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
175 ) -> Result<HealthGetReportResult, fidl::Error> {
176 let _response = fidl::client::decode_transaction_body::<
177 fidl::encoding::FlexibleResultType<HealthReport, i32>,
178 fidl::encoding::DefaultFuchsiaResourceDialect,
179 0x45f3bc8cbb38e701,
180 >(_buf?)?
181 .into_result::<HealthMarker>("get_report")?;
182 Ok(_response.map(|x| x))
183 }
184 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HealthGetReportResult>(
185 (),
186 0x45f3bc8cbb38e701,
187 fidl::encoding::DynamicFlags::FLEXIBLE,
188 _decode,
189 )
190 }
191}
192
193pub struct HealthEventStream {
194 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
195}
196
197impl std::marker::Unpin for HealthEventStream {}
198
199impl futures::stream::FusedStream for HealthEventStream {
200 fn is_terminated(&self) -> bool {
201 self.event_receiver.is_terminated()
202 }
203}
204
205impl futures::Stream for HealthEventStream {
206 type Item = Result<HealthEvent, fidl::Error>;
207
208 fn poll_next(
209 mut self: std::pin::Pin<&mut Self>,
210 cx: &mut std::task::Context<'_>,
211 ) -> std::task::Poll<Option<Self::Item>> {
212 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
213 &mut self.event_receiver,
214 cx
215 )?) {
216 Some(buf) => std::task::Poll::Ready(Some(HealthEvent::decode(buf))),
217 None => std::task::Poll::Ready(None),
218 }
219 }
220}
221
222#[derive(Debug)]
223pub enum HealthEvent {
224 #[non_exhaustive]
225 _UnknownEvent {
226 ordinal: u64,
228 },
229}
230
231impl HealthEvent {
232 fn decode(
234 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
235 ) -> Result<HealthEvent, fidl::Error> {
236 let (bytes, _handles) = buf.split_mut();
237 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
238 debug_assert_eq!(tx_header.tx_id, 0);
239 match tx_header.ordinal {
240 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
241 Ok(HealthEvent::_UnknownEvent { ordinal: tx_header.ordinal })
242 }
243 _ => Err(fidl::Error::UnknownOrdinal {
244 ordinal: tx_header.ordinal,
245 protocol_name: <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
246 }),
247 }
248 }
249}
250
251pub struct HealthRequestStream {
253 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
254 is_terminated: bool,
255}
256
257impl std::marker::Unpin for HealthRequestStream {}
258
259impl futures::stream::FusedStream for HealthRequestStream {
260 fn is_terminated(&self) -> bool {
261 self.is_terminated
262 }
263}
264
265impl fidl::endpoints::RequestStream for HealthRequestStream {
266 type Protocol = HealthMarker;
267 type ControlHandle = HealthControlHandle;
268
269 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
270 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
271 }
272
273 fn control_handle(&self) -> Self::ControlHandle {
274 HealthControlHandle { inner: self.inner.clone() }
275 }
276
277 fn into_inner(
278 self,
279 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
280 {
281 (self.inner, self.is_terminated)
282 }
283
284 fn from_inner(
285 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
286 is_terminated: bool,
287 ) -> Self {
288 Self { inner, is_terminated }
289 }
290}
291
292impl futures::Stream for HealthRequestStream {
293 type Item = Result<HealthRequest, fidl::Error>;
294
295 fn poll_next(
296 mut self: std::pin::Pin<&mut Self>,
297 cx: &mut std::task::Context<'_>,
298 ) -> std::task::Poll<Option<Self::Item>> {
299 let this = &mut *self;
300 if this.inner.check_shutdown(cx) {
301 this.is_terminated = true;
302 return std::task::Poll::Ready(None);
303 }
304 if this.is_terminated {
305 panic!("polled HealthRequestStream after completion");
306 }
307 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
308 |bytes, handles| {
309 match this.inner.channel().read_etc(cx, bytes, handles) {
310 std::task::Poll::Ready(Ok(())) => {}
311 std::task::Poll::Pending => return std::task::Poll::Pending,
312 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
313 this.is_terminated = true;
314 return std::task::Poll::Ready(None);
315 }
316 std::task::Poll::Ready(Err(e)) => {
317 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
318 e.into(),
319 ))));
320 }
321 }
322
323 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
325
326 std::task::Poll::Ready(Some(match header.ordinal {
327 0x45f3bc8cbb38e701 => {
328 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
329 let mut req = fidl::new_empty!(
330 fidl::encoding::EmptyPayload,
331 fidl::encoding::DefaultFuchsiaResourceDialect
332 );
333 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
334 let control_handle = HealthControlHandle { inner: this.inner.clone() };
335 Ok(HealthRequest::GetReport {
336 responder: HealthGetReportResponder {
337 control_handle: std::mem::ManuallyDrop::new(control_handle),
338 tx_id: header.tx_id,
339 },
340 })
341 }
342 _ if header.tx_id == 0
343 && header
344 .dynamic_flags()
345 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
346 {
347 Ok(HealthRequest::_UnknownMethod {
348 ordinal: header.ordinal,
349 control_handle: HealthControlHandle { inner: this.inner.clone() },
350 method_type: fidl::MethodType::OneWay,
351 })
352 }
353 _ if header
354 .dynamic_flags()
355 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
356 {
357 this.inner.send_framework_err(
358 fidl::encoding::FrameworkErr::UnknownMethod,
359 header.tx_id,
360 header.ordinal,
361 header.dynamic_flags(),
362 (bytes, handles),
363 )?;
364 Ok(HealthRequest::_UnknownMethod {
365 ordinal: header.ordinal,
366 control_handle: HealthControlHandle { inner: this.inner.clone() },
367 method_type: fidl::MethodType::TwoWay,
368 })
369 }
370 _ => Err(fidl::Error::UnknownOrdinal {
371 ordinal: header.ordinal,
372 protocol_name:
373 <HealthMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
374 }),
375 }))
376 },
377 )
378 }
379}
380
381#[derive(Debug)]
383pub enum HealthRequest {
384 GetReport { responder: HealthGetReportResponder },
386 #[non_exhaustive]
388 _UnknownMethod {
389 ordinal: u64,
391 control_handle: HealthControlHandle,
392 method_type: fidl::MethodType,
393 },
394}
395
396impl HealthRequest {
397 #[allow(irrefutable_let_patterns)]
398 pub fn into_get_report(self) -> Option<(HealthGetReportResponder)> {
399 if let HealthRequest::GetReport { responder } = self { Some((responder)) } else { None }
400 }
401
402 pub fn method_name(&self) -> &'static str {
404 match *self {
405 HealthRequest::GetReport { .. } => "get_report",
406 HealthRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
407 "unknown one-way method"
408 }
409 HealthRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
410 "unknown two-way method"
411 }
412 }
413 }
414}
415
416#[derive(Debug, Clone)]
417pub struct HealthControlHandle {
418 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
419}
420
421impl fidl::endpoints::ControlHandle for HealthControlHandle {
422 fn shutdown(&self) {
423 self.inner.shutdown()
424 }
425
426 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
427 self.inner.shutdown_with_epitaph(status)
428 }
429
430 fn is_closed(&self) -> bool {
431 self.inner.channel().is_closed()
432 }
433 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
434 self.inner.channel().on_closed()
435 }
436
437 #[cfg(target_os = "fuchsia")]
438 fn signal_peer(
439 &self,
440 clear_mask: zx::Signals,
441 set_mask: zx::Signals,
442 ) -> Result<(), zx_status::Status> {
443 use fidl::Peered;
444 self.inner.channel().signal_peer(clear_mask, set_mask)
445 }
446}
447
448impl HealthControlHandle {}
449
450#[must_use = "FIDL methods require a response to be sent"]
451#[derive(Debug)]
452pub struct HealthGetReportResponder {
453 control_handle: std::mem::ManuallyDrop<HealthControlHandle>,
454 tx_id: u32,
455}
456
457impl std::ops::Drop for HealthGetReportResponder {
461 fn drop(&mut self) {
462 self.control_handle.shutdown();
463 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
465 }
466}
467
468impl fidl::endpoints::Responder for HealthGetReportResponder {
469 type ControlHandle = HealthControlHandle;
470
471 fn control_handle(&self) -> &HealthControlHandle {
472 &self.control_handle
473 }
474
475 fn drop_without_shutdown(mut self) {
476 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
478 std::mem::forget(self);
480 }
481}
482
483impl HealthGetReportResponder {
484 pub fn send(self, mut result: Result<&HealthReport, i32>) -> Result<(), fidl::Error> {
488 let _result = self.send_raw(result);
489 if _result.is_err() {
490 self.control_handle.shutdown();
491 }
492 self.drop_without_shutdown();
493 _result
494 }
495
496 pub fn send_no_shutdown_on_err(
498 self,
499 mut result: Result<&HealthReport, i32>,
500 ) -> Result<(), fidl::Error> {
501 let _result = self.send_raw(result);
502 self.drop_without_shutdown();
503 _result
504 }
505
506 fn send_raw(&self, mut result: Result<&HealthReport, i32>) -> Result<(), fidl::Error> {
507 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<HealthReport, i32>>(
508 fidl::encoding::FlexibleResult::new(result),
509 self.tx_id,
510 0x45f3bc8cbb38e701,
511 fidl::encoding::DynamicFlags::FLEXIBLE,
512 )
513 }
514}
515
516#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
517pub struct PolicyProviderMarker;
518
519impl fidl::endpoints::ProtocolMarker for PolicyProviderMarker {
520 type Proxy = PolicyProviderProxy;
521 type RequestStream = PolicyProviderRequestStream;
522 #[cfg(target_os = "fuchsia")]
523 type SynchronousProxy = PolicyProviderSynchronousProxy;
524
525 const DEBUG_NAME: &'static str = "(anonymous) PolicyProvider";
526}
527
528pub trait PolicyProviderProxyInterface: Send + Sync {
529 type WatchDeviceStateResponseFut: std::future::Future<
530 Output = Result<
531 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
532 fidl::Error,
533 >,
534 > + Send;
535 fn r#watch_device_state(&self) -> Self::WatchDeviceStateResponseFut;
536}
537#[derive(Debug)]
538#[cfg(target_os = "fuchsia")]
539pub struct PolicyProviderSynchronousProxy {
540 client: fidl::client::sync::Client,
541}
542
543#[cfg(target_os = "fuchsia")]
544impl fidl::endpoints::SynchronousProxy for PolicyProviderSynchronousProxy {
545 type Proxy = PolicyProviderProxy;
546 type Protocol = PolicyProviderMarker;
547
548 fn from_channel(inner: fidl::Channel) -> Self {
549 Self::new(inner)
550 }
551
552 fn into_channel(self) -> fidl::Channel {
553 self.client.into_channel()
554 }
555
556 fn as_channel(&self) -> &fidl::Channel {
557 self.client.as_channel()
558 }
559}
560
561#[cfg(target_os = "fuchsia")]
562impl PolicyProviderSynchronousProxy {
563 pub fn new(channel: fidl::Channel) -> Self {
564 Self { client: fidl::client::sync::Client::new(channel) }
565 }
566
567 pub fn into_channel(self) -> fidl::Channel {
568 self.client.into_channel()
569 }
570
571 pub fn wait_for_event(
574 &self,
575 deadline: zx::MonotonicInstant,
576 ) -> Result<PolicyProviderEvent, fidl::Error> {
577 PolicyProviderEvent::decode(self.client.wait_for_event::<PolicyProviderMarker>(deadline)?)
578 }
579
580 pub fn r#watch_device_state(
586 &self,
587 ___deadline: zx::MonotonicInstant,
588 ) -> Result<
589 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
590 fidl::Error,
591 > {
592 let _response = self
593 .client
594 .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
595 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
596 i32,
597 >, PolicyProviderMarker>(
598 (),
599 0x44628a2275753738,
600 fidl::encoding::DynamicFlags::FLEXIBLE,
601 ___deadline,
602 )?
603 .into_result::<PolicyProviderMarker>("watch_device_state")?;
604 Ok(_response.map(|x| x))
605 }
606}
607
608#[cfg(target_os = "fuchsia")]
609impl From<PolicyProviderSynchronousProxy> for zx::NullableHandle {
610 fn from(value: PolicyProviderSynchronousProxy) -> Self {
611 value.into_channel().into()
612 }
613}
614
615#[cfg(target_os = "fuchsia")]
616impl From<fidl::Channel> for PolicyProviderSynchronousProxy {
617 fn from(value: fidl::Channel) -> Self {
618 Self::new(value)
619 }
620}
621
622#[cfg(target_os = "fuchsia")]
623impl fidl::endpoints::FromClient for PolicyProviderSynchronousProxy {
624 type Protocol = PolicyProviderMarker;
625
626 fn from_client(value: fidl::endpoints::ClientEnd<PolicyProviderMarker>) -> Self {
627 Self::new(value.into_channel())
628 }
629}
630
631#[derive(Debug, Clone)]
632pub struct PolicyProviderProxy {
633 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
634}
635
636impl fidl::endpoints::Proxy for PolicyProviderProxy {
637 type Protocol = PolicyProviderMarker;
638
639 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
640 Self::new(inner)
641 }
642
643 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
644 self.client.into_channel().map_err(|client| Self { client })
645 }
646
647 fn as_channel(&self) -> &::fidl::AsyncChannel {
648 self.client.as_channel()
649 }
650}
651
652impl PolicyProviderProxy {
653 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
655 let protocol_name = <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
656 Self { client: fidl::client::Client::new(channel, protocol_name) }
657 }
658
659 pub fn take_event_stream(&self) -> PolicyProviderEventStream {
665 PolicyProviderEventStream { event_receiver: self.client.take_event_receiver() }
666 }
667
668 pub fn r#watch_device_state(
674 &self,
675 ) -> fidl::client::QueryResponseFut<
676 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
677 fidl::encoding::DefaultFuchsiaResourceDialect,
678 > {
679 PolicyProviderProxyInterface::r#watch_device_state(self)
680 }
681}
682
683impl PolicyProviderProxyInterface for PolicyProviderProxy {
684 type WatchDeviceStateResponseFut = fidl::client::QueryResponseFut<
685 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
686 fidl::encoding::DefaultFuchsiaResourceDialect,
687 >;
688 fn r#watch_device_state(&self) -> Self::WatchDeviceStateResponseFut {
689 fn _decode(
690 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
691 ) -> Result<
692 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
693 fidl::Error,
694 > {
695 let _response = fidl::client::decode_transaction_body::<
696 fidl::encoding::FlexibleResultType<
697 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
698 i32,
699 >,
700 fidl::encoding::DefaultFuchsiaResourceDialect,
701 0x44628a2275753738,
702 >(_buf?)?
703 .into_result::<PolicyProviderMarker>("watch_device_state")?;
704 Ok(_response.map(|x| x))
705 }
706 self.client.send_query_and_decode::<
707 fidl::encoding::EmptyPayload,
708 fidl_fuchsia_hardware_usb_policy::DeviceStateWatcherWatchDeviceStateResult,
709 >(
710 (),
711 0x44628a2275753738,
712 fidl::encoding::DynamicFlags::FLEXIBLE,
713 _decode,
714 )
715 }
716}
717
718pub struct PolicyProviderEventStream {
719 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
720}
721
722impl std::marker::Unpin for PolicyProviderEventStream {}
723
724impl futures::stream::FusedStream for PolicyProviderEventStream {
725 fn is_terminated(&self) -> bool {
726 self.event_receiver.is_terminated()
727 }
728}
729
730impl futures::Stream for PolicyProviderEventStream {
731 type Item = Result<PolicyProviderEvent, fidl::Error>;
732
733 fn poll_next(
734 mut self: std::pin::Pin<&mut Self>,
735 cx: &mut std::task::Context<'_>,
736 ) -> std::task::Poll<Option<Self::Item>> {
737 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
738 &mut self.event_receiver,
739 cx
740 )?) {
741 Some(buf) => std::task::Poll::Ready(Some(PolicyProviderEvent::decode(buf))),
742 None => std::task::Poll::Ready(None),
743 }
744 }
745}
746
747#[derive(Debug)]
748pub enum PolicyProviderEvent {
749 #[non_exhaustive]
750 _UnknownEvent {
751 ordinal: u64,
753 },
754}
755
756impl PolicyProviderEvent {
757 fn decode(
759 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
760 ) -> Result<PolicyProviderEvent, fidl::Error> {
761 let (bytes, _handles) = buf.split_mut();
762 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
763 debug_assert_eq!(tx_header.tx_id, 0);
764 match tx_header.ordinal {
765 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
766 Ok(PolicyProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
767 }
768 _ => Err(fidl::Error::UnknownOrdinal {
769 ordinal: tx_header.ordinal,
770 protocol_name:
771 <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
772 }),
773 }
774 }
775}
776
777pub struct PolicyProviderRequestStream {
779 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
780 is_terminated: bool,
781}
782
783impl std::marker::Unpin for PolicyProviderRequestStream {}
784
785impl futures::stream::FusedStream for PolicyProviderRequestStream {
786 fn is_terminated(&self) -> bool {
787 self.is_terminated
788 }
789}
790
791impl fidl::endpoints::RequestStream for PolicyProviderRequestStream {
792 type Protocol = PolicyProviderMarker;
793 type ControlHandle = PolicyProviderControlHandle;
794
795 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
796 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
797 }
798
799 fn control_handle(&self) -> Self::ControlHandle {
800 PolicyProviderControlHandle { inner: self.inner.clone() }
801 }
802
803 fn into_inner(
804 self,
805 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
806 {
807 (self.inner, self.is_terminated)
808 }
809
810 fn from_inner(
811 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
812 is_terminated: bool,
813 ) -> Self {
814 Self { inner, is_terminated }
815 }
816}
817
818impl futures::Stream for PolicyProviderRequestStream {
819 type Item = Result<PolicyProviderRequest, fidl::Error>;
820
821 fn poll_next(
822 mut self: std::pin::Pin<&mut Self>,
823 cx: &mut std::task::Context<'_>,
824 ) -> std::task::Poll<Option<Self::Item>> {
825 let this = &mut *self;
826 if this.inner.check_shutdown(cx) {
827 this.is_terminated = true;
828 return std::task::Poll::Ready(None);
829 }
830 if this.is_terminated {
831 panic!("polled PolicyProviderRequestStream after completion");
832 }
833 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
834 |bytes, handles| {
835 match this.inner.channel().read_etc(cx, bytes, handles) {
836 std::task::Poll::Ready(Ok(())) => {}
837 std::task::Poll::Pending => return std::task::Poll::Pending,
838 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
839 this.is_terminated = true;
840 return std::task::Poll::Ready(None);
841 }
842 std::task::Poll::Ready(Err(e)) => {
843 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
844 e.into(),
845 ))));
846 }
847 }
848
849 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
851
852 std::task::Poll::Ready(Some(match header.ordinal {
853 0x44628a2275753738 => {
854 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
855 let mut req = fidl::new_empty!(
856 fidl::encoding::EmptyPayload,
857 fidl::encoding::DefaultFuchsiaResourceDialect
858 );
859 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
860 let control_handle =
861 PolicyProviderControlHandle { inner: this.inner.clone() };
862 Ok(PolicyProviderRequest::WatchDeviceState {
863 responder: PolicyProviderWatchDeviceStateResponder {
864 control_handle: std::mem::ManuallyDrop::new(control_handle),
865 tx_id: header.tx_id,
866 },
867 })
868 }
869 _ if header.tx_id == 0
870 && header
871 .dynamic_flags()
872 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
873 {
874 Ok(PolicyProviderRequest::_UnknownMethod {
875 ordinal: header.ordinal,
876 control_handle: PolicyProviderControlHandle {
877 inner: this.inner.clone(),
878 },
879 method_type: fidl::MethodType::OneWay,
880 })
881 }
882 _ if header
883 .dynamic_flags()
884 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
885 {
886 this.inner.send_framework_err(
887 fidl::encoding::FrameworkErr::UnknownMethod,
888 header.tx_id,
889 header.ordinal,
890 header.dynamic_flags(),
891 (bytes, handles),
892 )?;
893 Ok(PolicyProviderRequest::_UnknownMethod {
894 ordinal: header.ordinal,
895 control_handle: PolicyProviderControlHandle {
896 inner: this.inner.clone(),
897 },
898 method_type: fidl::MethodType::TwoWay,
899 })
900 }
901 _ => Err(fidl::Error::UnknownOrdinal {
902 ordinal: header.ordinal,
903 protocol_name:
904 <PolicyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
905 }),
906 }))
907 },
908 )
909 }
910}
911
912#[derive(Debug)]
914pub enum PolicyProviderRequest {
915 WatchDeviceState { responder: PolicyProviderWatchDeviceStateResponder },
921 #[non_exhaustive]
923 _UnknownMethod {
924 ordinal: u64,
926 control_handle: PolicyProviderControlHandle,
927 method_type: fidl::MethodType,
928 },
929}
930
931impl PolicyProviderRequest {
932 #[allow(irrefutable_let_patterns)]
933 pub fn into_watch_device_state(self) -> Option<(PolicyProviderWatchDeviceStateResponder)> {
934 if let PolicyProviderRequest::WatchDeviceState { responder } = self {
935 Some((responder))
936 } else {
937 None
938 }
939 }
940
941 pub fn method_name(&self) -> &'static str {
943 match *self {
944 PolicyProviderRequest::WatchDeviceState { .. } => "watch_device_state",
945 PolicyProviderRequest::_UnknownMethod {
946 method_type: fidl::MethodType::OneWay, ..
947 } => "unknown one-way method",
948 PolicyProviderRequest::_UnknownMethod {
949 method_type: fidl::MethodType::TwoWay, ..
950 } => "unknown two-way method",
951 }
952 }
953}
954
955#[derive(Debug, Clone)]
956pub struct PolicyProviderControlHandle {
957 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
958}
959
960impl fidl::endpoints::ControlHandle for PolicyProviderControlHandle {
961 fn shutdown(&self) {
962 self.inner.shutdown()
963 }
964
965 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
966 self.inner.shutdown_with_epitaph(status)
967 }
968
969 fn is_closed(&self) -> bool {
970 self.inner.channel().is_closed()
971 }
972 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
973 self.inner.channel().on_closed()
974 }
975
976 #[cfg(target_os = "fuchsia")]
977 fn signal_peer(
978 &self,
979 clear_mask: zx::Signals,
980 set_mask: zx::Signals,
981 ) -> Result<(), zx_status::Status> {
982 use fidl::Peered;
983 self.inner.channel().signal_peer(clear_mask, set_mask)
984 }
985}
986
987impl PolicyProviderControlHandle {}
988
989#[must_use = "FIDL methods require a response to be sent"]
990#[derive(Debug)]
991pub struct PolicyProviderWatchDeviceStateResponder {
992 control_handle: std::mem::ManuallyDrop<PolicyProviderControlHandle>,
993 tx_id: u32,
994}
995
996impl std::ops::Drop for PolicyProviderWatchDeviceStateResponder {
1000 fn drop(&mut self) {
1001 self.control_handle.shutdown();
1002 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1004 }
1005}
1006
1007impl fidl::endpoints::Responder for PolicyProviderWatchDeviceStateResponder {
1008 type ControlHandle = PolicyProviderControlHandle;
1009
1010 fn control_handle(&self) -> &PolicyProviderControlHandle {
1011 &self.control_handle
1012 }
1013
1014 fn drop_without_shutdown(mut self) {
1015 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1017 std::mem::forget(self);
1019 }
1020}
1021
1022impl PolicyProviderWatchDeviceStateResponder {
1023 pub fn send(
1027 self,
1028 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
1029 ) -> Result<(), fidl::Error> {
1030 let _result = self.send_raw(result);
1031 if _result.is_err() {
1032 self.control_handle.shutdown();
1033 }
1034 self.drop_without_shutdown();
1035 _result
1036 }
1037
1038 pub fn send_no_shutdown_on_err(
1040 self,
1041 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
1042 ) -> Result<(), fidl::Error> {
1043 let _result = self.send_raw(result);
1044 self.drop_without_shutdown();
1045 _result
1046 }
1047
1048 fn send_raw(
1049 &self,
1050 mut result: Result<&fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate, i32>,
1051 ) -> Result<(), fidl::Error> {
1052 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1053 fidl_fuchsia_hardware_usb_policy::DeviceStateUpdate,
1054 i32,
1055 >>(
1056 fidl::encoding::FlexibleResult::new(result),
1057 self.tx_id,
1058 0x44628a2275753738,
1059 fidl::encoding::DynamicFlags::FLEXIBLE,
1060 )
1061 }
1062}
1063
1064#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1065pub struct ServiceMarker;
1066
1067#[cfg(target_os = "fuchsia")]
1068impl fidl::endpoints::ServiceMarker for ServiceMarker {
1069 type Proxy = ServiceProxy;
1070 type Request = ServiceRequest;
1071 const SERVICE_NAME: &'static str = "fuchsia.usb.policy.Service";
1072}
1073
1074#[cfg(target_os = "fuchsia")]
1078pub enum ServiceRequest {
1079 Provider(PolicyProviderRequestStream),
1081}
1082
1083#[cfg(target_os = "fuchsia")]
1084impl fidl::endpoints::ServiceRequest for ServiceRequest {
1085 type Service = ServiceMarker;
1086
1087 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1088 match name {
1089 "provider" => Self::Provider(
1090 <PolicyProviderRequestStream as fidl::endpoints::RequestStream>::from_channel(
1091 _channel,
1092 ),
1093 ),
1094 _ => panic!("no such member protocol name for service Service"),
1095 }
1096 }
1097
1098 fn member_names() -> &'static [&'static str] {
1099 &["provider"]
1100 }
1101}
1102#[cfg(target_os = "fuchsia")]
1104pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1105
1106#[cfg(target_os = "fuchsia")]
1107impl fidl::endpoints::ServiceProxy for ServiceProxy {
1108 type Service = ServiceMarker;
1109
1110 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1111 Self(opener)
1112 }
1113}
1114
1115#[cfg(target_os = "fuchsia")]
1116impl ServiceProxy {
1117 pub fn connect_to_provider(&self) -> Result<PolicyProviderProxy, fidl::Error> {
1119 let (proxy, server_end) = fidl::endpoints::create_proxy::<PolicyProviderMarker>();
1120 self.connect_channel_to_provider(server_end)?;
1121 Ok(proxy)
1122 }
1123
1124 pub fn connect_to_provider_sync(&self) -> Result<PolicyProviderSynchronousProxy, fidl::Error> {
1127 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<PolicyProviderMarker>();
1128 self.connect_channel_to_provider(server_end)?;
1129 Ok(proxy)
1130 }
1131
1132 pub fn connect_channel_to_provider(
1135 &self,
1136 server_end: fidl::endpoints::ServerEnd<PolicyProviderMarker>,
1137 ) -> Result<(), fidl::Error> {
1138 self.0.open_member("provider", server_end.into_channel())
1139 }
1140
1141 pub fn instance_name(&self) -> &str {
1142 self.0.instance_name()
1143 }
1144}
1145
1146mod internal {
1147 use super::*;
1148}