Skip to main content

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