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