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_power_clientlevel_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ConnectorConnectRequest {
16 pub client_type: ClientType,
17 pub watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ConnectorConnectRequest {}
21
22#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
23pub struct ConnectorMarker;
24
25impl fidl::endpoints::ProtocolMarker for ConnectorMarker {
26 type Proxy = ConnectorProxy;
27 type RequestStream = ConnectorRequestStream;
28 #[cfg(target_os = "fuchsia")]
29 type SynchronousProxy = ConnectorSynchronousProxy;
30
31 const DEBUG_NAME: &'static str = "fuchsia.power.clientlevel.Connector";
32}
33impl fidl::endpoints::DiscoverableProtocolMarker for ConnectorMarker {}
34
35pub trait ConnectorProxyInterface: Send + Sync {
36 fn r#connect(
37 &self,
38 client_type: ClientType,
39 watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
40 ) -> Result<(), fidl::Error>;
41}
42#[derive(Debug)]
43#[cfg(target_os = "fuchsia")]
44pub struct ConnectorSynchronousProxy {
45 client: fidl::client::sync::Client,
46}
47
48#[cfg(target_os = "fuchsia")]
49impl fidl::endpoints::SynchronousProxy for ConnectorSynchronousProxy {
50 type Proxy = ConnectorProxy;
51 type Protocol = ConnectorMarker;
52
53 fn from_channel(inner: fidl::Channel) -> Self {
54 Self::new(inner)
55 }
56
57 fn into_channel(self) -> fidl::Channel {
58 self.client.into_channel()
59 }
60
61 fn as_channel(&self) -> &fidl::Channel {
62 self.client.as_channel()
63 }
64}
65
66#[cfg(target_os = "fuchsia")]
67impl ConnectorSynchronousProxy {
68 pub fn new(channel: fidl::Channel) -> Self {
69 Self { client: fidl::client::sync::Client::new(channel) }
70 }
71
72 pub fn into_channel(self) -> fidl::Channel {
73 self.client.into_channel()
74 }
75
76 pub fn wait_for_event(
79 &self,
80 deadline: zx::MonotonicInstant,
81 ) -> Result<ConnectorEvent, fidl::Error> {
82 ConnectorEvent::decode(self.client.wait_for_event::<ConnectorMarker>(deadline)?)
83 }
84
85 pub fn r#connect(
103 &self,
104 mut client_type: ClientType,
105 mut watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
106 ) -> Result<(), fidl::Error> {
107 self.client.send::<ConnectorConnectRequest>(
108 (client_type, watcher),
109 0x29e603fe743fd08a,
110 fidl::encoding::DynamicFlags::empty(),
111 )
112 }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl From<ConnectorSynchronousProxy> for zx::NullableHandle {
117 fn from(value: ConnectorSynchronousProxy) -> Self {
118 value.into_channel().into()
119 }
120}
121
122#[cfg(target_os = "fuchsia")]
123impl From<fidl::Channel> for ConnectorSynchronousProxy {
124 fn from(value: fidl::Channel) -> Self {
125 Self::new(value)
126 }
127}
128
129#[cfg(target_os = "fuchsia")]
130impl fidl::endpoints::FromClient for ConnectorSynchronousProxy {
131 type Protocol = ConnectorMarker;
132
133 fn from_client(value: fidl::endpoints::ClientEnd<ConnectorMarker>) -> Self {
134 Self::new(value.into_channel())
135 }
136}
137
138#[derive(Debug, Clone)]
139pub struct ConnectorProxy {
140 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
141}
142
143impl fidl::endpoints::Proxy for ConnectorProxy {
144 type Protocol = ConnectorMarker;
145
146 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
147 Self::new(inner)
148 }
149
150 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
151 self.client.into_channel().map_err(|client| Self { client })
152 }
153
154 fn as_channel(&self) -> &::fidl::AsyncChannel {
155 self.client.as_channel()
156 }
157}
158
159impl ConnectorProxy {
160 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
162 let protocol_name = <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
163 Self { client: fidl::client::Client::new(channel, protocol_name) }
164 }
165
166 pub fn take_event_stream(&self) -> ConnectorEventStream {
172 ConnectorEventStream { event_receiver: self.client.take_event_receiver() }
173 }
174
175 pub fn r#connect(
193 &self,
194 mut client_type: ClientType,
195 mut watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
196 ) -> Result<(), fidl::Error> {
197 ConnectorProxyInterface::r#connect(self, client_type, watcher)
198 }
199}
200
201impl ConnectorProxyInterface for ConnectorProxy {
202 fn r#connect(
203 &self,
204 mut client_type: ClientType,
205 mut watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
206 ) -> Result<(), fidl::Error> {
207 self.client.send::<ConnectorConnectRequest>(
208 (client_type, watcher),
209 0x29e603fe743fd08a,
210 fidl::encoding::DynamicFlags::empty(),
211 )
212 }
213}
214
215pub struct ConnectorEventStream {
216 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
217}
218
219impl std::marker::Unpin for ConnectorEventStream {}
220
221impl futures::stream::FusedStream for ConnectorEventStream {
222 fn is_terminated(&self) -> bool {
223 self.event_receiver.is_terminated()
224 }
225}
226
227impl futures::Stream for ConnectorEventStream {
228 type Item = Result<ConnectorEvent, fidl::Error>;
229
230 fn poll_next(
231 mut self: std::pin::Pin<&mut Self>,
232 cx: &mut std::task::Context<'_>,
233 ) -> std::task::Poll<Option<Self::Item>> {
234 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
235 &mut self.event_receiver,
236 cx
237 )?) {
238 Some(buf) => std::task::Poll::Ready(Some(ConnectorEvent::decode(buf))),
239 None => std::task::Poll::Ready(None),
240 }
241 }
242}
243
244#[derive(Debug)]
245pub enum ConnectorEvent {}
246
247impl ConnectorEvent {
248 fn decode(
250 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
251 ) -> Result<ConnectorEvent, fidl::Error> {
252 let (bytes, _handles) = buf.split_mut();
253 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
254 debug_assert_eq!(tx_header.tx_id, 0);
255 match tx_header.ordinal {
256 _ => Err(fidl::Error::UnknownOrdinal {
257 ordinal: tx_header.ordinal,
258 protocol_name: <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
259 }),
260 }
261 }
262}
263
264pub struct ConnectorRequestStream {
266 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
267 is_terminated: bool,
268}
269
270impl std::marker::Unpin for ConnectorRequestStream {}
271
272impl futures::stream::FusedStream for ConnectorRequestStream {
273 fn is_terminated(&self) -> bool {
274 self.is_terminated
275 }
276}
277
278impl fidl::endpoints::RequestStream for ConnectorRequestStream {
279 type Protocol = ConnectorMarker;
280 type ControlHandle = ConnectorControlHandle;
281
282 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
283 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
284 }
285
286 fn control_handle(&self) -> Self::ControlHandle {
287 ConnectorControlHandle { inner: self.inner.clone() }
288 }
289
290 fn into_inner(
291 self,
292 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
293 {
294 (self.inner, self.is_terminated)
295 }
296
297 fn from_inner(
298 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
299 is_terminated: bool,
300 ) -> Self {
301 Self { inner, is_terminated }
302 }
303}
304
305impl futures::Stream for ConnectorRequestStream {
306 type Item = Result<ConnectorRequest, fidl::Error>;
307
308 fn poll_next(
309 mut self: std::pin::Pin<&mut Self>,
310 cx: &mut std::task::Context<'_>,
311 ) -> std::task::Poll<Option<Self::Item>> {
312 let this = &mut *self;
313 if this.inner.check_shutdown(cx) {
314 this.is_terminated = true;
315 return std::task::Poll::Ready(None);
316 }
317 if this.is_terminated {
318 panic!("polled ConnectorRequestStream after completion");
319 }
320 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
321 |bytes, handles| {
322 match this.inner.channel().read_etc(cx, bytes, handles) {
323 std::task::Poll::Ready(Ok(())) => {}
324 std::task::Poll::Pending => return std::task::Poll::Pending,
325 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
326 this.is_terminated = true;
327 return std::task::Poll::Ready(None);
328 }
329 std::task::Poll::Ready(Err(e)) => {
330 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
331 e.into(),
332 ))));
333 }
334 }
335
336 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
338
339 std::task::Poll::Ready(Some(match header.ordinal {
340 0x29e603fe743fd08a => {
341 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
342 let mut req = fidl::new_empty!(
343 ConnectorConnectRequest,
344 fidl::encoding::DefaultFuchsiaResourceDialect
345 );
346 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorConnectRequest>(&header, _body_bytes, handles, &mut req)?;
347 let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
348 Ok(ConnectorRequest::Connect {
349 client_type: req.client_type,
350 watcher: req.watcher,
351
352 control_handle,
353 })
354 }
355 _ => Err(fidl::Error::UnknownOrdinal {
356 ordinal: header.ordinal,
357 protocol_name:
358 <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
359 }),
360 }))
361 },
362 )
363 }
364}
365
366#[derive(Debug)]
369pub enum ConnectorRequest {
370 Connect {
388 client_type: ClientType,
389 watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
390 control_handle: ConnectorControlHandle,
391 },
392}
393
394impl ConnectorRequest {
395 #[allow(irrefutable_let_patterns)]
396 pub fn into_connect(
397 self,
398 ) -> Option<(ClientType, fidl::endpoints::ServerEnd<WatcherMarker>, ConnectorControlHandle)>
399 {
400 if let ConnectorRequest::Connect { client_type, watcher, control_handle } = self {
401 Some((client_type, watcher, control_handle))
402 } else {
403 None
404 }
405 }
406
407 pub fn method_name(&self) -> &'static str {
409 match *self {
410 ConnectorRequest::Connect { .. } => "connect",
411 }
412 }
413}
414
415#[derive(Debug, Clone)]
416pub struct ConnectorControlHandle {
417 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
418}
419
420impl ConnectorControlHandle {
421 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
422 self.inner.shutdown_with_epitaph(status.into())
423 }
424}
425
426impl fidl::endpoints::ControlHandle for ConnectorControlHandle {
427 fn shutdown(&self) {
428 self.inner.shutdown()
429 }
430
431 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
432 self.inner.shutdown_with_epitaph(status)
433 }
434
435 fn is_closed(&self) -> bool {
436 self.inner.channel().is_closed()
437 }
438 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
439 self.inner.channel().on_closed()
440 }
441
442 #[cfg(target_os = "fuchsia")]
443 fn signal_peer(
444 &self,
445 clear_mask: zx::Signals,
446 set_mask: zx::Signals,
447 ) -> Result<(), zx_status::Status> {
448 use fidl::Peered;
449 self.inner.channel().signal_peer(clear_mask, set_mask)
450 }
451}
452
453impl ConnectorControlHandle {}
454
455#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
456pub struct WatcherMarker;
457
458impl fidl::endpoints::ProtocolMarker for WatcherMarker {
459 type Proxy = WatcherProxy;
460 type RequestStream = WatcherRequestStream;
461 #[cfg(target_os = "fuchsia")]
462 type SynchronousProxy = WatcherSynchronousProxy;
463
464 const DEBUG_NAME: &'static str = "(anonymous) Watcher";
465}
466
467pub trait WatcherProxyInterface: Send + Sync {
468 type WatchResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
469 fn r#watch(&self) -> Self::WatchResponseFut;
470}
471#[derive(Debug)]
472#[cfg(target_os = "fuchsia")]
473pub struct WatcherSynchronousProxy {
474 client: fidl::client::sync::Client,
475}
476
477#[cfg(target_os = "fuchsia")]
478impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
479 type Proxy = WatcherProxy;
480 type Protocol = WatcherMarker;
481
482 fn from_channel(inner: fidl::Channel) -> Self {
483 Self::new(inner)
484 }
485
486 fn into_channel(self) -> fidl::Channel {
487 self.client.into_channel()
488 }
489
490 fn as_channel(&self) -> &fidl::Channel {
491 self.client.as_channel()
492 }
493}
494
495#[cfg(target_os = "fuchsia")]
496impl WatcherSynchronousProxy {
497 pub fn new(channel: fidl::Channel) -> Self {
498 Self { client: fidl::client::sync::Client::new(channel) }
499 }
500
501 pub fn into_channel(self) -> fidl::Channel {
502 self.client.into_channel()
503 }
504
505 pub fn wait_for_event(
508 &self,
509 deadline: zx::MonotonicInstant,
510 ) -> Result<WatcherEvent, fidl::Error> {
511 WatcherEvent::decode(self.client.wait_for_event::<WatcherMarker>(deadline)?)
512 }
513
514 pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
531 let _response = self
532 .client
533 .send_query::<fidl::encoding::EmptyPayload, WatcherWatchResponse, WatcherMarker>(
534 (),
535 0x29592d2e62f4101a,
536 fidl::encoding::DynamicFlags::empty(),
537 ___deadline,
538 )?;
539 Ok(_response.level)
540 }
541}
542
543#[cfg(target_os = "fuchsia")]
544impl From<WatcherSynchronousProxy> for zx::NullableHandle {
545 fn from(value: WatcherSynchronousProxy) -> Self {
546 value.into_channel().into()
547 }
548}
549
550#[cfg(target_os = "fuchsia")]
551impl From<fidl::Channel> for WatcherSynchronousProxy {
552 fn from(value: fidl::Channel) -> Self {
553 Self::new(value)
554 }
555}
556
557#[cfg(target_os = "fuchsia")]
558impl fidl::endpoints::FromClient for WatcherSynchronousProxy {
559 type Protocol = WatcherMarker;
560
561 fn from_client(value: fidl::endpoints::ClientEnd<WatcherMarker>) -> Self {
562 Self::new(value.into_channel())
563 }
564}
565
566#[derive(Debug, Clone)]
567pub struct WatcherProxy {
568 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
569}
570
571impl fidl::endpoints::Proxy for WatcherProxy {
572 type Protocol = WatcherMarker;
573
574 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
575 Self::new(inner)
576 }
577
578 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
579 self.client.into_channel().map_err(|client| Self { client })
580 }
581
582 fn as_channel(&self) -> &::fidl::AsyncChannel {
583 self.client.as_channel()
584 }
585}
586
587impl WatcherProxy {
588 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
590 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
591 Self { client: fidl::client::Client::new(channel, protocol_name) }
592 }
593
594 pub fn take_event_stream(&self) -> WatcherEventStream {
600 WatcherEventStream { event_receiver: self.client.take_event_receiver() }
601 }
602
603 pub fn r#watch(
620 &self,
621 ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
622 WatcherProxyInterface::r#watch(self)
623 }
624}
625
626impl WatcherProxyInterface for WatcherProxy {
627 type WatchResponseFut =
628 fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
629 fn r#watch(&self) -> Self::WatchResponseFut {
630 fn _decode(
631 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
632 ) -> Result<u64, fidl::Error> {
633 let _response = fidl::client::decode_transaction_body::<
634 WatcherWatchResponse,
635 fidl::encoding::DefaultFuchsiaResourceDialect,
636 0x29592d2e62f4101a,
637 >(_buf?)?;
638 Ok(_response.level)
639 }
640 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
641 (),
642 0x29592d2e62f4101a,
643 fidl::encoding::DynamicFlags::empty(),
644 _decode,
645 )
646 }
647}
648
649pub struct WatcherEventStream {
650 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
651}
652
653impl std::marker::Unpin for WatcherEventStream {}
654
655impl futures::stream::FusedStream for WatcherEventStream {
656 fn is_terminated(&self) -> bool {
657 self.event_receiver.is_terminated()
658 }
659}
660
661impl futures::Stream for WatcherEventStream {
662 type Item = Result<WatcherEvent, fidl::Error>;
663
664 fn poll_next(
665 mut self: std::pin::Pin<&mut Self>,
666 cx: &mut std::task::Context<'_>,
667 ) -> std::task::Poll<Option<Self::Item>> {
668 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
669 &mut self.event_receiver,
670 cx
671 )?) {
672 Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
673 None => std::task::Poll::Ready(None),
674 }
675 }
676}
677
678#[derive(Debug)]
679pub enum WatcherEvent {}
680
681impl WatcherEvent {
682 fn decode(
684 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
685 ) -> Result<WatcherEvent, fidl::Error> {
686 let (bytes, _handles) = buf.split_mut();
687 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
688 debug_assert_eq!(tx_header.tx_id, 0);
689 match tx_header.ordinal {
690 _ => Err(fidl::Error::UnknownOrdinal {
691 ordinal: tx_header.ordinal,
692 protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
693 }),
694 }
695 }
696}
697
698pub struct WatcherRequestStream {
700 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
701 is_terminated: bool,
702}
703
704impl std::marker::Unpin for WatcherRequestStream {}
705
706impl futures::stream::FusedStream for WatcherRequestStream {
707 fn is_terminated(&self) -> bool {
708 self.is_terminated
709 }
710}
711
712impl fidl::endpoints::RequestStream for WatcherRequestStream {
713 type Protocol = WatcherMarker;
714 type ControlHandle = WatcherControlHandle;
715
716 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
717 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
718 }
719
720 fn control_handle(&self) -> Self::ControlHandle {
721 WatcherControlHandle { inner: self.inner.clone() }
722 }
723
724 fn into_inner(
725 self,
726 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
727 {
728 (self.inner, self.is_terminated)
729 }
730
731 fn from_inner(
732 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
733 is_terminated: bool,
734 ) -> Self {
735 Self { inner, is_terminated }
736 }
737}
738
739impl futures::Stream for WatcherRequestStream {
740 type Item = Result<WatcherRequest, fidl::Error>;
741
742 fn poll_next(
743 mut self: std::pin::Pin<&mut Self>,
744 cx: &mut std::task::Context<'_>,
745 ) -> std::task::Poll<Option<Self::Item>> {
746 let this = &mut *self;
747 if this.inner.check_shutdown(cx) {
748 this.is_terminated = true;
749 return std::task::Poll::Ready(None);
750 }
751 if this.is_terminated {
752 panic!("polled WatcherRequestStream after completion");
753 }
754 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
755 |bytes, handles| {
756 match this.inner.channel().read_etc(cx, bytes, handles) {
757 std::task::Poll::Ready(Ok(())) => {}
758 std::task::Poll::Pending => return std::task::Poll::Pending,
759 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
760 this.is_terminated = true;
761 return std::task::Poll::Ready(None);
762 }
763 std::task::Poll::Ready(Err(e)) => {
764 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
765 e.into(),
766 ))));
767 }
768 }
769
770 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
772
773 std::task::Poll::Ready(Some(match header.ordinal {
774 0x29592d2e62f4101a => {
775 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
776 let mut req = fidl::new_empty!(
777 fidl::encoding::EmptyPayload,
778 fidl::encoding::DefaultFuchsiaResourceDialect
779 );
780 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
781 let control_handle = WatcherControlHandle { inner: this.inner.clone() };
782 Ok(WatcherRequest::Watch {
783 responder: WatcherWatchResponder {
784 control_handle: std::mem::ManuallyDrop::new(control_handle),
785 tx_id: header.tx_id,
786 },
787 })
788 }
789 _ => Err(fidl::Error::UnknownOrdinal {
790 ordinal: header.ordinal,
791 protocol_name:
792 <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
793 }),
794 }))
795 },
796 )
797 }
798}
799
800#[derive(Debug)]
809pub enum WatcherRequest {
810 Watch { responder: WatcherWatchResponder },
827}
828
829impl WatcherRequest {
830 #[allow(irrefutable_let_patterns)]
831 pub fn into_watch(self) -> Option<(WatcherWatchResponder)> {
832 if let WatcherRequest::Watch { responder } = self { Some((responder)) } else { None }
833 }
834
835 pub fn method_name(&self) -> &'static str {
837 match *self {
838 WatcherRequest::Watch { .. } => "watch",
839 }
840 }
841}
842
843#[derive(Debug, Clone)]
844pub struct WatcherControlHandle {
845 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
846}
847
848impl WatcherControlHandle {
849 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
850 self.inner.shutdown_with_epitaph(status.into())
851 }
852}
853
854impl fidl::endpoints::ControlHandle for WatcherControlHandle {
855 fn shutdown(&self) {
856 self.inner.shutdown()
857 }
858
859 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
860 self.inner.shutdown_with_epitaph(status)
861 }
862
863 fn is_closed(&self) -> bool {
864 self.inner.channel().is_closed()
865 }
866 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
867 self.inner.channel().on_closed()
868 }
869
870 #[cfg(target_os = "fuchsia")]
871 fn signal_peer(
872 &self,
873 clear_mask: zx::Signals,
874 set_mask: zx::Signals,
875 ) -> Result<(), zx_status::Status> {
876 use fidl::Peered;
877 self.inner.channel().signal_peer(clear_mask, set_mask)
878 }
879}
880
881impl WatcherControlHandle {}
882
883#[must_use = "FIDL methods require a response to be sent"]
884#[derive(Debug)]
885pub struct WatcherWatchResponder {
886 control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
887 tx_id: u32,
888}
889
890impl std::ops::Drop for WatcherWatchResponder {
894 fn drop(&mut self) {
895 self.control_handle.shutdown();
896 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
898 }
899}
900
901impl fidl::endpoints::Responder for WatcherWatchResponder {
902 type ControlHandle = WatcherControlHandle;
903
904 fn control_handle(&self) -> &WatcherControlHandle {
905 &self.control_handle
906 }
907
908 fn drop_without_shutdown(mut self) {
909 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
911 std::mem::forget(self);
913 }
914}
915
916impl WatcherWatchResponder {
917 pub fn send(self, mut level: u64) -> Result<(), fidl::Error> {
921 let _result = self.send_raw(level);
922 if _result.is_err() {
923 self.control_handle.shutdown();
924 }
925 self.drop_without_shutdown();
926 _result
927 }
928
929 pub fn send_no_shutdown_on_err(self, mut level: u64) -> Result<(), fidl::Error> {
931 let _result = self.send_raw(level);
932 self.drop_without_shutdown();
933 _result
934 }
935
936 fn send_raw(&self, mut level: u64) -> Result<(), fidl::Error> {
937 self.control_handle.inner.send::<WatcherWatchResponse>(
938 (level,),
939 self.tx_id,
940 0x29592d2e62f4101a,
941 fidl::encoding::DynamicFlags::empty(),
942 )
943 }
944}
945
946mod internal {
947 use super::*;
948
949 impl fidl::encoding::ResourceTypeMarker for ConnectorConnectRequest {
950 type Borrowed<'a> = &'a mut Self;
951 fn take_or_borrow<'a>(
952 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
953 ) -> Self::Borrowed<'a> {
954 value
955 }
956 }
957
958 unsafe impl fidl::encoding::TypeMarker for ConnectorConnectRequest {
959 type Owned = Self;
960
961 #[inline(always)]
962 fn inline_align(_context: fidl::encoding::Context) -> usize {
963 4
964 }
965
966 #[inline(always)]
967 fn inline_size(_context: fidl::encoding::Context) -> usize {
968 8
969 }
970 }
971
972 unsafe impl
973 fidl::encoding::Encode<
974 ConnectorConnectRequest,
975 fidl::encoding::DefaultFuchsiaResourceDialect,
976 > for &mut ConnectorConnectRequest
977 {
978 #[inline]
979 unsafe fn encode(
980 self,
981 encoder: &mut fidl::encoding::Encoder<
982 '_,
983 fidl::encoding::DefaultFuchsiaResourceDialect,
984 >,
985 offset: usize,
986 _depth: fidl::encoding::Depth,
987 ) -> fidl::Result<()> {
988 encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
989 fidl::encoding::Encode::<ConnectorConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
991 (
992 <ClientType as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
993 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
994 ),
995 encoder, offset, _depth
996 )
997 }
998 }
999 unsafe impl<
1000 T0: fidl::encoding::Encode<ClientType, fidl::encoding::DefaultFuchsiaResourceDialect>,
1001 T1: fidl::encoding::Encode<
1002 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
1003 fidl::encoding::DefaultFuchsiaResourceDialect,
1004 >,
1005 >
1006 fidl::encoding::Encode<
1007 ConnectorConnectRequest,
1008 fidl::encoding::DefaultFuchsiaResourceDialect,
1009 > for (T0, T1)
1010 {
1011 #[inline]
1012 unsafe fn encode(
1013 self,
1014 encoder: &mut fidl::encoding::Encoder<
1015 '_,
1016 fidl::encoding::DefaultFuchsiaResourceDialect,
1017 >,
1018 offset: usize,
1019 depth: fidl::encoding::Depth,
1020 ) -> fidl::Result<()> {
1021 encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
1022 self.0.encode(encoder, offset + 0, depth)?;
1026 self.1.encode(encoder, offset + 4, depth)?;
1027 Ok(())
1028 }
1029 }
1030
1031 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1032 for ConnectorConnectRequest
1033 {
1034 #[inline(always)]
1035 fn new_empty() -> Self {
1036 Self {
1037 client_type: fidl::new_empty!(
1038 ClientType,
1039 fidl::encoding::DefaultFuchsiaResourceDialect
1040 ),
1041 watcher: fidl::new_empty!(
1042 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
1043 fidl::encoding::DefaultFuchsiaResourceDialect
1044 ),
1045 }
1046 }
1047
1048 #[inline]
1049 unsafe fn decode(
1050 &mut self,
1051 decoder: &mut fidl::encoding::Decoder<
1052 '_,
1053 fidl::encoding::DefaultFuchsiaResourceDialect,
1054 >,
1055 offset: usize,
1056 _depth: fidl::encoding::Depth,
1057 ) -> fidl::Result<()> {
1058 decoder.debug_check_bounds::<Self>(offset);
1059 fidl::decode!(
1061 ClientType,
1062 fidl::encoding::DefaultFuchsiaResourceDialect,
1063 &mut self.client_type,
1064 decoder,
1065 offset + 0,
1066 _depth
1067 )?;
1068 fidl::decode!(
1069 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
1070 fidl::encoding::DefaultFuchsiaResourceDialect,
1071 &mut self.watcher,
1072 decoder,
1073 offset + 4,
1074 _depth
1075 )?;
1076 Ok(())
1077 }
1078 }
1079}