fidl_fuchsia_net_routes/
fidl_fuchsia_net_routes.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_routes__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct StateV4GetRuleWatcherV4Request {
16    pub watcher: fidl::endpoints::ServerEnd<RuleWatcherV4Marker>,
17    pub options: RuleWatcherOptionsV4,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for StateV4GetRuleWatcherV4Request
22{
23}
24
25#[derive(Debug, PartialEq)]
26pub struct StateV4GetWatcherV4Request {
27    pub watcher: fidl::endpoints::ServerEnd<WatcherV4Marker>,
28    pub options: WatcherOptionsV4,
29}
30
31impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
32    for StateV4GetWatcherV4Request
33{
34}
35
36#[derive(Debug, PartialEq)]
37pub struct StateV6GetRuleWatcherV6Request {
38    pub watcher: fidl::endpoints::ServerEnd<RuleWatcherV6Marker>,
39    pub options: RuleWatcherOptionsV6,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for StateV6GetRuleWatcherV6Request
44{
45}
46
47#[derive(Debug, PartialEq)]
48pub struct StateV6GetWatcherV6Request {
49    pub watcher: fidl::endpoints::ServerEnd<WatcherV6Marker>,
50    pub options: WatcherOptionsV6,
51}
52
53impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
54    for StateV6GetWatcherV6Request
55{
56}
57
58#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
59pub struct RuleWatcherV4Marker;
60
61impl fidl::endpoints::ProtocolMarker for RuleWatcherV4Marker {
62    type Proxy = RuleWatcherV4Proxy;
63    type RequestStream = RuleWatcherV4RequestStream;
64    #[cfg(target_os = "fuchsia")]
65    type SynchronousProxy = RuleWatcherV4SynchronousProxy;
66
67    const DEBUG_NAME: &'static str = "(anonymous) RuleWatcherV4";
68}
69
70pub trait RuleWatcherV4ProxyInterface: Send + Sync {
71    type WatchResponseFut: std::future::Future<Output = Result<Vec<RuleEventV4>, fidl::Error>>
72        + Send;
73    fn r#watch(&self) -> Self::WatchResponseFut;
74}
75#[derive(Debug)]
76#[cfg(target_os = "fuchsia")]
77pub struct RuleWatcherV4SynchronousProxy {
78    client: fidl::client::sync::Client,
79}
80
81#[cfg(target_os = "fuchsia")]
82impl fidl::endpoints::SynchronousProxy for RuleWatcherV4SynchronousProxy {
83    type Proxy = RuleWatcherV4Proxy;
84    type Protocol = RuleWatcherV4Marker;
85
86    fn from_channel(inner: fidl::Channel) -> Self {
87        Self::new(inner)
88    }
89
90    fn into_channel(self) -> fidl::Channel {
91        self.client.into_channel()
92    }
93
94    fn as_channel(&self) -> &fidl::Channel {
95        self.client.as_channel()
96    }
97}
98
99#[cfg(target_os = "fuchsia")]
100impl RuleWatcherV4SynchronousProxy {
101    pub fn new(channel: fidl::Channel) -> Self {
102        let protocol_name = <RuleWatcherV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
103        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
104    }
105
106    pub fn into_channel(self) -> fidl::Channel {
107        self.client.into_channel()
108    }
109
110    /// Waits until an event arrives and returns it. It is safe for other
111    /// threads to make concurrent requests while waiting for an event.
112    pub fn wait_for_event(
113        &self,
114        deadline: zx::MonotonicInstant,
115    ) -> Result<RuleWatcherV4Event, fidl::Error> {
116        RuleWatcherV4Event::decode(self.client.wait_for_event(deadline)?)
117    }
118
119    /// Hanging-Get style API for observing routing rule changes.
120    ///
121    /// Clients must only have one pending `Watch` call at a time. Calling
122    /// `Watch` while a request is already pending will cause the protocol to
123    /// close.
124    ///
125    /// The first N events will always be `existing` where N is the number of
126    /// IPv4 rules that already existed when the server-end of the protocol was
127    /// initialized. The following event will be `idle` signaling the end of the
128    /// `existing` events. At this point the client has watched all existing
129    /// state and will never again observe an `existing` event.
130    ///
131    /// - response `events` A vector of at most `MAX_EVENTS` events.
132    pub fn r#watch(
133        &self,
134        ___deadline: zx::MonotonicInstant,
135    ) -> Result<Vec<RuleEventV4>, fidl::Error> {
136        let _response =
137            self.client.send_query::<fidl::encoding::EmptyPayload, RuleWatcherV4WatchResponse>(
138                (),
139                0x7f94d7ea0f843271,
140                fidl::encoding::DynamicFlags::empty(),
141                ___deadline,
142            )?;
143        Ok(_response.events)
144    }
145}
146
147#[cfg(target_os = "fuchsia")]
148impl From<RuleWatcherV4SynchronousProxy> for zx::Handle {
149    fn from(value: RuleWatcherV4SynchronousProxy) -> Self {
150        value.into_channel().into()
151    }
152}
153
154#[cfg(target_os = "fuchsia")]
155impl From<fidl::Channel> for RuleWatcherV4SynchronousProxy {
156    fn from(value: fidl::Channel) -> Self {
157        Self::new(value)
158    }
159}
160
161#[cfg(target_os = "fuchsia")]
162impl fidl::endpoints::FromClient for RuleWatcherV4SynchronousProxy {
163    type Protocol = RuleWatcherV4Marker;
164
165    fn from_client(value: fidl::endpoints::ClientEnd<RuleWatcherV4Marker>) -> Self {
166        Self::new(value.into_channel())
167    }
168}
169
170#[derive(Debug, Clone)]
171pub struct RuleWatcherV4Proxy {
172    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
173}
174
175impl fidl::endpoints::Proxy for RuleWatcherV4Proxy {
176    type Protocol = RuleWatcherV4Marker;
177
178    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
179        Self::new(inner)
180    }
181
182    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
183        self.client.into_channel().map_err(|client| Self { client })
184    }
185
186    fn as_channel(&self) -> &::fidl::AsyncChannel {
187        self.client.as_channel()
188    }
189}
190
191impl RuleWatcherV4Proxy {
192    /// Create a new Proxy for fuchsia.net.routes/RuleWatcherV4.
193    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
194        let protocol_name = <RuleWatcherV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
195        Self { client: fidl::client::Client::new(channel, protocol_name) }
196    }
197
198    /// Get a Stream of events from the remote end of the protocol.
199    ///
200    /// # Panics
201    ///
202    /// Panics if the event stream was already taken.
203    pub fn take_event_stream(&self) -> RuleWatcherV4EventStream {
204        RuleWatcherV4EventStream { event_receiver: self.client.take_event_receiver() }
205    }
206
207    /// Hanging-Get style API for observing routing rule changes.
208    ///
209    /// Clients must only have one pending `Watch` call at a time. Calling
210    /// `Watch` while a request is already pending will cause the protocol to
211    /// close.
212    ///
213    /// The first N events will always be `existing` where N is the number of
214    /// IPv4 rules that already existed when the server-end of the protocol was
215    /// initialized. The following event will be `idle` signaling the end of the
216    /// `existing` events. At this point the client has watched all existing
217    /// state and will never again observe an `existing` event.
218    ///
219    /// - response `events` A vector of at most `MAX_EVENTS` events.
220    pub fn r#watch(
221        &self,
222    ) -> fidl::client::QueryResponseFut<
223        Vec<RuleEventV4>,
224        fidl::encoding::DefaultFuchsiaResourceDialect,
225    > {
226        RuleWatcherV4ProxyInterface::r#watch(self)
227    }
228}
229
230impl RuleWatcherV4ProxyInterface for RuleWatcherV4Proxy {
231    type WatchResponseFut = fidl::client::QueryResponseFut<
232        Vec<RuleEventV4>,
233        fidl::encoding::DefaultFuchsiaResourceDialect,
234    >;
235    fn r#watch(&self) -> Self::WatchResponseFut {
236        fn _decode(
237            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
238        ) -> Result<Vec<RuleEventV4>, fidl::Error> {
239            let _response = fidl::client::decode_transaction_body::<
240                RuleWatcherV4WatchResponse,
241                fidl::encoding::DefaultFuchsiaResourceDialect,
242                0x7f94d7ea0f843271,
243            >(_buf?)?;
244            Ok(_response.events)
245        }
246        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<RuleEventV4>>(
247            (),
248            0x7f94d7ea0f843271,
249            fidl::encoding::DynamicFlags::empty(),
250            _decode,
251        )
252    }
253}
254
255pub struct RuleWatcherV4EventStream {
256    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
257}
258
259impl std::marker::Unpin for RuleWatcherV4EventStream {}
260
261impl futures::stream::FusedStream for RuleWatcherV4EventStream {
262    fn is_terminated(&self) -> bool {
263        self.event_receiver.is_terminated()
264    }
265}
266
267impl futures::Stream for RuleWatcherV4EventStream {
268    type Item = Result<RuleWatcherV4Event, fidl::Error>;
269
270    fn poll_next(
271        mut self: std::pin::Pin<&mut Self>,
272        cx: &mut std::task::Context<'_>,
273    ) -> std::task::Poll<Option<Self::Item>> {
274        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
275            &mut self.event_receiver,
276            cx
277        )?) {
278            Some(buf) => std::task::Poll::Ready(Some(RuleWatcherV4Event::decode(buf))),
279            None => std::task::Poll::Ready(None),
280        }
281    }
282}
283
284#[derive(Debug)]
285pub enum RuleWatcherV4Event {}
286
287impl RuleWatcherV4Event {
288    /// Decodes a message buffer as a [`RuleWatcherV4Event`].
289    fn decode(
290        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
291    ) -> Result<RuleWatcherV4Event, fidl::Error> {
292        let (bytes, _handles) = buf.split_mut();
293        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
294        debug_assert_eq!(tx_header.tx_id, 0);
295        match tx_header.ordinal {
296            _ => Err(fidl::Error::UnknownOrdinal {
297                ordinal: tx_header.ordinal,
298                protocol_name: <RuleWatcherV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
299            }),
300        }
301    }
302}
303
304/// A Stream of incoming requests for fuchsia.net.routes/RuleWatcherV4.
305pub struct RuleWatcherV4RequestStream {
306    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
307    is_terminated: bool,
308}
309
310impl std::marker::Unpin for RuleWatcherV4RequestStream {}
311
312impl futures::stream::FusedStream for RuleWatcherV4RequestStream {
313    fn is_terminated(&self) -> bool {
314        self.is_terminated
315    }
316}
317
318impl fidl::endpoints::RequestStream for RuleWatcherV4RequestStream {
319    type Protocol = RuleWatcherV4Marker;
320    type ControlHandle = RuleWatcherV4ControlHandle;
321
322    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
323        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
324    }
325
326    fn control_handle(&self) -> Self::ControlHandle {
327        RuleWatcherV4ControlHandle { inner: self.inner.clone() }
328    }
329
330    fn into_inner(
331        self,
332    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
333    {
334        (self.inner, self.is_terminated)
335    }
336
337    fn from_inner(
338        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
339        is_terminated: bool,
340    ) -> Self {
341        Self { inner, is_terminated }
342    }
343}
344
345impl futures::Stream for RuleWatcherV4RequestStream {
346    type Item = Result<RuleWatcherV4Request, fidl::Error>;
347
348    fn poll_next(
349        mut self: std::pin::Pin<&mut Self>,
350        cx: &mut std::task::Context<'_>,
351    ) -> std::task::Poll<Option<Self::Item>> {
352        let this = &mut *self;
353        if this.inner.check_shutdown(cx) {
354            this.is_terminated = true;
355            return std::task::Poll::Ready(None);
356        }
357        if this.is_terminated {
358            panic!("polled RuleWatcherV4RequestStream after completion");
359        }
360        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
361            |bytes, handles| {
362                match this.inner.channel().read_etc(cx, bytes, handles) {
363                    std::task::Poll::Ready(Ok(())) => {}
364                    std::task::Poll::Pending => return std::task::Poll::Pending,
365                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
366                        this.is_terminated = true;
367                        return std::task::Poll::Ready(None);
368                    }
369                    std::task::Poll::Ready(Err(e)) => {
370                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
371                            e.into(),
372                        ))))
373                    }
374                }
375
376                // A message has been received from the channel
377                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
378
379                std::task::Poll::Ready(Some(match header.ordinal {
380                    0x7f94d7ea0f843271 => {
381                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
382                        let mut req = fidl::new_empty!(
383                            fidl::encoding::EmptyPayload,
384                            fidl::encoding::DefaultFuchsiaResourceDialect
385                        );
386                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
387                        let control_handle =
388                            RuleWatcherV4ControlHandle { inner: this.inner.clone() };
389                        Ok(RuleWatcherV4Request::Watch {
390                            responder: RuleWatcherV4WatchResponder {
391                                control_handle: std::mem::ManuallyDrop::new(control_handle),
392                                tx_id: header.tx_id,
393                            },
394                        })
395                    }
396                    _ => Err(fidl::Error::UnknownOrdinal {
397                        ordinal: header.ordinal,
398                        protocol_name:
399                            <RuleWatcherV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
400                    }),
401                }))
402            },
403        )
404    }
405}
406
407/// An observer protocol for changes in the system's IPv4 rules table.
408#[derive(Debug)]
409pub enum RuleWatcherV4Request {
410    /// Hanging-Get style API for observing routing rule changes.
411    ///
412    /// Clients must only have one pending `Watch` call at a time. Calling
413    /// `Watch` while a request is already pending will cause the protocol to
414    /// close.
415    ///
416    /// The first N events will always be `existing` where N is the number of
417    /// IPv4 rules that already existed when the server-end of the protocol was
418    /// initialized. The following event will be `idle` signaling the end of the
419    /// `existing` events. At this point the client has watched all existing
420    /// state and will never again observe an `existing` event.
421    ///
422    /// - response `events` A vector of at most `MAX_EVENTS` events.
423    Watch { responder: RuleWatcherV4WatchResponder },
424}
425
426impl RuleWatcherV4Request {
427    #[allow(irrefutable_let_patterns)]
428    pub fn into_watch(self) -> Option<(RuleWatcherV4WatchResponder)> {
429        if let RuleWatcherV4Request::Watch { responder } = self {
430            Some((responder))
431        } else {
432            None
433        }
434    }
435
436    /// Name of the method defined in FIDL
437    pub fn method_name(&self) -> &'static str {
438        match *self {
439            RuleWatcherV4Request::Watch { .. } => "watch",
440        }
441    }
442}
443
444#[derive(Debug, Clone)]
445pub struct RuleWatcherV4ControlHandle {
446    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
447}
448
449impl fidl::endpoints::ControlHandle for RuleWatcherV4ControlHandle {
450    fn shutdown(&self) {
451        self.inner.shutdown()
452    }
453    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
454        self.inner.shutdown_with_epitaph(status)
455    }
456
457    fn is_closed(&self) -> bool {
458        self.inner.channel().is_closed()
459    }
460    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
461        self.inner.channel().on_closed()
462    }
463
464    #[cfg(target_os = "fuchsia")]
465    fn signal_peer(
466        &self,
467        clear_mask: zx::Signals,
468        set_mask: zx::Signals,
469    ) -> Result<(), zx_status::Status> {
470        use fidl::Peered;
471        self.inner.channel().signal_peer(clear_mask, set_mask)
472    }
473}
474
475impl RuleWatcherV4ControlHandle {}
476
477#[must_use = "FIDL methods require a response to be sent"]
478#[derive(Debug)]
479pub struct RuleWatcherV4WatchResponder {
480    control_handle: std::mem::ManuallyDrop<RuleWatcherV4ControlHandle>,
481    tx_id: u32,
482}
483
484/// Set the the channel to be shutdown (see [`RuleWatcherV4ControlHandle::shutdown`])
485/// if the responder is dropped without sending a response, so that the client
486/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
487impl std::ops::Drop for RuleWatcherV4WatchResponder {
488    fn drop(&mut self) {
489        self.control_handle.shutdown();
490        // Safety: drops once, never accessed again
491        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
492    }
493}
494
495impl fidl::endpoints::Responder for RuleWatcherV4WatchResponder {
496    type ControlHandle = RuleWatcherV4ControlHandle;
497
498    fn control_handle(&self) -> &RuleWatcherV4ControlHandle {
499        &self.control_handle
500    }
501
502    fn drop_without_shutdown(mut self) {
503        // Safety: drops once, never accessed again due to mem::forget
504        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
505        // Prevent Drop from running (which would shut down the channel)
506        std::mem::forget(self);
507    }
508}
509
510impl RuleWatcherV4WatchResponder {
511    /// Sends a response to the FIDL transaction.
512    ///
513    /// Sets the channel to shutdown if an error occurs.
514    pub fn send(self, mut events: &[RuleEventV4]) -> Result<(), fidl::Error> {
515        let _result = self.send_raw(events);
516        if _result.is_err() {
517            self.control_handle.shutdown();
518        }
519        self.drop_without_shutdown();
520        _result
521    }
522
523    /// Similar to "send" but does not shutdown the channel if an error occurs.
524    pub fn send_no_shutdown_on_err(self, mut events: &[RuleEventV4]) -> Result<(), fidl::Error> {
525        let _result = self.send_raw(events);
526        self.drop_without_shutdown();
527        _result
528    }
529
530    fn send_raw(&self, mut events: &[RuleEventV4]) -> Result<(), fidl::Error> {
531        self.control_handle.inner.send::<RuleWatcherV4WatchResponse>(
532            (events,),
533            self.tx_id,
534            0x7f94d7ea0f843271,
535            fidl::encoding::DynamicFlags::empty(),
536        )
537    }
538}
539
540#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
541pub struct RuleWatcherV6Marker;
542
543impl fidl::endpoints::ProtocolMarker for RuleWatcherV6Marker {
544    type Proxy = RuleWatcherV6Proxy;
545    type RequestStream = RuleWatcherV6RequestStream;
546    #[cfg(target_os = "fuchsia")]
547    type SynchronousProxy = RuleWatcherV6SynchronousProxy;
548
549    const DEBUG_NAME: &'static str = "(anonymous) RuleWatcherV6";
550}
551
552pub trait RuleWatcherV6ProxyInterface: Send + Sync {
553    type WatchResponseFut: std::future::Future<Output = Result<Vec<RuleEventV6>, fidl::Error>>
554        + Send;
555    fn r#watch(&self) -> Self::WatchResponseFut;
556}
557#[derive(Debug)]
558#[cfg(target_os = "fuchsia")]
559pub struct RuleWatcherV6SynchronousProxy {
560    client: fidl::client::sync::Client,
561}
562
563#[cfg(target_os = "fuchsia")]
564impl fidl::endpoints::SynchronousProxy for RuleWatcherV6SynchronousProxy {
565    type Proxy = RuleWatcherV6Proxy;
566    type Protocol = RuleWatcherV6Marker;
567
568    fn from_channel(inner: fidl::Channel) -> Self {
569        Self::new(inner)
570    }
571
572    fn into_channel(self) -> fidl::Channel {
573        self.client.into_channel()
574    }
575
576    fn as_channel(&self) -> &fidl::Channel {
577        self.client.as_channel()
578    }
579}
580
581#[cfg(target_os = "fuchsia")]
582impl RuleWatcherV6SynchronousProxy {
583    pub fn new(channel: fidl::Channel) -> Self {
584        let protocol_name = <RuleWatcherV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
585        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
586    }
587
588    pub fn into_channel(self) -> fidl::Channel {
589        self.client.into_channel()
590    }
591
592    /// Waits until an event arrives and returns it. It is safe for other
593    /// threads to make concurrent requests while waiting for an event.
594    pub fn wait_for_event(
595        &self,
596        deadline: zx::MonotonicInstant,
597    ) -> Result<RuleWatcherV6Event, fidl::Error> {
598        RuleWatcherV6Event::decode(self.client.wait_for_event(deadline)?)
599    }
600
601    /// Hanging-Get style API for observing routing rule changes.
602    ///
603    /// Clients must only have one pending `Watch` call at a time. Calling
604    /// `Watch` while a request is already pending will cause the protocol to
605    /// close.
606    ///
607    /// The first N events will always be `existing` where N is the number of
608    /// IPv6 rules that already existed when the server-end of the protocol was
609    /// initialized. The following event will be `idle` signaling the end of the
610    /// `existing` events. At this point the client has watched all existing
611    /// state and will never again observe an `existing` event.
612    ///
613    /// - response `events` A vector of at most `MAX_EVENTS` events.
614    pub fn r#watch(
615        &self,
616        ___deadline: zx::MonotonicInstant,
617    ) -> Result<Vec<RuleEventV6>, fidl::Error> {
618        let _response =
619            self.client.send_query::<fidl::encoding::EmptyPayload, RuleWatcherV6WatchResponse>(
620                (),
621                0x5ccd746122bfa678,
622                fidl::encoding::DynamicFlags::empty(),
623                ___deadline,
624            )?;
625        Ok(_response.events)
626    }
627}
628
629#[cfg(target_os = "fuchsia")]
630impl From<RuleWatcherV6SynchronousProxy> for zx::Handle {
631    fn from(value: RuleWatcherV6SynchronousProxy) -> Self {
632        value.into_channel().into()
633    }
634}
635
636#[cfg(target_os = "fuchsia")]
637impl From<fidl::Channel> for RuleWatcherV6SynchronousProxy {
638    fn from(value: fidl::Channel) -> Self {
639        Self::new(value)
640    }
641}
642
643#[cfg(target_os = "fuchsia")]
644impl fidl::endpoints::FromClient for RuleWatcherV6SynchronousProxy {
645    type Protocol = RuleWatcherV6Marker;
646
647    fn from_client(value: fidl::endpoints::ClientEnd<RuleWatcherV6Marker>) -> Self {
648        Self::new(value.into_channel())
649    }
650}
651
652#[derive(Debug, Clone)]
653pub struct RuleWatcherV6Proxy {
654    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
655}
656
657impl fidl::endpoints::Proxy for RuleWatcherV6Proxy {
658    type Protocol = RuleWatcherV6Marker;
659
660    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
661        Self::new(inner)
662    }
663
664    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
665        self.client.into_channel().map_err(|client| Self { client })
666    }
667
668    fn as_channel(&self) -> &::fidl::AsyncChannel {
669        self.client.as_channel()
670    }
671}
672
673impl RuleWatcherV6Proxy {
674    /// Create a new Proxy for fuchsia.net.routes/RuleWatcherV6.
675    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
676        let protocol_name = <RuleWatcherV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
677        Self { client: fidl::client::Client::new(channel, protocol_name) }
678    }
679
680    /// Get a Stream of events from the remote end of the protocol.
681    ///
682    /// # Panics
683    ///
684    /// Panics if the event stream was already taken.
685    pub fn take_event_stream(&self) -> RuleWatcherV6EventStream {
686        RuleWatcherV6EventStream { event_receiver: self.client.take_event_receiver() }
687    }
688
689    /// Hanging-Get style API for observing routing rule changes.
690    ///
691    /// Clients must only have one pending `Watch` call at a time. Calling
692    /// `Watch` while a request is already pending will cause the protocol to
693    /// close.
694    ///
695    /// The first N events will always be `existing` where N is the number of
696    /// IPv6 rules that already existed when the server-end of the protocol was
697    /// initialized. The following event will be `idle` signaling the end of the
698    /// `existing` events. At this point the client has watched all existing
699    /// state and will never again observe an `existing` event.
700    ///
701    /// - response `events` A vector of at most `MAX_EVENTS` events.
702    pub fn r#watch(
703        &self,
704    ) -> fidl::client::QueryResponseFut<
705        Vec<RuleEventV6>,
706        fidl::encoding::DefaultFuchsiaResourceDialect,
707    > {
708        RuleWatcherV6ProxyInterface::r#watch(self)
709    }
710}
711
712impl RuleWatcherV6ProxyInterface for RuleWatcherV6Proxy {
713    type WatchResponseFut = fidl::client::QueryResponseFut<
714        Vec<RuleEventV6>,
715        fidl::encoding::DefaultFuchsiaResourceDialect,
716    >;
717    fn r#watch(&self) -> Self::WatchResponseFut {
718        fn _decode(
719            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
720        ) -> Result<Vec<RuleEventV6>, fidl::Error> {
721            let _response = fidl::client::decode_transaction_body::<
722                RuleWatcherV6WatchResponse,
723                fidl::encoding::DefaultFuchsiaResourceDialect,
724                0x5ccd746122bfa678,
725            >(_buf?)?;
726            Ok(_response.events)
727        }
728        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<RuleEventV6>>(
729            (),
730            0x5ccd746122bfa678,
731            fidl::encoding::DynamicFlags::empty(),
732            _decode,
733        )
734    }
735}
736
737pub struct RuleWatcherV6EventStream {
738    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
739}
740
741impl std::marker::Unpin for RuleWatcherV6EventStream {}
742
743impl futures::stream::FusedStream for RuleWatcherV6EventStream {
744    fn is_terminated(&self) -> bool {
745        self.event_receiver.is_terminated()
746    }
747}
748
749impl futures::Stream for RuleWatcherV6EventStream {
750    type Item = Result<RuleWatcherV6Event, fidl::Error>;
751
752    fn poll_next(
753        mut self: std::pin::Pin<&mut Self>,
754        cx: &mut std::task::Context<'_>,
755    ) -> std::task::Poll<Option<Self::Item>> {
756        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
757            &mut self.event_receiver,
758            cx
759        )?) {
760            Some(buf) => std::task::Poll::Ready(Some(RuleWatcherV6Event::decode(buf))),
761            None => std::task::Poll::Ready(None),
762        }
763    }
764}
765
766#[derive(Debug)]
767pub enum RuleWatcherV6Event {}
768
769impl RuleWatcherV6Event {
770    /// Decodes a message buffer as a [`RuleWatcherV6Event`].
771    fn decode(
772        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
773    ) -> Result<RuleWatcherV6Event, fidl::Error> {
774        let (bytes, _handles) = buf.split_mut();
775        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
776        debug_assert_eq!(tx_header.tx_id, 0);
777        match tx_header.ordinal {
778            _ => Err(fidl::Error::UnknownOrdinal {
779                ordinal: tx_header.ordinal,
780                protocol_name: <RuleWatcherV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
781            }),
782        }
783    }
784}
785
786/// A Stream of incoming requests for fuchsia.net.routes/RuleWatcherV6.
787pub struct RuleWatcherV6RequestStream {
788    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
789    is_terminated: bool,
790}
791
792impl std::marker::Unpin for RuleWatcherV6RequestStream {}
793
794impl futures::stream::FusedStream for RuleWatcherV6RequestStream {
795    fn is_terminated(&self) -> bool {
796        self.is_terminated
797    }
798}
799
800impl fidl::endpoints::RequestStream for RuleWatcherV6RequestStream {
801    type Protocol = RuleWatcherV6Marker;
802    type ControlHandle = RuleWatcherV6ControlHandle;
803
804    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
805        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
806    }
807
808    fn control_handle(&self) -> Self::ControlHandle {
809        RuleWatcherV6ControlHandle { inner: self.inner.clone() }
810    }
811
812    fn into_inner(
813        self,
814    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
815    {
816        (self.inner, self.is_terminated)
817    }
818
819    fn from_inner(
820        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
821        is_terminated: bool,
822    ) -> Self {
823        Self { inner, is_terminated }
824    }
825}
826
827impl futures::Stream for RuleWatcherV6RequestStream {
828    type Item = Result<RuleWatcherV6Request, fidl::Error>;
829
830    fn poll_next(
831        mut self: std::pin::Pin<&mut Self>,
832        cx: &mut std::task::Context<'_>,
833    ) -> std::task::Poll<Option<Self::Item>> {
834        let this = &mut *self;
835        if this.inner.check_shutdown(cx) {
836            this.is_terminated = true;
837            return std::task::Poll::Ready(None);
838        }
839        if this.is_terminated {
840            panic!("polled RuleWatcherV6RequestStream after completion");
841        }
842        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
843            |bytes, handles| {
844                match this.inner.channel().read_etc(cx, bytes, handles) {
845                    std::task::Poll::Ready(Ok(())) => {}
846                    std::task::Poll::Pending => return std::task::Poll::Pending,
847                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
848                        this.is_terminated = true;
849                        return std::task::Poll::Ready(None);
850                    }
851                    std::task::Poll::Ready(Err(e)) => {
852                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
853                            e.into(),
854                        ))))
855                    }
856                }
857
858                // A message has been received from the channel
859                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
860
861                std::task::Poll::Ready(Some(match header.ordinal {
862                    0x5ccd746122bfa678 => {
863                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
864                        let mut req = fidl::new_empty!(
865                            fidl::encoding::EmptyPayload,
866                            fidl::encoding::DefaultFuchsiaResourceDialect
867                        );
868                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
869                        let control_handle =
870                            RuleWatcherV6ControlHandle { inner: this.inner.clone() };
871                        Ok(RuleWatcherV6Request::Watch {
872                            responder: RuleWatcherV6WatchResponder {
873                                control_handle: std::mem::ManuallyDrop::new(control_handle),
874                                tx_id: header.tx_id,
875                            },
876                        })
877                    }
878                    _ => Err(fidl::Error::UnknownOrdinal {
879                        ordinal: header.ordinal,
880                        protocol_name:
881                            <RuleWatcherV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
882                    }),
883                }))
884            },
885        )
886    }
887}
888
889/// An observer protocol for changes in the system's IPv6 rules table.
890#[derive(Debug)]
891pub enum RuleWatcherV6Request {
892    /// Hanging-Get style API for observing routing rule changes.
893    ///
894    /// Clients must only have one pending `Watch` call at a time. Calling
895    /// `Watch` while a request is already pending will cause the protocol to
896    /// close.
897    ///
898    /// The first N events will always be `existing` where N is the number of
899    /// IPv6 rules that already existed when the server-end of the protocol was
900    /// initialized. The following event will be `idle` signaling the end of the
901    /// `existing` events. At this point the client has watched all existing
902    /// state and will never again observe an `existing` event.
903    ///
904    /// - response `events` A vector of at most `MAX_EVENTS` events.
905    Watch { responder: RuleWatcherV6WatchResponder },
906}
907
908impl RuleWatcherV6Request {
909    #[allow(irrefutable_let_patterns)]
910    pub fn into_watch(self) -> Option<(RuleWatcherV6WatchResponder)> {
911        if let RuleWatcherV6Request::Watch { responder } = self {
912            Some((responder))
913        } else {
914            None
915        }
916    }
917
918    /// Name of the method defined in FIDL
919    pub fn method_name(&self) -> &'static str {
920        match *self {
921            RuleWatcherV6Request::Watch { .. } => "watch",
922        }
923    }
924}
925
926#[derive(Debug, Clone)]
927pub struct RuleWatcherV6ControlHandle {
928    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
929}
930
931impl fidl::endpoints::ControlHandle for RuleWatcherV6ControlHandle {
932    fn shutdown(&self) {
933        self.inner.shutdown()
934    }
935    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
936        self.inner.shutdown_with_epitaph(status)
937    }
938
939    fn is_closed(&self) -> bool {
940        self.inner.channel().is_closed()
941    }
942    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
943        self.inner.channel().on_closed()
944    }
945
946    #[cfg(target_os = "fuchsia")]
947    fn signal_peer(
948        &self,
949        clear_mask: zx::Signals,
950        set_mask: zx::Signals,
951    ) -> Result<(), zx_status::Status> {
952        use fidl::Peered;
953        self.inner.channel().signal_peer(clear_mask, set_mask)
954    }
955}
956
957impl RuleWatcherV6ControlHandle {}
958
959#[must_use = "FIDL methods require a response to be sent"]
960#[derive(Debug)]
961pub struct RuleWatcherV6WatchResponder {
962    control_handle: std::mem::ManuallyDrop<RuleWatcherV6ControlHandle>,
963    tx_id: u32,
964}
965
966/// Set the the channel to be shutdown (see [`RuleWatcherV6ControlHandle::shutdown`])
967/// if the responder is dropped without sending a response, so that the client
968/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
969impl std::ops::Drop for RuleWatcherV6WatchResponder {
970    fn drop(&mut self) {
971        self.control_handle.shutdown();
972        // Safety: drops once, never accessed again
973        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
974    }
975}
976
977impl fidl::endpoints::Responder for RuleWatcherV6WatchResponder {
978    type ControlHandle = RuleWatcherV6ControlHandle;
979
980    fn control_handle(&self) -> &RuleWatcherV6ControlHandle {
981        &self.control_handle
982    }
983
984    fn drop_without_shutdown(mut self) {
985        // Safety: drops once, never accessed again due to mem::forget
986        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
987        // Prevent Drop from running (which would shut down the channel)
988        std::mem::forget(self);
989    }
990}
991
992impl RuleWatcherV6WatchResponder {
993    /// Sends a response to the FIDL transaction.
994    ///
995    /// Sets the channel to shutdown if an error occurs.
996    pub fn send(self, mut events: &[RuleEventV6]) -> Result<(), fidl::Error> {
997        let _result = self.send_raw(events);
998        if _result.is_err() {
999            self.control_handle.shutdown();
1000        }
1001        self.drop_without_shutdown();
1002        _result
1003    }
1004
1005    /// Similar to "send" but does not shutdown the channel if an error occurs.
1006    pub fn send_no_shutdown_on_err(self, mut events: &[RuleEventV6]) -> Result<(), fidl::Error> {
1007        let _result = self.send_raw(events);
1008        self.drop_without_shutdown();
1009        _result
1010    }
1011
1012    fn send_raw(&self, mut events: &[RuleEventV6]) -> Result<(), fidl::Error> {
1013        self.control_handle.inner.send::<RuleWatcherV6WatchResponse>(
1014            (events,),
1015            self.tx_id,
1016            0x5ccd746122bfa678,
1017            fidl::encoding::DynamicFlags::empty(),
1018        )
1019    }
1020}
1021
1022#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1023pub struct StateMarker;
1024
1025impl fidl::endpoints::ProtocolMarker for StateMarker {
1026    type Proxy = StateProxy;
1027    type RequestStream = StateRequestStream;
1028    #[cfg(target_os = "fuchsia")]
1029    type SynchronousProxy = StateSynchronousProxy;
1030
1031    const DEBUG_NAME: &'static str = "fuchsia.net.routes.State";
1032}
1033impl fidl::endpoints::DiscoverableProtocolMarker for StateMarker {}
1034pub type StateResolveResult = Result<Resolved, i32>;
1035pub type StateResolve2Result = Result<ResolveResult, ResolveError>;
1036pub type StateGetRouteTableNameResult = Result<String, StateGetRouteTableNameError>;
1037
1038pub trait StateProxyInterface: Send + Sync {
1039    type ResolveResponseFut: std::future::Future<Output = Result<StateResolveResult, fidl::Error>>
1040        + Send;
1041    fn r#resolve(&self, destination: &fidl_fuchsia_net::IpAddress) -> Self::ResolveResponseFut;
1042    type Resolve2ResponseFut: std::future::Future<Output = Result<StateResolve2Result, fidl::Error>>
1043        + Send;
1044    fn r#resolve2(
1045        &self,
1046        destination: &fidl_fuchsia_net::IpAddress,
1047        options: &ResolveOptions,
1048    ) -> Self::Resolve2ResponseFut;
1049    type GetRouteTableNameResponseFut: std::future::Future<Output = Result<StateGetRouteTableNameResult, fidl::Error>>
1050        + Send;
1051    fn r#get_route_table_name(&self, table_id: u32) -> Self::GetRouteTableNameResponseFut;
1052}
1053#[derive(Debug)]
1054#[cfg(target_os = "fuchsia")]
1055pub struct StateSynchronousProxy {
1056    client: fidl::client::sync::Client,
1057}
1058
1059#[cfg(target_os = "fuchsia")]
1060impl fidl::endpoints::SynchronousProxy for StateSynchronousProxy {
1061    type Proxy = StateProxy;
1062    type Protocol = StateMarker;
1063
1064    fn from_channel(inner: fidl::Channel) -> Self {
1065        Self::new(inner)
1066    }
1067
1068    fn into_channel(self) -> fidl::Channel {
1069        self.client.into_channel()
1070    }
1071
1072    fn as_channel(&self) -> &fidl::Channel {
1073        self.client.as_channel()
1074    }
1075}
1076
1077#[cfg(target_os = "fuchsia")]
1078impl StateSynchronousProxy {
1079    pub fn new(channel: fidl::Channel) -> Self {
1080        let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1081        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1082    }
1083
1084    pub fn into_channel(self) -> fidl::Channel {
1085        self.client.into_channel()
1086    }
1087
1088    /// Waits until an event arrives and returns it. It is safe for other
1089    /// threads to make concurrent requests while waiting for an event.
1090    pub fn wait_for_event(
1091        &self,
1092        deadline: zx::MonotonicInstant,
1093    ) -> Result<StateEvent, fidl::Error> {
1094        StateEvent::decode(self.client.wait_for_event(deadline)?)
1095    }
1096
1097    /// Resolves the route to a destination.
1098    ///
1099    /// + request `destination` the IP address to resolve a route to. If the
1100    ///     unspecified address (all zeroes) is provided, the default route will
1101    ///     be returned. The variant of `destination` determines variant of
1102    ///     [`fuchsia.net/IpAddress`] fields in the resolved route.
1103    /// - response `result` contains the resolved route to `destination`.
1104    /// * error `ZX_ERR_ADDRESS_UNREACHABLE` if `destination` can't be resolved.
1105    pub fn r#resolve(
1106        &self,
1107        mut destination: &fidl_fuchsia_net::IpAddress,
1108        ___deadline: zx::MonotonicInstant,
1109    ) -> Result<StateResolveResult, fidl::Error> {
1110        let _response = self.client.send_query::<
1111            StateResolveRequest,
1112            fidl::encoding::ResultType<StateResolveResponse, i32>,
1113        >(
1114            (destination,),
1115            0x1541bc37d2d1dfb0,
1116            fidl::encoding::DynamicFlags::empty(),
1117            ___deadline,
1118        )?;
1119        Ok(_response.map(|x| x.result))
1120    }
1121
1122    /// Resolves the route to a destination.
1123    ///
1124    /// + request `destination` the IP address to resolve a route to. If the
1125    ///     unspecified address (all zeroes) is provided, the default route will
1126    ///     be returned. The variant of `destination` determines variant of
1127    ///     [`fuchsia.net/IpAddress`] fields in the resolved route.
1128    /// + request `options` contains optional information used for the route resolution.
1129    /// - response `result` contains the resolved route to `destination`.
1130    /// * error `ADDRESS_UNREACHABLE` if `destination` can't be resolved.
1131    pub fn r#resolve2(
1132        &self,
1133        mut destination: &fidl_fuchsia_net::IpAddress,
1134        mut options: &ResolveOptions,
1135        ___deadline: zx::MonotonicInstant,
1136    ) -> Result<StateResolve2Result, fidl::Error> {
1137        let _response = self.client.send_query::<StateResolve2Request, fidl::encoding::ResultType<
1138            StateResolve2Response,
1139            ResolveError,
1140        >>(
1141            (destination, options),
1142            0x3a37608b6851f75c,
1143            fidl::encoding::DynamicFlags::empty(),
1144            ___deadline,
1145        )?;
1146        Ok(_response.map(|x| x.result))
1147    }
1148
1149    /// Gets the route table name by its ID.
1150    ///
1151    /// + request `table_id` the ID of the route table in question.
1152    /// - response `table_name` the name of the route table, if the route table
1153    /// does not have a name, an empty string is returned.
1154    /// * error `NO_TABLE` if the route table does not exist.
1155    pub fn r#get_route_table_name(
1156        &self,
1157        mut table_id: u32,
1158        ___deadline: zx::MonotonicInstant,
1159    ) -> Result<StateGetRouteTableNameResult, fidl::Error> {
1160        let _response =
1161            self.client.send_query::<StateGetRouteTableNameRequest, fidl::encoding::ResultType<
1162                StateGetRouteTableNameResponse,
1163                StateGetRouteTableNameError,
1164            >>(
1165                (table_id,),
1166                0x6fed5423c7ce421a,
1167                fidl::encoding::DynamicFlags::empty(),
1168                ___deadline,
1169            )?;
1170        Ok(_response.map(|x| x.table_name))
1171    }
1172}
1173
1174#[cfg(target_os = "fuchsia")]
1175impl From<StateSynchronousProxy> for zx::Handle {
1176    fn from(value: StateSynchronousProxy) -> Self {
1177        value.into_channel().into()
1178    }
1179}
1180
1181#[cfg(target_os = "fuchsia")]
1182impl From<fidl::Channel> for StateSynchronousProxy {
1183    fn from(value: fidl::Channel) -> Self {
1184        Self::new(value)
1185    }
1186}
1187
1188#[cfg(target_os = "fuchsia")]
1189impl fidl::endpoints::FromClient for StateSynchronousProxy {
1190    type Protocol = StateMarker;
1191
1192    fn from_client(value: fidl::endpoints::ClientEnd<StateMarker>) -> Self {
1193        Self::new(value.into_channel())
1194    }
1195}
1196
1197#[derive(Debug, Clone)]
1198pub struct StateProxy {
1199    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1200}
1201
1202impl fidl::endpoints::Proxy for StateProxy {
1203    type Protocol = StateMarker;
1204
1205    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1206        Self::new(inner)
1207    }
1208
1209    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1210        self.client.into_channel().map_err(|client| Self { client })
1211    }
1212
1213    fn as_channel(&self) -> &::fidl::AsyncChannel {
1214        self.client.as_channel()
1215    }
1216}
1217
1218impl StateProxy {
1219    /// Create a new Proxy for fuchsia.net.routes/State.
1220    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1221        let protocol_name = <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1222        Self { client: fidl::client::Client::new(channel, protocol_name) }
1223    }
1224
1225    /// Get a Stream of events from the remote end of the protocol.
1226    ///
1227    /// # Panics
1228    ///
1229    /// Panics if the event stream was already taken.
1230    pub fn take_event_stream(&self) -> StateEventStream {
1231        StateEventStream { event_receiver: self.client.take_event_receiver() }
1232    }
1233
1234    /// Resolves the route to a destination.
1235    ///
1236    /// + request `destination` the IP address to resolve a route to. If the
1237    ///     unspecified address (all zeroes) is provided, the default route will
1238    ///     be returned. The variant of `destination` determines variant of
1239    ///     [`fuchsia.net/IpAddress`] fields in the resolved route.
1240    /// - response `result` contains the resolved route to `destination`.
1241    /// * error `ZX_ERR_ADDRESS_UNREACHABLE` if `destination` can't be resolved.
1242    pub fn r#resolve(
1243        &self,
1244        mut destination: &fidl_fuchsia_net::IpAddress,
1245    ) -> fidl::client::QueryResponseFut<
1246        StateResolveResult,
1247        fidl::encoding::DefaultFuchsiaResourceDialect,
1248    > {
1249        StateProxyInterface::r#resolve(self, destination)
1250    }
1251
1252    /// Resolves the route to a destination.
1253    ///
1254    /// + request `destination` the IP address to resolve a route to. If the
1255    ///     unspecified address (all zeroes) is provided, the default route will
1256    ///     be returned. The variant of `destination` determines variant of
1257    ///     [`fuchsia.net/IpAddress`] fields in the resolved route.
1258    /// + request `options` contains optional information used for the route resolution.
1259    /// - response `result` contains the resolved route to `destination`.
1260    /// * error `ADDRESS_UNREACHABLE` if `destination` can't be resolved.
1261    pub fn r#resolve2(
1262        &self,
1263        mut destination: &fidl_fuchsia_net::IpAddress,
1264        mut options: &ResolveOptions,
1265    ) -> fidl::client::QueryResponseFut<
1266        StateResolve2Result,
1267        fidl::encoding::DefaultFuchsiaResourceDialect,
1268    > {
1269        StateProxyInterface::r#resolve2(self, destination, options)
1270    }
1271
1272    /// Gets the route table name by its ID.
1273    ///
1274    /// + request `table_id` the ID of the route table in question.
1275    /// - response `table_name` the name of the route table, if the route table
1276    /// does not have a name, an empty string is returned.
1277    /// * error `NO_TABLE` if the route table does not exist.
1278    pub fn r#get_route_table_name(
1279        &self,
1280        mut table_id: u32,
1281    ) -> fidl::client::QueryResponseFut<
1282        StateGetRouteTableNameResult,
1283        fidl::encoding::DefaultFuchsiaResourceDialect,
1284    > {
1285        StateProxyInterface::r#get_route_table_name(self, table_id)
1286    }
1287}
1288
1289impl StateProxyInterface for StateProxy {
1290    type ResolveResponseFut = fidl::client::QueryResponseFut<
1291        StateResolveResult,
1292        fidl::encoding::DefaultFuchsiaResourceDialect,
1293    >;
1294    fn r#resolve(&self, mut destination: &fidl_fuchsia_net::IpAddress) -> Self::ResolveResponseFut {
1295        fn _decode(
1296            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1297        ) -> Result<StateResolveResult, fidl::Error> {
1298            let _response = fidl::client::decode_transaction_body::<
1299                fidl::encoding::ResultType<StateResolveResponse, i32>,
1300                fidl::encoding::DefaultFuchsiaResourceDialect,
1301                0x1541bc37d2d1dfb0,
1302            >(_buf?)?;
1303            Ok(_response.map(|x| x.result))
1304        }
1305        self.client.send_query_and_decode::<StateResolveRequest, StateResolveResult>(
1306            (destination,),
1307            0x1541bc37d2d1dfb0,
1308            fidl::encoding::DynamicFlags::empty(),
1309            _decode,
1310        )
1311    }
1312
1313    type Resolve2ResponseFut = fidl::client::QueryResponseFut<
1314        StateResolve2Result,
1315        fidl::encoding::DefaultFuchsiaResourceDialect,
1316    >;
1317    fn r#resolve2(
1318        &self,
1319        mut destination: &fidl_fuchsia_net::IpAddress,
1320        mut options: &ResolveOptions,
1321    ) -> Self::Resolve2ResponseFut {
1322        fn _decode(
1323            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1324        ) -> Result<StateResolve2Result, fidl::Error> {
1325            let _response = fidl::client::decode_transaction_body::<
1326                fidl::encoding::ResultType<StateResolve2Response, ResolveError>,
1327                fidl::encoding::DefaultFuchsiaResourceDialect,
1328                0x3a37608b6851f75c,
1329            >(_buf?)?;
1330            Ok(_response.map(|x| x.result))
1331        }
1332        self.client.send_query_and_decode::<StateResolve2Request, StateResolve2Result>(
1333            (destination, options),
1334            0x3a37608b6851f75c,
1335            fidl::encoding::DynamicFlags::empty(),
1336            _decode,
1337        )
1338    }
1339
1340    type GetRouteTableNameResponseFut = fidl::client::QueryResponseFut<
1341        StateGetRouteTableNameResult,
1342        fidl::encoding::DefaultFuchsiaResourceDialect,
1343    >;
1344    fn r#get_route_table_name(&self, mut table_id: u32) -> Self::GetRouteTableNameResponseFut {
1345        fn _decode(
1346            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1347        ) -> Result<StateGetRouteTableNameResult, fidl::Error> {
1348            let _response = fidl::client::decode_transaction_body::<
1349                fidl::encoding::ResultType<
1350                    StateGetRouteTableNameResponse,
1351                    StateGetRouteTableNameError,
1352                >,
1353                fidl::encoding::DefaultFuchsiaResourceDialect,
1354                0x6fed5423c7ce421a,
1355            >(_buf?)?;
1356            Ok(_response.map(|x| x.table_name))
1357        }
1358        self.client
1359            .send_query_and_decode::<StateGetRouteTableNameRequest, StateGetRouteTableNameResult>(
1360                (table_id,),
1361                0x6fed5423c7ce421a,
1362                fidl::encoding::DynamicFlags::empty(),
1363                _decode,
1364            )
1365    }
1366}
1367
1368pub struct StateEventStream {
1369    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1370}
1371
1372impl std::marker::Unpin for StateEventStream {}
1373
1374impl futures::stream::FusedStream for StateEventStream {
1375    fn is_terminated(&self) -> bool {
1376        self.event_receiver.is_terminated()
1377    }
1378}
1379
1380impl futures::Stream for StateEventStream {
1381    type Item = Result<StateEvent, fidl::Error>;
1382
1383    fn poll_next(
1384        mut self: std::pin::Pin<&mut Self>,
1385        cx: &mut std::task::Context<'_>,
1386    ) -> std::task::Poll<Option<Self::Item>> {
1387        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1388            &mut self.event_receiver,
1389            cx
1390        )?) {
1391            Some(buf) => std::task::Poll::Ready(Some(StateEvent::decode(buf))),
1392            None => std::task::Poll::Ready(None),
1393        }
1394    }
1395}
1396
1397#[derive(Debug)]
1398pub enum StateEvent {}
1399
1400impl StateEvent {
1401    /// Decodes a message buffer as a [`StateEvent`].
1402    fn decode(
1403        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1404    ) -> Result<StateEvent, fidl::Error> {
1405        let (bytes, _handles) = buf.split_mut();
1406        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1407        debug_assert_eq!(tx_header.tx_id, 0);
1408        match tx_header.ordinal {
1409            _ => Err(fidl::Error::UnknownOrdinal {
1410                ordinal: tx_header.ordinal,
1411                protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1412            }),
1413        }
1414    }
1415}
1416
1417/// A Stream of incoming requests for fuchsia.net.routes/State.
1418pub struct StateRequestStream {
1419    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1420    is_terminated: bool,
1421}
1422
1423impl std::marker::Unpin for StateRequestStream {}
1424
1425impl futures::stream::FusedStream for StateRequestStream {
1426    fn is_terminated(&self) -> bool {
1427        self.is_terminated
1428    }
1429}
1430
1431impl fidl::endpoints::RequestStream for StateRequestStream {
1432    type Protocol = StateMarker;
1433    type ControlHandle = StateControlHandle;
1434
1435    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1436        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1437    }
1438
1439    fn control_handle(&self) -> Self::ControlHandle {
1440        StateControlHandle { inner: self.inner.clone() }
1441    }
1442
1443    fn into_inner(
1444        self,
1445    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1446    {
1447        (self.inner, self.is_terminated)
1448    }
1449
1450    fn from_inner(
1451        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1452        is_terminated: bool,
1453    ) -> Self {
1454        Self { inner, is_terminated }
1455    }
1456}
1457
1458impl futures::Stream for StateRequestStream {
1459    type Item = Result<StateRequest, fidl::Error>;
1460
1461    fn poll_next(
1462        mut self: std::pin::Pin<&mut Self>,
1463        cx: &mut std::task::Context<'_>,
1464    ) -> std::task::Poll<Option<Self::Item>> {
1465        let this = &mut *self;
1466        if this.inner.check_shutdown(cx) {
1467            this.is_terminated = true;
1468            return std::task::Poll::Ready(None);
1469        }
1470        if this.is_terminated {
1471            panic!("polled StateRequestStream after completion");
1472        }
1473        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1474            |bytes, handles| {
1475                match this.inner.channel().read_etc(cx, bytes, handles) {
1476                    std::task::Poll::Ready(Ok(())) => {}
1477                    std::task::Poll::Pending => return std::task::Poll::Pending,
1478                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1479                        this.is_terminated = true;
1480                        return std::task::Poll::Ready(None);
1481                    }
1482                    std::task::Poll::Ready(Err(e)) => {
1483                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1484                            e.into(),
1485                        ))))
1486                    }
1487                }
1488
1489                // A message has been received from the channel
1490                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1491
1492                std::task::Poll::Ready(Some(match header.ordinal {
1493                    0x1541bc37d2d1dfb0 => {
1494                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1495                        let mut req = fidl::new_empty!(
1496                            StateResolveRequest,
1497                            fidl::encoding::DefaultFuchsiaResourceDialect
1498                        );
1499                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateResolveRequest>(&header, _body_bytes, handles, &mut req)?;
1500                        let control_handle = StateControlHandle { inner: this.inner.clone() };
1501                        Ok(StateRequest::Resolve {
1502                            destination: req.destination,
1503
1504                            responder: StateResolveResponder {
1505                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1506                                tx_id: header.tx_id,
1507                            },
1508                        })
1509                    }
1510                    0x3a37608b6851f75c => {
1511                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1512                        let mut req = fidl::new_empty!(
1513                            StateResolve2Request,
1514                            fidl::encoding::DefaultFuchsiaResourceDialect
1515                        );
1516                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateResolve2Request>(&header, _body_bytes, handles, &mut req)?;
1517                        let control_handle = StateControlHandle { inner: this.inner.clone() };
1518                        Ok(StateRequest::Resolve2 {
1519                            destination: req.destination,
1520                            options: req.options,
1521
1522                            responder: StateResolve2Responder {
1523                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1524                                tx_id: header.tx_id,
1525                            },
1526                        })
1527                    }
1528                    0x6fed5423c7ce421a => {
1529                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1530                        let mut req = fidl::new_empty!(
1531                            StateGetRouteTableNameRequest,
1532                            fidl::encoding::DefaultFuchsiaResourceDialect
1533                        );
1534                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateGetRouteTableNameRequest>(&header, _body_bytes, handles, &mut req)?;
1535                        let control_handle = StateControlHandle { inner: this.inner.clone() };
1536                        Ok(StateRequest::GetRouteTableName {
1537                            table_id: req.table_id,
1538
1539                            responder: StateGetRouteTableNameResponder {
1540                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1541                                tx_id: header.tx_id,
1542                            },
1543                        })
1544                    }
1545                    _ => Err(fidl::Error::UnknownOrdinal {
1546                        ordinal: header.ordinal,
1547                        protocol_name: <StateMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1548                    }),
1549                }))
1550            },
1551        )
1552    }
1553}
1554
1555/// Provides access to the system's routing state.
1556#[derive(Debug)]
1557pub enum StateRequest {
1558    /// Resolves the route to a destination.
1559    ///
1560    /// + request `destination` the IP address to resolve a route to. If the
1561    ///     unspecified address (all zeroes) is provided, the default route will
1562    ///     be returned. The variant of `destination` determines variant of
1563    ///     [`fuchsia.net/IpAddress`] fields in the resolved route.
1564    /// - response `result` contains the resolved route to `destination`.
1565    /// * error `ZX_ERR_ADDRESS_UNREACHABLE` if `destination` can't be resolved.
1566    Resolve { destination: fidl_fuchsia_net::IpAddress, responder: StateResolveResponder },
1567    /// Resolves the route to a destination.
1568    ///
1569    /// + request `destination` the IP address to resolve a route to. If the
1570    ///     unspecified address (all zeroes) is provided, the default route will
1571    ///     be returned. The variant of `destination` determines variant of
1572    ///     [`fuchsia.net/IpAddress`] fields in the resolved route.
1573    /// + request `options` contains optional information used for the route resolution.
1574    /// - response `result` contains the resolved route to `destination`.
1575    /// * error `ADDRESS_UNREACHABLE` if `destination` can't be resolved.
1576    Resolve2 {
1577        destination: fidl_fuchsia_net::IpAddress,
1578        options: ResolveOptions,
1579        responder: StateResolve2Responder,
1580    },
1581    /// Gets the route table name by its ID.
1582    ///
1583    /// + request `table_id` the ID of the route table in question.
1584    /// - response `table_name` the name of the route table, if the route table
1585    /// does not have a name, an empty string is returned.
1586    /// * error `NO_TABLE` if the route table does not exist.
1587    GetRouteTableName { table_id: u32, responder: StateGetRouteTableNameResponder },
1588}
1589
1590impl StateRequest {
1591    #[allow(irrefutable_let_patterns)]
1592    pub fn into_resolve(self) -> Option<(fidl_fuchsia_net::IpAddress, StateResolveResponder)> {
1593        if let StateRequest::Resolve { destination, responder } = self {
1594            Some((destination, responder))
1595        } else {
1596            None
1597        }
1598    }
1599
1600    #[allow(irrefutable_let_patterns)]
1601    pub fn into_resolve2(
1602        self,
1603    ) -> Option<(fidl_fuchsia_net::IpAddress, ResolveOptions, StateResolve2Responder)> {
1604        if let StateRequest::Resolve2 { destination, options, responder } = self {
1605            Some((destination, options, responder))
1606        } else {
1607            None
1608        }
1609    }
1610
1611    #[allow(irrefutable_let_patterns)]
1612    pub fn into_get_route_table_name(self) -> Option<(u32, StateGetRouteTableNameResponder)> {
1613        if let StateRequest::GetRouteTableName { table_id, responder } = self {
1614            Some((table_id, responder))
1615        } else {
1616            None
1617        }
1618    }
1619
1620    /// Name of the method defined in FIDL
1621    pub fn method_name(&self) -> &'static str {
1622        match *self {
1623            StateRequest::Resolve { .. } => "resolve",
1624            StateRequest::Resolve2 { .. } => "resolve2",
1625            StateRequest::GetRouteTableName { .. } => "get_route_table_name",
1626        }
1627    }
1628}
1629
1630#[derive(Debug, Clone)]
1631pub struct StateControlHandle {
1632    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1633}
1634
1635impl fidl::endpoints::ControlHandle for StateControlHandle {
1636    fn shutdown(&self) {
1637        self.inner.shutdown()
1638    }
1639    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1640        self.inner.shutdown_with_epitaph(status)
1641    }
1642
1643    fn is_closed(&self) -> bool {
1644        self.inner.channel().is_closed()
1645    }
1646    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1647        self.inner.channel().on_closed()
1648    }
1649
1650    #[cfg(target_os = "fuchsia")]
1651    fn signal_peer(
1652        &self,
1653        clear_mask: zx::Signals,
1654        set_mask: zx::Signals,
1655    ) -> Result<(), zx_status::Status> {
1656        use fidl::Peered;
1657        self.inner.channel().signal_peer(clear_mask, set_mask)
1658    }
1659}
1660
1661impl StateControlHandle {}
1662
1663#[must_use = "FIDL methods require a response to be sent"]
1664#[derive(Debug)]
1665pub struct StateResolveResponder {
1666    control_handle: std::mem::ManuallyDrop<StateControlHandle>,
1667    tx_id: u32,
1668}
1669
1670/// Set the the channel to be shutdown (see [`StateControlHandle::shutdown`])
1671/// if the responder is dropped without sending a response, so that the client
1672/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1673impl std::ops::Drop for StateResolveResponder {
1674    fn drop(&mut self) {
1675        self.control_handle.shutdown();
1676        // Safety: drops once, never accessed again
1677        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1678    }
1679}
1680
1681impl fidl::endpoints::Responder for StateResolveResponder {
1682    type ControlHandle = StateControlHandle;
1683
1684    fn control_handle(&self) -> &StateControlHandle {
1685        &self.control_handle
1686    }
1687
1688    fn drop_without_shutdown(mut self) {
1689        // Safety: drops once, never accessed again due to mem::forget
1690        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1691        // Prevent Drop from running (which would shut down the channel)
1692        std::mem::forget(self);
1693    }
1694}
1695
1696impl StateResolveResponder {
1697    /// Sends a response to the FIDL transaction.
1698    ///
1699    /// Sets the channel to shutdown if an error occurs.
1700    pub fn send(self, mut result: Result<&Resolved, i32>) -> Result<(), fidl::Error> {
1701        let _result = self.send_raw(result);
1702        if _result.is_err() {
1703            self.control_handle.shutdown();
1704        }
1705        self.drop_without_shutdown();
1706        _result
1707    }
1708
1709    /// Similar to "send" but does not shutdown the channel if an error occurs.
1710    pub fn send_no_shutdown_on_err(
1711        self,
1712        mut result: Result<&Resolved, i32>,
1713    ) -> Result<(), fidl::Error> {
1714        let _result = self.send_raw(result);
1715        self.drop_without_shutdown();
1716        _result
1717    }
1718
1719    fn send_raw(&self, mut result: Result<&Resolved, i32>) -> Result<(), fidl::Error> {
1720        self.control_handle.inner.send::<fidl::encoding::ResultType<StateResolveResponse, i32>>(
1721            result.map(|result| (result,)),
1722            self.tx_id,
1723            0x1541bc37d2d1dfb0,
1724            fidl::encoding::DynamicFlags::empty(),
1725        )
1726    }
1727}
1728
1729#[must_use = "FIDL methods require a response to be sent"]
1730#[derive(Debug)]
1731pub struct StateResolve2Responder {
1732    control_handle: std::mem::ManuallyDrop<StateControlHandle>,
1733    tx_id: u32,
1734}
1735
1736/// Set the the channel to be shutdown (see [`StateControlHandle::shutdown`])
1737/// if the responder is dropped without sending a response, so that the client
1738/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1739impl std::ops::Drop for StateResolve2Responder {
1740    fn drop(&mut self) {
1741        self.control_handle.shutdown();
1742        // Safety: drops once, never accessed again
1743        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1744    }
1745}
1746
1747impl fidl::endpoints::Responder for StateResolve2Responder {
1748    type ControlHandle = StateControlHandle;
1749
1750    fn control_handle(&self) -> &StateControlHandle {
1751        &self.control_handle
1752    }
1753
1754    fn drop_without_shutdown(mut self) {
1755        // Safety: drops once, never accessed again due to mem::forget
1756        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1757        // Prevent Drop from running (which would shut down the channel)
1758        std::mem::forget(self);
1759    }
1760}
1761
1762impl StateResolve2Responder {
1763    /// Sends a response to the FIDL transaction.
1764    ///
1765    /// Sets the channel to shutdown if an error occurs.
1766    pub fn send(self, mut result: Result<&ResolveResult, ResolveError>) -> Result<(), fidl::Error> {
1767        let _result = self.send_raw(result);
1768        if _result.is_err() {
1769            self.control_handle.shutdown();
1770        }
1771        self.drop_without_shutdown();
1772        _result
1773    }
1774
1775    /// Similar to "send" but does not shutdown the channel if an error occurs.
1776    pub fn send_no_shutdown_on_err(
1777        self,
1778        mut result: Result<&ResolveResult, ResolveError>,
1779    ) -> Result<(), fidl::Error> {
1780        let _result = self.send_raw(result);
1781        self.drop_without_shutdown();
1782        _result
1783    }
1784
1785    fn send_raw(
1786        &self,
1787        mut result: Result<&ResolveResult, ResolveError>,
1788    ) -> Result<(), fidl::Error> {
1789        self.control_handle
1790            .inner
1791            .send::<fidl::encoding::ResultType<StateResolve2Response, ResolveError>>(
1792                result.map(|result| (result,)),
1793                self.tx_id,
1794                0x3a37608b6851f75c,
1795                fidl::encoding::DynamicFlags::empty(),
1796            )
1797    }
1798}
1799
1800#[must_use = "FIDL methods require a response to be sent"]
1801#[derive(Debug)]
1802pub struct StateGetRouteTableNameResponder {
1803    control_handle: std::mem::ManuallyDrop<StateControlHandle>,
1804    tx_id: u32,
1805}
1806
1807/// Set the the channel to be shutdown (see [`StateControlHandle::shutdown`])
1808/// if the responder is dropped without sending a response, so that the client
1809/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1810impl std::ops::Drop for StateGetRouteTableNameResponder {
1811    fn drop(&mut self) {
1812        self.control_handle.shutdown();
1813        // Safety: drops once, never accessed again
1814        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1815    }
1816}
1817
1818impl fidl::endpoints::Responder for StateGetRouteTableNameResponder {
1819    type ControlHandle = StateControlHandle;
1820
1821    fn control_handle(&self) -> &StateControlHandle {
1822        &self.control_handle
1823    }
1824
1825    fn drop_without_shutdown(mut self) {
1826        // Safety: drops once, never accessed again due to mem::forget
1827        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1828        // Prevent Drop from running (which would shut down the channel)
1829        std::mem::forget(self);
1830    }
1831}
1832
1833impl StateGetRouteTableNameResponder {
1834    /// Sends a response to the FIDL transaction.
1835    ///
1836    /// Sets the channel to shutdown if an error occurs.
1837    pub fn send(
1838        self,
1839        mut result: Result<&str, StateGetRouteTableNameError>,
1840    ) -> Result<(), fidl::Error> {
1841        let _result = self.send_raw(result);
1842        if _result.is_err() {
1843            self.control_handle.shutdown();
1844        }
1845        self.drop_without_shutdown();
1846        _result
1847    }
1848
1849    /// Similar to "send" but does not shutdown the channel if an error occurs.
1850    pub fn send_no_shutdown_on_err(
1851        self,
1852        mut result: Result<&str, StateGetRouteTableNameError>,
1853    ) -> Result<(), fidl::Error> {
1854        let _result = self.send_raw(result);
1855        self.drop_without_shutdown();
1856        _result
1857    }
1858
1859    fn send_raw(
1860        &self,
1861        mut result: Result<&str, StateGetRouteTableNameError>,
1862    ) -> Result<(), fidl::Error> {
1863        self.control_handle.inner.send::<fidl::encoding::ResultType<
1864            StateGetRouteTableNameResponse,
1865            StateGetRouteTableNameError,
1866        >>(
1867            result.map(|table_name| (table_name,)),
1868            self.tx_id,
1869            0x6fed5423c7ce421a,
1870            fidl::encoding::DynamicFlags::empty(),
1871        )
1872    }
1873}
1874
1875#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1876pub struct StateV4Marker;
1877
1878impl fidl::endpoints::ProtocolMarker for StateV4Marker {
1879    type Proxy = StateV4Proxy;
1880    type RequestStream = StateV4RequestStream;
1881    #[cfg(target_os = "fuchsia")]
1882    type SynchronousProxy = StateV4SynchronousProxy;
1883
1884    const DEBUG_NAME: &'static str = "fuchsia.net.routes.StateV4";
1885}
1886impl fidl::endpoints::DiscoverableProtocolMarker for StateV4Marker {}
1887
1888pub trait StateV4ProxyInterface: Send + Sync {
1889    fn r#get_watcher_v4(
1890        &self,
1891        watcher: fidl::endpoints::ServerEnd<WatcherV4Marker>,
1892        options: &WatcherOptionsV4,
1893    ) -> Result<(), fidl::Error>;
1894    fn r#get_rule_watcher_v4(
1895        &self,
1896        watcher: fidl::endpoints::ServerEnd<RuleWatcherV4Marker>,
1897        options: &RuleWatcherOptionsV4,
1898    ) -> Result<(), fidl::Error>;
1899}
1900#[derive(Debug)]
1901#[cfg(target_os = "fuchsia")]
1902pub struct StateV4SynchronousProxy {
1903    client: fidl::client::sync::Client,
1904}
1905
1906#[cfg(target_os = "fuchsia")]
1907impl fidl::endpoints::SynchronousProxy for StateV4SynchronousProxy {
1908    type Proxy = StateV4Proxy;
1909    type Protocol = StateV4Marker;
1910
1911    fn from_channel(inner: fidl::Channel) -> Self {
1912        Self::new(inner)
1913    }
1914
1915    fn into_channel(self) -> fidl::Channel {
1916        self.client.into_channel()
1917    }
1918
1919    fn as_channel(&self) -> &fidl::Channel {
1920        self.client.as_channel()
1921    }
1922}
1923
1924#[cfg(target_os = "fuchsia")]
1925impl StateV4SynchronousProxy {
1926    pub fn new(channel: fidl::Channel) -> Self {
1927        let protocol_name = <StateV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1928        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1929    }
1930
1931    pub fn into_channel(self) -> fidl::Channel {
1932        self.client.into_channel()
1933    }
1934
1935    /// Waits until an event arrives and returns it. It is safe for other
1936    /// threads to make concurrent requests while waiting for an event.
1937    pub fn wait_for_event(
1938        &self,
1939        deadline: zx::MonotonicInstant,
1940    ) -> Result<StateV4Event, fidl::Error> {
1941        StateV4Event::decode(self.client.wait_for_event(deadline)?)
1942    }
1943
1944    /// Initialize a watcher for IPv4 routing state.
1945    ///
1946    /// + request 'watcher' grants access to the `WatcherV4` Protocol.
1947    /// + request `watch_options` specifies the behavior of the `WatcherV4`.
1948    pub fn r#get_watcher_v4(
1949        &self,
1950        mut watcher: fidl::endpoints::ServerEnd<WatcherV4Marker>,
1951        mut options: &WatcherOptionsV4,
1952    ) -> Result<(), fidl::Error> {
1953        self.client.send::<StateV4GetWatcherV4Request>(
1954            (watcher, options),
1955            0x30dcbe770492c20a,
1956            fidl::encoding::DynamicFlags::empty(),
1957        )
1958    }
1959
1960    /// Initialize a watcher for IPv4 rules state.
1961    ///
1962    /// + request 'watcher' grants access to the `RuleWatcherV4` Protocol.
1963    /// + request `watch_options` specifies the behavior of the `RuleWatcherV4`.
1964    pub fn r#get_rule_watcher_v4(
1965        &self,
1966        mut watcher: fidl::endpoints::ServerEnd<RuleWatcherV4Marker>,
1967        mut options: &RuleWatcherOptionsV4,
1968    ) -> Result<(), fidl::Error> {
1969        self.client.send::<StateV4GetRuleWatcherV4Request>(
1970            (watcher, options),
1971            0x2bbcc7012b5147a1,
1972            fidl::encoding::DynamicFlags::empty(),
1973        )
1974    }
1975}
1976
1977#[cfg(target_os = "fuchsia")]
1978impl From<StateV4SynchronousProxy> for zx::Handle {
1979    fn from(value: StateV4SynchronousProxy) -> Self {
1980        value.into_channel().into()
1981    }
1982}
1983
1984#[cfg(target_os = "fuchsia")]
1985impl From<fidl::Channel> for StateV4SynchronousProxy {
1986    fn from(value: fidl::Channel) -> Self {
1987        Self::new(value)
1988    }
1989}
1990
1991#[cfg(target_os = "fuchsia")]
1992impl fidl::endpoints::FromClient for StateV4SynchronousProxy {
1993    type Protocol = StateV4Marker;
1994
1995    fn from_client(value: fidl::endpoints::ClientEnd<StateV4Marker>) -> Self {
1996        Self::new(value.into_channel())
1997    }
1998}
1999
2000#[derive(Debug, Clone)]
2001pub struct StateV4Proxy {
2002    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2003}
2004
2005impl fidl::endpoints::Proxy for StateV4Proxy {
2006    type Protocol = StateV4Marker;
2007
2008    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2009        Self::new(inner)
2010    }
2011
2012    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2013        self.client.into_channel().map_err(|client| Self { client })
2014    }
2015
2016    fn as_channel(&self) -> &::fidl::AsyncChannel {
2017        self.client.as_channel()
2018    }
2019}
2020
2021impl StateV4Proxy {
2022    /// Create a new Proxy for fuchsia.net.routes/StateV4.
2023    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2024        let protocol_name = <StateV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2025        Self { client: fidl::client::Client::new(channel, protocol_name) }
2026    }
2027
2028    /// Get a Stream of events from the remote end of the protocol.
2029    ///
2030    /// # Panics
2031    ///
2032    /// Panics if the event stream was already taken.
2033    pub fn take_event_stream(&self) -> StateV4EventStream {
2034        StateV4EventStream { event_receiver: self.client.take_event_receiver() }
2035    }
2036
2037    /// Initialize a watcher for IPv4 routing state.
2038    ///
2039    /// + request 'watcher' grants access to the `WatcherV4` Protocol.
2040    /// + request `watch_options` specifies the behavior of the `WatcherV4`.
2041    pub fn r#get_watcher_v4(
2042        &self,
2043        mut watcher: fidl::endpoints::ServerEnd<WatcherV4Marker>,
2044        mut options: &WatcherOptionsV4,
2045    ) -> Result<(), fidl::Error> {
2046        StateV4ProxyInterface::r#get_watcher_v4(self, watcher, options)
2047    }
2048
2049    /// Initialize a watcher for IPv4 rules state.
2050    ///
2051    /// + request 'watcher' grants access to the `RuleWatcherV4` Protocol.
2052    /// + request `watch_options` specifies the behavior of the `RuleWatcherV4`.
2053    pub fn r#get_rule_watcher_v4(
2054        &self,
2055        mut watcher: fidl::endpoints::ServerEnd<RuleWatcherV4Marker>,
2056        mut options: &RuleWatcherOptionsV4,
2057    ) -> Result<(), fidl::Error> {
2058        StateV4ProxyInterface::r#get_rule_watcher_v4(self, watcher, options)
2059    }
2060}
2061
2062impl StateV4ProxyInterface for StateV4Proxy {
2063    fn r#get_watcher_v4(
2064        &self,
2065        mut watcher: fidl::endpoints::ServerEnd<WatcherV4Marker>,
2066        mut options: &WatcherOptionsV4,
2067    ) -> Result<(), fidl::Error> {
2068        self.client.send::<StateV4GetWatcherV4Request>(
2069            (watcher, options),
2070            0x30dcbe770492c20a,
2071            fidl::encoding::DynamicFlags::empty(),
2072        )
2073    }
2074
2075    fn r#get_rule_watcher_v4(
2076        &self,
2077        mut watcher: fidl::endpoints::ServerEnd<RuleWatcherV4Marker>,
2078        mut options: &RuleWatcherOptionsV4,
2079    ) -> Result<(), fidl::Error> {
2080        self.client.send::<StateV4GetRuleWatcherV4Request>(
2081            (watcher, options),
2082            0x2bbcc7012b5147a1,
2083            fidl::encoding::DynamicFlags::empty(),
2084        )
2085    }
2086}
2087
2088pub struct StateV4EventStream {
2089    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2090}
2091
2092impl std::marker::Unpin for StateV4EventStream {}
2093
2094impl futures::stream::FusedStream for StateV4EventStream {
2095    fn is_terminated(&self) -> bool {
2096        self.event_receiver.is_terminated()
2097    }
2098}
2099
2100impl futures::Stream for StateV4EventStream {
2101    type Item = Result<StateV4Event, fidl::Error>;
2102
2103    fn poll_next(
2104        mut self: std::pin::Pin<&mut Self>,
2105        cx: &mut std::task::Context<'_>,
2106    ) -> std::task::Poll<Option<Self::Item>> {
2107        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2108            &mut self.event_receiver,
2109            cx
2110        )?) {
2111            Some(buf) => std::task::Poll::Ready(Some(StateV4Event::decode(buf))),
2112            None => std::task::Poll::Ready(None),
2113        }
2114    }
2115}
2116
2117#[derive(Debug)]
2118pub enum StateV4Event {}
2119
2120impl StateV4Event {
2121    /// Decodes a message buffer as a [`StateV4Event`].
2122    fn decode(
2123        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2124    ) -> Result<StateV4Event, fidl::Error> {
2125        let (bytes, _handles) = buf.split_mut();
2126        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2127        debug_assert_eq!(tx_header.tx_id, 0);
2128        match tx_header.ordinal {
2129            _ => Err(fidl::Error::UnknownOrdinal {
2130                ordinal: tx_header.ordinal,
2131                protocol_name: <StateV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2132            }),
2133        }
2134    }
2135}
2136
2137/// A Stream of incoming requests for fuchsia.net.routes/StateV4.
2138pub struct StateV4RequestStream {
2139    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2140    is_terminated: bool,
2141}
2142
2143impl std::marker::Unpin for StateV4RequestStream {}
2144
2145impl futures::stream::FusedStream for StateV4RequestStream {
2146    fn is_terminated(&self) -> bool {
2147        self.is_terminated
2148    }
2149}
2150
2151impl fidl::endpoints::RequestStream for StateV4RequestStream {
2152    type Protocol = StateV4Marker;
2153    type ControlHandle = StateV4ControlHandle;
2154
2155    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2156        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2157    }
2158
2159    fn control_handle(&self) -> Self::ControlHandle {
2160        StateV4ControlHandle { inner: self.inner.clone() }
2161    }
2162
2163    fn into_inner(
2164        self,
2165    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2166    {
2167        (self.inner, self.is_terminated)
2168    }
2169
2170    fn from_inner(
2171        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2172        is_terminated: bool,
2173    ) -> Self {
2174        Self { inner, is_terminated }
2175    }
2176}
2177
2178impl futures::Stream for StateV4RequestStream {
2179    type Item = Result<StateV4Request, fidl::Error>;
2180
2181    fn poll_next(
2182        mut self: std::pin::Pin<&mut Self>,
2183        cx: &mut std::task::Context<'_>,
2184    ) -> std::task::Poll<Option<Self::Item>> {
2185        let this = &mut *self;
2186        if this.inner.check_shutdown(cx) {
2187            this.is_terminated = true;
2188            return std::task::Poll::Ready(None);
2189        }
2190        if this.is_terminated {
2191            panic!("polled StateV4RequestStream after completion");
2192        }
2193        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2194            |bytes, handles| {
2195                match this.inner.channel().read_etc(cx, bytes, handles) {
2196                    std::task::Poll::Ready(Ok(())) => {}
2197                    std::task::Poll::Pending => return std::task::Poll::Pending,
2198                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2199                        this.is_terminated = true;
2200                        return std::task::Poll::Ready(None);
2201                    }
2202                    std::task::Poll::Ready(Err(e)) => {
2203                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2204                            e.into(),
2205                        ))))
2206                    }
2207                }
2208
2209                // A message has been received from the channel
2210                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2211
2212                std::task::Poll::Ready(Some(match header.ordinal {
2213                    0x30dcbe770492c20a => {
2214                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2215                        let mut req = fidl::new_empty!(
2216                            StateV4GetWatcherV4Request,
2217                            fidl::encoding::DefaultFuchsiaResourceDialect
2218                        );
2219                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateV4GetWatcherV4Request>(&header, _body_bytes, handles, &mut req)?;
2220                        let control_handle = StateV4ControlHandle { inner: this.inner.clone() };
2221                        Ok(StateV4Request::GetWatcherV4 {
2222                            watcher: req.watcher,
2223                            options: req.options,
2224
2225                            control_handle,
2226                        })
2227                    }
2228                    0x2bbcc7012b5147a1 => {
2229                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2230                        let mut req = fidl::new_empty!(
2231                            StateV4GetRuleWatcherV4Request,
2232                            fidl::encoding::DefaultFuchsiaResourceDialect
2233                        );
2234                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateV4GetRuleWatcherV4Request>(&header, _body_bytes, handles, &mut req)?;
2235                        let control_handle = StateV4ControlHandle { inner: this.inner.clone() };
2236                        Ok(StateV4Request::GetRuleWatcherV4 {
2237                            watcher: req.watcher,
2238                            options: req.options,
2239
2240                            control_handle,
2241                        })
2242                    }
2243                    _ => Err(fidl::Error::UnknownOrdinal {
2244                        ordinal: header.ordinal,
2245                        protocol_name:
2246                            <StateV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2247                    }),
2248                }))
2249            },
2250        )
2251    }
2252}
2253
2254/// Provides observability to the system's IPv4 routing state.
2255#[derive(Debug)]
2256pub enum StateV4Request {
2257    /// Initialize a watcher for IPv4 routing state.
2258    ///
2259    /// + request 'watcher' grants access to the `WatcherV4` Protocol.
2260    /// + request `watch_options` specifies the behavior of the `WatcherV4`.
2261    GetWatcherV4 {
2262        watcher: fidl::endpoints::ServerEnd<WatcherV4Marker>,
2263        options: WatcherOptionsV4,
2264        control_handle: StateV4ControlHandle,
2265    },
2266    /// Initialize a watcher for IPv4 rules state.
2267    ///
2268    /// + request 'watcher' grants access to the `RuleWatcherV4` Protocol.
2269    /// + request `watch_options` specifies the behavior of the `RuleWatcherV4`.
2270    GetRuleWatcherV4 {
2271        watcher: fidl::endpoints::ServerEnd<RuleWatcherV4Marker>,
2272        options: RuleWatcherOptionsV4,
2273        control_handle: StateV4ControlHandle,
2274    },
2275}
2276
2277impl StateV4Request {
2278    #[allow(irrefutable_let_patterns)]
2279    pub fn into_get_watcher_v4(
2280        self,
2281    ) -> Option<(fidl::endpoints::ServerEnd<WatcherV4Marker>, WatcherOptionsV4, StateV4ControlHandle)>
2282    {
2283        if let StateV4Request::GetWatcherV4 { watcher, options, control_handle } = self {
2284            Some((watcher, options, control_handle))
2285        } else {
2286            None
2287        }
2288    }
2289
2290    #[allow(irrefutable_let_patterns)]
2291    pub fn into_get_rule_watcher_v4(
2292        self,
2293    ) -> Option<(
2294        fidl::endpoints::ServerEnd<RuleWatcherV4Marker>,
2295        RuleWatcherOptionsV4,
2296        StateV4ControlHandle,
2297    )> {
2298        if let StateV4Request::GetRuleWatcherV4 { watcher, options, control_handle } = self {
2299            Some((watcher, options, control_handle))
2300        } else {
2301            None
2302        }
2303    }
2304
2305    /// Name of the method defined in FIDL
2306    pub fn method_name(&self) -> &'static str {
2307        match *self {
2308            StateV4Request::GetWatcherV4 { .. } => "get_watcher_v4",
2309            StateV4Request::GetRuleWatcherV4 { .. } => "get_rule_watcher_v4",
2310        }
2311    }
2312}
2313
2314#[derive(Debug, Clone)]
2315pub struct StateV4ControlHandle {
2316    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2317}
2318
2319impl fidl::endpoints::ControlHandle for StateV4ControlHandle {
2320    fn shutdown(&self) {
2321        self.inner.shutdown()
2322    }
2323    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2324        self.inner.shutdown_with_epitaph(status)
2325    }
2326
2327    fn is_closed(&self) -> bool {
2328        self.inner.channel().is_closed()
2329    }
2330    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2331        self.inner.channel().on_closed()
2332    }
2333
2334    #[cfg(target_os = "fuchsia")]
2335    fn signal_peer(
2336        &self,
2337        clear_mask: zx::Signals,
2338        set_mask: zx::Signals,
2339    ) -> Result<(), zx_status::Status> {
2340        use fidl::Peered;
2341        self.inner.channel().signal_peer(clear_mask, set_mask)
2342    }
2343}
2344
2345impl StateV4ControlHandle {}
2346
2347#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2348pub struct StateV6Marker;
2349
2350impl fidl::endpoints::ProtocolMarker for StateV6Marker {
2351    type Proxy = StateV6Proxy;
2352    type RequestStream = StateV6RequestStream;
2353    #[cfg(target_os = "fuchsia")]
2354    type SynchronousProxy = StateV6SynchronousProxy;
2355
2356    const DEBUG_NAME: &'static str = "fuchsia.net.routes.StateV6";
2357}
2358impl fidl::endpoints::DiscoverableProtocolMarker for StateV6Marker {}
2359
2360pub trait StateV6ProxyInterface: Send + Sync {
2361    fn r#get_watcher_v6(
2362        &self,
2363        watcher: fidl::endpoints::ServerEnd<WatcherV6Marker>,
2364        options: &WatcherOptionsV6,
2365    ) -> Result<(), fidl::Error>;
2366    fn r#get_rule_watcher_v6(
2367        &self,
2368        watcher: fidl::endpoints::ServerEnd<RuleWatcherV6Marker>,
2369        options: &RuleWatcherOptionsV6,
2370    ) -> Result<(), fidl::Error>;
2371}
2372#[derive(Debug)]
2373#[cfg(target_os = "fuchsia")]
2374pub struct StateV6SynchronousProxy {
2375    client: fidl::client::sync::Client,
2376}
2377
2378#[cfg(target_os = "fuchsia")]
2379impl fidl::endpoints::SynchronousProxy for StateV6SynchronousProxy {
2380    type Proxy = StateV6Proxy;
2381    type Protocol = StateV6Marker;
2382
2383    fn from_channel(inner: fidl::Channel) -> Self {
2384        Self::new(inner)
2385    }
2386
2387    fn into_channel(self) -> fidl::Channel {
2388        self.client.into_channel()
2389    }
2390
2391    fn as_channel(&self) -> &fidl::Channel {
2392        self.client.as_channel()
2393    }
2394}
2395
2396#[cfg(target_os = "fuchsia")]
2397impl StateV6SynchronousProxy {
2398    pub fn new(channel: fidl::Channel) -> Self {
2399        let protocol_name = <StateV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2400        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2401    }
2402
2403    pub fn into_channel(self) -> fidl::Channel {
2404        self.client.into_channel()
2405    }
2406
2407    /// Waits until an event arrives and returns it. It is safe for other
2408    /// threads to make concurrent requests while waiting for an event.
2409    pub fn wait_for_event(
2410        &self,
2411        deadline: zx::MonotonicInstant,
2412    ) -> Result<StateV6Event, fidl::Error> {
2413        StateV6Event::decode(self.client.wait_for_event(deadline)?)
2414    }
2415
2416    /// Initialize a watcher for IPv6 routing state.
2417    ///
2418    /// + request 'watcher' grants access to the `WatcherV6` Protocol.
2419    /// + request `watch_options` specifies the behavior of the `WatcherV6`.
2420    pub fn r#get_watcher_v6(
2421        &self,
2422        mut watcher: fidl::endpoints::ServerEnd<WatcherV6Marker>,
2423        mut options: &WatcherOptionsV6,
2424    ) -> Result<(), fidl::Error> {
2425        self.client.send::<StateV6GetWatcherV6Request>(
2426            (watcher, options),
2427            0x777e3c40c98f586,
2428            fidl::encoding::DynamicFlags::empty(),
2429        )
2430    }
2431
2432    /// Initialize a watcher for IPv6 rules state.
2433    ///
2434    /// + request 'watcher' grants access to the `RuleWatcherV6` Protocol.
2435    /// + request `watch_options` specifies the behavior of the `RuleWatcherV6`.
2436    pub fn r#get_rule_watcher_v6(
2437        &self,
2438        mut watcher: fidl::endpoints::ServerEnd<RuleWatcherV6Marker>,
2439        mut options: &RuleWatcherOptionsV6,
2440    ) -> Result<(), fidl::Error> {
2441        self.client.send::<StateV6GetRuleWatcherV6Request>(
2442            (watcher, options),
2443            0x91433a23d464f6,
2444            fidl::encoding::DynamicFlags::empty(),
2445        )
2446    }
2447}
2448
2449#[cfg(target_os = "fuchsia")]
2450impl From<StateV6SynchronousProxy> for zx::Handle {
2451    fn from(value: StateV6SynchronousProxy) -> Self {
2452        value.into_channel().into()
2453    }
2454}
2455
2456#[cfg(target_os = "fuchsia")]
2457impl From<fidl::Channel> for StateV6SynchronousProxy {
2458    fn from(value: fidl::Channel) -> Self {
2459        Self::new(value)
2460    }
2461}
2462
2463#[cfg(target_os = "fuchsia")]
2464impl fidl::endpoints::FromClient for StateV6SynchronousProxy {
2465    type Protocol = StateV6Marker;
2466
2467    fn from_client(value: fidl::endpoints::ClientEnd<StateV6Marker>) -> Self {
2468        Self::new(value.into_channel())
2469    }
2470}
2471
2472#[derive(Debug, Clone)]
2473pub struct StateV6Proxy {
2474    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2475}
2476
2477impl fidl::endpoints::Proxy for StateV6Proxy {
2478    type Protocol = StateV6Marker;
2479
2480    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2481        Self::new(inner)
2482    }
2483
2484    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2485        self.client.into_channel().map_err(|client| Self { client })
2486    }
2487
2488    fn as_channel(&self) -> &::fidl::AsyncChannel {
2489        self.client.as_channel()
2490    }
2491}
2492
2493impl StateV6Proxy {
2494    /// Create a new Proxy for fuchsia.net.routes/StateV6.
2495    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2496        let protocol_name = <StateV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2497        Self { client: fidl::client::Client::new(channel, protocol_name) }
2498    }
2499
2500    /// Get a Stream of events from the remote end of the protocol.
2501    ///
2502    /// # Panics
2503    ///
2504    /// Panics if the event stream was already taken.
2505    pub fn take_event_stream(&self) -> StateV6EventStream {
2506        StateV6EventStream { event_receiver: self.client.take_event_receiver() }
2507    }
2508
2509    /// Initialize a watcher for IPv6 routing state.
2510    ///
2511    /// + request 'watcher' grants access to the `WatcherV6` Protocol.
2512    /// + request `watch_options` specifies the behavior of the `WatcherV6`.
2513    pub fn r#get_watcher_v6(
2514        &self,
2515        mut watcher: fidl::endpoints::ServerEnd<WatcherV6Marker>,
2516        mut options: &WatcherOptionsV6,
2517    ) -> Result<(), fidl::Error> {
2518        StateV6ProxyInterface::r#get_watcher_v6(self, watcher, options)
2519    }
2520
2521    /// Initialize a watcher for IPv6 rules state.
2522    ///
2523    /// + request 'watcher' grants access to the `RuleWatcherV6` Protocol.
2524    /// + request `watch_options` specifies the behavior of the `RuleWatcherV6`.
2525    pub fn r#get_rule_watcher_v6(
2526        &self,
2527        mut watcher: fidl::endpoints::ServerEnd<RuleWatcherV6Marker>,
2528        mut options: &RuleWatcherOptionsV6,
2529    ) -> Result<(), fidl::Error> {
2530        StateV6ProxyInterface::r#get_rule_watcher_v6(self, watcher, options)
2531    }
2532}
2533
2534impl StateV6ProxyInterface for StateV6Proxy {
2535    fn r#get_watcher_v6(
2536        &self,
2537        mut watcher: fidl::endpoints::ServerEnd<WatcherV6Marker>,
2538        mut options: &WatcherOptionsV6,
2539    ) -> Result<(), fidl::Error> {
2540        self.client.send::<StateV6GetWatcherV6Request>(
2541            (watcher, options),
2542            0x777e3c40c98f586,
2543            fidl::encoding::DynamicFlags::empty(),
2544        )
2545    }
2546
2547    fn r#get_rule_watcher_v6(
2548        &self,
2549        mut watcher: fidl::endpoints::ServerEnd<RuleWatcherV6Marker>,
2550        mut options: &RuleWatcherOptionsV6,
2551    ) -> Result<(), fidl::Error> {
2552        self.client.send::<StateV6GetRuleWatcherV6Request>(
2553            (watcher, options),
2554            0x91433a23d464f6,
2555            fidl::encoding::DynamicFlags::empty(),
2556        )
2557    }
2558}
2559
2560pub struct StateV6EventStream {
2561    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2562}
2563
2564impl std::marker::Unpin for StateV6EventStream {}
2565
2566impl futures::stream::FusedStream for StateV6EventStream {
2567    fn is_terminated(&self) -> bool {
2568        self.event_receiver.is_terminated()
2569    }
2570}
2571
2572impl futures::Stream for StateV6EventStream {
2573    type Item = Result<StateV6Event, fidl::Error>;
2574
2575    fn poll_next(
2576        mut self: std::pin::Pin<&mut Self>,
2577        cx: &mut std::task::Context<'_>,
2578    ) -> std::task::Poll<Option<Self::Item>> {
2579        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2580            &mut self.event_receiver,
2581            cx
2582        )?) {
2583            Some(buf) => std::task::Poll::Ready(Some(StateV6Event::decode(buf))),
2584            None => std::task::Poll::Ready(None),
2585        }
2586    }
2587}
2588
2589#[derive(Debug)]
2590pub enum StateV6Event {}
2591
2592impl StateV6Event {
2593    /// Decodes a message buffer as a [`StateV6Event`].
2594    fn decode(
2595        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2596    ) -> Result<StateV6Event, fidl::Error> {
2597        let (bytes, _handles) = buf.split_mut();
2598        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2599        debug_assert_eq!(tx_header.tx_id, 0);
2600        match tx_header.ordinal {
2601            _ => Err(fidl::Error::UnknownOrdinal {
2602                ordinal: tx_header.ordinal,
2603                protocol_name: <StateV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2604            }),
2605        }
2606    }
2607}
2608
2609/// A Stream of incoming requests for fuchsia.net.routes/StateV6.
2610pub struct StateV6RequestStream {
2611    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2612    is_terminated: bool,
2613}
2614
2615impl std::marker::Unpin for StateV6RequestStream {}
2616
2617impl futures::stream::FusedStream for StateV6RequestStream {
2618    fn is_terminated(&self) -> bool {
2619        self.is_terminated
2620    }
2621}
2622
2623impl fidl::endpoints::RequestStream for StateV6RequestStream {
2624    type Protocol = StateV6Marker;
2625    type ControlHandle = StateV6ControlHandle;
2626
2627    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2628        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2629    }
2630
2631    fn control_handle(&self) -> Self::ControlHandle {
2632        StateV6ControlHandle { inner: self.inner.clone() }
2633    }
2634
2635    fn into_inner(
2636        self,
2637    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2638    {
2639        (self.inner, self.is_terminated)
2640    }
2641
2642    fn from_inner(
2643        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2644        is_terminated: bool,
2645    ) -> Self {
2646        Self { inner, is_terminated }
2647    }
2648}
2649
2650impl futures::Stream for StateV6RequestStream {
2651    type Item = Result<StateV6Request, fidl::Error>;
2652
2653    fn poll_next(
2654        mut self: std::pin::Pin<&mut Self>,
2655        cx: &mut std::task::Context<'_>,
2656    ) -> std::task::Poll<Option<Self::Item>> {
2657        let this = &mut *self;
2658        if this.inner.check_shutdown(cx) {
2659            this.is_terminated = true;
2660            return std::task::Poll::Ready(None);
2661        }
2662        if this.is_terminated {
2663            panic!("polled StateV6RequestStream after completion");
2664        }
2665        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2666            |bytes, handles| {
2667                match this.inner.channel().read_etc(cx, bytes, handles) {
2668                    std::task::Poll::Ready(Ok(())) => {}
2669                    std::task::Poll::Pending => return std::task::Poll::Pending,
2670                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2671                        this.is_terminated = true;
2672                        return std::task::Poll::Ready(None);
2673                    }
2674                    std::task::Poll::Ready(Err(e)) => {
2675                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2676                            e.into(),
2677                        ))))
2678                    }
2679                }
2680
2681                // A message has been received from the channel
2682                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2683
2684                std::task::Poll::Ready(Some(match header.ordinal {
2685                    0x777e3c40c98f586 => {
2686                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2687                        let mut req = fidl::new_empty!(
2688                            StateV6GetWatcherV6Request,
2689                            fidl::encoding::DefaultFuchsiaResourceDialect
2690                        );
2691                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateV6GetWatcherV6Request>(&header, _body_bytes, handles, &mut req)?;
2692                        let control_handle = StateV6ControlHandle { inner: this.inner.clone() };
2693                        Ok(StateV6Request::GetWatcherV6 {
2694                            watcher: req.watcher,
2695                            options: req.options,
2696
2697                            control_handle,
2698                        })
2699                    }
2700                    0x91433a23d464f6 => {
2701                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2702                        let mut req = fidl::new_empty!(
2703                            StateV6GetRuleWatcherV6Request,
2704                            fidl::encoding::DefaultFuchsiaResourceDialect
2705                        );
2706                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StateV6GetRuleWatcherV6Request>(&header, _body_bytes, handles, &mut req)?;
2707                        let control_handle = StateV6ControlHandle { inner: this.inner.clone() };
2708                        Ok(StateV6Request::GetRuleWatcherV6 {
2709                            watcher: req.watcher,
2710                            options: req.options,
2711
2712                            control_handle,
2713                        })
2714                    }
2715                    _ => Err(fidl::Error::UnknownOrdinal {
2716                        ordinal: header.ordinal,
2717                        protocol_name:
2718                            <StateV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2719                    }),
2720                }))
2721            },
2722        )
2723    }
2724}
2725
2726/// Provides observability to the system's IPv6 routing state.
2727#[derive(Debug)]
2728pub enum StateV6Request {
2729    /// Initialize a watcher for IPv6 routing state.
2730    ///
2731    /// + request 'watcher' grants access to the `WatcherV6` Protocol.
2732    /// + request `watch_options` specifies the behavior of the `WatcherV6`.
2733    GetWatcherV6 {
2734        watcher: fidl::endpoints::ServerEnd<WatcherV6Marker>,
2735        options: WatcherOptionsV6,
2736        control_handle: StateV6ControlHandle,
2737    },
2738    /// Initialize a watcher for IPv6 rules state.
2739    ///
2740    /// + request 'watcher' grants access to the `RuleWatcherV6` Protocol.
2741    /// + request `watch_options` specifies the behavior of the `RuleWatcherV6`.
2742    GetRuleWatcherV6 {
2743        watcher: fidl::endpoints::ServerEnd<RuleWatcherV6Marker>,
2744        options: RuleWatcherOptionsV6,
2745        control_handle: StateV6ControlHandle,
2746    },
2747}
2748
2749impl StateV6Request {
2750    #[allow(irrefutable_let_patterns)]
2751    pub fn into_get_watcher_v6(
2752        self,
2753    ) -> Option<(fidl::endpoints::ServerEnd<WatcherV6Marker>, WatcherOptionsV6, StateV6ControlHandle)>
2754    {
2755        if let StateV6Request::GetWatcherV6 { watcher, options, control_handle } = self {
2756            Some((watcher, options, control_handle))
2757        } else {
2758            None
2759        }
2760    }
2761
2762    #[allow(irrefutable_let_patterns)]
2763    pub fn into_get_rule_watcher_v6(
2764        self,
2765    ) -> Option<(
2766        fidl::endpoints::ServerEnd<RuleWatcherV6Marker>,
2767        RuleWatcherOptionsV6,
2768        StateV6ControlHandle,
2769    )> {
2770        if let StateV6Request::GetRuleWatcherV6 { watcher, options, control_handle } = self {
2771            Some((watcher, options, control_handle))
2772        } else {
2773            None
2774        }
2775    }
2776
2777    /// Name of the method defined in FIDL
2778    pub fn method_name(&self) -> &'static str {
2779        match *self {
2780            StateV6Request::GetWatcherV6 { .. } => "get_watcher_v6",
2781            StateV6Request::GetRuleWatcherV6 { .. } => "get_rule_watcher_v6",
2782        }
2783    }
2784}
2785
2786#[derive(Debug, Clone)]
2787pub struct StateV6ControlHandle {
2788    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2789}
2790
2791impl fidl::endpoints::ControlHandle for StateV6ControlHandle {
2792    fn shutdown(&self) {
2793        self.inner.shutdown()
2794    }
2795    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2796        self.inner.shutdown_with_epitaph(status)
2797    }
2798
2799    fn is_closed(&self) -> bool {
2800        self.inner.channel().is_closed()
2801    }
2802    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2803        self.inner.channel().on_closed()
2804    }
2805
2806    #[cfg(target_os = "fuchsia")]
2807    fn signal_peer(
2808        &self,
2809        clear_mask: zx::Signals,
2810        set_mask: zx::Signals,
2811    ) -> Result<(), zx_status::Status> {
2812        use fidl::Peered;
2813        self.inner.channel().signal_peer(clear_mask, set_mask)
2814    }
2815}
2816
2817impl StateV6ControlHandle {}
2818
2819#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2820pub struct WatcherV4Marker;
2821
2822impl fidl::endpoints::ProtocolMarker for WatcherV4Marker {
2823    type Proxy = WatcherV4Proxy;
2824    type RequestStream = WatcherV4RequestStream;
2825    #[cfg(target_os = "fuchsia")]
2826    type SynchronousProxy = WatcherV4SynchronousProxy;
2827
2828    const DEBUG_NAME: &'static str = "(anonymous) WatcherV4";
2829}
2830
2831pub trait WatcherV4ProxyInterface: Send + Sync {
2832    type WatchResponseFut: std::future::Future<Output = Result<Vec<EventV4>, fidl::Error>> + Send;
2833    fn r#watch(&self) -> Self::WatchResponseFut;
2834}
2835#[derive(Debug)]
2836#[cfg(target_os = "fuchsia")]
2837pub struct WatcherV4SynchronousProxy {
2838    client: fidl::client::sync::Client,
2839}
2840
2841#[cfg(target_os = "fuchsia")]
2842impl fidl::endpoints::SynchronousProxy for WatcherV4SynchronousProxy {
2843    type Proxy = WatcherV4Proxy;
2844    type Protocol = WatcherV4Marker;
2845
2846    fn from_channel(inner: fidl::Channel) -> Self {
2847        Self::new(inner)
2848    }
2849
2850    fn into_channel(self) -> fidl::Channel {
2851        self.client.into_channel()
2852    }
2853
2854    fn as_channel(&self) -> &fidl::Channel {
2855        self.client.as_channel()
2856    }
2857}
2858
2859#[cfg(target_os = "fuchsia")]
2860impl WatcherV4SynchronousProxy {
2861    pub fn new(channel: fidl::Channel) -> Self {
2862        let protocol_name = <WatcherV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2863        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2864    }
2865
2866    pub fn into_channel(self) -> fidl::Channel {
2867        self.client.into_channel()
2868    }
2869
2870    /// Waits until an event arrives and returns it. It is safe for other
2871    /// threads to make concurrent requests while waiting for an event.
2872    pub fn wait_for_event(
2873        &self,
2874        deadline: zx::MonotonicInstant,
2875    ) -> Result<WatcherV4Event, fidl::Error> {
2876        WatcherV4Event::decode(self.client.wait_for_event(deadline)?)
2877    }
2878
2879    /// Hanging-Get style API for observing routing changes.
2880    ///
2881    /// Clients must only have one pending `Watch` call at a time. Calling
2882    /// `Watch` while a request is already pending will cause the protocol to
2883    /// close.
2884    ///
2885    /// The first N events will always be `existing` where N is the number of
2886    /// IPv4 routes that already existed when the server-end of the protocol was
2887    /// initialized. The following event will be `idle` signaling the end of the
2888    /// `existing` events. At this point the client has watched all existing
2889    /// state and will never again observe an `existing` event.
2890    ///
2891    /// Events are returned in batches of up to `MAX_EVENTS` events. There is no
2892    /// correlation between the batch size/boundary and it's contents: it is
2893    /// perfectly valid for the server to split the block of `existing` events,
2894    /// across several batches. Clients should view this API as providing a
2895    /// stream of events, where batches are used to reduce IPC load on the
2896    /// system.
2897    ///
2898    /// - response `events` A vector of at most `MAX_EVENTS` events.
2899    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<EventV4>, fidl::Error> {
2900        let _response =
2901            self.client.send_query::<fidl::encoding::EmptyPayload, WatcherV4WatchResponse>(
2902                (),
2903                0x71f2fdee0b307ac2,
2904                fidl::encoding::DynamicFlags::empty(),
2905                ___deadline,
2906            )?;
2907        Ok(_response.events)
2908    }
2909}
2910
2911#[cfg(target_os = "fuchsia")]
2912impl From<WatcherV4SynchronousProxy> for zx::Handle {
2913    fn from(value: WatcherV4SynchronousProxy) -> Self {
2914        value.into_channel().into()
2915    }
2916}
2917
2918#[cfg(target_os = "fuchsia")]
2919impl From<fidl::Channel> for WatcherV4SynchronousProxy {
2920    fn from(value: fidl::Channel) -> Self {
2921        Self::new(value)
2922    }
2923}
2924
2925#[cfg(target_os = "fuchsia")]
2926impl fidl::endpoints::FromClient for WatcherV4SynchronousProxy {
2927    type Protocol = WatcherV4Marker;
2928
2929    fn from_client(value: fidl::endpoints::ClientEnd<WatcherV4Marker>) -> Self {
2930        Self::new(value.into_channel())
2931    }
2932}
2933
2934#[derive(Debug, Clone)]
2935pub struct WatcherV4Proxy {
2936    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2937}
2938
2939impl fidl::endpoints::Proxy for WatcherV4Proxy {
2940    type Protocol = WatcherV4Marker;
2941
2942    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2943        Self::new(inner)
2944    }
2945
2946    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2947        self.client.into_channel().map_err(|client| Self { client })
2948    }
2949
2950    fn as_channel(&self) -> &::fidl::AsyncChannel {
2951        self.client.as_channel()
2952    }
2953}
2954
2955impl WatcherV4Proxy {
2956    /// Create a new Proxy for fuchsia.net.routes/WatcherV4.
2957    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2958        let protocol_name = <WatcherV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2959        Self { client: fidl::client::Client::new(channel, protocol_name) }
2960    }
2961
2962    /// Get a Stream of events from the remote end of the protocol.
2963    ///
2964    /// # Panics
2965    ///
2966    /// Panics if the event stream was already taken.
2967    pub fn take_event_stream(&self) -> WatcherV4EventStream {
2968        WatcherV4EventStream { event_receiver: self.client.take_event_receiver() }
2969    }
2970
2971    /// Hanging-Get style API for observing routing changes.
2972    ///
2973    /// Clients must only have one pending `Watch` call at a time. Calling
2974    /// `Watch` while a request is already pending will cause the protocol to
2975    /// close.
2976    ///
2977    /// The first N events will always be `existing` where N is the number of
2978    /// IPv4 routes that already existed when the server-end of the protocol was
2979    /// initialized. The following event will be `idle` signaling the end of the
2980    /// `existing` events. At this point the client has watched all existing
2981    /// state and will never again observe an `existing` event.
2982    ///
2983    /// Events are returned in batches of up to `MAX_EVENTS` events. There is no
2984    /// correlation between the batch size/boundary and it's contents: it is
2985    /// perfectly valid for the server to split the block of `existing` events,
2986    /// across several batches. Clients should view this API as providing a
2987    /// stream of events, where batches are used to reduce IPC load on the
2988    /// system.
2989    ///
2990    /// - response `events` A vector of at most `MAX_EVENTS` events.
2991    pub fn r#watch(
2992        &self,
2993    ) -> fidl::client::QueryResponseFut<Vec<EventV4>, fidl::encoding::DefaultFuchsiaResourceDialect>
2994    {
2995        WatcherV4ProxyInterface::r#watch(self)
2996    }
2997}
2998
2999impl WatcherV4ProxyInterface for WatcherV4Proxy {
3000    type WatchResponseFut =
3001        fidl::client::QueryResponseFut<Vec<EventV4>, fidl::encoding::DefaultFuchsiaResourceDialect>;
3002    fn r#watch(&self) -> Self::WatchResponseFut {
3003        fn _decode(
3004            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3005        ) -> Result<Vec<EventV4>, fidl::Error> {
3006            let _response = fidl::client::decode_transaction_body::<
3007                WatcherV4WatchResponse,
3008                fidl::encoding::DefaultFuchsiaResourceDialect,
3009                0x71f2fdee0b307ac2,
3010            >(_buf?)?;
3011            Ok(_response.events)
3012        }
3013        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<EventV4>>(
3014            (),
3015            0x71f2fdee0b307ac2,
3016            fidl::encoding::DynamicFlags::empty(),
3017            _decode,
3018        )
3019    }
3020}
3021
3022pub struct WatcherV4EventStream {
3023    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3024}
3025
3026impl std::marker::Unpin for WatcherV4EventStream {}
3027
3028impl futures::stream::FusedStream for WatcherV4EventStream {
3029    fn is_terminated(&self) -> bool {
3030        self.event_receiver.is_terminated()
3031    }
3032}
3033
3034impl futures::Stream for WatcherV4EventStream {
3035    type Item = Result<WatcherV4Event, fidl::Error>;
3036
3037    fn poll_next(
3038        mut self: std::pin::Pin<&mut Self>,
3039        cx: &mut std::task::Context<'_>,
3040    ) -> std::task::Poll<Option<Self::Item>> {
3041        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3042            &mut self.event_receiver,
3043            cx
3044        )?) {
3045            Some(buf) => std::task::Poll::Ready(Some(WatcherV4Event::decode(buf))),
3046            None => std::task::Poll::Ready(None),
3047        }
3048    }
3049}
3050
3051#[derive(Debug)]
3052pub enum WatcherV4Event {}
3053
3054impl WatcherV4Event {
3055    /// Decodes a message buffer as a [`WatcherV4Event`].
3056    fn decode(
3057        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3058    ) -> Result<WatcherV4Event, fidl::Error> {
3059        let (bytes, _handles) = buf.split_mut();
3060        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3061        debug_assert_eq!(tx_header.tx_id, 0);
3062        match tx_header.ordinal {
3063            _ => Err(fidl::Error::UnknownOrdinal {
3064                ordinal: tx_header.ordinal,
3065                protocol_name: <WatcherV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3066            }),
3067        }
3068    }
3069}
3070
3071/// A Stream of incoming requests for fuchsia.net.routes/WatcherV4.
3072pub struct WatcherV4RequestStream {
3073    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3074    is_terminated: bool,
3075}
3076
3077impl std::marker::Unpin for WatcherV4RequestStream {}
3078
3079impl futures::stream::FusedStream for WatcherV4RequestStream {
3080    fn is_terminated(&self) -> bool {
3081        self.is_terminated
3082    }
3083}
3084
3085impl fidl::endpoints::RequestStream for WatcherV4RequestStream {
3086    type Protocol = WatcherV4Marker;
3087    type ControlHandle = WatcherV4ControlHandle;
3088
3089    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3090        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3091    }
3092
3093    fn control_handle(&self) -> Self::ControlHandle {
3094        WatcherV4ControlHandle { inner: self.inner.clone() }
3095    }
3096
3097    fn into_inner(
3098        self,
3099    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3100    {
3101        (self.inner, self.is_terminated)
3102    }
3103
3104    fn from_inner(
3105        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3106        is_terminated: bool,
3107    ) -> Self {
3108        Self { inner, is_terminated }
3109    }
3110}
3111
3112impl futures::Stream for WatcherV4RequestStream {
3113    type Item = Result<WatcherV4Request, fidl::Error>;
3114
3115    fn poll_next(
3116        mut self: std::pin::Pin<&mut Self>,
3117        cx: &mut std::task::Context<'_>,
3118    ) -> std::task::Poll<Option<Self::Item>> {
3119        let this = &mut *self;
3120        if this.inner.check_shutdown(cx) {
3121            this.is_terminated = true;
3122            return std::task::Poll::Ready(None);
3123        }
3124        if this.is_terminated {
3125            panic!("polled WatcherV4RequestStream after completion");
3126        }
3127        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3128            |bytes, handles| {
3129                match this.inner.channel().read_etc(cx, bytes, handles) {
3130                    std::task::Poll::Ready(Ok(())) => {}
3131                    std::task::Poll::Pending => return std::task::Poll::Pending,
3132                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3133                        this.is_terminated = true;
3134                        return std::task::Poll::Ready(None);
3135                    }
3136                    std::task::Poll::Ready(Err(e)) => {
3137                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3138                            e.into(),
3139                        ))))
3140                    }
3141                }
3142
3143                // A message has been received from the channel
3144                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3145
3146                std::task::Poll::Ready(Some(match header.ordinal {
3147                    0x71f2fdee0b307ac2 => {
3148                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3149                        let mut req = fidl::new_empty!(
3150                            fidl::encoding::EmptyPayload,
3151                            fidl::encoding::DefaultFuchsiaResourceDialect
3152                        );
3153                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3154                        let control_handle = WatcherV4ControlHandle { inner: this.inner.clone() };
3155                        Ok(WatcherV4Request::Watch {
3156                            responder: WatcherV4WatchResponder {
3157                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3158                                tx_id: header.tx_id,
3159                            },
3160                        })
3161                    }
3162                    _ => Err(fidl::Error::UnknownOrdinal {
3163                        ordinal: header.ordinal,
3164                        protocol_name:
3165                            <WatcherV4Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3166                    }),
3167                }))
3168            },
3169        )
3170    }
3171}
3172
3173/// An observer protocol for changes in system's IPv4 routing state.
3174#[derive(Debug)]
3175pub enum WatcherV4Request {
3176    /// Hanging-Get style API for observing routing changes.
3177    ///
3178    /// Clients must only have one pending `Watch` call at a time. Calling
3179    /// `Watch` while a request is already pending will cause the protocol to
3180    /// close.
3181    ///
3182    /// The first N events will always be `existing` where N is the number of
3183    /// IPv4 routes that already existed when the server-end of the protocol was
3184    /// initialized. The following event will be `idle` signaling the end of the
3185    /// `existing` events. At this point the client has watched all existing
3186    /// state and will never again observe an `existing` event.
3187    ///
3188    /// Events are returned in batches of up to `MAX_EVENTS` events. There is no
3189    /// correlation between the batch size/boundary and it's contents: it is
3190    /// perfectly valid for the server to split the block of `existing` events,
3191    /// across several batches. Clients should view this API as providing a
3192    /// stream of events, where batches are used to reduce IPC load on the
3193    /// system.
3194    ///
3195    /// - response `events` A vector of at most `MAX_EVENTS` events.
3196    Watch { responder: WatcherV4WatchResponder },
3197}
3198
3199impl WatcherV4Request {
3200    #[allow(irrefutable_let_patterns)]
3201    pub fn into_watch(self) -> Option<(WatcherV4WatchResponder)> {
3202        if let WatcherV4Request::Watch { responder } = self {
3203            Some((responder))
3204        } else {
3205            None
3206        }
3207    }
3208
3209    /// Name of the method defined in FIDL
3210    pub fn method_name(&self) -> &'static str {
3211        match *self {
3212            WatcherV4Request::Watch { .. } => "watch",
3213        }
3214    }
3215}
3216
3217#[derive(Debug, Clone)]
3218pub struct WatcherV4ControlHandle {
3219    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3220}
3221
3222impl fidl::endpoints::ControlHandle for WatcherV4ControlHandle {
3223    fn shutdown(&self) {
3224        self.inner.shutdown()
3225    }
3226    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3227        self.inner.shutdown_with_epitaph(status)
3228    }
3229
3230    fn is_closed(&self) -> bool {
3231        self.inner.channel().is_closed()
3232    }
3233    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3234        self.inner.channel().on_closed()
3235    }
3236
3237    #[cfg(target_os = "fuchsia")]
3238    fn signal_peer(
3239        &self,
3240        clear_mask: zx::Signals,
3241        set_mask: zx::Signals,
3242    ) -> Result<(), zx_status::Status> {
3243        use fidl::Peered;
3244        self.inner.channel().signal_peer(clear_mask, set_mask)
3245    }
3246}
3247
3248impl WatcherV4ControlHandle {}
3249
3250#[must_use = "FIDL methods require a response to be sent"]
3251#[derive(Debug)]
3252pub struct WatcherV4WatchResponder {
3253    control_handle: std::mem::ManuallyDrop<WatcherV4ControlHandle>,
3254    tx_id: u32,
3255}
3256
3257/// Set the the channel to be shutdown (see [`WatcherV4ControlHandle::shutdown`])
3258/// if the responder is dropped without sending a response, so that the client
3259/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3260impl std::ops::Drop for WatcherV4WatchResponder {
3261    fn drop(&mut self) {
3262        self.control_handle.shutdown();
3263        // Safety: drops once, never accessed again
3264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3265    }
3266}
3267
3268impl fidl::endpoints::Responder for WatcherV4WatchResponder {
3269    type ControlHandle = WatcherV4ControlHandle;
3270
3271    fn control_handle(&self) -> &WatcherV4ControlHandle {
3272        &self.control_handle
3273    }
3274
3275    fn drop_without_shutdown(mut self) {
3276        // Safety: drops once, never accessed again due to mem::forget
3277        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3278        // Prevent Drop from running (which would shut down the channel)
3279        std::mem::forget(self);
3280    }
3281}
3282
3283impl WatcherV4WatchResponder {
3284    /// Sends a response to the FIDL transaction.
3285    ///
3286    /// Sets the channel to shutdown if an error occurs.
3287    pub fn send(self, mut events: &[EventV4]) -> Result<(), fidl::Error> {
3288        let _result = self.send_raw(events);
3289        if _result.is_err() {
3290            self.control_handle.shutdown();
3291        }
3292        self.drop_without_shutdown();
3293        _result
3294    }
3295
3296    /// Similar to "send" but does not shutdown the channel if an error occurs.
3297    pub fn send_no_shutdown_on_err(self, mut events: &[EventV4]) -> Result<(), fidl::Error> {
3298        let _result = self.send_raw(events);
3299        self.drop_without_shutdown();
3300        _result
3301    }
3302
3303    fn send_raw(&self, mut events: &[EventV4]) -> Result<(), fidl::Error> {
3304        self.control_handle.inner.send::<WatcherV4WatchResponse>(
3305            (events,),
3306            self.tx_id,
3307            0x71f2fdee0b307ac2,
3308            fidl::encoding::DynamicFlags::empty(),
3309        )
3310    }
3311}
3312
3313#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3314pub struct WatcherV6Marker;
3315
3316impl fidl::endpoints::ProtocolMarker for WatcherV6Marker {
3317    type Proxy = WatcherV6Proxy;
3318    type RequestStream = WatcherV6RequestStream;
3319    #[cfg(target_os = "fuchsia")]
3320    type SynchronousProxy = WatcherV6SynchronousProxy;
3321
3322    const DEBUG_NAME: &'static str = "(anonymous) WatcherV6";
3323}
3324
3325pub trait WatcherV6ProxyInterface: Send + Sync {
3326    type WatchResponseFut: std::future::Future<Output = Result<Vec<EventV6>, fidl::Error>> + Send;
3327    fn r#watch(&self) -> Self::WatchResponseFut;
3328}
3329#[derive(Debug)]
3330#[cfg(target_os = "fuchsia")]
3331pub struct WatcherV6SynchronousProxy {
3332    client: fidl::client::sync::Client,
3333}
3334
3335#[cfg(target_os = "fuchsia")]
3336impl fidl::endpoints::SynchronousProxy for WatcherV6SynchronousProxy {
3337    type Proxy = WatcherV6Proxy;
3338    type Protocol = WatcherV6Marker;
3339
3340    fn from_channel(inner: fidl::Channel) -> Self {
3341        Self::new(inner)
3342    }
3343
3344    fn into_channel(self) -> fidl::Channel {
3345        self.client.into_channel()
3346    }
3347
3348    fn as_channel(&self) -> &fidl::Channel {
3349        self.client.as_channel()
3350    }
3351}
3352
3353#[cfg(target_os = "fuchsia")]
3354impl WatcherV6SynchronousProxy {
3355    pub fn new(channel: fidl::Channel) -> Self {
3356        let protocol_name = <WatcherV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3357        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3358    }
3359
3360    pub fn into_channel(self) -> fidl::Channel {
3361        self.client.into_channel()
3362    }
3363
3364    /// Waits until an event arrives and returns it. It is safe for other
3365    /// threads to make concurrent requests while waiting for an event.
3366    pub fn wait_for_event(
3367        &self,
3368        deadline: zx::MonotonicInstant,
3369    ) -> Result<WatcherV6Event, fidl::Error> {
3370        WatcherV6Event::decode(self.client.wait_for_event(deadline)?)
3371    }
3372
3373    /// Hanging-Get style API for observing routing changes.
3374    ///
3375    /// Clients must only have one pending `Watch` call at a time. Calling
3376    /// `Watch` while a request is already pending will cause the protocol to
3377    /// close.
3378    ///
3379    /// The first N events will always be `existing` where N is the number of
3380    /// IPv6 routes that already existed when the server-end of the protocol was
3381    /// initialized. The following event will be `idle` signaling the end of the
3382    /// `existing` events. At this point the client has watched all existing
3383    /// state and will never again observe an `existing` event.
3384    ///
3385    /// Events are returned in batches of up to `MAX_EVENTS` events. There is no
3386    /// correlation between the batch size/boundary and it's contents: it is
3387    /// perfectly valid for the server to split the block of `existing` events,
3388    /// across several batches. Clients should view this API as providing a
3389    /// stream of events, where batches are used to reduce IPC load on the
3390    /// system.
3391    ///
3392    /// - response `events` A vector of at most `MAX_EVENTS` events.
3393    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<EventV6>, fidl::Error> {
3394        let _response =
3395            self.client.send_query::<fidl::encoding::EmptyPayload, WatcherV6WatchResponse>(
3396                (),
3397                0x82f5e48afc8811e,
3398                fidl::encoding::DynamicFlags::empty(),
3399                ___deadline,
3400            )?;
3401        Ok(_response.events)
3402    }
3403}
3404
3405#[cfg(target_os = "fuchsia")]
3406impl From<WatcherV6SynchronousProxy> for zx::Handle {
3407    fn from(value: WatcherV6SynchronousProxy) -> Self {
3408        value.into_channel().into()
3409    }
3410}
3411
3412#[cfg(target_os = "fuchsia")]
3413impl From<fidl::Channel> for WatcherV6SynchronousProxy {
3414    fn from(value: fidl::Channel) -> Self {
3415        Self::new(value)
3416    }
3417}
3418
3419#[cfg(target_os = "fuchsia")]
3420impl fidl::endpoints::FromClient for WatcherV6SynchronousProxy {
3421    type Protocol = WatcherV6Marker;
3422
3423    fn from_client(value: fidl::endpoints::ClientEnd<WatcherV6Marker>) -> Self {
3424        Self::new(value.into_channel())
3425    }
3426}
3427
3428#[derive(Debug, Clone)]
3429pub struct WatcherV6Proxy {
3430    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3431}
3432
3433impl fidl::endpoints::Proxy for WatcherV6Proxy {
3434    type Protocol = WatcherV6Marker;
3435
3436    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3437        Self::new(inner)
3438    }
3439
3440    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3441        self.client.into_channel().map_err(|client| Self { client })
3442    }
3443
3444    fn as_channel(&self) -> &::fidl::AsyncChannel {
3445        self.client.as_channel()
3446    }
3447}
3448
3449impl WatcherV6Proxy {
3450    /// Create a new Proxy for fuchsia.net.routes/WatcherV6.
3451    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3452        let protocol_name = <WatcherV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3453        Self { client: fidl::client::Client::new(channel, protocol_name) }
3454    }
3455
3456    /// Get a Stream of events from the remote end of the protocol.
3457    ///
3458    /// # Panics
3459    ///
3460    /// Panics if the event stream was already taken.
3461    pub fn take_event_stream(&self) -> WatcherV6EventStream {
3462        WatcherV6EventStream { event_receiver: self.client.take_event_receiver() }
3463    }
3464
3465    /// Hanging-Get style API for observing routing changes.
3466    ///
3467    /// Clients must only have one pending `Watch` call at a time. Calling
3468    /// `Watch` while a request is already pending will cause the protocol to
3469    /// close.
3470    ///
3471    /// The first N events will always be `existing` where N is the number of
3472    /// IPv6 routes that already existed when the server-end of the protocol was
3473    /// initialized. The following event will be `idle` signaling the end of the
3474    /// `existing` events. At this point the client has watched all existing
3475    /// state and will never again observe an `existing` event.
3476    ///
3477    /// Events are returned in batches of up to `MAX_EVENTS` events. There is no
3478    /// correlation between the batch size/boundary and it's contents: it is
3479    /// perfectly valid for the server to split the block of `existing` events,
3480    /// across several batches. Clients should view this API as providing a
3481    /// stream of events, where batches are used to reduce IPC load on the
3482    /// system.
3483    ///
3484    /// - response `events` A vector of at most `MAX_EVENTS` events.
3485    pub fn r#watch(
3486        &self,
3487    ) -> fidl::client::QueryResponseFut<Vec<EventV6>, fidl::encoding::DefaultFuchsiaResourceDialect>
3488    {
3489        WatcherV6ProxyInterface::r#watch(self)
3490    }
3491}
3492
3493impl WatcherV6ProxyInterface for WatcherV6Proxy {
3494    type WatchResponseFut =
3495        fidl::client::QueryResponseFut<Vec<EventV6>, fidl::encoding::DefaultFuchsiaResourceDialect>;
3496    fn r#watch(&self) -> Self::WatchResponseFut {
3497        fn _decode(
3498            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3499        ) -> Result<Vec<EventV6>, fidl::Error> {
3500            let _response = fidl::client::decode_transaction_body::<
3501                WatcherV6WatchResponse,
3502                fidl::encoding::DefaultFuchsiaResourceDialect,
3503                0x82f5e48afc8811e,
3504            >(_buf?)?;
3505            Ok(_response.events)
3506        }
3507        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<EventV6>>(
3508            (),
3509            0x82f5e48afc8811e,
3510            fidl::encoding::DynamicFlags::empty(),
3511            _decode,
3512        )
3513    }
3514}
3515
3516pub struct WatcherV6EventStream {
3517    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3518}
3519
3520impl std::marker::Unpin for WatcherV6EventStream {}
3521
3522impl futures::stream::FusedStream for WatcherV6EventStream {
3523    fn is_terminated(&self) -> bool {
3524        self.event_receiver.is_terminated()
3525    }
3526}
3527
3528impl futures::Stream for WatcherV6EventStream {
3529    type Item = Result<WatcherV6Event, fidl::Error>;
3530
3531    fn poll_next(
3532        mut self: std::pin::Pin<&mut Self>,
3533        cx: &mut std::task::Context<'_>,
3534    ) -> std::task::Poll<Option<Self::Item>> {
3535        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3536            &mut self.event_receiver,
3537            cx
3538        )?) {
3539            Some(buf) => std::task::Poll::Ready(Some(WatcherV6Event::decode(buf))),
3540            None => std::task::Poll::Ready(None),
3541        }
3542    }
3543}
3544
3545#[derive(Debug)]
3546pub enum WatcherV6Event {}
3547
3548impl WatcherV6Event {
3549    /// Decodes a message buffer as a [`WatcherV6Event`].
3550    fn decode(
3551        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3552    ) -> Result<WatcherV6Event, fidl::Error> {
3553        let (bytes, _handles) = buf.split_mut();
3554        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3555        debug_assert_eq!(tx_header.tx_id, 0);
3556        match tx_header.ordinal {
3557            _ => Err(fidl::Error::UnknownOrdinal {
3558                ordinal: tx_header.ordinal,
3559                protocol_name: <WatcherV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3560            }),
3561        }
3562    }
3563}
3564
3565/// A Stream of incoming requests for fuchsia.net.routes/WatcherV6.
3566pub struct WatcherV6RequestStream {
3567    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3568    is_terminated: bool,
3569}
3570
3571impl std::marker::Unpin for WatcherV6RequestStream {}
3572
3573impl futures::stream::FusedStream for WatcherV6RequestStream {
3574    fn is_terminated(&self) -> bool {
3575        self.is_terminated
3576    }
3577}
3578
3579impl fidl::endpoints::RequestStream for WatcherV6RequestStream {
3580    type Protocol = WatcherV6Marker;
3581    type ControlHandle = WatcherV6ControlHandle;
3582
3583    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3584        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3585    }
3586
3587    fn control_handle(&self) -> Self::ControlHandle {
3588        WatcherV6ControlHandle { inner: self.inner.clone() }
3589    }
3590
3591    fn into_inner(
3592        self,
3593    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3594    {
3595        (self.inner, self.is_terminated)
3596    }
3597
3598    fn from_inner(
3599        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3600        is_terminated: bool,
3601    ) -> Self {
3602        Self { inner, is_terminated }
3603    }
3604}
3605
3606impl futures::Stream for WatcherV6RequestStream {
3607    type Item = Result<WatcherV6Request, fidl::Error>;
3608
3609    fn poll_next(
3610        mut self: std::pin::Pin<&mut Self>,
3611        cx: &mut std::task::Context<'_>,
3612    ) -> std::task::Poll<Option<Self::Item>> {
3613        let this = &mut *self;
3614        if this.inner.check_shutdown(cx) {
3615            this.is_terminated = true;
3616            return std::task::Poll::Ready(None);
3617        }
3618        if this.is_terminated {
3619            panic!("polled WatcherV6RequestStream after completion");
3620        }
3621        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3622            |bytes, handles| {
3623                match this.inner.channel().read_etc(cx, bytes, handles) {
3624                    std::task::Poll::Ready(Ok(())) => {}
3625                    std::task::Poll::Pending => return std::task::Poll::Pending,
3626                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3627                        this.is_terminated = true;
3628                        return std::task::Poll::Ready(None);
3629                    }
3630                    std::task::Poll::Ready(Err(e)) => {
3631                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3632                            e.into(),
3633                        ))))
3634                    }
3635                }
3636
3637                // A message has been received from the channel
3638                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3639
3640                std::task::Poll::Ready(Some(match header.ordinal {
3641                    0x82f5e48afc8811e => {
3642                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3643                        let mut req = fidl::new_empty!(
3644                            fidl::encoding::EmptyPayload,
3645                            fidl::encoding::DefaultFuchsiaResourceDialect
3646                        );
3647                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3648                        let control_handle = WatcherV6ControlHandle { inner: this.inner.clone() };
3649                        Ok(WatcherV6Request::Watch {
3650                            responder: WatcherV6WatchResponder {
3651                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3652                                tx_id: header.tx_id,
3653                            },
3654                        })
3655                    }
3656                    _ => Err(fidl::Error::UnknownOrdinal {
3657                        ordinal: header.ordinal,
3658                        protocol_name:
3659                            <WatcherV6Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3660                    }),
3661                }))
3662            },
3663        )
3664    }
3665}
3666
3667/// An observer protocol for changes in system's IPv6 routing state.
3668#[derive(Debug)]
3669pub enum WatcherV6Request {
3670    /// Hanging-Get style API for observing routing changes.
3671    ///
3672    /// Clients must only have one pending `Watch` call at a time. Calling
3673    /// `Watch` while a request is already pending will cause the protocol to
3674    /// close.
3675    ///
3676    /// The first N events will always be `existing` where N is the number of
3677    /// IPv6 routes that already existed when the server-end of the protocol was
3678    /// initialized. The following event will be `idle` signaling the end of the
3679    /// `existing` events. At this point the client has watched all existing
3680    /// state and will never again observe an `existing` event.
3681    ///
3682    /// Events are returned in batches of up to `MAX_EVENTS` events. There is no
3683    /// correlation between the batch size/boundary and it's contents: it is
3684    /// perfectly valid for the server to split the block of `existing` events,
3685    /// across several batches. Clients should view this API as providing a
3686    /// stream of events, where batches are used to reduce IPC load on the
3687    /// system.
3688    ///
3689    /// - response `events` A vector of at most `MAX_EVENTS` events.
3690    Watch { responder: WatcherV6WatchResponder },
3691}
3692
3693impl WatcherV6Request {
3694    #[allow(irrefutable_let_patterns)]
3695    pub fn into_watch(self) -> Option<(WatcherV6WatchResponder)> {
3696        if let WatcherV6Request::Watch { responder } = self {
3697            Some((responder))
3698        } else {
3699            None
3700        }
3701    }
3702
3703    /// Name of the method defined in FIDL
3704    pub fn method_name(&self) -> &'static str {
3705        match *self {
3706            WatcherV6Request::Watch { .. } => "watch",
3707        }
3708    }
3709}
3710
3711#[derive(Debug, Clone)]
3712pub struct WatcherV6ControlHandle {
3713    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3714}
3715
3716impl fidl::endpoints::ControlHandle for WatcherV6ControlHandle {
3717    fn shutdown(&self) {
3718        self.inner.shutdown()
3719    }
3720    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3721        self.inner.shutdown_with_epitaph(status)
3722    }
3723
3724    fn is_closed(&self) -> bool {
3725        self.inner.channel().is_closed()
3726    }
3727    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3728        self.inner.channel().on_closed()
3729    }
3730
3731    #[cfg(target_os = "fuchsia")]
3732    fn signal_peer(
3733        &self,
3734        clear_mask: zx::Signals,
3735        set_mask: zx::Signals,
3736    ) -> Result<(), zx_status::Status> {
3737        use fidl::Peered;
3738        self.inner.channel().signal_peer(clear_mask, set_mask)
3739    }
3740}
3741
3742impl WatcherV6ControlHandle {}
3743
3744#[must_use = "FIDL methods require a response to be sent"]
3745#[derive(Debug)]
3746pub struct WatcherV6WatchResponder {
3747    control_handle: std::mem::ManuallyDrop<WatcherV6ControlHandle>,
3748    tx_id: u32,
3749}
3750
3751/// Set the the channel to be shutdown (see [`WatcherV6ControlHandle::shutdown`])
3752/// if the responder is dropped without sending a response, so that the client
3753/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3754impl std::ops::Drop for WatcherV6WatchResponder {
3755    fn drop(&mut self) {
3756        self.control_handle.shutdown();
3757        // Safety: drops once, never accessed again
3758        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3759    }
3760}
3761
3762impl fidl::endpoints::Responder for WatcherV6WatchResponder {
3763    type ControlHandle = WatcherV6ControlHandle;
3764
3765    fn control_handle(&self) -> &WatcherV6ControlHandle {
3766        &self.control_handle
3767    }
3768
3769    fn drop_without_shutdown(mut self) {
3770        // Safety: drops once, never accessed again due to mem::forget
3771        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3772        // Prevent Drop from running (which would shut down the channel)
3773        std::mem::forget(self);
3774    }
3775}
3776
3777impl WatcherV6WatchResponder {
3778    /// Sends a response to the FIDL transaction.
3779    ///
3780    /// Sets the channel to shutdown if an error occurs.
3781    pub fn send(self, mut events: &[EventV6]) -> Result<(), fidl::Error> {
3782        let _result = self.send_raw(events);
3783        if _result.is_err() {
3784            self.control_handle.shutdown();
3785        }
3786        self.drop_without_shutdown();
3787        _result
3788    }
3789
3790    /// Similar to "send" but does not shutdown the channel if an error occurs.
3791    pub fn send_no_shutdown_on_err(self, mut events: &[EventV6]) -> Result<(), fidl::Error> {
3792        let _result = self.send_raw(events);
3793        self.drop_without_shutdown();
3794        _result
3795    }
3796
3797    fn send_raw(&self, mut events: &[EventV6]) -> Result<(), fidl::Error> {
3798        self.control_handle.inner.send::<WatcherV6WatchResponse>(
3799            (events,),
3800            self.tx_id,
3801            0x82f5e48afc8811e,
3802            fidl::encoding::DynamicFlags::empty(),
3803        )
3804    }
3805}
3806
3807mod internal {
3808    use super::*;
3809
3810    impl fidl::encoding::ResourceTypeMarker for StateV4GetRuleWatcherV4Request {
3811        type Borrowed<'a> = &'a mut Self;
3812        fn take_or_borrow<'a>(
3813            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3814        ) -> Self::Borrowed<'a> {
3815            value
3816        }
3817    }
3818
3819    unsafe impl fidl::encoding::TypeMarker for StateV4GetRuleWatcherV4Request {
3820        type Owned = Self;
3821
3822        #[inline(always)]
3823        fn inline_align(_context: fidl::encoding::Context) -> usize {
3824            8
3825        }
3826
3827        #[inline(always)]
3828        fn inline_size(_context: fidl::encoding::Context) -> usize {
3829            24
3830        }
3831    }
3832
3833    unsafe impl
3834        fidl::encoding::Encode<
3835            StateV4GetRuleWatcherV4Request,
3836            fidl::encoding::DefaultFuchsiaResourceDialect,
3837        > for &mut StateV4GetRuleWatcherV4Request
3838    {
3839        #[inline]
3840        unsafe fn encode(
3841            self,
3842            encoder: &mut fidl::encoding::Encoder<
3843                '_,
3844                fidl::encoding::DefaultFuchsiaResourceDialect,
3845            >,
3846            offset: usize,
3847            _depth: fidl::encoding::Depth,
3848        ) -> fidl::Result<()> {
3849            encoder.debug_check_bounds::<StateV4GetRuleWatcherV4Request>(offset);
3850            // Delegate to tuple encoding.
3851            fidl::encoding::Encode::<StateV4GetRuleWatcherV4Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3852                (
3853                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleWatcherV4Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
3854                    <RuleWatcherOptionsV4 as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
3855                ),
3856                encoder, offset, _depth
3857            )
3858        }
3859    }
3860    unsafe impl<
3861            T0: fidl::encoding::Encode<
3862                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleWatcherV4Marker>>,
3863                fidl::encoding::DefaultFuchsiaResourceDialect,
3864            >,
3865            T1: fidl::encoding::Encode<
3866                RuleWatcherOptionsV4,
3867                fidl::encoding::DefaultFuchsiaResourceDialect,
3868            >,
3869        >
3870        fidl::encoding::Encode<
3871            StateV4GetRuleWatcherV4Request,
3872            fidl::encoding::DefaultFuchsiaResourceDialect,
3873        > for (T0, T1)
3874    {
3875        #[inline]
3876        unsafe fn encode(
3877            self,
3878            encoder: &mut fidl::encoding::Encoder<
3879                '_,
3880                fidl::encoding::DefaultFuchsiaResourceDialect,
3881            >,
3882            offset: usize,
3883            depth: fidl::encoding::Depth,
3884        ) -> fidl::Result<()> {
3885            encoder.debug_check_bounds::<StateV4GetRuleWatcherV4Request>(offset);
3886            // Zero out padding regions. There's no need to apply masks
3887            // because the unmasked parts will be overwritten by fields.
3888            unsafe {
3889                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3890                (ptr as *mut u64).write_unaligned(0);
3891            }
3892            // Write the fields.
3893            self.0.encode(encoder, offset + 0, depth)?;
3894            self.1.encode(encoder, offset + 8, depth)?;
3895            Ok(())
3896        }
3897    }
3898
3899    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3900        for StateV4GetRuleWatcherV4Request
3901    {
3902        #[inline(always)]
3903        fn new_empty() -> Self {
3904            Self {
3905                watcher: fidl::new_empty!(
3906                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleWatcherV4Marker>>,
3907                    fidl::encoding::DefaultFuchsiaResourceDialect
3908                ),
3909                options: fidl::new_empty!(
3910                    RuleWatcherOptionsV4,
3911                    fidl::encoding::DefaultFuchsiaResourceDialect
3912                ),
3913            }
3914        }
3915
3916        #[inline]
3917        unsafe fn decode(
3918            &mut self,
3919            decoder: &mut fidl::encoding::Decoder<
3920                '_,
3921                fidl::encoding::DefaultFuchsiaResourceDialect,
3922            >,
3923            offset: usize,
3924            _depth: fidl::encoding::Depth,
3925        ) -> fidl::Result<()> {
3926            decoder.debug_check_bounds::<Self>(offset);
3927            // Verify that padding bytes are zero.
3928            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3929            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3930            let mask = 0xffffffff00000000u64;
3931            let maskedval = padval & mask;
3932            if maskedval != 0 {
3933                return Err(fidl::Error::NonZeroPadding {
3934                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3935                });
3936            }
3937            fidl::decode!(
3938                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleWatcherV4Marker>>,
3939                fidl::encoding::DefaultFuchsiaResourceDialect,
3940                &mut self.watcher,
3941                decoder,
3942                offset + 0,
3943                _depth
3944            )?;
3945            fidl::decode!(
3946                RuleWatcherOptionsV4,
3947                fidl::encoding::DefaultFuchsiaResourceDialect,
3948                &mut self.options,
3949                decoder,
3950                offset + 8,
3951                _depth
3952            )?;
3953            Ok(())
3954        }
3955    }
3956
3957    impl fidl::encoding::ResourceTypeMarker for StateV4GetWatcherV4Request {
3958        type Borrowed<'a> = &'a mut Self;
3959        fn take_or_borrow<'a>(
3960            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3961        ) -> Self::Borrowed<'a> {
3962            value
3963        }
3964    }
3965
3966    unsafe impl fidl::encoding::TypeMarker for StateV4GetWatcherV4Request {
3967        type Owned = Self;
3968
3969        #[inline(always)]
3970        fn inline_align(_context: fidl::encoding::Context) -> usize {
3971            8
3972        }
3973
3974        #[inline(always)]
3975        fn inline_size(_context: fidl::encoding::Context) -> usize {
3976            24
3977        }
3978    }
3979
3980    unsafe impl
3981        fidl::encoding::Encode<
3982            StateV4GetWatcherV4Request,
3983            fidl::encoding::DefaultFuchsiaResourceDialect,
3984        > for &mut StateV4GetWatcherV4Request
3985    {
3986        #[inline]
3987        unsafe fn encode(
3988            self,
3989            encoder: &mut fidl::encoding::Encoder<
3990                '_,
3991                fidl::encoding::DefaultFuchsiaResourceDialect,
3992            >,
3993            offset: usize,
3994            _depth: fidl::encoding::Depth,
3995        ) -> fidl::Result<()> {
3996            encoder.debug_check_bounds::<StateV4GetWatcherV4Request>(offset);
3997            // Delegate to tuple encoding.
3998            fidl::encoding::Encode::<StateV4GetWatcherV4Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3999                (
4000                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherV4Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
4001                    <WatcherOptionsV4 as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
4002                ),
4003                encoder, offset, _depth
4004            )
4005        }
4006    }
4007    unsafe impl<
4008            T0: fidl::encoding::Encode<
4009                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherV4Marker>>,
4010                fidl::encoding::DefaultFuchsiaResourceDialect,
4011            >,
4012            T1: fidl::encoding::Encode<WatcherOptionsV4, fidl::encoding::DefaultFuchsiaResourceDialect>,
4013        >
4014        fidl::encoding::Encode<
4015            StateV4GetWatcherV4Request,
4016            fidl::encoding::DefaultFuchsiaResourceDialect,
4017        > for (T0, T1)
4018    {
4019        #[inline]
4020        unsafe fn encode(
4021            self,
4022            encoder: &mut fidl::encoding::Encoder<
4023                '_,
4024                fidl::encoding::DefaultFuchsiaResourceDialect,
4025            >,
4026            offset: usize,
4027            depth: fidl::encoding::Depth,
4028        ) -> fidl::Result<()> {
4029            encoder.debug_check_bounds::<StateV4GetWatcherV4Request>(offset);
4030            // Zero out padding regions. There's no need to apply masks
4031            // because the unmasked parts will be overwritten by fields.
4032            unsafe {
4033                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4034                (ptr as *mut u64).write_unaligned(0);
4035            }
4036            // Write the fields.
4037            self.0.encode(encoder, offset + 0, depth)?;
4038            self.1.encode(encoder, offset + 8, depth)?;
4039            Ok(())
4040        }
4041    }
4042
4043    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4044        for StateV4GetWatcherV4Request
4045    {
4046        #[inline(always)]
4047        fn new_empty() -> Self {
4048            Self {
4049                watcher: fidl::new_empty!(
4050                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherV4Marker>>,
4051                    fidl::encoding::DefaultFuchsiaResourceDialect
4052                ),
4053                options: fidl::new_empty!(
4054                    WatcherOptionsV4,
4055                    fidl::encoding::DefaultFuchsiaResourceDialect
4056                ),
4057            }
4058        }
4059
4060        #[inline]
4061        unsafe fn decode(
4062            &mut self,
4063            decoder: &mut fidl::encoding::Decoder<
4064                '_,
4065                fidl::encoding::DefaultFuchsiaResourceDialect,
4066            >,
4067            offset: usize,
4068            _depth: fidl::encoding::Depth,
4069        ) -> fidl::Result<()> {
4070            decoder.debug_check_bounds::<Self>(offset);
4071            // Verify that padding bytes are zero.
4072            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4073            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4074            let mask = 0xffffffff00000000u64;
4075            let maskedval = padval & mask;
4076            if maskedval != 0 {
4077                return Err(fidl::Error::NonZeroPadding {
4078                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4079                });
4080            }
4081            fidl::decode!(
4082                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherV4Marker>>,
4083                fidl::encoding::DefaultFuchsiaResourceDialect,
4084                &mut self.watcher,
4085                decoder,
4086                offset + 0,
4087                _depth
4088            )?;
4089            fidl::decode!(
4090                WatcherOptionsV4,
4091                fidl::encoding::DefaultFuchsiaResourceDialect,
4092                &mut self.options,
4093                decoder,
4094                offset + 8,
4095                _depth
4096            )?;
4097            Ok(())
4098        }
4099    }
4100
4101    impl fidl::encoding::ResourceTypeMarker for StateV6GetRuleWatcherV6Request {
4102        type Borrowed<'a> = &'a mut Self;
4103        fn take_or_borrow<'a>(
4104            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4105        ) -> Self::Borrowed<'a> {
4106            value
4107        }
4108    }
4109
4110    unsafe impl fidl::encoding::TypeMarker for StateV6GetRuleWatcherV6Request {
4111        type Owned = Self;
4112
4113        #[inline(always)]
4114        fn inline_align(_context: fidl::encoding::Context) -> usize {
4115            8
4116        }
4117
4118        #[inline(always)]
4119        fn inline_size(_context: fidl::encoding::Context) -> usize {
4120            24
4121        }
4122    }
4123
4124    unsafe impl
4125        fidl::encoding::Encode<
4126            StateV6GetRuleWatcherV6Request,
4127            fidl::encoding::DefaultFuchsiaResourceDialect,
4128        > for &mut StateV6GetRuleWatcherV6Request
4129    {
4130        #[inline]
4131        unsafe fn encode(
4132            self,
4133            encoder: &mut fidl::encoding::Encoder<
4134                '_,
4135                fidl::encoding::DefaultFuchsiaResourceDialect,
4136            >,
4137            offset: usize,
4138            _depth: fidl::encoding::Depth,
4139        ) -> fidl::Result<()> {
4140            encoder.debug_check_bounds::<StateV6GetRuleWatcherV6Request>(offset);
4141            // Delegate to tuple encoding.
4142            fidl::encoding::Encode::<StateV6GetRuleWatcherV6Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4143                (
4144                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleWatcherV6Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
4145                    <RuleWatcherOptionsV6 as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
4146                ),
4147                encoder, offset, _depth
4148            )
4149        }
4150    }
4151    unsafe impl<
4152            T0: fidl::encoding::Encode<
4153                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleWatcherV6Marker>>,
4154                fidl::encoding::DefaultFuchsiaResourceDialect,
4155            >,
4156            T1: fidl::encoding::Encode<
4157                RuleWatcherOptionsV6,
4158                fidl::encoding::DefaultFuchsiaResourceDialect,
4159            >,
4160        >
4161        fidl::encoding::Encode<
4162            StateV6GetRuleWatcherV6Request,
4163            fidl::encoding::DefaultFuchsiaResourceDialect,
4164        > for (T0, T1)
4165    {
4166        #[inline]
4167        unsafe fn encode(
4168            self,
4169            encoder: &mut fidl::encoding::Encoder<
4170                '_,
4171                fidl::encoding::DefaultFuchsiaResourceDialect,
4172            >,
4173            offset: usize,
4174            depth: fidl::encoding::Depth,
4175        ) -> fidl::Result<()> {
4176            encoder.debug_check_bounds::<StateV6GetRuleWatcherV6Request>(offset);
4177            // Zero out padding regions. There's no need to apply masks
4178            // because the unmasked parts will be overwritten by fields.
4179            unsafe {
4180                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4181                (ptr as *mut u64).write_unaligned(0);
4182            }
4183            // Write the fields.
4184            self.0.encode(encoder, offset + 0, depth)?;
4185            self.1.encode(encoder, offset + 8, depth)?;
4186            Ok(())
4187        }
4188    }
4189
4190    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4191        for StateV6GetRuleWatcherV6Request
4192    {
4193        #[inline(always)]
4194        fn new_empty() -> Self {
4195            Self {
4196                watcher: fidl::new_empty!(
4197                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleWatcherV6Marker>>,
4198                    fidl::encoding::DefaultFuchsiaResourceDialect
4199                ),
4200                options: fidl::new_empty!(
4201                    RuleWatcherOptionsV6,
4202                    fidl::encoding::DefaultFuchsiaResourceDialect
4203                ),
4204            }
4205        }
4206
4207        #[inline]
4208        unsafe fn decode(
4209            &mut self,
4210            decoder: &mut fidl::encoding::Decoder<
4211                '_,
4212                fidl::encoding::DefaultFuchsiaResourceDialect,
4213            >,
4214            offset: usize,
4215            _depth: fidl::encoding::Depth,
4216        ) -> fidl::Result<()> {
4217            decoder.debug_check_bounds::<Self>(offset);
4218            // Verify that padding bytes are zero.
4219            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4220            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4221            let mask = 0xffffffff00000000u64;
4222            let maskedval = padval & mask;
4223            if maskedval != 0 {
4224                return Err(fidl::Error::NonZeroPadding {
4225                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4226                });
4227            }
4228            fidl::decode!(
4229                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleWatcherV6Marker>>,
4230                fidl::encoding::DefaultFuchsiaResourceDialect,
4231                &mut self.watcher,
4232                decoder,
4233                offset + 0,
4234                _depth
4235            )?;
4236            fidl::decode!(
4237                RuleWatcherOptionsV6,
4238                fidl::encoding::DefaultFuchsiaResourceDialect,
4239                &mut self.options,
4240                decoder,
4241                offset + 8,
4242                _depth
4243            )?;
4244            Ok(())
4245        }
4246    }
4247
4248    impl fidl::encoding::ResourceTypeMarker for StateV6GetWatcherV6Request {
4249        type Borrowed<'a> = &'a mut Self;
4250        fn take_or_borrow<'a>(
4251            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4252        ) -> Self::Borrowed<'a> {
4253            value
4254        }
4255    }
4256
4257    unsafe impl fidl::encoding::TypeMarker for StateV6GetWatcherV6Request {
4258        type Owned = Self;
4259
4260        #[inline(always)]
4261        fn inline_align(_context: fidl::encoding::Context) -> usize {
4262            8
4263        }
4264
4265        #[inline(always)]
4266        fn inline_size(_context: fidl::encoding::Context) -> usize {
4267            24
4268        }
4269    }
4270
4271    unsafe impl
4272        fidl::encoding::Encode<
4273            StateV6GetWatcherV6Request,
4274            fidl::encoding::DefaultFuchsiaResourceDialect,
4275        > for &mut StateV6GetWatcherV6Request
4276    {
4277        #[inline]
4278        unsafe fn encode(
4279            self,
4280            encoder: &mut fidl::encoding::Encoder<
4281                '_,
4282                fidl::encoding::DefaultFuchsiaResourceDialect,
4283            >,
4284            offset: usize,
4285            _depth: fidl::encoding::Depth,
4286        ) -> fidl::Result<()> {
4287            encoder.debug_check_bounds::<StateV6GetWatcherV6Request>(offset);
4288            // Delegate to tuple encoding.
4289            fidl::encoding::Encode::<StateV6GetWatcherV6Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4290                (
4291                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherV6Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
4292                    <WatcherOptionsV6 as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
4293                ),
4294                encoder, offset, _depth
4295            )
4296        }
4297    }
4298    unsafe impl<
4299            T0: fidl::encoding::Encode<
4300                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherV6Marker>>,
4301                fidl::encoding::DefaultFuchsiaResourceDialect,
4302            >,
4303            T1: fidl::encoding::Encode<WatcherOptionsV6, fidl::encoding::DefaultFuchsiaResourceDialect>,
4304        >
4305        fidl::encoding::Encode<
4306            StateV6GetWatcherV6Request,
4307            fidl::encoding::DefaultFuchsiaResourceDialect,
4308        > for (T0, T1)
4309    {
4310        #[inline]
4311        unsafe fn encode(
4312            self,
4313            encoder: &mut fidl::encoding::Encoder<
4314                '_,
4315                fidl::encoding::DefaultFuchsiaResourceDialect,
4316            >,
4317            offset: usize,
4318            depth: fidl::encoding::Depth,
4319        ) -> fidl::Result<()> {
4320            encoder.debug_check_bounds::<StateV6GetWatcherV6Request>(offset);
4321            // Zero out padding regions. There's no need to apply masks
4322            // because the unmasked parts will be overwritten by fields.
4323            unsafe {
4324                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4325                (ptr as *mut u64).write_unaligned(0);
4326            }
4327            // Write the fields.
4328            self.0.encode(encoder, offset + 0, depth)?;
4329            self.1.encode(encoder, offset + 8, depth)?;
4330            Ok(())
4331        }
4332    }
4333
4334    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4335        for StateV6GetWatcherV6Request
4336    {
4337        #[inline(always)]
4338        fn new_empty() -> Self {
4339            Self {
4340                watcher: fidl::new_empty!(
4341                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherV6Marker>>,
4342                    fidl::encoding::DefaultFuchsiaResourceDialect
4343                ),
4344                options: fidl::new_empty!(
4345                    WatcherOptionsV6,
4346                    fidl::encoding::DefaultFuchsiaResourceDialect
4347                ),
4348            }
4349        }
4350
4351        #[inline]
4352        unsafe fn decode(
4353            &mut self,
4354            decoder: &mut fidl::encoding::Decoder<
4355                '_,
4356                fidl::encoding::DefaultFuchsiaResourceDialect,
4357            >,
4358            offset: usize,
4359            _depth: fidl::encoding::Depth,
4360        ) -> fidl::Result<()> {
4361            decoder.debug_check_bounds::<Self>(offset);
4362            // Verify that padding bytes are zero.
4363            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4364            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4365            let mask = 0xffffffff00000000u64;
4366            let maskedval = padval & mask;
4367            if maskedval != 0 {
4368                return Err(fidl::Error::NonZeroPadding {
4369                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4370                });
4371            }
4372            fidl::decode!(
4373                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WatcherV6Marker>>,
4374                fidl::encoding::DefaultFuchsiaResourceDialect,
4375                &mut self.watcher,
4376                decoder,
4377                offset + 0,
4378                _depth
4379            )?;
4380            fidl::decode!(
4381                WatcherOptionsV6,
4382                fidl::encoding::DefaultFuchsiaResourceDialect,
4383                &mut self.options,
4384                decoder,
4385                offset + 8,
4386                _depth
4387            )?;
4388            Ok(())
4389        }
4390    }
4391}