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 fidl::endpoints::ControlHandle for StateControlHandle {
396 fn shutdown(&self) {
397 self.inner.shutdown()
398 }
399
400 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
401 self.inner.shutdown_with_epitaph(status)
402 }
403
404 fn is_closed(&self) -> bool {
405 self.inner.channel().is_closed()
406 }
407 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
408 self.inner.channel().on_closed()
409 }
410
411 #[cfg(target_os = "fuchsia")]
412 fn signal_peer(
413 &self,
414 clear_mask: zx::Signals,
415 set_mask: zx::Signals,
416 ) -> Result<(), zx_status::Status> {
417 use fidl::Peered;
418 self.inner.channel().signal_peer(clear_mask, set_mask)
419 }
420}
421
422impl StateControlHandle {}
423
424#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
425pub struct WatcherMarker;
426
427impl fidl::endpoints::ProtocolMarker for WatcherMarker {
428 type Proxy = WatcherProxy;
429 type RequestStream = WatcherRequestStream;
430 #[cfg(target_os = "fuchsia")]
431 type SynchronousProxy = WatcherSynchronousProxy;
432
433 const DEBUG_NAME: &'static str = "(anonymous) Watcher";
434}
435
436pub trait WatcherProxyInterface: Send + Sync {
437 type WatchResponseFut: std::future::Future<Output = Result<Event, fidl::Error>> + Send;
438 fn r#watch(&self) -> Self::WatchResponseFut;
439}
440#[derive(Debug)]
441#[cfg(target_os = "fuchsia")]
442pub struct WatcherSynchronousProxy {
443 client: fidl::client::sync::Client,
444}
445
446#[cfg(target_os = "fuchsia")]
447impl fidl::endpoints::SynchronousProxy for WatcherSynchronousProxy {
448 type Proxy = WatcherProxy;
449 type Protocol = WatcherMarker;
450
451 fn from_channel(inner: fidl::Channel) -> Self {
452 Self::new(inner)
453 }
454
455 fn into_channel(self) -> fidl::Channel {
456 self.client.into_channel()
457 }
458
459 fn as_channel(&self) -> &fidl::Channel {
460 self.client.as_channel()
461 }
462}
463
464#[cfg(target_os = "fuchsia")]
465impl WatcherSynchronousProxy {
466 pub fn new(channel: fidl::Channel) -> Self {
467 Self { client: fidl::client::sync::Client::new(channel) }
468 }
469
470 pub fn into_channel(self) -> fidl::Channel {
471 self.client.into_channel()
472 }
473
474 pub fn wait_for_event(
477 &self,
478 deadline: zx::MonotonicInstant,
479 ) -> Result<WatcherEvent, fidl::Error> {
480 WatcherEvent::decode(self.client.wait_for_event::<WatcherMarker>(deadline)?)
481 }
482
483 pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Event, fidl::Error> {
503 let _response = self
504 .client
505 .send_query::<fidl::encoding::EmptyPayload, WatcherWatchResponse, WatcherMarker>(
506 (),
507 0x550767aa9faeeef3,
508 fidl::encoding::DynamicFlags::empty(),
509 ___deadline,
510 )?;
511 Ok(_response.event)
512 }
513}
514
515#[cfg(target_os = "fuchsia")]
516impl From<WatcherSynchronousProxy> for zx::NullableHandle {
517 fn from(value: WatcherSynchronousProxy) -> Self {
518 value.into_channel().into()
519 }
520}
521
522#[cfg(target_os = "fuchsia")]
523impl From<fidl::Channel> for WatcherSynchronousProxy {
524 fn from(value: fidl::Channel) -> Self {
525 Self::new(value)
526 }
527}
528
529#[cfg(target_os = "fuchsia")]
530impl fidl::endpoints::FromClient for WatcherSynchronousProxy {
531 type Protocol = WatcherMarker;
532
533 fn from_client(value: fidl::endpoints::ClientEnd<WatcherMarker>) -> Self {
534 Self::new(value.into_channel())
535 }
536}
537
538#[derive(Debug, Clone)]
539pub struct WatcherProxy {
540 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
541}
542
543impl fidl::endpoints::Proxy for WatcherProxy {
544 type Protocol = WatcherMarker;
545
546 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
547 Self::new(inner)
548 }
549
550 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
551 self.client.into_channel().map_err(|client| Self { client })
552 }
553
554 fn as_channel(&self) -> &::fidl::AsyncChannel {
555 self.client.as_channel()
556 }
557}
558
559impl WatcherProxy {
560 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
562 let protocol_name = <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
563 Self { client: fidl::client::Client::new(channel, protocol_name) }
564 }
565
566 pub fn take_event_stream(&self) -> WatcherEventStream {
572 WatcherEventStream { event_receiver: self.client.take_event_receiver() }
573 }
574
575 pub fn r#watch(
595 &self,
596 ) -> fidl::client::QueryResponseFut<Event, fidl::encoding::DefaultFuchsiaResourceDialect> {
597 WatcherProxyInterface::r#watch(self)
598 }
599}
600
601impl WatcherProxyInterface for WatcherProxy {
602 type WatchResponseFut =
603 fidl::client::QueryResponseFut<Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
604 fn r#watch(&self) -> Self::WatchResponseFut {
605 fn _decode(
606 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
607 ) -> Result<Event, fidl::Error> {
608 let _response = fidl::client::decode_transaction_body::<
609 WatcherWatchResponse,
610 fidl::encoding::DefaultFuchsiaResourceDialect,
611 0x550767aa9faeeef3,
612 >(_buf?)?;
613 Ok(_response.event)
614 }
615 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Event>(
616 (),
617 0x550767aa9faeeef3,
618 fidl::encoding::DynamicFlags::empty(),
619 _decode,
620 )
621 }
622}
623
624pub struct WatcherEventStream {
625 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
626}
627
628impl std::marker::Unpin for WatcherEventStream {}
629
630impl futures::stream::FusedStream for WatcherEventStream {
631 fn is_terminated(&self) -> bool {
632 self.event_receiver.is_terminated()
633 }
634}
635
636impl futures::Stream for WatcherEventStream {
637 type Item = Result<WatcherEvent, fidl::Error>;
638
639 fn poll_next(
640 mut self: std::pin::Pin<&mut Self>,
641 cx: &mut std::task::Context<'_>,
642 ) -> std::task::Poll<Option<Self::Item>> {
643 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
644 &mut self.event_receiver,
645 cx
646 )?) {
647 Some(buf) => std::task::Poll::Ready(Some(WatcherEvent::decode(buf))),
648 None => std::task::Poll::Ready(None),
649 }
650 }
651}
652
653#[derive(Debug)]
654pub enum WatcherEvent {}
655
656impl WatcherEvent {
657 fn decode(
659 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
660 ) -> Result<WatcherEvent, fidl::Error> {
661 let (bytes, _handles) = buf.split_mut();
662 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
663 debug_assert_eq!(tx_header.tx_id, 0);
664 match tx_header.ordinal {
665 _ => Err(fidl::Error::UnknownOrdinal {
666 ordinal: tx_header.ordinal,
667 protocol_name: <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
668 }),
669 }
670 }
671}
672
673pub struct WatcherRequestStream {
675 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
676 is_terminated: bool,
677}
678
679impl std::marker::Unpin for WatcherRequestStream {}
680
681impl futures::stream::FusedStream for WatcherRequestStream {
682 fn is_terminated(&self) -> bool {
683 self.is_terminated
684 }
685}
686
687impl fidl::endpoints::RequestStream for WatcherRequestStream {
688 type Protocol = WatcherMarker;
689 type ControlHandle = WatcherControlHandle;
690
691 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
692 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
693 }
694
695 fn control_handle(&self) -> Self::ControlHandle {
696 WatcherControlHandle { inner: self.inner.clone() }
697 }
698
699 fn into_inner(
700 self,
701 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
702 {
703 (self.inner, self.is_terminated)
704 }
705
706 fn from_inner(
707 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
708 is_terminated: bool,
709 ) -> Self {
710 Self { inner, is_terminated }
711 }
712}
713
714impl futures::Stream for WatcherRequestStream {
715 type Item = Result<WatcherRequest, fidl::Error>;
716
717 fn poll_next(
718 mut self: std::pin::Pin<&mut Self>,
719 cx: &mut std::task::Context<'_>,
720 ) -> std::task::Poll<Option<Self::Item>> {
721 let this = &mut *self;
722 if this.inner.check_shutdown(cx) {
723 this.is_terminated = true;
724 return std::task::Poll::Ready(None);
725 }
726 if this.is_terminated {
727 panic!("polled WatcherRequestStream after completion");
728 }
729 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
730 |bytes, handles| {
731 match this.inner.channel().read_etc(cx, bytes, handles) {
732 std::task::Poll::Ready(Ok(())) => {}
733 std::task::Poll::Pending => return std::task::Poll::Pending,
734 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
735 this.is_terminated = true;
736 return std::task::Poll::Ready(None);
737 }
738 std::task::Poll::Ready(Err(e)) => {
739 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
740 e.into(),
741 ))));
742 }
743 }
744
745 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
747
748 std::task::Poll::Ready(Some(match header.ordinal {
749 0x550767aa9faeeef3 => {
750 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
751 let mut req = fidl::new_empty!(
752 fidl::encoding::EmptyPayload,
753 fidl::encoding::DefaultFuchsiaResourceDialect
754 );
755 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
756 let control_handle = WatcherControlHandle { inner: this.inner.clone() };
757 Ok(WatcherRequest::Watch {
758 responder: WatcherWatchResponder {
759 control_handle: std::mem::ManuallyDrop::new(control_handle),
760 tx_id: header.tx_id,
761 },
762 })
763 }
764 _ => Err(fidl::Error::UnknownOrdinal {
765 ordinal: header.ordinal,
766 protocol_name:
767 <WatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
768 }),
769 }))
770 },
771 )
772 }
773}
774
775#[derive(Debug)]
778pub enum WatcherRequest {
779 Watch { responder: WatcherWatchResponder },
799}
800
801impl WatcherRequest {
802 #[allow(irrefutable_let_patterns)]
803 pub fn into_watch(self) -> Option<(WatcherWatchResponder)> {
804 if let WatcherRequest::Watch { responder } = self { Some((responder)) } else { None }
805 }
806
807 pub fn method_name(&self) -> &'static str {
809 match *self {
810 WatcherRequest::Watch { .. } => "watch",
811 }
812 }
813}
814
815#[derive(Debug, Clone)]
816pub struct WatcherControlHandle {
817 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
818}
819
820impl fidl::endpoints::ControlHandle for WatcherControlHandle {
821 fn shutdown(&self) {
822 self.inner.shutdown()
823 }
824
825 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
826 self.inner.shutdown_with_epitaph(status)
827 }
828
829 fn is_closed(&self) -> bool {
830 self.inner.channel().is_closed()
831 }
832 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
833 self.inner.channel().on_closed()
834 }
835
836 #[cfg(target_os = "fuchsia")]
837 fn signal_peer(
838 &self,
839 clear_mask: zx::Signals,
840 set_mask: zx::Signals,
841 ) -> Result<(), zx_status::Status> {
842 use fidl::Peered;
843 self.inner.channel().signal_peer(clear_mask, set_mask)
844 }
845}
846
847impl WatcherControlHandle {}
848
849#[must_use = "FIDL methods require a response to be sent"]
850#[derive(Debug)]
851pub struct WatcherWatchResponder {
852 control_handle: std::mem::ManuallyDrop<WatcherControlHandle>,
853 tx_id: u32,
854}
855
856impl std::ops::Drop for WatcherWatchResponder {
860 fn drop(&mut self) {
861 self.control_handle.shutdown();
862 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
864 }
865}
866
867impl fidl::endpoints::Responder for WatcherWatchResponder {
868 type ControlHandle = WatcherControlHandle;
869
870 fn control_handle(&self) -> &WatcherControlHandle {
871 &self.control_handle
872 }
873
874 fn drop_without_shutdown(mut self) {
875 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877 std::mem::forget(self);
879 }
880}
881
882impl WatcherWatchResponder {
883 pub fn send(self, mut event: &Event) -> Result<(), fidl::Error> {
887 let _result = self.send_raw(event);
888 if _result.is_err() {
889 self.control_handle.shutdown();
890 }
891 self.drop_without_shutdown();
892 _result
893 }
894
895 pub fn send_no_shutdown_on_err(self, mut event: &Event) -> Result<(), fidl::Error> {
897 let _result = self.send_raw(event);
898 self.drop_without_shutdown();
899 _result
900 }
901
902 fn send_raw(&self, mut event: &Event) -> Result<(), fidl::Error> {
903 self.control_handle.inner.send::<WatcherWatchResponse>(
904 (event,),
905 self.tx_id,
906 0x550767aa9faeeef3,
907 fidl::encoding::DynamicFlags::empty(),
908 )
909 }
910}
911
912mod internal {
913 use super::*;
914
915 impl fidl::encoding::ResourceTypeMarker for StateGetWatcherRequest {
916 type Borrowed<'a> = &'a mut Self;
917 fn take_or_borrow<'a>(
918 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
919 ) -> Self::Borrowed<'a> {
920 value
921 }
922 }
923
924 unsafe impl fidl::encoding::TypeMarker for StateGetWatcherRequest {
925 type Owned = Self;
926
927 #[inline(always)]
928 fn inline_align(_context: fidl::encoding::Context) -> usize {
929 8
930 }
931
932 #[inline(always)]
933 fn inline_size(_context: fidl::encoding::Context) -> usize {
934 24
935 }
936 }
937
938 unsafe impl
939 fidl::encoding::Encode<
940 StateGetWatcherRequest,
941 fidl::encoding::DefaultFuchsiaResourceDialect,
942 > for &mut StateGetWatcherRequest
943 {
944 #[inline]
945 unsafe fn encode(
946 self,
947 encoder: &mut fidl::encoding::Encoder<
948 '_,
949 fidl::encoding::DefaultFuchsiaResourceDialect,
950 >,
951 offset: usize,
952 _depth: fidl::encoding::Depth,
953 ) -> fidl::Result<()> {
954 encoder.debug_check_bounds::<StateGetWatcherRequest>(offset);
955 fidl::encoding::Encode::<StateGetWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
957 (
958 <WatcherOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
959 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
960 ),
961 encoder, offset, _depth
962 )
963 }
964 }
965 unsafe impl<
966 T0: fidl::encoding::Encode<WatcherOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
967 T1: fidl::encoding::Encode<
968 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
969 fidl::encoding::DefaultFuchsiaResourceDialect,
970 >,
971 >
972 fidl::encoding::Encode<
973 StateGetWatcherRequest,
974 fidl::encoding::DefaultFuchsiaResourceDialect,
975 > for (T0, T1)
976 {
977 #[inline]
978 unsafe fn encode(
979 self,
980 encoder: &mut fidl::encoding::Encoder<
981 '_,
982 fidl::encoding::DefaultFuchsiaResourceDialect,
983 >,
984 offset: usize,
985 depth: fidl::encoding::Depth,
986 ) -> fidl::Result<()> {
987 encoder.debug_check_bounds::<StateGetWatcherRequest>(offset);
988 unsafe {
991 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
992 (ptr as *mut u64).write_unaligned(0);
993 }
994 self.0.encode(encoder, offset + 0, depth)?;
996 self.1.encode(encoder, offset + 16, depth)?;
997 Ok(())
998 }
999 }
1000
1001 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1002 for StateGetWatcherRequest
1003 {
1004 #[inline(always)]
1005 fn new_empty() -> Self {
1006 Self {
1007 options: fidl::new_empty!(
1008 WatcherOptions,
1009 fidl::encoding::DefaultFuchsiaResourceDialect
1010 ),
1011 watcher: fidl::new_empty!(
1012 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
1013 fidl::encoding::DefaultFuchsiaResourceDialect
1014 ),
1015 }
1016 }
1017
1018 #[inline]
1019 unsafe fn decode(
1020 &mut self,
1021 decoder: &mut fidl::encoding::Decoder<
1022 '_,
1023 fidl::encoding::DefaultFuchsiaResourceDialect,
1024 >,
1025 offset: usize,
1026 _depth: fidl::encoding::Depth,
1027 ) -> fidl::Result<()> {
1028 decoder.debug_check_bounds::<Self>(offset);
1029 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1031 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1032 let mask = 0xffffffff00000000u64;
1033 let maskedval = padval & mask;
1034 if maskedval != 0 {
1035 return Err(fidl::Error::NonZeroPadding {
1036 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1037 });
1038 }
1039 fidl::decode!(
1040 WatcherOptions,
1041 fidl::encoding::DefaultFuchsiaResourceDialect,
1042 &mut self.options,
1043 decoder,
1044 offset + 0,
1045 _depth
1046 )?;
1047 fidl::decode!(
1048 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherMarker>>,
1049 fidl::encoding::DefaultFuchsiaResourceDialect,
1050 &mut self.watcher,
1051 decoder,
1052 offset + 16,
1053 _depth
1054 )?;
1055 Ok(())
1056 }
1057 }
1058}