fidl_fuchsia_net_routes/
fidl_fuchsia_net_routes.rs

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