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_net_interfaces_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct StateGetWatcherRequest {
16 pub options: WatcherOptions,
18 pub watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for StateGetWatcherRequest {}
22
23#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
24pub struct StateMarker;
25
26impl fidl::endpoints::ProtocolMarker for StateMarker {
27 type Proxy = StateProxy;
28 type RequestStream = StateRequestStream;
29 #[cfg(target_os = "fuchsia")]
30 type SynchronousProxy = StateSynchronousProxy;
31
32 const DEBUG_NAME: &'static str = "fuchsia.net.interfaces.State";
33}
34impl fidl::endpoints::DiscoverableProtocolMarker for StateMarker {}
35
36pub trait StateProxyInterface: Send + Sync {
37 fn r#get_watcher(
38 &self,
39 options: &WatcherOptions,
40 watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
41 ) -> Result<(), fidl::Error>;
42}
43#[derive(Debug)]
44#[cfg(target_os = "fuchsia")]
45pub struct StateSynchronousProxy {
46 client: fidl::client::sync::Client,
47}
48
49#[cfg(target_os = "fuchsia")]
50impl fidl::endpoints::SynchronousProxy for StateSynchronousProxy {
51 type Proxy = StateProxy;
52 type Protocol = StateMarker;
53
54 fn from_channel(inner: fidl::Channel) -> Self {
55 Self::new(inner)
56 }
57
58 fn into_channel(self) -> fidl::Channel {
59 self.client.into_channel()
60 }
61
62 fn as_channel(&self) -> &fidl::Channel {
63 self.client.as_channel()
64 }
65}
66
67#[cfg(target_os = "fuchsia")]
68impl StateSynchronousProxy {
69 pub fn new(channel: fidl::Channel) -> Self {
70 Self { client: fidl::client::sync::Client::new(channel) }
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<StateEvent, fidl::Error> {
83 StateEvent::decode(self.client.wait_for_event::<StateMarker>(deadline)?)
84 }
85
86 pub fn r#get_watcher(
96 &self,
97 mut options: &WatcherOptions,
98 mut watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
99 ) -> Result<(), fidl::Error> {
100 self.client.send::<StateGetWatcherRequest>(
101 (options, watcher),
102 0x4fe223c98b263ae3,
103 fidl::encoding::DynamicFlags::empty(),
104 )
105 }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl From<StateSynchronousProxy> for zx::NullableHandle {
110 fn from(value: StateSynchronousProxy) -> Self {
111 value.into_channel().into()
112 }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl From<fidl::Channel> for StateSynchronousProxy {
117 fn from(value: fidl::Channel) -> Self {
118 Self::new(value)
119 }
120}
121
122#[cfg(target_os = "fuchsia")]
123impl fidl::endpoints::FromClient for StateSynchronousProxy {
124 type Protocol = StateMarker;
125
126 fn from_client(value: fidl::endpoints::ClientEnd<StateMarker>) -> Self {
127 Self::new(value.into_channel())
128 }
129}
130
131#[derive(Debug, Clone)]
132pub struct StateProxy {
133 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
134}
135
136impl fidl::endpoints::Proxy for StateProxy {
137 type Protocol = StateMarker;
138
139 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
140 Self::new(inner)
141 }
142
143 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
144 self.client.into_channel().map_err(|client| Self { client })
145 }
146
147 fn as_channel(&self) -> &::fidl::AsyncChannel {
148 self.client.as_channel()
149 }
150}
151
152impl StateProxy {
153 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
155 let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156 Self { client: fidl::client::Client::new(channel, protocol_name) }
157 }
158
159 pub fn take_event_stream(&self) -> StateEventStream {
165 StateEventStream { event_receiver: self.client.take_event_receiver() }
166 }
167
168 pub fn r#get_watcher(
178 &self,
179 mut options: &WatcherOptions,
180 mut watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
181 ) -> Result<(), fidl::Error> {
182 StateProxyInterface::r#get_watcher(self, options, watcher)
183 }
184}
185
186impl StateProxyInterface for StateProxy {
187 fn r#get_watcher(
188 &self,
189 mut options: &WatcherOptions,
190 mut watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
191 ) -> Result<(), fidl::Error> {
192 self.client.send::<StateGetWatcherRequest>(
193 (options, watcher),
194 0x4fe223c98b263ae3,
195 fidl::encoding::DynamicFlags::empty(),
196 )
197 }
198}
199
200pub struct StateEventStream {
201 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
202}
203
204impl std::marker::Unpin for StateEventStream {}
205
206impl futures::stream::FusedStream for StateEventStream {
207 fn is_terminated(&self) -> bool {
208 self.event_receiver.is_terminated()
209 }
210}
211
212impl futures::Stream for StateEventStream {
213 type Item = Result<StateEvent, fidl::Error>;
214
215 fn poll_next(
216 mut self: std::pin::Pin<&mut Self>,
217 cx: &mut std::task::Context<'_>,
218 ) -> std::task::Poll<Option<Self::Item>> {
219 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
220 &mut self.event_receiver,
221 cx
222 )?) {
223 Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
224 None => std::task::Poll::Ready(None),
225 }
226 }
227}
228
229#[derive(Debug)]
230pub enum StateEvent {}
231
232impl StateEvent {
233 fn decode(
235 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
236 ) -> Result<StateEvent, fidl::Error> {
237 let (bytes, _handles) = buf.split_mut();
238 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
239 debug_assert_eq!(tx_header.tx_id, 0);
240 match tx_header.ordinal {
241 _ => Err(fidl::Error::UnknownOrdinal {
242 ordinal: tx_header.ordinal,
243 protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
244 }),
245 }
246 }
247}
248
249pub struct StateRequestStream {
251 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
252 is_terminated: bool,
253}
254
255impl std::marker::Unpin for StateRequestStream {}
256
257impl futures::stream::FusedStream for StateRequestStream {
258 fn is_terminated(&self) -> bool {
259 self.is_terminated
260 }
261}
262
263impl fidl::endpoints::RequestStream for StateRequestStream {
264 type Protocol = StateMarker;
265 type ControlHandle = StateControlHandle;
266
267 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
268 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
269 }
270
271 fn control_handle(&self) -> Self::ControlHandle {
272 StateControlHandle { inner: self.inner.clone() }
273 }
274
275 fn into_inner(
276 self,
277 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
278 {
279 (self.inner, self.is_terminated)
280 }
281
282 fn from_inner(
283 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
284 is_terminated: bool,
285 ) -> Self {
286 Self { inner, is_terminated }
287 }
288}
289
290impl futures::Stream for StateRequestStream {
291 type Item = Result<StateRequest, fidl::Error>;
292
293 fn poll_next(
294 mut self: std::pin::Pin<&mut Self>,
295 cx: &mut std::task::Context<'_>,
296 ) -> std::task::Poll<Option<Self::Item>> {
297 let this = &mut *self;
298 if this.inner.check_shutdown(cx) {
299 this.is_terminated = true;
300 return std::task::Poll::Ready(None);
301 }
302 if this.is_terminated {
303 panic!("polled StateRequestStream after completion");
304 }
305 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
306 |bytes, handles| {
307 match this.inner.channel().read_etc(cx, bytes, handles) {
308 std::task::Poll::Ready(Ok(())) => {}
309 std::task::Poll::Pending => return std::task::Poll::Pending,
310 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
311 this.is_terminated = true;
312 return std::task::Poll::Ready(None);
313 }
314 std::task::Poll::Ready(Err(e)) => {
315 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
316 e.into(),
317 ))));
318 }
319 }
320
321 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
323
324 std::task::Poll::Ready(Some(match header.ordinal {
325 0x4fe223c98b263ae3 => {
326 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
327 let mut req = fidl::new_empty!(
328 StateGetWatcherRequest,
329 fidl::encoding::DefaultFuchsiaResourceDialect
330 );
331 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateGetWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
332 let control_handle = StateControlHandle { inner: this.inner.clone() };
333 Ok(StateRequest::GetWatcher {
334 options: req.options,
335 watcher: req.watcher,
336
337 control_handle,
338 })
339 }
340 _ => Err(fidl::Error::UnknownOrdinal {
341 ordinal: header.ordinal,
342 protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
343 }),
344 }))
345 },
346 )
347 }
348}
349
350#[derive(Debug)]
352pub enum StateRequest {
353 GetWatcher {
363 options: WatcherOptions,
364 watcher: fidl::endpoints::ServerEnd<WatcherMarker>,
365 control_handle: StateControlHandle,
366 },
367}
368
369impl StateRequest {
370 #[allow(irrefutable_let_patterns)]
371 pub fn into_get_watcher(
372 self,
373 ) -> Option<(WatcherOptions, fidl::endpoints::ServerEnd<WatcherMarker>, StateControlHandle)>
374 {
375 if let StateRequest::GetWatcher { options, watcher, control_handle } = self {
376 Some((options, watcher, control_handle))
377 } else {
378 None
379 }
380 }
381
382 pub fn method_name(&self) -> &'static str {
384 match *self {
385 StateRequest::GetWatcher { .. } => "get_watcher",
386 }
387 }
388}
389
390#[derive(Debug, Clone)]
391pub struct StateControlHandle {
392 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
393}
394
395impl StateControlHandle {
396 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
397 self.inner.shutdown_with_epitaph(status.into())
398 }
399}
400
401impl fidl::endpoints::ControlHandle for StateControlHandle {
402 fn shutdown(&self) {
403 self.inner.shutdown()
404 }
405
406 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
407 self.inner.shutdown_with_epitaph(status)
408 }
409
410 fn is_closed(&self) -> bool {
411 self.inner.channel().is_closed()
412 }
413 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
414 self.inner.channel().on_closed()
415 }
416
417 #[cfg(target_os = "fuchsia")]
418 fn signal_peer(
419 &self,
420 clear_mask: zx::Signals,
421 set_mask: zx::Signals,
422 ) -> Result<(), zx_status::Status> {
423 use fidl::Peered;
424 self.inner.channel().signal_peer(clear_mask, set_mask)
425 }
426}
427
428impl StateControlHandle {}
429
430#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
431pub struct WatcherMarker;
432
433impl fidl::endpoints::ProtocolMarker for WatcherMarker {
434 type Proxy = WatcherProxy;
435 type RequestStream = WatcherRequestStream;
436 #[cfg(target_os = "fuchsia")]
437 type SynchronousProxy = WatcherSynchronousProxy;
438
439 const DEBUG_NAME: &'static str = "(anonymous) Watcher";
440}
441
442pub trait WatcherProxyInterface: Send + Sync {
443 type WatchResponseFut: std::future::Future<Output = Result<Event, fidl::Error>> + Send;
444 fn r#watch(&self) -> Self::WatchResponseFut;
445}
446#[derive(Debug)]
447#[cfg(target_os = "fuchsia")]
448pub struct WatcherSynchronousProxy {
449 client: fidl::client::sync::Client,
450}
451
452#[cfg(target_os = "fuchsia")]
453impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
454 type Proxy = WatcherProxy;
455 type Protocol = WatcherMarker;
456
457 fn from_channel(inner: fidl::Channel) -> Self {
458 Self::new(inner)
459 }
460
461 fn into_channel(self) -> fidl::Channel {
462 self.client.into_channel()
463 }
464
465 fn as_channel(&self) -> &fidl::Channel {
466 self.client.as_channel()
467 }
468}
469
470#[cfg(target_os = "fuchsia")]
471impl WatcherSynchronousProxy {
472 pub fn new(channel: fidl::Channel) -> Self {
473 Self { client: fidl::client::sync::Client::new(channel) }
474 }
475
476 pub fn into_channel(self) -> fidl::Channel {
477 self.client.into_channel()
478 }
479
480 pub fn wait_for_event(
483 &self,
484 deadline: zx::MonotonicInstant,
485 ) -> Result<WatcherEvent, fidl::Error> {
486 WatcherEvent::decode(self.client.wait_for_event::<WatcherMarker>(deadline)?)
487 }
488
489 pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Event, fidl::Error> {
509 let _response = self
510 .client
511 .send_query::<fidl::encoding::EmptyPayload, WatcherWatchResponse, WatcherMarker>(
512 (),
513 0x550767aa9faeeef3,
514 fidl::encoding::DynamicFlags::empty(),
515 ___deadline,
516 )?;
517 Ok(_response.event)
518 }
519}
520
521#[cfg(target_os = "fuchsia")]
522impl From<WatcherSynchronousProxy> for zx::NullableHandle {
523 fn from(value: WatcherSynchronousProxy) -> Self {
524 value.into_channel().into()
525 }
526}
527
528#[cfg(target_os = "fuchsia")]
529impl From<fidl::Channel> for WatcherSynchronousProxy {
530 fn from(value: fidl::Channel) -> Self {
531 Self::new(value)
532 }
533}
534
535#[cfg(target_os = "fuchsia")]
536impl fidl::endpoints::FromClient for WatcherSynchronousProxy {
537 type Protocol = WatcherMarker;
538
539 fn from_client(value: fidl::endpoints::ClientEnd<WatcherMarker>) -> Self {
540 Self::new(value.into_channel())
541 }
542}
543
544#[derive(Debug, Clone)]
545pub struct WatcherProxy {
546 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
547}
548
549impl fidl::endpoints::Proxy for WatcherProxy {
550 type Protocol = WatcherMarker;
551
552 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
553 Self::new(inner)
554 }
555
556 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
557 self.client.into_channel().map_err(|client| Self { client })
558 }
559
560 fn as_channel(&self) -> &::fidl::AsyncChannel {
561 self.client.as_channel()
562 }
563}
564
565impl WatcherProxy {
566 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
568 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
569 Self { client: fidl::client::Client::new(channel, protocol_name) }
570 }
571
572 pub fn take_event_stream(&self) -> WatcherEventStream {
578 WatcherEventStream { event_receiver: self.client.take_event_receiver() }
579 }
580
581 pub fn r#watch(
601 &self,
602 ) -> fidl::client::QueryResponseFut<Event, fidl::encoding::DefaultFuchsiaResourceDialect> {
603 WatcherProxyInterface::r#watch(self)
604 }
605}
606
607impl WatcherProxyInterface for WatcherProxy {
608 type WatchResponseFut =
609 fidl::client::QueryResponseFut<Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
610 fn r#watch(&self) -> Self::WatchResponseFut {
611 fn _decode(
612 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
613 ) -> Result<Event, fidl::Error> {
614 let _response = fidl::client::decode_transaction_body::<
615 WatcherWatchResponse,
616 fidl::encoding::DefaultFuchsiaResourceDialect,
617 0x550767aa9faeeef3,
618 >(_buf?)?;
619 Ok(_response.event)
620 }
621 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Event>(
622 (),
623 0x550767aa9faeeef3,
624 fidl::encoding::DynamicFlags::empty(),
625 _decode,
626 )
627 }
628}
629
630pub struct WatcherEventStream {
631 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
632}
633
634impl std::marker::Unpin for WatcherEventStream {}
635
636impl futures::stream::FusedStream for WatcherEventStream {
637 fn is_terminated(&self) -> bool {
638 self.event_receiver.is_terminated()
639 }
640}
641
642impl futures::Stream for WatcherEventStream {
643 type Item = Result<WatcherEvent, fidl::Error>;
644
645 fn poll_next(
646 mut self: std::pin::Pin<&mut Self>,
647 cx: &mut std::task::Context<'_>,
648 ) -> std::task::Poll<Option<Self::Item>> {
649 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
650 &mut self.event_receiver,
651 cx
652 )?) {
653 Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
654 None => std::task::Poll::Ready(None),
655 }
656 }
657}
658
659#[derive(Debug)]
660pub enum WatcherEvent {}
661
662impl WatcherEvent {
663 fn decode(
665 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
666 ) -> Result<WatcherEvent, fidl::Error> {
667 let (bytes, _handles) = buf.split_mut();
668 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
669 debug_assert_eq!(tx_header.tx_id, 0);
670 match tx_header.ordinal {
671 _ => Err(fidl::Error::UnknownOrdinal {
672 ordinal: tx_header.ordinal,
673 protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
674 }),
675 }
676 }
677}
678
679pub struct WatcherRequestStream {
681 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
682 is_terminated: bool,
683}
684
685impl std::marker::Unpin for WatcherRequestStream {}
686
687impl futures::stream::FusedStream for WatcherRequestStream {
688 fn is_terminated(&self) -> bool {
689 self.is_terminated
690 }
691}
692
693impl fidl::endpoints::RequestStream for WatcherRequestStream {
694 type Protocol = WatcherMarker;
695 type ControlHandle = WatcherControlHandle;
696
697 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
698 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
699 }
700
701 fn control_handle(&self) -> Self::ControlHandle {
702 WatcherControlHandle { inner: self.inner.clone() }
703 }
704
705 fn into_inner(
706 self,
707 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
708 {
709 (self.inner, self.is_terminated)
710 }
711
712 fn from_inner(
713 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
714 is_terminated: bool,
715 ) -> Self {
716 Self { inner, is_terminated }
717 }
718}
719
720impl futures::Stream for WatcherRequestStream {
721 type Item = Result<WatcherRequest, fidl::Error>;
722
723 fn poll_next(
724 mut self: std::pin::Pin<&mut Self>,
725 cx: &mut std::task::Context<'_>,
726 ) -> std::task::Poll<Option<Self::Item>> {
727 let this = &mut *self;
728 if this.inner.check_shutdown(cx) {
729 this.is_terminated = true;
730 return std::task::Poll::Ready(None);
731 }
732 if this.is_terminated {
733 panic!("polled WatcherRequestStream after completion");
734 }
735 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
736 |bytes, handles| {
737 match this.inner.channel().read_etc(cx, bytes, handles) {
738 std::task::Poll::Ready(Ok(())) => {}
739 std::task::Poll::Pending => return std::task::Poll::Pending,
740 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
741 this.is_terminated = true;
742 return std::task::Poll::Ready(None);
743 }
744 std::task::Poll::Ready(Err(e)) => {
745 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
746 e.into(),
747 ))));
748 }
749 }
750
751 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
753
754 std::task::Poll::Ready(Some(match header.ordinal {
755 0x550767aa9faeeef3 => {
756 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
757 let mut req = fidl::new_empty!(
758 fidl::encoding::EmptyPayload,
759 fidl::encoding::DefaultFuchsiaResourceDialect
760 );
761 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
762 let control_handle = WatcherControlHandle { inner: this.inner.clone() };
763 Ok(WatcherRequest::Watch {
764 responder: WatcherWatchResponder {
765 control_handle: std::mem::ManuallyDrop::new(control_handle),
766 tx_id: header.tx_id,
767 },
768 })
769 }
770 _ => Err(fidl::Error::UnknownOrdinal {
771 ordinal: header.ordinal,
772 protocol_name:
773 <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
774 }),
775 }))
776 },
777 )
778 }
779}
780
781#[derive(Debug)]
784pub enum WatcherRequest {
785 Watch { responder: WatcherWatchResponder },
805}
806
807impl WatcherRequest {
808 #[allow(irrefutable_let_patterns)]
809 pub fn into_watch(self) -> Option<(WatcherWatchResponder)> {
810 if let WatcherRequest::Watch { responder } = self { Some((responder)) } else { None }
811 }
812
813 pub fn method_name(&self) -> &'static str {
815 match *self {
816 WatcherRequest::Watch { .. } => "watch",
817 }
818 }
819}
820
821#[derive(Debug, Clone)]
822pub struct WatcherControlHandle {
823 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
824}
825
826impl WatcherControlHandle {
827 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
828 self.inner.shutdown_with_epitaph(status.into())
829 }
830}
831
832impl fidl::endpoints::ControlHandle for WatcherControlHandle {
833 fn shutdown(&self) {
834 self.inner.shutdown()
835 }
836
837 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
838 self.inner.shutdown_with_epitaph(status)
839 }
840
841 fn is_closed(&self) -> bool {
842 self.inner.channel().is_closed()
843 }
844 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
845 self.inner.channel().on_closed()
846 }
847
848 #[cfg(target_os = "fuchsia")]
849 fn signal_peer(
850 &self,
851 clear_mask: zx::Signals,
852 set_mask: zx::Signals,
853 ) -> Result<(), zx_status::Status> {
854 use fidl::Peered;
855 self.inner.channel().signal_peer(clear_mask, set_mask)
856 }
857}
858
859impl WatcherControlHandle {}
860
861#[must_use = "FIDL methods require a response to be sent"]
862#[derive(Debug)]
863pub struct WatcherWatchResponder {
864 control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
865 tx_id: u32,
866}
867
868impl std::ops::Drop for WatcherWatchResponder {
872 fn drop(&mut self) {
873 self.control_handle.shutdown();
874 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
876 }
877}
878
879impl fidl::endpoints::Responder for WatcherWatchResponder {
880 type ControlHandle = WatcherControlHandle;
881
882 fn control_handle(&self) -> &WatcherControlHandle {
883 &self.control_handle
884 }
885
886 fn drop_without_shutdown(mut self) {
887 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
889 std::mem::forget(self);
891 }
892}
893
894impl WatcherWatchResponder {
895 pub fn send(self, mut event: &Event) -> Result<(), fidl::Error> {
899 let _result = self.send_raw(event);
900 if _result.is_err() {
901 self.control_handle.shutdown();
902 }
903 self.drop_without_shutdown();
904 _result
905 }
906
907 pub fn send_no_shutdown_on_err(self, mut event: &Event) -> Result<(), fidl::Error> {
909 let _result = self.send_raw(event);
910 self.drop_without_shutdown();
911 _result
912 }
913
914 fn send_raw(&self, mut event: &Event) -> Result<(), fidl::Error> {
915 self.control_handle.inner.send::<WatcherWatchResponse>(
916 (event,),
917 self.tx_id,
918 0x550767aa9faeeef3,
919 fidl::encoding::DynamicFlags::empty(),
920 )
921 }
922}
923
924mod internal {
925 use super::*;
926
927 impl fidl::encoding::ResourceTypeMarker for StateGetWatcherRequest {
928 type Borrowed<'a> = &'a mut Self;
929 fn take_or_borrow<'a>(
930 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
931 ) -> Self::Borrowed<'a> {
932 value
933 }
934 }
935
936 unsafe impl fidl::encoding::TypeMarker for StateGetWatcherRequest {
937 type Owned = Self;
938
939 #[inline(always)]
940 fn inline_align(_context: fidl::encoding::Context) -> usize {
941 8
942 }
943
944 #[inline(always)]
945 fn inline_size(_context: fidl::encoding::Context) -> usize {
946 24
947 }
948 }
949
950 unsafe impl
951 fidl::encoding::Encode<
952 StateGetWatcherRequest,
953 fidl::encoding::DefaultFuchsiaResourceDialect,
954 > for &mut StateGetWatcherRequest
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::<StateGetWatcherRequest>(offset);
967 fidl::encoding::Encode::<StateGetWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
969 (
970 <WatcherOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
971 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
972 ),
973 encoder, offset, _depth
974 )
975 }
976 }
977 unsafe impl<
978 T0: fidl::encoding::Encode<WatcherOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
979 T1: fidl::encoding::Encode<
980 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
981 fidl::encoding::DefaultFuchsiaResourceDialect,
982 >,
983 >
984 fidl::encoding::Encode<
985 StateGetWatcherRequest,
986 fidl::encoding::DefaultFuchsiaResourceDialect,
987 > for (T0, T1)
988 {
989 #[inline]
990 unsafe fn encode(
991 self,
992 encoder: &mut fidl::encoding::Encoder<
993 '_,
994 fidl::encoding::DefaultFuchsiaResourceDialect,
995 >,
996 offset: usize,
997 depth: fidl::encoding::Depth,
998 ) -> fidl::Result<()> {
999 encoder.debug_check_bounds::<StateGetWatcherRequest>(offset);
1000 unsafe {
1003 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1004 (ptr as *mut u64).write_unaligned(0);
1005 }
1006 self.0.encode(encoder, offset + 0, depth)?;
1008 self.1.encode(encoder, offset + 16, depth)?;
1009 Ok(())
1010 }
1011 }
1012
1013 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1014 for StateGetWatcherRequest
1015 {
1016 #[inline(always)]
1017 fn new_empty() -> Self {
1018 Self {
1019 options: fidl::new_empty!(
1020 WatcherOptions,
1021 fidl::encoding::DefaultFuchsiaResourceDialect
1022 ),
1023 watcher: fidl::new_empty!(
1024 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
1025 fidl::encoding::DefaultFuchsiaResourceDialect
1026 ),
1027 }
1028 }
1029
1030 #[inline]
1031 unsafe fn decode(
1032 &mut self,
1033 decoder: &mut fidl::encoding::Decoder<
1034 '_,
1035 fidl::encoding::DefaultFuchsiaResourceDialect,
1036 >,
1037 offset: usize,
1038 _depth: fidl::encoding::Depth,
1039 ) -> fidl::Result<()> {
1040 decoder.debug_check_bounds::<Self>(offset);
1041 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1043 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1044 let mask = 0xffffffff00000000u64;
1045 let maskedval = padval & mask;
1046 if maskedval != 0 {
1047 return Err(fidl::Error::NonZeroPadding {
1048 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1049 });
1050 }
1051 fidl::decode!(
1052 WatcherOptions,
1053 fidl::encoding::DefaultFuchsiaResourceDialect,
1054 &mut self.options,
1055 decoder,
1056 offset + 0,
1057 _depth
1058 )?;
1059 fidl::decode!(
1060 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
1061 fidl::encoding::DefaultFuchsiaResourceDialect,
1062 &mut self.watcher,
1063 decoder,
1064 offset + 16,
1065 _depth
1066 )?;
1067 Ok(())
1068 }
1069 }
1070}