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_thermal_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ClientStateConnectorConnectRequest {
16 pub client_type: String,
17 pub watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for ClientStateConnectorConnectRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct ClientStateConnectorMarker;
27
28impl fidl::endpoints::ProtocolMarker for ClientStateConnectorMarker {
29 type Proxy = ClientStateConnectorProxy;
30 type RequestStream = ClientStateConnectorRequestStream;
31 #[cfg(target_os = "fuchsia")]
32 type SynchronousProxy = ClientStateConnectorSynchronousProxy;
33
34 const DEBUG_NAME: &'static str = "fuchsia.thermal.ClientStateConnector";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for ClientStateConnectorMarker {}
37
38pub trait ClientStateConnectorProxyInterface: Send + Sync {
39 fn r#connect(
40 &self,
41 client_type: &str,
42 watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
43 ) -> Result<(), fidl::Error>;
44}
45#[derive(Debug)]
46#[cfg(target_os = "fuchsia")]
47pub struct ClientStateConnectorSynchronousProxy {
48 client: fidl::client::sync::Client,
49}
50
51#[cfg(target_os = "fuchsia")]
52impl fidl::endpoints::SynchronousProxy for ClientStateConnectorSynchronousProxy {
53 type Proxy = ClientStateConnectorProxy;
54 type Protocol = ClientStateConnectorMarker;
55
56 fn from_channel(inner: fidl::Channel) -> Self {
57 Self::new(inner)
58 }
59
60 fn into_channel(self) -> fidl::Channel {
61 self.client.into_channel()
62 }
63
64 fn as_channel(&self) -> &fidl::Channel {
65 self.client.as_channel()
66 }
67}
68
69#[cfg(target_os = "fuchsia")]
70impl ClientStateConnectorSynchronousProxy {
71 pub fn new(channel: fidl::Channel) -> Self {
72 let protocol_name =
73 <ClientStateConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
74 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
75 }
76
77 pub fn into_channel(self) -> fidl::Channel {
78 self.client.into_channel()
79 }
80
81 pub fn wait_for_event(
84 &self,
85 deadline: zx::MonotonicInstant,
86 ) -> Result<ClientStateConnectorEvent, fidl::Error> {
87 ClientStateConnectorEvent::decode(self.client.wait_for_event(deadline)?)
88 }
89
90 pub fn r#connect(
108 &self,
109 mut client_type: &str,
110 mut watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
111 ) -> Result<(), fidl::Error> {
112 self.client.send::<ClientStateConnectorConnectRequest>(
113 (client_type, watcher),
114 0x65abd3ba57ddaa1d,
115 fidl::encoding::DynamicFlags::empty(),
116 )
117 }
118}
119
120#[derive(Debug, Clone)]
121pub struct ClientStateConnectorProxy {
122 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
123}
124
125impl fidl::endpoints::Proxy for ClientStateConnectorProxy {
126 type Protocol = ClientStateConnectorMarker;
127
128 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
129 Self::new(inner)
130 }
131
132 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
133 self.client.into_channel().map_err(|client| Self { client })
134 }
135
136 fn as_channel(&self) -> &::fidl::AsyncChannel {
137 self.client.as_channel()
138 }
139}
140
141impl ClientStateConnectorProxy {
142 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
144 let protocol_name =
145 <ClientStateConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
146 Self { client: fidl::client::Client::new(channel, protocol_name) }
147 }
148
149 pub fn take_event_stream(&self) -> ClientStateConnectorEventStream {
155 ClientStateConnectorEventStream { event_receiver: self.client.take_event_receiver() }
156 }
157
158 pub fn r#connect(
176 &self,
177 mut client_type: &str,
178 mut watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
179 ) -> Result<(), fidl::Error> {
180 ClientStateConnectorProxyInterface::r#connect(self, client_type, watcher)
181 }
182}
183
184impl ClientStateConnectorProxyInterface for ClientStateConnectorProxy {
185 fn r#connect(
186 &self,
187 mut client_type: &str,
188 mut watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
189 ) -> Result<(), fidl::Error> {
190 self.client.send::<ClientStateConnectorConnectRequest>(
191 (client_type, watcher),
192 0x65abd3ba57ddaa1d,
193 fidl::encoding::DynamicFlags::empty(),
194 )
195 }
196}
197
198pub struct ClientStateConnectorEventStream {
199 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
200}
201
202impl std::marker::Unpin for ClientStateConnectorEventStream {}
203
204impl futures::stream::FusedStream for ClientStateConnectorEventStream {
205 fn is_terminated(&self) -> bool {
206 self.event_receiver.is_terminated()
207 }
208}
209
210impl futures::Stream for ClientStateConnectorEventStream {
211 type Item = Result<ClientStateConnectorEvent, fidl::Error>;
212
213 fn poll_next(
214 mut self: std::pin::Pin<&mut Self>,
215 cx: &mut std::task::Context<'_>,
216 ) -> std::task::Poll<Option<Self::Item>> {
217 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
218 &mut self.event_receiver,
219 cx
220 )?) {
221 Some(buf) => std::task::Poll::Ready(Some(ClientStateConnectorEvent::decode(buf))),
222 None => std::task::Poll::Ready(None),
223 }
224 }
225}
226
227#[derive(Debug)]
228pub enum ClientStateConnectorEvent {}
229
230impl ClientStateConnectorEvent {
231 fn decode(
233 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
234 ) -> Result<ClientStateConnectorEvent, fidl::Error> {
235 let (bytes, _handles) = buf.split_mut();
236 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
237 debug_assert_eq!(tx_header.tx_id, 0);
238 match tx_header.ordinal {
239 _ => Err(fidl::Error::UnknownOrdinal {
240 ordinal: tx_header.ordinal,
241 protocol_name:
242 <ClientStateConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
243 }),
244 }
245 }
246}
247
248pub struct ClientStateConnectorRequestStream {
250 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
251 is_terminated: bool,
252}
253
254impl std::marker::Unpin for ClientStateConnectorRequestStream {}
255
256impl futures::stream::FusedStream for ClientStateConnectorRequestStream {
257 fn is_terminated(&self) -> bool {
258 self.is_terminated
259 }
260}
261
262impl fidl::endpoints::RequestStream for ClientStateConnectorRequestStream {
263 type Protocol = ClientStateConnectorMarker;
264 type ControlHandle = ClientStateConnectorControlHandle;
265
266 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
267 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
268 }
269
270 fn control_handle(&self) -> Self::ControlHandle {
271 ClientStateConnectorControlHandle { inner: self.inner.clone() }
272 }
273
274 fn into_inner(
275 self,
276 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
277 {
278 (self.inner, self.is_terminated)
279 }
280
281 fn from_inner(
282 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
283 is_terminated: bool,
284 ) -> Self {
285 Self { inner, is_terminated }
286 }
287}
288
289impl futures::Stream for ClientStateConnectorRequestStream {
290 type Item = Result<ClientStateConnectorRequest, fidl::Error>;
291
292 fn poll_next(
293 mut self: std::pin::Pin<&mut Self>,
294 cx: &mut std::task::Context<'_>,
295 ) -> std::task::Poll<Option<Self::Item>> {
296 let this = &mut *self;
297 if this.inner.check_shutdown(cx) {
298 this.is_terminated = true;
299 return std::task::Poll::Ready(None);
300 }
301 if this.is_terminated {
302 panic!("polled ClientStateConnectorRequestStream after completion");
303 }
304 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
305 |bytes, handles| {
306 match this.inner.channel().read_etc(cx, bytes, handles) {
307 std::task::Poll::Ready(Ok(())) => {}
308 std::task::Poll::Pending => return std::task::Poll::Pending,
309 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
310 this.is_terminated = true;
311 return std::task::Poll::Ready(None);
312 }
313 std::task::Poll::Ready(Err(e)) => {
314 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
315 e.into(),
316 ))))
317 }
318 }
319
320 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
322
323 std::task::Poll::Ready(Some(match header.ordinal {
324 0x65abd3ba57ddaa1d => {
325 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
326 let mut req = fidl::new_empty!(ClientStateConnectorConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
327 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientStateConnectorConnectRequest>(&header, _body_bytes, handles, &mut req)?;
328 let control_handle = ClientStateConnectorControlHandle {
329 inner: this.inner.clone(),
330 };
331 Ok(ClientStateConnectorRequest::Connect {client_type: req.client_type,
332watcher: req.watcher,
333
334 control_handle,
335 })
336 }
337 _ => Err(fidl::Error::UnknownOrdinal {
338 ordinal: header.ordinal,
339 protocol_name: <ClientStateConnectorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
340 }),
341 }))
342 },
343 )
344 }
345}
346
347#[derive(Debug)]
350pub enum ClientStateConnectorRequest {
351 Connect {
369 client_type: String,
370 watcher: fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
371 control_handle: ClientStateConnectorControlHandle,
372 },
373}
374
375impl ClientStateConnectorRequest {
376 #[allow(irrefutable_let_patterns)]
377 pub fn into_connect(
378 self,
379 ) -> Option<(
380 String,
381 fidl::endpoints::ServerEnd<ClientStateWatcherMarker>,
382 ClientStateConnectorControlHandle,
383 )> {
384 if let ClientStateConnectorRequest::Connect { client_type, watcher, control_handle } = self
385 {
386 Some((client_type, watcher, control_handle))
387 } else {
388 None
389 }
390 }
391
392 pub fn method_name(&self) -> &'static str {
394 match *self {
395 ClientStateConnectorRequest::Connect { .. } => "connect",
396 }
397 }
398}
399
400#[derive(Debug, Clone)]
401pub struct ClientStateConnectorControlHandle {
402 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
403}
404
405impl fidl::endpoints::ControlHandle for ClientStateConnectorControlHandle {
406 fn shutdown(&self) {
407 self.inner.shutdown()
408 }
409 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
410 self.inner.shutdown_with_epitaph(status)
411 }
412
413 fn is_closed(&self) -> bool {
414 self.inner.channel().is_closed()
415 }
416 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
417 self.inner.channel().on_closed()
418 }
419
420 #[cfg(target_os = "fuchsia")]
421 fn signal_peer(
422 &self,
423 clear_mask: zx::Signals,
424 set_mask: zx::Signals,
425 ) -> Result<(), zx_status::Status> {
426 use fidl::Peered;
427 self.inner.channel().signal_peer(clear_mask, set_mask)
428 }
429}
430
431impl ClientStateConnectorControlHandle {}
432
433#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
434pub struct ClientStateWatcherMarker;
435
436impl fidl::endpoints::ProtocolMarker for ClientStateWatcherMarker {
437 type Proxy = ClientStateWatcherProxy;
438 type RequestStream = ClientStateWatcherRequestStream;
439 #[cfg(target_os = "fuchsia")]
440 type SynchronousProxy = ClientStateWatcherSynchronousProxy;
441
442 const DEBUG_NAME: &'static str = "(anonymous) ClientStateWatcher";
443}
444
445pub trait ClientStateWatcherProxyInterface: Send + Sync {
446 type WatchResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
447 fn r#watch(&self) -> Self::WatchResponseFut;
448}
449#[derive(Debug)]
450#[cfg(target_os = "fuchsia")]
451pub struct ClientStateWatcherSynchronousProxy {
452 client: fidl::client::sync::Client,
453}
454
455#[cfg(target_os = "fuchsia")]
456impl fidl::endpoints::SynchronousProxy for ClientStateWatcherSynchronousProxy {
457 type Proxy = ClientStateWatcherProxy;
458 type Protocol = ClientStateWatcherMarker;
459
460 fn from_channel(inner: fidl::Channel) -> Self {
461 Self::new(inner)
462 }
463
464 fn into_channel(self) -> fidl::Channel {
465 self.client.into_channel()
466 }
467
468 fn as_channel(&self) -> &fidl::Channel {
469 self.client.as_channel()
470 }
471}
472
473#[cfg(target_os = "fuchsia")]
474impl ClientStateWatcherSynchronousProxy {
475 pub fn new(channel: fidl::Channel) -> Self {
476 let protocol_name =
477 <ClientStateWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
478 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
479 }
480
481 pub fn into_channel(self) -> fidl::Channel {
482 self.client.into_channel()
483 }
484
485 pub fn wait_for_event(
488 &self,
489 deadline: zx::MonotonicInstant,
490 ) -> Result<ClientStateWatcherEvent, fidl::Error> {
491 ClientStateWatcherEvent::decode(self.client.wait_for_event(deadline)?)
492 }
493
494 pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<u64, fidl::Error> {
511 let _response = self
512 .client
513 .send_query::<fidl::encoding::EmptyPayload, ClientStateWatcherWatchResponse>(
514 (),
515 0x44831316a9942f7e,
516 fidl::encoding::DynamicFlags::empty(),
517 ___deadline,
518 )?;
519 Ok(_response.state)
520 }
521}
522
523#[derive(Debug, Clone)]
524pub struct ClientStateWatcherProxy {
525 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
526}
527
528impl fidl::endpoints::Proxy for ClientStateWatcherProxy {
529 type Protocol = ClientStateWatcherMarker;
530
531 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
532 Self::new(inner)
533 }
534
535 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
536 self.client.into_channel().map_err(|client| Self { client })
537 }
538
539 fn as_channel(&self) -> &::fidl::AsyncChannel {
540 self.client.as_channel()
541 }
542}
543
544impl ClientStateWatcherProxy {
545 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
547 let protocol_name =
548 <ClientStateWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
549 Self { client: fidl::client::Client::new(channel, protocol_name) }
550 }
551
552 pub fn take_event_stream(&self) -> ClientStateWatcherEventStream {
558 ClientStateWatcherEventStream { event_receiver: self.client.take_event_receiver() }
559 }
560
561 pub fn r#watch(
578 &self,
579 ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
580 ClientStateWatcherProxyInterface::r#watch(self)
581 }
582}
583
584impl ClientStateWatcherProxyInterface for ClientStateWatcherProxy {
585 type WatchResponseFut =
586 fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
587 fn r#watch(&self) -> Self::WatchResponseFut {
588 fn _decode(
589 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
590 ) -> Result<u64, fidl::Error> {
591 let _response = fidl::client::decode_transaction_body::<
592 ClientStateWatcherWatchResponse,
593 fidl::encoding::DefaultFuchsiaResourceDialect,
594 0x44831316a9942f7e,
595 >(_buf?)?;
596 Ok(_response.state)
597 }
598 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, u64>(
599 (),
600 0x44831316a9942f7e,
601 fidl::encoding::DynamicFlags::empty(),
602 _decode,
603 )
604 }
605}
606
607pub struct ClientStateWatcherEventStream {
608 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
609}
610
611impl std::marker::Unpin for ClientStateWatcherEventStream {}
612
613impl futures::stream::FusedStream for ClientStateWatcherEventStream {
614 fn is_terminated(&self) -> bool {
615 self.event_receiver.is_terminated()
616 }
617}
618
619impl futures::Stream for ClientStateWatcherEventStream {
620 type Item = Result<ClientStateWatcherEvent, fidl::Error>;
621
622 fn poll_next(
623 mut self: std::pin::Pin<&mut Self>,
624 cx: &mut std::task::Context<'_>,
625 ) -> std::task::Poll<Option<Self::Item>> {
626 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
627 &mut self.event_receiver,
628 cx
629 )?) {
630 Some(buf) => std::task::Poll::Ready(Some(ClientStateWatcherEvent::decode(buf))),
631 None => std::task::Poll::Ready(None),
632 }
633 }
634}
635
636#[derive(Debug)]
637pub enum ClientStateWatcherEvent {}
638
639impl ClientStateWatcherEvent {
640 fn decode(
642 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
643 ) -> Result<ClientStateWatcherEvent, fidl::Error> {
644 let (bytes, _handles) = buf.split_mut();
645 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
646 debug_assert_eq!(tx_header.tx_id, 0);
647 match tx_header.ordinal {
648 _ => Err(fidl::Error::UnknownOrdinal {
649 ordinal: tx_header.ordinal,
650 protocol_name:
651 <ClientStateWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
652 }),
653 }
654 }
655}
656
657pub struct ClientStateWatcherRequestStream {
659 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
660 is_terminated: bool,
661}
662
663impl std::marker::Unpin for ClientStateWatcherRequestStream {}
664
665impl futures::stream::FusedStream for ClientStateWatcherRequestStream {
666 fn is_terminated(&self) -> bool {
667 self.is_terminated
668 }
669}
670
671impl fidl::endpoints::RequestStream for ClientStateWatcherRequestStream {
672 type Protocol = ClientStateWatcherMarker;
673 type ControlHandle = ClientStateWatcherControlHandle;
674
675 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
676 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
677 }
678
679 fn control_handle(&self) -> Self::ControlHandle {
680 ClientStateWatcherControlHandle { inner: self.inner.clone() }
681 }
682
683 fn into_inner(
684 self,
685 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
686 {
687 (self.inner, self.is_terminated)
688 }
689
690 fn from_inner(
691 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
692 is_terminated: bool,
693 ) -> Self {
694 Self { inner, is_terminated }
695 }
696}
697
698impl futures::Stream for ClientStateWatcherRequestStream {
699 type Item = Result<ClientStateWatcherRequest, fidl::Error>;
700
701 fn poll_next(
702 mut self: std::pin::Pin<&mut Self>,
703 cx: &mut std::task::Context<'_>,
704 ) -> std::task::Poll<Option<Self::Item>> {
705 let this = &mut *self;
706 if this.inner.check_shutdown(cx) {
707 this.is_terminated = true;
708 return std::task::Poll::Ready(None);
709 }
710 if this.is_terminated {
711 panic!("polled ClientStateWatcherRequestStream after completion");
712 }
713 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
714 |bytes, handles| {
715 match this.inner.channel().read_etc(cx, bytes, handles) {
716 std::task::Poll::Ready(Ok(())) => {}
717 std::task::Poll::Pending => return std::task::Poll::Pending,
718 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
719 this.is_terminated = true;
720 return std::task::Poll::Ready(None);
721 }
722 std::task::Poll::Ready(Err(e)) => {
723 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
724 e.into(),
725 ))))
726 }
727 }
728
729 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
731
732 std::task::Poll::Ready(Some(match header.ordinal {
733 0x44831316a9942f7e => {
734 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
735 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
736 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
737 let control_handle = ClientStateWatcherControlHandle {
738 inner: this.inner.clone(),
739 };
740 Ok(ClientStateWatcherRequest::Watch {
741 responder: ClientStateWatcherWatchResponder {
742 control_handle: std::mem::ManuallyDrop::new(control_handle),
743 tx_id: header.tx_id,
744 },
745 })
746 }
747 _ => Err(fidl::Error::UnknownOrdinal {
748 ordinal: header.ordinal,
749 protocol_name: <ClientStateWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
750 }),
751 }))
752 },
753 )
754 }
755}
756
757#[derive(Debug)]
766pub enum ClientStateWatcherRequest {
767 Watch { responder: ClientStateWatcherWatchResponder },
784}
785
786impl ClientStateWatcherRequest {
787 #[allow(irrefutable_let_patterns)]
788 pub fn into_watch(self) -> Option<(ClientStateWatcherWatchResponder)> {
789 if let ClientStateWatcherRequest::Watch { responder } = self {
790 Some((responder))
791 } else {
792 None
793 }
794 }
795
796 pub fn method_name(&self) -> &'static str {
798 match *self {
799 ClientStateWatcherRequest::Watch { .. } => "watch",
800 }
801 }
802}
803
804#[derive(Debug, Clone)]
805pub struct ClientStateWatcherControlHandle {
806 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
807}
808
809impl fidl::endpoints::ControlHandle for ClientStateWatcherControlHandle {
810 fn shutdown(&self) {
811 self.inner.shutdown()
812 }
813 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
814 self.inner.shutdown_with_epitaph(status)
815 }
816
817 fn is_closed(&self) -> bool {
818 self.inner.channel().is_closed()
819 }
820 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
821 self.inner.channel().on_closed()
822 }
823
824 #[cfg(target_os = "fuchsia")]
825 fn signal_peer(
826 &self,
827 clear_mask: zx::Signals,
828 set_mask: zx::Signals,
829 ) -> Result<(), zx_status::Status> {
830 use fidl::Peered;
831 self.inner.channel().signal_peer(clear_mask, set_mask)
832 }
833}
834
835impl ClientStateWatcherControlHandle {}
836
837#[must_use = "FIDL methods require a response to be sent"]
838#[derive(Debug)]
839pub struct ClientStateWatcherWatchResponder {
840 control_handle: std::mem::ManuallyDrop<ClientStateWatcherControlHandle>,
841 tx_id: u32,
842}
843
844impl std::ops::Drop for ClientStateWatcherWatchResponder {
848 fn drop(&mut self) {
849 self.control_handle.shutdown();
850 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
852 }
853}
854
855impl fidl::endpoints::Responder for ClientStateWatcherWatchResponder {
856 type ControlHandle = ClientStateWatcherControlHandle;
857
858 fn control_handle(&self) -> &ClientStateWatcherControlHandle {
859 &self.control_handle
860 }
861
862 fn drop_without_shutdown(mut self) {
863 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
865 std::mem::forget(self);
867 }
868}
869
870impl ClientStateWatcherWatchResponder {
871 pub fn send(self, mut state: u64) -> Result<(), fidl::Error> {
875 let _result = self.send_raw(state);
876 if _result.is_err() {
877 self.control_handle.shutdown();
878 }
879 self.drop_without_shutdown();
880 _result
881 }
882
883 pub fn send_no_shutdown_on_err(self, mut state: u64) -> Result<(), fidl::Error> {
885 let _result = self.send_raw(state);
886 self.drop_without_shutdown();
887 _result
888 }
889
890 fn send_raw(&self, mut state: u64) -> Result<(), fidl::Error> {
891 self.control_handle.inner.send::<ClientStateWatcherWatchResponse>(
892 (state,),
893 self.tx_id,
894 0x44831316a9942f7e,
895 fidl::encoding::DynamicFlags::empty(),
896 )
897 }
898}
899
900mod internal {
901 use super::*;
902
903 impl fidl::encoding::ResourceTypeMarker for ClientStateConnectorConnectRequest {
904 type Borrowed<'a> = &'a mut Self;
905 fn take_or_borrow<'a>(
906 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
907 ) -> Self::Borrowed<'a> {
908 value
909 }
910 }
911
912 unsafe impl fidl::encoding::TypeMarker for ClientStateConnectorConnectRequest {
913 type Owned = Self;
914
915 #[inline(always)]
916 fn inline_align(_context: fidl::encoding::Context) -> usize {
917 8
918 }
919
920 #[inline(always)]
921 fn inline_size(_context: fidl::encoding::Context) -> usize {
922 24
923 }
924 }
925
926 unsafe impl
927 fidl::encoding::Encode<
928 ClientStateConnectorConnectRequest,
929 fidl::encoding::DefaultFuchsiaResourceDialect,
930 > for &mut ClientStateConnectorConnectRequest
931 {
932 #[inline]
933 unsafe fn encode(
934 self,
935 encoder: &mut fidl::encoding::Encoder<
936 '_,
937 fidl::encoding::DefaultFuchsiaResourceDialect,
938 >,
939 offset: usize,
940 _depth: fidl::encoding::Depth,
941 ) -> fidl::Result<()> {
942 encoder.debug_check_bounds::<ClientStateConnectorConnectRequest>(offset);
943 fidl::encoding::Encode::<ClientStateConnectorConnectRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
945 (
946 <fidl::encoding::BoundedString<8> as fidl::encoding::ValueTypeMarker>::borrow(&self.client_type),
947 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientStateWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
948 ),
949 encoder, offset, _depth
950 )
951 }
952 }
953 unsafe impl<
954 T0: fidl::encoding::Encode<
955 fidl::encoding::BoundedString<8>,
956 fidl::encoding::DefaultFuchsiaResourceDialect,
957 >,
958 T1: fidl::encoding::Encode<
959 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientStateWatcherMarker>>,
960 fidl::encoding::DefaultFuchsiaResourceDialect,
961 >,
962 >
963 fidl::encoding::Encode<
964 ClientStateConnectorConnectRequest,
965 fidl::encoding::DefaultFuchsiaResourceDialect,
966 > for (T0, T1)
967 {
968 #[inline]
969 unsafe fn encode(
970 self,
971 encoder: &mut fidl::encoding::Encoder<
972 '_,
973 fidl::encoding::DefaultFuchsiaResourceDialect,
974 >,
975 offset: usize,
976 depth: fidl::encoding::Depth,
977 ) -> fidl::Result<()> {
978 encoder.debug_check_bounds::<ClientStateConnectorConnectRequest>(offset);
979 unsafe {
982 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
983 (ptr as *mut u64).write_unaligned(0);
984 }
985 self.0.encode(encoder, offset + 0, depth)?;
987 self.1.encode(encoder, offset + 16, depth)?;
988 Ok(())
989 }
990 }
991
992 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
993 for ClientStateConnectorConnectRequest
994 {
995 #[inline(always)]
996 fn new_empty() -> Self {
997 Self {
998 client_type: fidl::new_empty!(
999 fidl::encoding::BoundedString<8>,
1000 fidl::encoding::DefaultFuchsiaResourceDialect
1001 ),
1002 watcher: fidl::new_empty!(
1003 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientStateWatcherMarker>>,
1004 fidl::encoding::DefaultFuchsiaResourceDialect
1005 ),
1006 }
1007 }
1008
1009 #[inline]
1010 unsafe fn decode(
1011 &mut self,
1012 decoder: &mut fidl::encoding::Decoder<
1013 '_,
1014 fidl::encoding::DefaultFuchsiaResourceDialect,
1015 >,
1016 offset: usize,
1017 _depth: fidl::encoding::Depth,
1018 ) -> fidl::Result<()> {
1019 decoder.debug_check_bounds::<Self>(offset);
1020 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1022 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1023 let mask = 0xffffffff00000000u64;
1024 let maskedval = padval & mask;
1025 if maskedval != 0 {
1026 return Err(fidl::Error::NonZeroPadding {
1027 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1028 });
1029 }
1030 fidl::decode!(
1031 fidl::encoding::BoundedString<8>,
1032 fidl::encoding::DefaultFuchsiaResourceDialect,
1033 &mut self.client_type,
1034 decoder,
1035 offset + 0,
1036 _depth
1037 )?;
1038 fidl::decode!(
1039 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ClientStateWatcherMarker>>,
1040 fidl::encoding::DefaultFuchsiaResourceDialect,
1041 &mut self.watcher,
1042 decoder,
1043 offset + 16,
1044 _depth
1045 )?;
1046 Ok(())
1047 }
1048 }
1049}