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