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#[derive(Debug, Clone)]
117pub struct ConnectorProxy {
118 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
119}
120
121impl fidl::endpoints::Proxy for ConnectorProxy {
122 type Protocol = ConnectorMarker;
123
124 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
125 Self::new(inner)
126 }
127
128 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
129 self.client.into_channel().map_err(|client| Self { client })
130 }
131
132 fn as_channel(&self) -> &::fidl::AsyncChannel {
133 self.client.as_channel()
134 }
135}
136
137impl ConnectorProxy {
138 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
140 let protocol_name = <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
141 Self { client: fidl::client::Client::new(channel, protocol_name) }
142 }
143
144 pub fn take_event_stream(&self) -> ConnectorEventStream {
150 ConnectorEventStream { event_receiver: self.client.take_event_receiver() }
151 }
152
153 pub fn r#connect(
171 &self,
172 mut client_type: ClientType,
173 mut watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
174 ) -> Result<(), fidl::Error> {
175 ConnectorProxyInterface::r#connect(self, client_type, watcher)
176 }
177}
178
179impl ConnectorProxyInterface for ConnectorProxy {
180 fn r#connect(
181 &self,
182 mut client_type: ClientType,
183 mut watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
184 ) -> Result<(), fidl::Error> {
185 self.client.send::<ConnectorConnectRequest>(
186 (client_type, watcher),
187 0x29e603fe743fd08a,
188 fidl::encoding::DynamicFlags::empty(),
189 )
190 }
191}
192
193pub struct ConnectorEventStream {
194 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
195}
196
197impl std::marker::Unpin for ConnectorEventStream {}
198
199impl futures::stream::FusedStream for ConnectorEventStream {
200 fn is_terminated(&self) -> bool {
201 self.event_receiver.is_terminated()
202 }
203}
204
205impl futures::Stream for ConnectorEventStream {
206 type Item = Result<ConnectorEvent, 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(ConnectorEvent::decode(buf))),
217 None => std::task::Poll::Ready(None),
218 }
219 }
220}
221
222#[derive(Debug)]
223pub enum ConnectorEvent {}
224
225impl ConnectorEvent {
226 fn decode(
228 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
229 ) -> Result<ConnectorEvent, fidl::Error> {
230 let (bytes, _handles) = buf.split_mut();
231 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
232 debug_assert_eq!(tx_header.tx_id, 0);
233 match tx_header.ordinal {
234 _ => Err(fidl::Error::UnknownOrdinal {
235 ordinal: tx_header.ordinal,
236 protocol_name: <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
237 }),
238 }
239 }
240}
241
242pub struct ConnectorRequestStream {
244 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
245 is_terminated: bool,
246}
247
248impl std::marker::Unpin for ConnectorRequestStream {}
249
250impl futures::stream::FusedStream for ConnectorRequestStream {
251 fn is_terminated(&self) -> bool {
252 self.is_terminated
253 }
254}
255
256impl fidl::endpoints::RequestStream for ConnectorRequestStream {
257 type Protocol = ConnectorMarker;
258 type ControlHandle = ConnectorControlHandle;
259
260 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
261 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
262 }
263
264 fn control_handle(&self) -> Self::ControlHandle {
265 ConnectorControlHandle { inner: self.inner.clone() }
266 }
267
268 fn into_inner(
269 self,
270 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
271 {
272 (self.inner, self.is_terminated)
273 }
274
275 fn from_inner(
276 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
277 is_terminated: bool,
278 ) -> Self {
279 Self { inner, is_terminated }
280 }
281}
282
283impl futures::Stream for ConnectorRequestStream {
284 type Item = Result<ConnectorRequest, fidl::Error>;
285
286 fn poll_next(
287 mut self: std::pin::Pin<&mut Self>,
288 cx: &mut std::task::Context<'_>,
289 ) -> std::task::Poll<Option<Self::Item>> {
290 let this = &mut *self;
291 if this.inner.check_shutdown(cx) {
292 this.is_terminated = true;
293 return std::task::Poll::Ready(None);
294 }
295 if this.is_terminated {
296 panic!("polled ConnectorRequestStream after completion");
297 }
298 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
299 |bytes, handles| {
300 match this.inner.channel().read_etc(cx, bytes, handles) {
301 std::task::Poll::Ready(Ok(())) => {}
302 std::task::Poll::Pending => return std::task::Poll::Pending,
303 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
304 this.is_terminated = true;
305 return std::task::Poll::Ready(None);
306 }
307 std::task::Poll::Ready(Err(e)) => {
308 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
309 e.into(),
310 ))))
311 }
312 }
313
314 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
316
317 std::task::Poll::Ready(Some(match header.ordinal {
318 0x29e603fe743fd08a => {
319 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
320 let mut req = fidl::new_empty!(
321 ConnectorConnectRequest,
322 fidl::encoding::DefaultFuchsiaResourceDialect
323 );
324 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConnectorConnectRequest>(&header, _body_bytes, handles, &mut req)?;
325 let control_handle = ConnectorControlHandle { inner: this.inner.clone() };
326 Ok(ConnectorRequest::Connect {
327 client_type: req.client_type,
328 watcher: req.watcher,
329
330 control_handle,
331 })
332 }
333 _ => Err(fidl::Error::UnknownOrdinal {
334 ordinal: header.ordinal,
335 protocol_name:
336 <ConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
337 }),
338 }))
339 },
340 )
341 }
342}
343
344#[derive(Debug)]
347pub enum ConnectorRequest {
348 Connect {
366 client_type: ClientType,
367 watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
368 control_handle: ConnectorControlHandle,
369 },
370}
371
372impl ConnectorRequest {
373 #[allow(irrefutable_let_patterns)]
374 pub fn into_connect(
375 self,
376 ) -> Option<(ClientType, fidl::endpoints::ServerEnd<WatcherMarker>, ConnectorControlHandle)>
377 {
378 if let ConnectorRequest::Connect { client_type, watcher, control_handle } = self {
379 Some((client_type, watcher, control_handle))
380 } else {
381 None
382 }
383 }
384
385 pub fn method_name(&self) -> &'static str {
387 match *self {
388 ConnectorRequest::Connect { .. } => "connect",
389 }
390 }
391}
392
393#[derive(Debug, Clone)]
394pub struct ConnectorControlHandle {
395 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
396}
397
398impl fidl::endpoints::ControlHandle for ConnectorControlHandle {
399 fn shutdown(&self) {
400 self.inner.shutdown()
401 }
402 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
403 self.inner.shutdown_with_epitaph(status)
404 }
405
406 fn is_closed(&self) -> bool {
407 self.inner.channel().is_closed()
408 }
409 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
410 self.inner.channel().on_closed()
411 }
412
413 #[cfg(target_os = "fuchsia")]
414 fn signal_peer(
415 &self,
416 clear_mask: zx::Signals,
417 set_mask: zx::Signals,
418 ) -> Result<(), zx_status::Status> {
419 use fidl::Peered;
420 self.inner.channel().signal_peer(clear_mask, set_mask)
421 }
422}
423
424impl ConnectorControlHandle {}
425
426#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
427pub struct WatcherMarker;
428
429impl fidl::endpoints::ProtocolMarker for WatcherMarker {
430 type Proxy = WatcherProxy;
431 type RequestStream = WatcherRequestStream;
432 #[cfg(target_os = "fuchsia")]
433 type SynchronousProxy = WatcherSynchronousProxy;
434
435 const DEBUG_NAME: &'static str = "(anonymous) Watcher";
436}
437
438pub trait WatcherProxyInterface: Send + Sync {
439 type WatchResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
440 fn r#watch(&self) -> Self::WatchResponseFut;
441}
442#[derive(Debug)]
443#[cfg(target_os = "fuchsia")]
444pub struct WatcherSynchronousProxy {
445 client: fidl::client::sync::Client,
446}
447
448#[cfg(target_os = "fuchsia")]
449impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
450 type Proxy = WatcherProxy;
451 type Protocol = WatcherMarker;
452
453 fn from_channel(inner: fidl::Channel) -> Self {
454 Self::new(inner)
455 }
456
457 fn into_channel(self) -> fidl::Channel {
458 self.client.into_channel()
459 }
460
461 fn as_channel(&self) -> &fidl::Channel {
462 self.client.as_channel()
463 }
464}
465
466#[cfg(target_os = "fuchsia")]
467impl WatcherSynchronousProxy {
468 pub fn new(channel: fidl::Channel) -> Self {
469 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
470 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
471 }
472
473 pub fn into_channel(self) -> fidl::Channel {
474 self.client.into_channel()
475 }
476
477 pub fn wait_for_event(
480 &self,
481 deadline: zx::MonotonicInstant,
482 ) -> Result<WatcherEvent, fidl::Error> {
483 WatcherEvent::decode(self.client.wait_for_event(deadline)?)
484 }
485
486 pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
503 let _response =
504 self.client.send_query::<fidl::encoding::EmptyPayload, WatcherWatchResponse>(
505 (),
506 0x29592d2e62f4101a,
507 fidl::encoding::DynamicFlags::empty(),
508 ___deadline,
509 )?;
510 Ok(_response.level)
511 }
512}
513
514#[derive(Debug, Clone)]
515pub struct WatcherProxy {
516 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
517}
518
519impl fidl::endpoints::Proxy for WatcherProxy {
520 type Protocol = WatcherMarker;
521
522 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
523 Self::new(inner)
524 }
525
526 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
527 self.client.into_channel().map_err(|client| Self { client })
528 }
529
530 fn as_channel(&self) -> &::fidl::AsyncChannel {
531 self.client.as_channel()
532 }
533}
534
535impl WatcherProxy {
536 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
538 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
539 Self { client: fidl::client::Client::new(channel, protocol_name) }
540 }
541
542 pub fn take_event_stream(&self) -> WatcherEventStream {
548 WatcherEventStream { event_receiver: self.client.take_event_receiver() }
549 }
550
551 pub fn r#watch(
568 &self,
569 ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
570 WatcherProxyInterface::r#watch(self)
571 }
572}
573
574impl WatcherProxyInterface for WatcherProxy {
575 type WatchResponseFut =
576 fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
577 fn r#watch(&self) -> Self::WatchResponseFut {
578 fn _decode(
579 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
580 ) -> Result<u64, fidl::Error> {
581 let _response = fidl::client::decode_transaction_body::<
582 WatcherWatchResponse,
583 fidl::encoding::DefaultFuchsiaResourceDialect,
584 0x29592d2e62f4101a,
585 >(_buf?)?;
586 Ok(_response.level)
587 }
588 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
589 (),
590 0x29592d2e62f4101a,
591 fidl::encoding::DynamicFlags::empty(),
592 _decode,
593 )
594 }
595}
596
597pub struct WatcherEventStream {
598 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
599}
600
601impl std::marker::Unpin for WatcherEventStream {}
602
603impl futures::stream::FusedStream for WatcherEventStream {
604 fn is_terminated(&self) -> bool {
605 self.event_receiver.is_terminated()
606 }
607}
608
609impl futures::Stream for WatcherEventStream {
610 type Item = Result<WatcherEvent, fidl::Error>;
611
612 fn poll_next(
613 mut self: std::pin::Pin<&mut Self>,
614 cx: &mut std::task::Context<'_>,
615 ) -> std::task::Poll<Option<Self::Item>> {
616 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
617 &mut self.event_receiver,
618 cx
619 )?) {
620 Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
621 None => std::task::Poll::Ready(None),
622 }
623 }
624}
625
626#[derive(Debug)]
627pub enum WatcherEvent {}
628
629impl WatcherEvent {
630 fn decode(
632 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
633 ) -> Result<WatcherEvent, fidl::Error> {
634 let (bytes, _handles) = buf.split_mut();
635 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
636 debug_assert_eq!(tx_header.tx_id, 0);
637 match tx_header.ordinal {
638 _ => Err(fidl::Error::UnknownOrdinal {
639 ordinal: tx_header.ordinal,
640 protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
641 }),
642 }
643 }
644}
645
646pub struct WatcherRequestStream {
648 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
649 is_terminated: bool,
650}
651
652impl std::marker::Unpin for WatcherRequestStream {}
653
654impl futures::stream::FusedStream for WatcherRequestStream {
655 fn is_terminated(&self) -> bool {
656 self.is_terminated
657 }
658}
659
660impl fidl::endpoints::RequestStream for WatcherRequestStream {
661 type Protocol = WatcherMarker;
662 type ControlHandle = WatcherControlHandle;
663
664 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
665 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
666 }
667
668 fn control_handle(&self) -> Self::ControlHandle {
669 WatcherControlHandle { inner: self.inner.clone() }
670 }
671
672 fn into_inner(
673 self,
674 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
675 {
676 (self.inner, self.is_terminated)
677 }
678
679 fn from_inner(
680 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
681 is_terminated: bool,
682 ) -> Self {
683 Self { inner, is_terminated }
684 }
685}
686
687impl futures::Stream for WatcherRequestStream {
688 type Item = Result<WatcherRequest, fidl::Error>;
689
690 fn poll_next(
691 mut self: std::pin::Pin<&mut Self>,
692 cx: &mut std::task::Context<'_>,
693 ) -> std::task::Poll<Option<Self::Item>> {
694 let this = &mut *self;
695 if this.inner.check_shutdown(cx) {
696 this.is_terminated = true;
697 return std::task::Poll::Ready(None);
698 }
699 if this.is_terminated {
700 panic!("polled WatcherRequestStream after completion");
701 }
702 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
703 |bytes, handles| {
704 match this.inner.channel().read_etc(cx, bytes, handles) {
705 std::task::Poll::Ready(Ok(())) => {}
706 std::task::Poll::Pending => return std::task::Poll::Pending,
707 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
708 this.is_terminated = true;
709 return std::task::Poll::Ready(None);
710 }
711 std::task::Poll::Ready(Err(e)) => {
712 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
713 e.into(),
714 ))))
715 }
716 }
717
718 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
720
721 std::task::Poll::Ready(Some(match header.ordinal {
722 0x29592d2e62f4101a => {
723 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
724 let mut req = fidl::new_empty!(
725 fidl::encoding::EmptyPayload,
726 fidl::encoding::DefaultFuchsiaResourceDialect
727 );
728 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
729 let control_handle = WatcherControlHandle { inner: this.inner.clone() };
730 Ok(WatcherRequest::Watch {
731 responder: WatcherWatchResponder {
732 control_handle: std::mem::ManuallyDrop::new(control_handle),
733 tx_id: header.tx_id,
734 },
735 })
736 }
737 _ => Err(fidl::Error::UnknownOrdinal {
738 ordinal: header.ordinal,
739 protocol_name:
740 <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
741 }),
742 }))
743 },
744 )
745 }
746}
747
748#[derive(Debug)]
757pub enum WatcherRequest {
758 Watch { responder: WatcherWatchResponder },
775}
776
777impl WatcherRequest {
778 #[allow(irrefutable_let_patterns)]
779 pub fn into_watch(self) -> Option<(WatcherWatchResponder)> {
780 if let WatcherRequest::Watch { responder } = self {
781 Some((responder))
782 } else {
783 None
784 }
785 }
786
787 pub fn method_name(&self) -> &'static str {
789 match *self {
790 WatcherRequest::Watch { .. } => "watch",
791 }
792 }
793}
794
795#[derive(Debug, Clone)]
796pub struct WatcherControlHandle {
797 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
798}
799
800impl fidl::endpoints::ControlHandle for WatcherControlHandle {
801 fn shutdown(&self) {
802 self.inner.shutdown()
803 }
804 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
805 self.inner.shutdown_with_epitaph(status)
806 }
807
808 fn is_closed(&self) -> bool {
809 self.inner.channel().is_closed()
810 }
811 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
812 self.inner.channel().on_closed()
813 }
814
815 #[cfg(target_os = "fuchsia")]
816 fn signal_peer(
817 &self,
818 clear_mask: zx::Signals,
819 set_mask: zx::Signals,
820 ) -> Result<(), zx_status::Status> {
821 use fidl::Peered;
822 self.inner.channel().signal_peer(clear_mask, set_mask)
823 }
824}
825
826impl WatcherControlHandle {}
827
828#[must_use = "FIDL methods require a response to be sent"]
829#[derive(Debug)]
830pub struct WatcherWatchResponder {
831 control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
832 tx_id: u32,
833}
834
835impl std::ops::Drop for WatcherWatchResponder {
839 fn drop(&mut self) {
840 self.control_handle.shutdown();
841 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
843 }
844}
845
846impl fidl::endpoints::Responder for WatcherWatchResponder {
847 type ControlHandle = WatcherControlHandle;
848
849 fn control_handle(&self) -> &WatcherControlHandle {
850 &self.control_handle
851 }
852
853 fn drop_without_shutdown(mut self) {
854 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
856 std::mem::forget(self);
858 }
859}
860
861impl WatcherWatchResponder {
862 pub fn send(self, mut level: u64) -> Result<(), fidl::Error> {
866 let _result = self.send_raw(level);
867 if _result.is_err() {
868 self.control_handle.shutdown();
869 }
870 self.drop_without_shutdown();
871 _result
872 }
873
874 pub fn send_no_shutdown_on_err(self, mut level: u64) -> Result<(), fidl::Error> {
876 let _result = self.send_raw(level);
877 self.drop_without_shutdown();
878 _result
879 }
880
881 fn send_raw(&self, mut level: u64) -> Result<(), fidl::Error> {
882 self.control_handle.inner.send::<WatcherWatchResponse>(
883 (level,),
884 self.tx_id,
885 0x29592d2e62f4101a,
886 fidl::encoding::DynamicFlags::empty(),
887 )
888 }
889}
890
891mod internal {
892 use super::*;
893
894 impl fidl::encoding::ResourceTypeMarker for ConnectorConnectRequest {
895 type Borrowed<'a> = &'a mut Self;
896 fn take_or_borrow<'a>(
897 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
898 ) -> Self::Borrowed<'a> {
899 value
900 }
901 }
902
903 unsafe impl fidl::encoding::TypeMarker for ConnectorConnectRequest {
904 type Owned = Self;
905
906 #[inline(always)]
907 fn inline_align(_context: fidl::encoding::Context) -> usize {
908 4
909 }
910
911 #[inline(always)]
912 fn inline_size(_context: fidl::encoding::Context) -> usize {
913 8
914 }
915 }
916
917 unsafe impl
918 fidl::encoding::Encode<
919 ConnectorConnectRequest,
920 fidl::encoding::DefaultFuchsiaResourceDialect,
921 > for &mut ConnectorConnectRequest
922 {
923 #[inline]
924 unsafe fn encode(
925 self,
926 encoder: &mut fidl::encoding::Encoder<
927 '_,
928 fidl::encoding::DefaultFuchsiaResourceDialect,
929 >,
930 offset: usize,
931 _depth: fidl::encoding::Depth,
932 ) -> fidl::Result<()> {
933 encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
934 fidl::encoding::Encode::<ConnectorConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
936 (
937 <ClientType as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
938 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
939 ),
940 encoder, offset, _depth
941 )
942 }
943 }
944 unsafe impl<
945 T0: fidl::encoding::Encode<ClientType, fidl::encoding::DefaultFuchsiaResourceDialect>,
946 T1: fidl::encoding::Encode<
947 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
948 fidl::encoding::DefaultFuchsiaResourceDialect,
949 >,
950 >
951 fidl::encoding::Encode<
952 ConnectorConnectRequest,
953 fidl::encoding::DefaultFuchsiaResourceDialect,
954 > for (T0, T1)
955 {
956 #[inline]
957 unsafe fn encode(
958 self,
959 encoder: &mut fidl::encoding::Encoder<
960 '_,
961 fidl::encoding::DefaultFuchsiaResourceDialect,
962 >,
963 offset: usize,
964 depth: fidl::encoding::Depth,
965 ) -> fidl::Result<()> {
966 encoder.debug_check_bounds::<ConnectorConnectRequest>(offset);
967 self.0.encode(encoder, offset + 0, depth)?;
971 self.1.encode(encoder, offset + 4, depth)?;
972 Ok(())
973 }
974 }
975
976 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
977 for ConnectorConnectRequest
978 {
979 #[inline(always)]
980 fn new_empty() -> Self {
981 Self {
982 client_type: fidl::new_empty!(
983 ClientType,
984 fidl::encoding::DefaultFuchsiaResourceDialect
985 ),
986 watcher: fidl::new_empty!(
987 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
988 fidl::encoding::DefaultFuchsiaResourceDialect
989 ),
990 }
991 }
992
993 #[inline]
994 unsafe fn decode(
995 &mut self,
996 decoder: &mut fidl::encoding::Decoder<
997 '_,
998 fidl::encoding::DefaultFuchsiaResourceDialect,
999 >,
1000 offset: usize,
1001 _depth: fidl::encoding::Depth,
1002 ) -> fidl::Result<()> {
1003 decoder.debug_check_bounds::<Self>(offset);
1004 fidl::decode!(
1006 ClientType,
1007 fidl::encoding::DefaultFuchsiaResourceDialect,
1008 &mut self.client_type,
1009 decoder,
1010 offset + 0,
1011 _depth
1012 )?;
1013 fidl::decode!(
1014 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
1015 fidl::encoding::DefaultFuchsiaResourceDialect,
1016 &mut self.watcher,
1017 decoder,
1018 offset + 4,
1019 _depth
1020 )?;
1021 Ok(())
1022 }
1023 }
1024}