Skip to main content

fidl_fuchsia_net_multicast_admin/
fidl_fuchsia_net_multicast_admin.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_multicast_admin_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct Ipv4RoutingTableControllerMarker;
16
17impl fidl::endpoints::ProtocolMarker for Ipv4RoutingTableControllerMarker {
18    type Proxy = Ipv4RoutingTableControllerProxy;
19    type RequestStream = Ipv4RoutingTableControllerRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = Ipv4RoutingTableControllerSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.net.multicast.admin.Ipv4RoutingTableController";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for Ipv4RoutingTableControllerMarker {}
26pub type Ipv4RoutingTableControllerAddRouteResult =
27    Result<(), Ipv4RoutingTableControllerAddRouteError>;
28pub type Ipv4RoutingTableControllerDelRouteResult =
29    Result<(), Ipv4RoutingTableControllerDelRouteError>;
30pub type Ipv4RoutingTableControllerGetRouteStatsResult =
31    Result<RouteStats, Ipv4RoutingTableControllerGetRouteStatsError>;
32
33pub trait Ipv4RoutingTableControllerProxyInterface: Send + Sync {
34    type AddRouteResponseFut: std::future::Future<Output = Result<Ipv4RoutingTableControllerAddRouteResult, fidl::Error>>
35        + Send;
36    fn r#add_route(
37        &self,
38        addresses: &Ipv4UnicastSourceAndMulticastDestination,
39        route: &Route,
40    ) -> Self::AddRouteResponseFut;
41    type DelRouteResponseFut: std::future::Future<Output = Result<Ipv4RoutingTableControllerDelRouteResult, fidl::Error>>
42        + Send;
43    fn r#del_route(
44        &self,
45        addresses: &Ipv4UnicastSourceAndMulticastDestination,
46    ) -> Self::DelRouteResponseFut;
47    type GetRouteStatsResponseFut: std::future::Future<
48            Output = Result<Ipv4RoutingTableControllerGetRouteStatsResult, fidl::Error>,
49        > + Send;
50    fn r#get_route_stats(
51        &self,
52        addresses: &Ipv4UnicastSourceAndMulticastDestination,
53    ) -> Self::GetRouteStatsResponseFut;
54    type WatchRoutingEventsResponseFut: std::future::Future<
55            Output = Result<
56                (u64, Ipv4UnicastSourceAndMulticastDestination, u64, RoutingEvent),
57                fidl::Error,
58            >,
59        > + Send;
60    fn r#watch_routing_events(&self) -> Self::WatchRoutingEventsResponseFut;
61}
62#[derive(Debug)]
63#[cfg(target_os = "fuchsia")]
64pub struct Ipv4RoutingTableControllerSynchronousProxy {
65    client: fidl::client::sync::Client,
66}
67
68#[cfg(target_os = "fuchsia")]
69impl fidl::endpoints::SynchronousProxy for Ipv4RoutingTableControllerSynchronousProxy {
70    type Proxy = Ipv4RoutingTableControllerProxy;
71    type Protocol = Ipv4RoutingTableControllerMarker;
72
73    fn from_channel(inner: fidl::Channel) -> Self {
74        Self::new(inner)
75    }
76
77    fn into_channel(self) -> fidl::Channel {
78        self.client.into_channel()
79    }
80
81    fn as_channel(&self) -> &fidl::Channel {
82        self.client.as_channel()
83    }
84}
85
86#[cfg(target_os = "fuchsia")]
87impl Ipv4RoutingTableControllerSynchronousProxy {
88    pub fn new(channel: fidl::Channel) -> Self {
89        Self { client: fidl::client::sync::Client::new(channel) }
90    }
91
92    pub fn into_channel(self) -> fidl::Channel {
93        self.client.into_channel()
94    }
95
96    /// Waits until an event arrives and returns it. It is safe for other
97    /// threads to make concurrent requests while waiting for an event.
98    pub fn wait_for_event(
99        &self,
100        deadline: zx::MonotonicInstant,
101    ) -> Result<Ipv4RoutingTableControllerEvent, fidl::Error> {
102        Ipv4RoutingTableControllerEvent::decode(
103            self.client.wait_for_event::<Ipv4RoutingTableControllerMarker>(deadline)?,
104        )
105    }
106
107    /// Adds a route such that packets matching the addresses will be forwarded
108    /// accordingly.
109    ///
110    /// The provided addresses act as the key for the route; any existing route
111    /// with the same addresses will be overwritten when this route is
112    /// installed.
113    ///
114    /// If a packet arrives at an interface different from the expected input
115    /// interface set in the route, the packet will not be forwarded and a
116    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
117    /// See [`WatchRoutingEvents`] for more details.
118    ///
119    /// + request `addresses` the addresses used to identify a route.
120    /// + request `route` the multicast route.
121    pub fn r#add_route(
122        &self,
123        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
124        mut route: &Route,
125        ___deadline: zx::MonotonicInstant,
126    ) -> Result<Ipv4RoutingTableControllerAddRouteResult, fidl::Error> {
127        let _response = self
128            .client
129            .send_query::<Ipv4RoutingTableControllerAddRouteRequest, fidl::encoding::ResultType<
130                fidl::encoding::EmptyStruct,
131                Ipv4RoutingTableControllerAddRouteError,
132            >, Ipv4RoutingTableControllerMarker>(
133                (addresses, route),
134                0x6098a90553ef1aed,
135                fidl::encoding::DynamicFlags::empty(),
136                ___deadline,
137            )?;
138        Ok(_response.map(|x| x))
139    }
140
141    /// Delete a route.
142    ///
143    /// + request `addresses` the addresses used to identify a route.
144    pub fn r#del_route(
145        &self,
146        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
147        ___deadline: zx::MonotonicInstant,
148    ) -> Result<Ipv4RoutingTableControllerDelRouteResult, fidl::Error> {
149        let _response = self
150            .client
151            .send_query::<Ipv4RoutingTableControllerDelRouteRequest, fidl::encoding::ResultType<
152                fidl::encoding::EmptyStruct,
153                Ipv4RoutingTableControllerDelRouteError,
154            >, Ipv4RoutingTableControllerMarker>(
155                (addresses,),
156                0x14a0727b797aff74,
157                fidl::encoding::DynamicFlags::empty(),
158                ___deadline,
159            )?;
160        Ok(_response.map(|x| x))
161    }
162
163    /// Get a snapshot of statistics about a specific route.
164    ///
165    /// + request `addresses` the addresses used to identify a route.
166    pub fn r#get_route_stats(
167        &self,
168        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
169        ___deadline: zx::MonotonicInstant,
170    ) -> Result<Ipv4RoutingTableControllerGetRouteStatsResult, fidl::Error> {
171        let _response = self.client.send_query::<
172            Ipv4RoutingTableControllerGetRouteStatsRequest,
173            fidl::encoding::ResultType<Ipv4RoutingTableControllerGetRouteStatsResponse, Ipv4RoutingTableControllerGetRouteStatsError>,
174            Ipv4RoutingTableControllerMarker,
175        >(
176            (addresses,),
177            0x176ad8488370c1e9,
178            fidl::encoding::DynamicFlags::empty(),
179            ___deadline,
180        )?;
181        Ok(_response.map(|x| x.stats))
182    }
183
184    /// Watch for events triggered by multicast packets.
185    ///
186    /// The server will queue events to return when this method is called. If no
187    /// events are ready, the call will block until an event is ready. The
188    /// server will drop new events if the client is not consuming them fast
189    /// enough and return the number of events dropped in-between events.
190    ///
191    /// It is invalid to call this method while a previous call is pending.
192    /// Doing so will cause the server end of the protocol to be closed.
193    ///
194    /// - response `dropped_events` the number of events that were dropped
195    ///   _immediately before_ the returned event was queued.
196    ///   returned event.
197    /// - response `addresses` the addresses in the multicast packet triggering
198    ///   the event.
199    /// - response `input_interface` the interface the multicast packet
200    ///   triggering the event arrived at.
201    /// - response `event` the event.
202    pub fn r#watch_routing_events(
203        &self,
204        ___deadline: zx::MonotonicInstant,
205    ) -> Result<(u64, Ipv4UnicastSourceAndMulticastDestination, u64, RoutingEvent), fidl::Error>
206    {
207        let _response = self.client.send_query::<
208            fidl::encoding::EmptyPayload,
209            Ipv4RoutingTableControllerWatchRoutingEventsResponse,
210            Ipv4RoutingTableControllerMarker,
211        >(
212            (),
213            0x3e4336c50718d7f9,
214            fidl::encoding::DynamicFlags::empty(),
215            ___deadline,
216        )?;
217        Ok((
218            _response.dropped_events,
219            _response.addresses,
220            _response.input_interface,
221            _response.event,
222        ))
223    }
224}
225
226#[cfg(target_os = "fuchsia")]
227impl From<Ipv4RoutingTableControllerSynchronousProxy> for zx::NullableHandle {
228    fn from(value: Ipv4RoutingTableControllerSynchronousProxy) -> Self {
229        value.into_channel().into()
230    }
231}
232
233#[cfg(target_os = "fuchsia")]
234impl From<fidl::Channel> for Ipv4RoutingTableControllerSynchronousProxy {
235    fn from(value: fidl::Channel) -> Self {
236        Self::new(value)
237    }
238}
239
240#[cfg(target_os = "fuchsia")]
241impl fidl::endpoints::FromClient for Ipv4RoutingTableControllerSynchronousProxy {
242    type Protocol = Ipv4RoutingTableControllerMarker;
243
244    fn from_client(value: fidl::endpoints::ClientEnd<Ipv4RoutingTableControllerMarker>) -> Self {
245        Self::new(value.into_channel())
246    }
247}
248
249#[derive(Debug, Clone)]
250pub struct Ipv4RoutingTableControllerProxy {
251    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
252}
253
254impl fidl::endpoints::Proxy for Ipv4RoutingTableControllerProxy {
255    type Protocol = Ipv4RoutingTableControllerMarker;
256
257    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
258        Self::new(inner)
259    }
260
261    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
262        self.client.into_channel().map_err(|client| Self { client })
263    }
264
265    fn as_channel(&self) -> &::fidl::AsyncChannel {
266        self.client.as_channel()
267    }
268}
269
270impl Ipv4RoutingTableControllerProxy {
271    /// Create a new Proxy for fuchsia.net.multicast.admin/Ipv4RoutingTableController.
272    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
273        let protocol_name =
274            <Ipv4RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
275        Self { client: fidl::client::Client::new(channel, protocol_name) }
276    }
277
278    /// Get a Stream of events from the remote end of the protocol.
279    ///
280    /// # Panics
281    ///
282    /// Panics if the event stream was already taken.
283    pub fn take_event_stream(&self) -> Ipv4RoutingTableControllerEventStream {
284        Ipv4RoutingTableControllerEventStream { event_receiver: self.client.take_event_receiver() }
285    }
286
287    /// Adds a route such that packets matching the addresses will be forwarded
288    /// accordingly.
289    ///
290    /// The provided addresses act as the key for the route; any existing route
291    /// with the same addresses will be overwritten when this route is
292    /// installed.
293    ///
294    /// If a packet arrives at an interface different from the expected input
295    /// interface set in the route, the packet will not be forwarded and a
296    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
297    /// See [`WatchRoutingEvents`] for more details.
298    ///
299    /// + request `addresses` the addresses used to identify a route.
300    /// + request `route` the multicast route.
301    pub fn r#add_route(
302        &self,
303        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
304        mut route: &Route,
305    ) -> fidl::client::QueryResponseFut<
306        Ipv4RoutingTableControllerAddRouteResult,
307        fidl::encoding::DefaultFuchsiaResourceDialect,
308    > {
309        Ipv4RoutingTableControllerProxyInterface::r#add_route(self, addresses, route)
310    }
311
312    /// Delete a route.
313    ///
314    /// + request `addresses` the addresses used to identify a route.
315    pub fn r#del_route(
316        &self,
317        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
318    ) -> fidl::client::QueryResponseFut<
319        Ipv4RoutingTableControllerDelRouteResult,
320        fidl::encoding::DefaultFuchsiaResourceDialect,
321    > {
322        Ipv4RoutingTableControllerProxyInterface::r#del_route(self, addresses)
323    }
324
325    /// Get a snapshot of statistics about a specific route.
326    ///
327    /// + request `addresses` the addresses used to identify a route.
328    pub fn r#get_route_stats(
329        &self,
330        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
331    ) -> fidl::client::QueryResponseFut<
332        Ipv4RoutingTableControllerGetRouteStatsResult,
333        fidl::encoding::DefaultFuchsiaResourceDialect,
334    > {
335        Ipv4RoutingTableControllerProxyInterface::r#get_route_stats(self, addresses)
336    }
337
338    /// Watch for events triggered by multicast packets.
339    ///
340    /// The server will queue events to return when this method is called. If no
341    /// events are ready, the call will block until an event is ready. The
342    /// server will drop new events if the client is not consuming them fast
343    /// enough and return the number of events dropped in-between events.
344    ///
345    /// It is invalid to call this method while a previous call is pending.
346    /// Doing so will cause the server end of the protocol to be closed.
347    ///
348    /// - response `dropped_events` the number of events that were dropped
349    ///   _immediately before_ the returned event was queued.
350    ///   returned event.
351    /// - response `addresses` the addresses in the multicast packet triggering
352    ///   the event.
353    /// - response `input_interface` the interface the multicast packet
354    ///   triggering the event arrived at.
355    /// - response `event` the event.
356    pub fn r#watch_routing_events(
357        &self,
358    ) -> fidl::client::QueryResponseFut<
359        (u64, Ipv4UnicastSourceAndMulticastDestination, u64, RoutingEvent),
360        fidl::encoding::DefaultFuchsiaResourceDialect,
361    > {
362        Ipv4RoutingTableControllerProxyInterface::r#watch_routing_events(self)
363    }
364}
365
366impl Ipv4RoutingTableControllerProxyInterface for Ipv4RoutingTableControllerProxy {
367    type AddRouteResponseFut = fidl::client::QueryResponseFut<
368        Ipv4RoutingTableControllerAddRouteResult,
369        fidl::encoding::DefaultFuchsiaResourceDialect,
370    >;
371    fn r#add_route(
372        &self,
373        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
374        mut route: &Route,
375    ) -> Self::AddRouteResponseFut {
376        fn _decode(
377            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
378        ) -> Result<Ipv4RoutingTableControllerAddRouteResult, fidl::Error> {
379            let _response = fidl::client::decode_transaction_body::<
380                fidl::encoding::ResultType<
381                    fidl::encoding::EmptyStruct,
382                    Ipv4RoutingTableControllerAddRouteError,
383                >,
384                fidl::encoding::DefaultFuchsiaResourceDialect,
385                0x6098a90553ef1aed,
386            >(_buf?)?;
387            Ok(_response.map(|x| x))
388        }
389        self.client.send_query_and_decode::<
390            Ipv4RoutingTableControllerAddRouteRequest,
391            Ipv4RoutingTableControllerAddRouteResult,
392        >(
393            (addresses, route,),
394            0x6098a90553ef1aed,
395            fidl::encoding::DynamicFlags::empty(),
396            _decode,
397        )
398    }
399
400    type DelRouteResponseFut = fidl::client::QueryResponseFut<
401        Ipv4RoutingTableControllerDelRouteResult,
402        fidl::encoding::DefaultFuchsiaResourceDialect,
403    >;
404    fn r#del_route(
405        &self,
406        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
407    ) -> Self::DelRouteResponseFut {
408        fn _decode(
409            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
410        ) -> Result<Ipv4RoutingTableControllerDelRouteResult, fidl::Error> {
411            let _response = fidl::client::decode_transaction_body::<
412                fidl::encoding::ResultType<
413                    fidl::encoding::EmptyStruct,
414                    Ipv4RoutingTableControllerDelRouteError,
415                >,
416                fidl::encoding::DefaultFuchsiaResourceDialect,
417                0x14a0727b797aff74,
418            >(_buf?)?;
419            Ok(_response.map(|x| x))
420        }
421        self.client.send_query_and_decode::<
422            Ipv4RoutingTableControllerDelRouteRequest,
423            Ipv4RoutingTableControllerDelRouteResult,
424        >(
425            (addresses,),
426            0x14a0727b797aff74,
427            fidl::encoding::DynamicFlags::empty(),
428            _decode,
429        )
430    }
431
432    type GetRouteStatsResponseFut = fidl::client::QueryResponseFut<
433        Ipv4RoutingTableControllerGetRouteStatsResult,
434        fidl::encoding::DefaultFuchsiaResourceDialect,
435    >;
436    fn r#get_route_stats(
437        &self,
438        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
439    ) -> Self::GetRouteStatsResponseFut {
440        fn _decode(
441            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
442        ) -> Result<Ipv4RoutingTableControllerGetRouteStatsResult, fidl::Error> {
443            let _response = fidl::client::decode_transaction_body::<
444                fidl::encoding::ResultType<
445                    Ipv4RoutingTableControllerGetRouteStatsResponse,
446                    Ipv4RoutingTableControllerGetRouteStatsError,
447                >,
448                fidl::encoding::DefaultFuchsiaResourceDialect,
449                0x176ad8488370c1e9,
450            >(_buf?)?;
451            Ok(_response.map(|x| x.stats))
452        }
453        self.client.send_query_and_decode::<
454            Ipv4RoutingTableControllerGetRouteStatsRequest,
455            Ipv4RoutingTableControllerGetRouteStatsResult,
456        >(
457            (addresses,),
458            0x176ad8488370c1e9,
459            fidl::encoding::DynamicFlags::empty(),
460            _decode,
461        )
462    }
463
464    type WatchRoutingEventsResponseFut = fidl::client::QueryResponseFut<
465        (u64, Ipv4UnicastSourceAndMulticastDestination, u64, RoutingEvent),
466        fidl::encoding::DefaultFuchsiaResourceDialect,
467    >;
468    fn r#watch_routing_events(&self) -> Self::WatchRoutingEventsResponseFut {
469        fn _decode(
470            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
471        ) -> Result<(u64, Ipv4UnicastSourceAndMulticastDestination, u64, RoutingEvent), fidl::Error>
472        {
473            let _response = fidl::client::decode_transaction_body::<
474                Ipv4RoutingTableControllerWatchRoutingEventsResponse,
475                fidl::encoding::DefaultFuchsiaResourceDialect,
476                0x3e4336c50718d7f9,
477            >(_buf?)?;
478            Ok((
479                _response.dropped_events,
480                _response.addresses,
481                _response.input_interface,
482                _response.event,
483            ))
484        }
485        self.client.send_query_and_decode::<
486            fidl::encoding::EmptyPayload,
487            (u64, Ipv4UnicastSourceAndMulticastDestination, u64, RoutingEvent),
488        >(
489            (),
490            0x3e4336c50718d7f9,
491            fidl::encoding::DynamicFlags::empty(),
492            _decode,
493        )
494    }
495}
496
497pub struct Ipv4RoutingTableControllerEventStream {
498    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
499}
500
501impl std::marker::Unpin for Ipv4RoutingTableControllerEventStream {}
502
503impl futures::stream::FusedStream for Ipv4RoutingTableControllerEventStream {
504    fn is_terminated(&self) -> bool {
505        self.event_receiver.is_terminated()
506    }
507}
508
509impl futures::Stream for Ipv4RoutingTableControllerEventStream {
510    type Item = Result<Ipv4RoutingTableControllerEvent, fidl::Error>;
511
512    fn poll_next(
513        mut self: std::pin::Pin<&mut Self>,
514        cx: &mut std::task::Context<'_>,
515    ) -> std::task::Poll<Option<Self::Item>> {
516        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
517            &mut self.event_receiver,
518            cx
519        )?) {
520            Some(buf) => std::task::Poll::Ready(Some(Ipv4RoutingTableControllerEvent::decode(buf))),
521            None => std::task::Poll::Ready(None),
522        }
523    }
524}
525
526#[derive(Debug)]
527pub enum Ipv4RoutingTableControllerEvent {
528    OnClose { error: TableControllerCloseReason },
529}
530
531impl Ipv4RoutingTableControllerEvent {
532    #[allow(irrefutable_let_patterns)]
533    pub fn into_on_close(self) -> Option<TableControllerCloseReason> {
534        if let Ipv4RoutingTableControllerEvent::OnClose { error } = self {
535            Some((error))
536        } else {
537            None
538        }
539    }
540
541    /// Decodes a message buffer as a [`Ipv4RoutingTableControllerEvent`].
542    fn decode(
543        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
544    ) -> Result<Ipv4RoutingTableControllerEvent, fidl::Error> {
545        let (bytes, _handles) = buf.split_mut();
546        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
547        debug_assert_eq!(tx_header.tx_id, 0);
548        match tx_header.ordinal {
549            0x3dec49c6c2070f14 => {
550                let mut out = fidl::new_empty!(Ipv4RoutingTableControllerOnCloseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
551                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv4RoutingTableControllerOnCloseRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
552                Ok((
553                    Ipv4RoutingTableControllerEvent::OnClose {error: out.error,
554
555                    }
556                ))
557            }
558            _ => Err(fidl::Error::UnknownOrdinal {
559                ordinal: tx_header.ordinal,
560                protocol_name: <Ipv4RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
561            })
562        }
563    }
564}
565
566/// A Stream of incoming requests for fuchsia.net.multicast.admin/Ipv4RoutingTableController.
567pub struct Ipv4RoutingTableControllerRequestStream {
568    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
569    is_terminated: bool,
570}
571
572impl std::marker::Unpin for Ipv4RoutingTableControllerRequestStream {}
573
574impl futures::stream::FusedStream for Ipv4RoutingTableControllerRequestStream {
575    fn is_terminated(&self) -> bool {
576        self.is_terminated
577    }
578}
579
580impl fidl::endpoints::RequestStream for Ipv4RoutingTableControllerRequestStream {
581    type Protocol = Ipv4RoutingTableControllerMarker;
582    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
583
584    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
585        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
586    }
587
588    fn control_handle(&self) -> Self::ControlHandle {
589        Ipv4RoutingTableControllerControlHandle { inner: self.inner.clone() }
590    }
591
592    fn into_inner(
593        self,
594    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
595    {
596        (self.inner, self.is_terminated)
597    }
598
599    fn from_inner(
600        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
601        is_terminated: bool,
602    ) -> Self {
603        Self { inner, is_terminated }
604    }
605}
606
607impl futures::Stream for Ipv4RoutingTableControllerRequestStream {
608    type Item = Result<Ipv4RoutingTableControllerRequest, fidl::Error>;
609
610    fn poll_next(
611        mut self: std::pin::Pin<&mut Self>,
612        cx: &mut std::task::Context<'_>,
613    ) -> std::task::Poll<Option<Self::Item>> {
614        let this = &mut *self;
615        if this.inner.check_shutdown(cx) {
616            this.is_terminated = true;
617            return std::task::Poll::Ready(None);
618        }
619        if this.is_terminated {
620            panic!("polled Ipv4RoutingTableControllerRequestStream after completion");
621        }
622        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
623            |bytes, handles| {
624                match this.inner.channel().read_etc(cx, bytes, handles) {
625                    std::task::Poll::Ready(Ok(())) => {}
626                    std::task::Poll::Pending => return std::task::Poll::Pending,
627                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
628                        this.is_terminated = true;
629                        return std::task::Poll::Ready(None);
630                    }
631                    std::task::Poll::Ready(Err(e)) => {
632                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
633                            e.into(),
634                        ))));
635                    }
636                }
637
638                // A message has been received from the channel
639                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
640
641                std::task::Poll::Ready(Some(match header.ordinal {
642                0x6098a90553ef1aed => {
643                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
644                    let mut req = fidl::new_empty!(Ipv4RoutingTableControllerAddRouteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
645                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv4RoutingTableControllerAddRouteRequest>(&header, _body_bytes, handles, &mut req)?;
646                    let control_handle = Ipv4RoutingTableControllerControlHandle {
647                        inner: this.inner.clone(),
648                    };
649                    Ok(Ipv4RoutingTableControllerRequest::AddRoute {addresses: req.addresses,
650route: req.route,
651
652                        responder: Ipv4RoutingTableControllerAddRouteResponder {
653                            control_handle: std::mem::ManuallyDrop::new(control_handle),
654                            tx_id: header.tx_id,
655                        },
656                    })
657                }
658                0x14a0727b797aff74 => {
659                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
660                    let mut req = fidl::new_empty!(Ipv4RoutingTableControllerDelRouteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
661                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv4RoutingTableControllerDelRouteRequest>(&header, _body_bytes, handles, &mut req)?;
662                    let control_handle = Ipv4RoutingTableControllerControlHandle {
663                        inner: this.inner.clone(),
664                    };
665                    Ok(Ipv4RoutingTableControllerRequest::DelRoute {addresses: req.addresses,
666
667                        responder: Ipv4RoutingTableControllerDelRouteResponder {
668                            control_handle: std::mem::ManuallyDrop::new(control_handle),
669                            tx_id: header.tx_id,
670                        },
671                    })
672                }
673                0x176ad8488370c1e9 => {
674                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
675                    let mut req = fidl::new_empty!(Ipv4RoutingTableControllerGetRouteStatsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
676                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv4RoutingTableControllerGetRouteStatsRequest>(&header, _body_bytes, handles, &mut req)?;
677                    let control_handle = Ipv4RoutingTableControllerControlHandle {
678                        inner: this.inner.clone(),
679                    };
680                    Ok(Ipv4RoutingTableControllerRequest::GetRouteStats {addresses: req.addresses,
681
682                        responder: Ipv4RoutingTableControllerGetRouteStatsResponder {
683                            control_handle: std::mem::ManuallyDrop::new(control_handle),
684                            tx_id: header.tx_id,
685                        },
686                    })
687                }
688                0x3e4336c50718d7f9 => {
689                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
690                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
691                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
692                    let control_handle = Ipv4RoutingTableControllerControlHandle {
693                        inner: this.inner.clone(),
694                    };
695                    Ok(Ipv4RoutingTableControllerRequest::WatchRoutingEvents {
696                        responder: Ipv4RoutingTableControllerWatchRoutingEventsResponder {
697                            control_handle: std::mem::ManuallyDrop::new(control_handle),
698                            tx_id: header.tx_id,
699                        },
700                    })
701                }
702                _ => Err(fidl::Error::UnknownOrdinal {
703                    ordinal: header.ordinal,
704                    protocol_name: <Ipv4RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
705                }),
706            }))
707            },
708        )
709    }
710}
711
712/// The IPv4 multicast routing controller.
713///
714/// Closing the client-end of the controller will disable multicast routing and
715/// clear the multicast routing table.
716#[derive(Debug)]
717pub enum Ipv4RoutingTableControllerRequest {
718    /// Adds a route such that packets matching the addresses will be forwarded
719    /// accordingly.
720    ///
721    /// The provided addresses act as the key for the route; any existing route
722    /// with the same addresses will be overwritten when this route is
723    /// installed.
724    ///
725    /// If a packet arrives at an interface different from the expected input
726    /// interface set in the route, the packet will not be forwarded and a
727    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
728    /// See [`WatchRoutingEvents`] for more details.
729    ///
730    /// + request `addresses` the addresses used to identify a route.
731    /// + request `route` the multicast route.
732    AddRoute {
733        addresses: Ipv4UnicastSourceAndMulticastDestination,
734        route: Route,
735        responder: Ipv4RoutingTableControllerAddRouteResponder,
736    },
737    /// Delete a route.
738    ///
739    /// + request `addresses` the addresses used to identify a route.
740    DelRoute {
741        addresses: Ipv4UnicastSourceAndMulticastDestination,
742        responder: Ipv4RoutingTableControllerDelRouteResponder,
743    },
744    /// Get a snapshot of statistics about a specific route.
745    ///
746    /// + request `addresses` the addresses used to identify a route.
747    GetRouteStats {
748        addresses: Ipv4UnicastSourceAndMulticastDestination,
749        responder: Ipv4RoutingTableControllerGetRouteStatsResponder,
750    },
751    /// Watch for events triggered by multicast packets.
752    ///
753    /// The server will queue events to return when this method is called. If no
754    /// events are ready, the call will block until an event is ready. The
755    /// server will drop new events if the client is not consuming them fast
756    /// enough and return the number of events dropped in-between events.
757    ///
758    /// It is invalid to call this method while a previous call is pending.
759    /// Doing so will cause the server end of the protocol to be closed.
760    ///
761    /// - response `dropped_events` the number of events that were dropped
762    ///   _immediately before_ the returned event was queued.
763    ///   returned event.
764    /// - response `addresses` the addresses in the multicast packet triggering
765    ///   the event.
766    /// - response `input_interface` the interface the multicast packet
767    ///   triggering the event arrived at.
768    /// - response `event` the event.
769    WatchRoutingEvents { responder: Ipv4RoutingTableControllerWatchRoutingEventsResponder },
770}
771
772impl Ipv4RoutingTableControllerRequest {
773    #[allow(irrefutable_let_patterns)]
774    pub fn into_add_route(
775        self,
776    ) -> Option<(
777        Ipv4UnicastSourceAndMulticastDestination,
778        Route,
779        Ipv4RoutingTableControllerAddRouteResponder,
780    )> {
781        if let Ipv4RoutingTableControllerRequest::AddRoute { addresses, route, responder } = self {
782            Some((addresses, route, responder))
783        } else {
784            None
785        }
786    }
787
788    #[allow(irrefutable_let_patterns)]
789    pub fn into_del_route(
790        self,
791    ) -> Option<(
792        Ipv4UnicastSourceAndMulticastDestination,
793        Ipv4RoutingTableControllerDelRouteResponder,
794    )> {
795        if let Ipv4RoutingTableControllerRequest::DelRoute { addresses, responder } = self {
796            Some((addresses, responder))
797        } else {
798            None
799        }
800    }
801
802    #[allow(irrefutable_let_patterns)]
803    pub fn into_get_route_stats(
804        self,
805    ) -> Option<(
806        Ipv4UnicastSourceAndMulticastDestination,
807        Ipv4RoutingTableControllerGetRouteStatsResponder,
808    )> {
809        if let Ipv4RoutingTableControllerRequest::GetRouteStats { addresses, responder } = self {
810            Some((addresses, responder))
811        } else {
812            None
813        }
814    }
815
816    #[allow(irrefutable_let_patterns)]
817    pub fn into_watch_routing_events(
818        self,
819    ) -> Option<(Ipv4RoutingTableControllerWatchRoutingEventsResponder)> {
820        if let Ipv4RoutingTableControllerRequest::WatchRoutingEvents { responder } = self {
821            Some((responder))
822        } else {
823            None
824        }
825    }
826
827    /// Name of the method defined in FIDL
828    pub fn method_name(&self) -> &'static str {
829        match *self {
830            Ipv4RoutingTableControllerRequest::AddRoute { .. } => "add_route",
831            Ipv4RoutingTableControllerRequest::DelRoute { .. } => "del_route",
832            Ipv4RoutingTableControllerRequest::GetRouteStats { .. } => "get_route_stats",
833            Ipv4RoutingTableControllerRequest::WatchRoutingEvents { .. } => "watch_routing_events",
834        }
835    }
836}
837
838#[derive(Debug, Clone)]
839pub struct Ipv4RoutingTableControllerControlHandle {
840    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
841}
842
843impl Ipv4RoutingTableControllerControlHandle {
844    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
845        self.inner.shutdown_with_epitaph(status.into())
846    }
847}
848
849impl fidl::endpoints::ControlHandle for Ipv4RoutingTableControllerControlHandle {
850    fn shutdown(&self) {
851        self.inner.shutdown()
852    }
853
854    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
855        self.inner.shutdown_with_epitaph(status)
856    }
857
858    fn is_closed(&self) -> bool {
859        self.inner.channel().is_closed()
860    }
861    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
862        self.inner.channel().on_closed()
863    }
864
865    #[cfg(target_os = "fuchsia")]
866    fn signal_peer(
867        &self,
868        clear_mask: zx::Signals,
869        set_mask: zx::Signals,
870    ) -> Result<(), zx_status::Status> {
871        use fidl::Peered;
872        self.inner.channel().signal_peer(clear_mask, set_mask)
873    }
874}
875
876impl Ipv4RoutingTableControllerControlHandle {
877    pub fn send_on_close(&self, mut error: TableControllerCloseReason) -> Result<(), fidl::Error> {
878        self.inner.send::<Ipv4RoutingTableControllerOnCloseRequest>(
879            (error,),
880            0,
881            0x3dec49c6c2070f14,
882            fidl::encoding::DynamicFlags::empty(),
883        )
884    }
885}
886
887#[must_use = "FIDL methods require a response to be sent"]
888#[derive(Debug)]
889pub struct Ipv4RoutingTableControllerAddRouteResponder {
890    control_handle: std::mem::ManuallyDrop<Ipv4RoutingTableControllerControlHandle>,
891    tx_id: u32,
892}
893
894/// Set the the channel to be shutdown (see [`Ipv4RoutingTableControllerControlHandle::shutdown`])
895/// if the responder is dropped without sending a response, so that the client
896/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
897impl std::ops::Drop for Ipv4RoutingTableControllerAddRouteResponder {
898    fn drop(&mut self) {
899        self.control_handle.shutdown();
900        // Safety: drops once, never accessed again
901        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
902    }
903}
904
905impl fidl::endpoints::Responder for Ipv4RoutingTableControllerAddRouteResponder {
906    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
907
908    fn control_handle(&self) -> &Ipv4RoutingTableControllerControlHandle {
909        &self.control_handle
910    }
911
912    fn drop_without_shutdown(mut self) {
913        // Safety: drops once, never accessed again due to mem::forget
914        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
915        // Prevent Drop from running (which would shut down the channel)
916        std::mem::forget(self);
917    }
918}
919
920impl Ipv4RoutingTableControllerAddRouteResponder {
921    /// Sends a response to the FIDL transaction.
922    ///
923    /// Sets the channel to shutdown if an error occurs.
924    pub fn send(
925        self,
926        mut result: Result<(), Ipv4RoutingTableControllerAddRouteError>,
927    ) -> Result<(), fidl::Error> {
928        let _result = self.send_raw(result);
929        if _result.is_err() {
930            self.control_handle.shutdown();
931        }
932        self.drop_without_shutdown();
933        _result
934    }
935
936    /// Similar to "send" but does not shutdown the channel if an error occurs.
937    pub fn send_no_shutdown_on_err(
938        self,
939        mut result: Result<(), Ipv4RoutingTableControllerAddRouteError>,
940    ) -> Result<(), fidl::Error> {
941        let _result = self.send_raw(result);
942        self.drop_without_shutdown();
943        _result
944    }
945
946    fn send_raw(
947        &self,
948        mut result: Result<(), Ipv4RoutingTableControllerAddRouteError>,
949    ) -> Result<(), fidl::Error> {
950        self.control_handle.inner.send::<fidl::encoding::ResultType<
951            fidl::encoding::EmptyStruct,
952            Ipv4RoutingTableControllerAddRouteError,
953        >>(
954            result,
955            self.tx_id,
956            0x6098a90553ef1aed,
957            fidl::encoding::DynamicFlags::empty(),
958        )
959    }
960}
961
962#[must_use = "FIDL methods require a response to be sent"]
963#[derive(Debug)]
964pub struct Ipv4RoutingTableControllerDelRouteResponder {
965    control_handle: std::mem::ManuallyDrop<Ipv4RoutingTableControllerControlHandle>,
966    tx_id: u32,
967}
968
969/// Set the the channel to be shutdown (see [`Ipv4RoutingTableControllerControlHandle::shutdown`])
970/// if the responder is dropped without sending a response, so that the client
971/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
972impl std::ops::Drop for Ipv4RoutingTableControllerDelRouteResponder {
973    fn drop(&mut self) {
974        self.control_handle.shutdown();
975        // Safety: drops once, never accessed again
976        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
977    }
978}
979
980impl fidl::endpoints::Responder for Ipv4RoutingTableControllerDelRouteResponder {
981    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
982
983    fn control_handle(&self) -> &Ipv4RoutingTableControllerControlHandle {
984        &self.control_handle
985    }
986
987    fn drop_without_shutdown(mut self) {
988        // Safety: drops once, never accessed again due to mem::forget
989        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
990        // Prevent Drop from running (which would shut down the channel)
991        std::mem::forget(self);
992    }
993}
994
995impl Ipv4RoutingTableControllerDelRouteResponder {
996    /// Sends a response to the FIDL transaction.
997    ///
998    /// Sets the channel to shutdown if an error occurs.
999    pub fn send(
1000        self,
1001        mut result: Result<(), Ipv4RoutingTableControllerDelRouteError>,
1002    ) -> Result<(), fidl::Error> {
1003        let _result = self.send_raw(result);
1004        if _result.is_err() {
1005            self.control_handle.shutdown();
1006        }
1007        self.drop_without_shutdown();
1008        _result
1009    }
1010
1011    /// Similar to "send" but does not shutdown the channel if an error occurs.
1012    pub fn send_no_shutdown_on_err(
1013        self,
1014        mut result: Result<(), Ipv4RoutingTableControllerDelRouteError>,
1015    ) -> Result<(), fidl::Error> {
1016        let _result = self.send_raw(result);
1017        self.drop_without_shutdown();
1018        _result
1019    }
1020
1021    fn send_raw(
1022        &self,
1023        mut result: Result<(), Ipv4RoutingTableControllerDelRouteError>,
1024    ) -> Result<(), fidl::Error> {
1025        self.control_handle.inner.send::<fidl::encoding::ResultType<
1026            fidl::encoding::EmptyStruct,
1027            Ipv4RoutingTableControllerDelRouteError,
1028        >>(
1029            result,
1030            self.tx_id,
1031            0x14a0727b797aff74,
1032            fidl::encoding::DynamicFlags::empty(),
1033        )
1034    }
1035}
1036
1037#[must_use = "FIDL methods require a response to be sent"]
1038#[derive(Debug)]
1039pub struct Ipv4RoutingTableControllerGetRouteStatsResponder {
1040    control_handle: std::mem::ManuallyDrop<Ipv4RoutingTableControllerControlHandle>,
1041    tx_id: u32,
1042}
1043
1044/// Set the the channel to be shutdown (see [`Ipv4RoutingTableControllerControlHandle::shutdown`])
1045/// if the responder is dropped without sending a response, so that the client
1046/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1047impl std::ops::Drop for Ipv4RoutingTableControllerGetRouteStatsResponder {
1048    fn drop(&mut self) {
1049        self.control_handle.shutdown();
1050        // Safety: drops once, never accessed again
1051        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1052    }
1053}
1054
1055impl fidl::endpoints::Responder for Ipv4RoutingTableControllerGetRouteStatsResponder {
1056    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
1057
1058    fn control_handle(&self) -> &Ipv4RoutingTableControllerControlHandle {
1059        &self.control_handle
1060    }
1061
1062    fn drop_without_shutdown(mut self) {
1063        // Safety: drops once, never accessed again due to mem::forget
1064        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1065        // Prevent Drop from running (which would shut down the channel)
1066        std::mem::forget(self);
1067    }
1068}
1069
1070impl Ipv4RoutingTableControllerGetRouteStatsResponder {
1071    /// Sends a response to the FIDL transaction.
1072    ///
1073    /// Sets the channel to shutdown if an error occurs.
1074    pub fn send(
1075        self,
1076        mut result: Result<&RouteStats, Ipv4RoutingTableControllerGetRouteStatsError>,
1077    ) -> Result<(), fidl::Error> {
1078        let _result = self.send_raw(result);
1079        if _result.is_err() {
1080            self.control_handle.shutdown();
1081        }
1082        self.drop_without_shutdown();
1083        _result
1084    }
1085
1086    /// Similar to "send" but does not shutdown the channel if an error occurs.
1087    pub fn send_no_shutdown_on_err(
1088        self,
1089        mut result: Result<&RouteStats, Ipv4RoutingTableControllerGetRouteStatsError>,
1090    ) -> Result<(), fidl::Error> {
1091        let _result = self.send_raw(result);
1092        self.drop_without_shutdown();
1093        _result
1094    }
1095
1096    fn send_raw(
1097        &self,
1098        mut result: Result<&RouteStats, Ipv4RoutingTableControllerGetRouteStatsError>,
1099    ) -> Result<(), fidl::Error> {
1100        self.control_handle.inner.send::<fidl::encoding::ResultType<
1101            Ipv4RoutingTableControllerGetRouteStatsResponse,
1102            Ipv4RoutingTableControllerGetRouteStatsError,
1103        >>(
1104            result.map(|stats| (stats,)),
1105            self.tx_id,
1106            0x176ad8488370c1e9,
1107            fidl::encoding::DynamicFlags::empty(),
1108        )
1109    }
1110}
1111
1112#[must_use = "FIDL methods require a response to be sent"]
1113#[derive(Debug)]
1114pub struct Ipv4RoutingTableControllerWatchRoutingEventsResponder {
1115    control_handle: std::mem::ManuallyDrop<Ipv4RoutingTableControllerControlHandle>,
1116    tx_id: u32,
1117}
1118
1119/// Set the the channel to be shutdown (see [`Ipv4RoutingTableControllerControlHandle::shutdown`])
1120/// if the responder is dropped without sending a response, so that the client
1121/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1122impl std::ops::Drop for Ipv4RoutingTableControllerWatchRoutingEventsResponder {
1123    fn drop(&mut self) {
1124        self.control_handle.shutdown();
1125        // Safety: drops once, never accessed again
1126        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1127    }
1128}
1129
1130impl fidl::endpoints::Responder for Ipv4RoutingTableControllerWatchRoutingEventsResponder {
1131    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
1132
1133    fn control_handle(&self) -> &Ipv4RoutingTableControllerControlHandle {
1134        &self.control_handle
1135    }
1136
1137    fn drop_without_shutdown(mut self) {
1138        // Safety: drops once, never accessed again due to mem::forget
1139        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1140        // Prevent Drop from running (which would shut down the channel)
1141        std::mem::forget(self);
1142    }
1143}
1144
1145impl Ipv4RoutingTableControllerWatchRoutingEventsResponder {
1146    /// Sends a response to the FIDL transaction.
1147    ///
1148    /// Sets the channel to shutdown if an error occurs.
1149    pub fn send(
1150        self,
1151        mut dropped_events: u64,
1152        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
1153        mut input_interface: u64,
1154        mut event: &RoutingEvent,
1155    ) -> Result<(), fidl::Error> {
1156        let _result = self.send_raw(dropped_events, addresses, input_interface, event);
1157        if _result.is_err() {
1158            self.control_handle.shutdown();
1159        }
1160        self.drop_without_shutdown();
1161        _result
1162    }
1163
1164    /// Similar to "send" but does not shutdown the channel if an error occurs.
1165    pub fn send_no_shutdown_on_err(
1166        self,
1167        mut dropped_events: u64,
1168        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
1169        mut input_interface: u64,
1170        mut event: &RoutingEvent,
1171    ) -> Result<(), fidl::Error> {
1172        let _result = self.send_raw(dropped_events, addresses, input_interface, event);
1173        self.drop_without_shutdown();
1174        _result
1175    }
1176
1177    fn send_raw(
1178        &self,
1179        mut dropped_events: u64,
1180        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
1181        mut input_interface: u64,
1182        mut event: &RoutingEvent,
1183    ) -> Result<(), fidl::Error> {
1184        self.control_handle.inner.send::<Ipv4RoutingTableControllerWatchRoutingEventsResponse>(
1185            (dropped_events, addresses, input_interface, event),
1186            self.tx_id,
1187            0x3e4336c50718d7f9,
1188            fidl::encoding::DynamicFlags::empty(),
1189        )
1190    }
1191}
1192
1193#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1194pub struct Ipv6RoutingTableControllerMarker;
1195
1196impl fidl::endpoints::ProtocolMarker for Ipv6RoutingTableControllerMarker {
1197    type Proxy = Ipv6RoutingTableControllerProxy;
1198    type RequestStream = Ipv6RoutingTableControllerRequestStream;
1199    #[cfg(target_os = "fuchsia")]
1200    type SynchronousProxy = Ipv6RoutingTableControllerSynchronousProxy;
1201
1202    const DEBUG_NAME: &'static str = "fuchsia.net.multicast.admin.Ipv6RoutingTableController";
1203}
1204impl fidl::endpoints::DiscoverableProtocolMarker for Ipv6RoutingTableControllerMarker {}
1205pub type Ipv6RoutingTableControllerAddRouteResult =
1206    Result<(), Ipv6RoutingTableControllerAddRouteError>;
1207pub type Ipv6RoutingTableControllerDelRouteResult =
1208    Result<(), Ipv6RoutingTableControllerDelRouteError>;
1209pub type Ipv6RoutingTableControllerGetRouteStatsResult =
1210    Result<RouteStats, Ipv6RoutingTableControllerGetRouteStatsError>;
1211
1212pub trait Ipv6RoutingTableControllerProxyInterface: Send + Sync {
1213    type AddRouteResponseFut: std::future::Future<Output = Result<Ipv6RoutingTableControllerAddRouteResult, fidl::Error>>
1214        + Send;
1215    fn r#add_route(
1216        &self,
1217        addresses: &Ipv6UnicastSourceAndMulticastDestination,
1218        route: &Route,
1219    ) -> Self::AddRouteResponseFut;
1220    type DelRouteResponseFut: std::future::Future<Output = Result<Ipv6RoutingTableControllerDelRouteResult, fidl::Error>>
1221        + Send;
1222    fn r#del_route(
1223        &self,
1224        addresses: &Ipv6UnicastSourceAndMulticastDestination,
1225    ) -> Self::DelRouteResponseFut;
1226    type GetRouteStatsResponseFut: std::future::Future<
1227            Output = Result<Ipv6RoutingTableControllerGetRouteStatsResult, fidl::Error>,
1228        > + Send;
1229    fn r#get_route_stats(
1230        &self,
1231        addresses: &Ipv6UnicastSourceAndMulticastDestination,
1232    ) -> Self::GetRouteStatsResponseFut;
1233    type WatchRoutingEventsResponseFut: std::future::Future<
1234            Output = Result<
1235                (u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent),
1236                fidl::Error,
1237            >,
1238        > + Send;
1239    fn r#watch_routing_events(&self) -> Self::WatchRoutingEventsResponseFut;
1240}
1241#[derive(Debug)]
1242#[cfg(target_os = "fuchsia")]
1243pub struct Ipv6RoutingTableControllerSynchronousProxy {
1244    client: fidl::client::sync::Client,
1245}
1246
1247#[cfg(target_os = "fuchsia")]
1248impl fidl::endpoints::SynchronousProxy for Ipv6RoutingTableControllerSynchronousProxy {
1249    type Proxy = Ipv6RoutingTableControllerProxy;
1250    type Protocol = Ipv6RoutingTableControllerMarker;
1251
1252    fn from_channel(inner: fidl::Channel) -> Self {
1253        Self::new(inner)
1254    }
1255
1256    fn into_channel(self) -> fidl::Channel {
1257        self.client.into_channel()
1258    }
1259
1260    fn as_channel(&self) -> &fidl::Channel {
1261        self.client.as_channel()
1262    }
1263}
1264
1265#[cfg(target_os = "fuchsia")]
1266impl Ipv6RoutingTableControllerSynchronousProxy {
1267    pub fn new(channel: fidl::Channel) -> Self {
1268        Self { client: fidl::client::sync::Client::new(channel) }
1269    }
1270
1271    pub fn into_channel(self) -> fidl::Channel {
1272        self.client.into_channel()
1273    }
1274
1275    /// Waits until an event arrives and returns it. It is safe for other
1276    /// threads to make concurrent requests while waiting for an event.
1277    pub fn wait_for_event(
1278        &self,
1279        deadline: zx::MonotonicInstant,
1280    ) -> Result<Ipv6RoutingTableControllerEvent, fidl::Error> {
1281        Ipv6RoutingTableControllerEvent::decode(
1282            self.client.wait_for_event::<Ipv6RoutingTableControllerMarker>(deadline)?,
1283        )
1284    }
1285
1286    /// Adds a route such that packets matching the addresses will be forwarded
1287    /// accordingly.
1288    ///
1289    /// The provided addresses act as the key for the route; any existing route
1290    /// with the same addresses will be overwritten when this route is
1291    /// installed.
1292    ///
1293    /// If a packet arrives at an interface different from the expected input
1294    /// interface set in the route, the packet will not be forwarded and a
1295    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
1296    /// See [`WatchRoutingEvents`] for more details.
1297    ///
1298    /// + request `addresses` the addresses used to identify a route.
1299    /// + request `route` the multicast route.
1300    pub fn r#add_route(
1301        &self,
1302        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1303        mut route: &Route,
1304        ___deadline: zx::MonotonicInstant,
1305    ) -> Result<Ipv6RoutingTableControllerAddRouteResult, fidl::Error> {
1306        let _response = self
1307            .client
1308            .send_query::<Ipv6RoutingTableControllerAddRouteRequest, fidl::encoding::ResultType<
1309                fidl::encoding::EmptyStruct,
1310                Ipv6RoutingTableControllerAddRouteError,
1311            >, Ipv6RoutingTableControllerMarker>(
1312                (addresses, route),
1313                0x71ca1f54a716de90,
1314                fidl::encoding::DynamicFlags::empty(),
1315                ___deadline,
1316            )?;
1317        Ok(_response.map(|x| x))
1318    }
1319
1320    /// Delete a route.
1321    ///
1322    /// + request `addresses` the addresses used to identify a route.
1323    pub fn r#del_route(
1324        &self,
1325        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1326        ___deadline: zx::MonotonicInstant,
1327    ) -> Result<Ipv6RoutingTableControllerDelRouteResult, fidl::Error> {
1328        let _response = self
1329            .client
1330            .send_query::<Ipv6RoutingTableControllerDelRouteRequest, fidl::encoding::ResultType<
1331                fidl::encoding::EmptyStruct,
1332                Ipv6RoutingTableControllerDelRouteError,
1333            >, Ipv6RoutingTableControllerMarker>(
1334                (addresses,),
1335                0x35b6c2ce4a7b3f13,
1336                fidl::encoding::DynamicFlags::empty(),
1337                ___deadline,
1338            )?;
1339        Ok(_response.map(|x| x))
1340    }
1341
1342    /// Get a snapshot of statistics about a specific route.
1343    ///
1344    /// + request `addresses` the addresses used to identify a route.
1345    pub fn r#get_route_stats(
1346        &self,
1347        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1348        ___deadline: zx::MonotonicInstant,
1349    ) -> Result<Ipv6RoutingTableControllerGetRouteStatsResult, fidl::Error> {
1350        let _response = self.client.send_query::<
1351            Ipv6RoutingTableControllerGetRouteStatsRequest,
1352            fidl::encoding::ResultType<Ipv6RoutingTableControllerGetRouteStatsResponse, Ipv6RoutingTableControllerGetRouteStatsError>,
1353            Ipv6RoutingTableControllerMarker,
1354        >(
1355            (addresses,),
1356            0x6d7fa5e9f18ef79f,
1357            fidl::encoding::DynamicFlags::empty(),
1358            ___deadline,
1359        )?;
1360        Ok(_response.map(|x| x.stats))
1361    }
1362
1363    /// Watch for events triggered by multicast packets.
1364    ///
1365    /// The server will queue events to return when this method is called. If no
1366    /// events are ready, the call will block until an event is ready. The
1367    /// server will drop new events if the client is not consuming them fast
1368    /// enough and return the number of events dropped in-between events.
1369    ///
1370    /// It is invalid to call this method while a previous call is pending.
1371    /// Doing so will cause the server end of the protocol to be closed.
1372    ///
1373    /// - response `dropped_events` the number of events that were dropped
1374    ///   _immediately before_ the returned event was queued.
1375    ///   returned event.
1376    /// - response `addresses` the addresses in the multicast packet triggering
1377    ///   the event.
1378    /// - response `input_interface` the interface the multicast packet
1379    ///   triggering the event arrived at.
1380    /// - response `event` the event.
1381    pub fn r#watch_routing_events(
1382        &self,
1383        ___deadline: zx::MonotonicInstant,
1384    ) -> Result<(u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent), fidl::Error>
1385    {
1386        let _response = self.client.send_query::<
1387            fidl::encoding::EmptyPayload,
1388            Ipv6RoutingTableControllerWatchRoutingEventsResponse,
1389            Ipv6RoutingTableControllerMarker,
1390        >(
1391            (),
1392            0x22a94526a0ea1078,
1393            fidl::encoding::DynamicFlags::empty(),
1394            ___deadline,
1395        )?;
1396        Ok((
1397            _response.dropped_events,
1398            _response.addresses,
1399            _response.input_interface,
1400            _response.event,
1401        ))
1402    }
1403}
1404
1405#[cfg(target_os = "fuchsia")]
1406impl From<Ipv6RoutingTableControllerSynchronousProxy> for zx::NullableHandle {
1407    fn from(value: Ipv6RoutingTableControllerSynchronousProxy) -> Self {
1408        value.into_channel().into()
1409    }
1410}
1411
1412#[cfg(target_os = "fuchsia")]
1413impl From<fidl::Channel> for Ipv6RoutingTableControllerSynchronousProxy {
1414    fn from(value: fidl::Channel) -> Self {
1415        Self::new(value)
1416    }
1417}
1418
1419#[cfg(target_os = "fuchsia")]
1420impl fidl::endpoints::FromClient for Ipv6RoutingTableControllerSynchronousProxy {
1421    type Protocol = Ipv6RoutingTableControllerMarker;
1422
1423    fn from_client(value: fidl::endpoints::ClientEnd<Ipv6RoutingTableControllerMarker>) -> Self {
1424        Self::new(value.into_channel())
1425    }
1426}
1427
1428#[derive(Debug, Clone)]
1429pub struct Ipv6RoutingTableControllerProxy {
1430    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1431}
1432
1433impl fidl::endpoints::Proxy for Ipv6RoutingTableControllerProxy {
1434    type Protocol = Ipv6RoutingTableControllerMarker;
1435
1436    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1437        Self::new(inner)
1438    }
1439
1440    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1441        self.client.into_channel().map_err(|client| Self { client })
1442    }
1443
1444    fn as_channel(&self) -> &::fidl::AsyncChannel {
1445        self.client.as_channel()
1446    }
1447}
1448
1449impl Ipv6RoutingTableControllerProxy {
1450    /// Create a new Proxy for fuchsia.net.multicast.admin/Ipv6RoutingTableController.
1451    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1452        let protocol_name =
1453            <Ipv6RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1454        Self { client: fidl::client::Client::new(channel, protocol_name) }
1455    }
1456
1457    /// Get a Stream of events from the remote end of the protocol.
1458    ///
1459    /// # Panics
1460    ///
1461    /// Panics if the event stream was already taken.
1462    pub fn take_event_stream(&self) -> Ipv6RoutingTableControllerEventStream {
1463        Ipv6RoutingTableControllerEventStream { event_receiver: self.client.take_event_receiver() }
1464    }
1465
1466    /// Adds a route such that packets matching the addresses will be forwarded
1467    /// accordingly.
1468    ///
1469    /// The provided addresses act as the key for the route; any existing route
1470    /// with the same addresses will be overwritten when this route is
1471    /// installed.
1472    ///
1473    /// If a packet arrives at an interface different from the expected input
1474    /// interface set in the route, the packet will not be forwarded and a
1475    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
1476    /// See [`WatchRoutingEvents`] for more details.
1477    ///
1478    /// + request `addresses` the addresses used to identify a route.
1479    /// + request `route` the multicast route.
1480    pub fn r#add_route(
1481        &self,
1482        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1483        mut route: &Route,
1484    ) -> fidl::client::QueryResponseFut<
1485        Ipv6RoutingTableControllerAddRouteResult,
1486        fidl::encoding::DefaultFuchsiaResourceDialect,
1487    > {
1488        Ipv6RoutingTableControllerProxyInterface::r#add_route(self, addresses, route)
1489    }
1490
1491    /// Delete a route.
1492    ///
1493    /// + request `addresses` the addresses used to identify a route.
1494    pub fn r#del_route(
1495        &self,
1496        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1497    ) -> fidl::client::QueryResponseFut<
1498        Ipv6RoutingTableControllerDelRouteResult,
1499        fidl::encoding::DefaultFuchsiaResourceDialect,
1500    > {
1501        Ipv6RoutingTableControllerProxyInterface::r#del_route(self, addresses)
1502    }
1503
1504    /// Get a snapshot of statistics about a specific route.
1505    ///
1506    /// + request `addresses` the addresses used to identify a route.
1507    pub fn r#get_route_stats(
1508        &self,
1509        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1510    ) -> fidl::client::QueryResponseFut<
1511        Ipv6RoutingTableControllerGetRouteStatsResult,
1512        fidl::encoding::DefaultFuchsiaResourceDialect,
1513    > {
1514        Ipv6RoutingTableControllerProxyInterface::r#get_route_stats(self, addresses)
1515    }
1516
1517    /// Watch for events triggered by multicast packets.
1518    ///
1519    /// The server will queue events to return when this method is called. If no
1520    /// events are ready, the call will block until an event is ready. The
1521    /// server will drop new events if the client is not consuming them fast
1522    /// enough and return the number of events dropped in-between events.
1523    ///
1524    /// It is invalid to call this method while a previous call is pending.
1525    /// Doing so will cause the server end of the protocol to be closed.
1526    ///
1527    /// - response `dropped_events` the number of events that were dropped
1528    ///   _immediately before_ the returned event was queued.
1529    ///   returned event.
1530    /// - response `addresses` the addresses in the multicast packet triggering
1531    ///   the event.
1532    /// - response `input_interface` the interface the multicast packet
1533    ///   triggering the event arrived at.
1534    /// - response `event` the event.
1535    pub fn r#watch_routing_events(
1536        &self,
1537    ) -> fidl::client::QueryResponseFut<
1538        (u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent),
1539        fidl::encoding::DefaultFuchsiaResourceDialect,
1540    > {
1541        Ipv6RoutingTableControllerProxyInterface::r#watch_routing_events(self)
1542    }
1543}
1544
1545impl Ipv6RoutingTableControllerProxyInterface for Ipv6RoutingTableControllerProxy {
1546    type AddRouteResponseFut = fidl::client::QueryResponseFut<
1547        Ipv6RoutingTableControllerAddRouteResult,
1548        fidl::encoding::DefaultFuchsiaResourceDialect,
1549    >;
1550    fn r#add_route(
1551        &self,
1552        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1553        mut route: &Route,
1554    ) -> Self::AddRouteResponseFut {
1555        fn _decode(
1556            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1557        ) -> Result<Ipv6RoutingTableControllerAddRouteResult, fidl::Error> {
1558            let _response = fidl::client::decode_transaction_body::<
1559                fidl::encoding::ResultType<
1560                    fidl::encoding::EmptyStruct,
1561                    Ipv6RoutingTableControllerAddRouteError,
1562                >,
1563                fidl::encoding::DefaultFuchsiaResourceDialect,
1564                0x71ca1f54a716de90,
1565            >(_buf?)?;
1566            Ok(_response.map(|x| x))
1567        }
1568        self.client.send_query_and_decode::<
1569            Ipv6RoutingTableControllerAddRouteRequest,
1570            Ipv6RoutingTableControllerAddRouteResult,
1571        >(
1572            (addresses, route,),
1573            0x71ca1f54a716de90,
1574            fidl::encoding::DynamicFlags::empty(),
1575            _decode,
1576        )
1577    }
1578
1579    type DelRouteResponseFut = fidl::client::QueryResponseFut<
1580        Ipv6RoutingTableControllerDelRouteResult,
1581        fidl::encoding::DefaultFuchsiaResourceDialect,
1582    >;
1583    fn r#del_route(
1584        &self,
1585        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1586    ) -> Self::DelRouteResponseFut {
1587        fn _decode(
1588            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1589        ) -> Result<Ipv6RoutingTableControllerDelRouteResult, fidl::Error> {
1590            let _response = fidl::client::decode_transaction_body::<
1591                fidl::encoding::ResultType<
1592                    fidl::encoding::EmptyStruct,
1593                    Ipv6RoutingTableControllerDelRouteError,
1594                >,
1595                fidl::encoding::DefaultFuchsiaResourceDialect,
1596                0x35b6c2ce4a7b3f13,
1597            >(_buf?)?;
1598            Ok(_response.map(|x| x))
1599        }
1600        self.client.send_query_and_decode::<
1601            Ipv6RoutingTableControllerDelRouteRequest,
1602            Ipv6RoutingTableControllerDelRouteResult,
1603        >(
1604            (addresses,),
1605            0x35b6c2ce4a7b3f13,
1606            fidl::encoding::DynamicFlags::empty(),
1607            _decode,
1608        )
1609    }
1610
1611    type GetRouteStatsResponseFut = fidl::client::QueryResponseFut<
1612        Ipv6RoutingTableControllerGetRouteStatsResult,
1613        fidl::encoding::DefaultFuchsiaResourceDialect,
1614    >;
1615    fn r#get_route_stats(
1616        &self,
1617        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1618    ) -> Self::GetRouteStatsResponseFut {
1619        fn _decode(
1620            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1621        ) -> Result<Ipv6RoutingTableControllerGetRouteStatsResult, fidl::Error> {
1622            let _response = fidl::client::decode_transaction_body::<
1623                fidl::encoding::ResultType<
1624                    Ipv6RoutingTableControllerGetRouteStatsResponse,
1625                    Ipv6RoutingTableControllerGetRouteStatsError,
1626                >,
1627                fidl::encoding::DefaultFuchsiaResourceDialect,
1628                0x6d7fa5e9f18ef79f,
1629            >(_buf?)?;
1630            Ok(_response.map(|x| x.stats))
1631        }
1632        self.client.send_query_and_decode::<
1633            Ipv6RoutingTableControllerGetRouteStatsRequest,
1634            Ipv6RoutingTableControllerGetRouteStatsResult,
1635        >(
1636            (addresses,),
1637            0x6d7fa5e9f18ef79f,
1638            fidl::encoding::DynamicFlags::empty(),
1639            _decode,
1640        )
1641    }
1642
1643    type WatchRoutingEventsResponseFut = fidl::client::QueryResponseFut<
1644        (u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent),
1645        fidl::encoding::DefaultFuchsiaResourceDialect,
1646    >;
1647    fn r#watch_routing_events(&self) -> Self::WatchRoutingEventsResponseFut {
1648        fn _decode(
1649            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1650        ) -> Result<(u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent), fidl::Error>
1651        {
1652            let _response = fidl::client::decode_transaction_body::<
1653                Ipv6RoutingTableControllerWatchRoutingEventsResponse,
1654                fidl::encoding::DefaultFuchsiaResourceDialect,
1655                0x22a94526a0ea1078,
1656            >(_buf?)?;
1657            Ok((
1658                _response.dropped_events,
1659                _response.addresses,
1660                _response.input_interface,
1661                _response.event,
1662            ))
1663        }
1664        self.client.send_query_and_decode::<
1665            fidl::encoding::EmptyPayload,
1666            (u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent),
1667        >(
1668            (),
1669            0x22a94526a0ea1078,
1670            fidl::encoding::DynamicFlags::empty(),
1671            _decode,
1672        )
1673    }
1674}
1675
1676pub struct Ipv6RoutingTableControllerEventStream {
1677    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1678}
1679
1680impl std::marker::Unpin for Ipv6RoutingTableControllerEventStream {}
1681
1682impl futures::stream::FusedStream for Ipv6RoutingTableControllerEventStream {
1683    fn is_terminated(&self) -> bool {
1684        self.event_receiver.is_terminated()
1685    }
1686}
1687
1688impl futures::Stream for Ipv6RoutingTableControllerEventStream {
1689    type Item = Result<Ipv6RoutingTableControllerEvent, fidl::Error>;
1690
1691    fn poll_next(
1692        mut self: std::pin::Pin<&mut Self>,
1693        cx: &mut std::task::Context<'_>,
1694    ) -> std::task::Poll<Option<Self::Item>> {
1695        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1696            &mut self.event_receiver,
1697            cx
1698        )?) {
1699            Some(buf) => std::task::Poll::Ready(Some(Ipv6RoutingTableControllerEvent::decode(buf))),
1700            None => std::task::Poll::Ready(None),
1701        }
1702    }
1703}
1704
1705#[derive(Debug)]
1706pub enum Ipv6RoutingTableControllerEvent {
1707    OnClose { error: TableControllerCloseReason },
1708}
1709
1710impl Ipv6RoutingTableControllerEvent {
1711    #[allow(irrefutable_let_patterns)]
1712    pub fn into_on_close(self) -> Option<TableControllerCloseReason> {
1713        if let Ipv6RoutingTableControllerEvent::OnClose { error } = self {
1714            Some((error))
1715        } else {
1716            None
1717        }
1718    }
1719
1720    /// Decodes a message buffer as a [`Ipv6RoutingTableControllerEvent`].
1721    fn decode(
1722        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1723    ) -> Result<Ipv6RoutingTableControllerEvent, fidl::Error> {
1724        let (bytes, _handles) = buf.split_mut();
1725        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1726        debug_assert_eq!(tx_header.tx_id, 0);
1727        match tx_header.ordinal {
1728            0x2d3a353489d1e0be => {
1729                let mut out = fidl::new_empty!(Ipv6RoutingTableControllerOnCloseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1730                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv6RoutingTableControllerOnCloseRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1731                Ok((
1732                    Ipv6RoutingTableControllerEvent::OnClose {error: out.error,
1733
1734                    }
1735                ))
1736            }
1737            _ => Err(fidl::Error::UnknownOrdinal {
1738                ordinal: tx_header.ordinal,
1739                protocol_name: <Ipv6RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1740            })
1741        }
1742    }
1743}
1744
1745/// A Stream of incoming requests for fuchsia.net.multicast.admin/Ipv6RoutingTableController.
1746pub struct Ipv6RoutingTableControllerRequestStream {
1747    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1748    is_terminated: bool,
1749}
1750
1751impl std::marker::Unpin for Ipv6RoutingTableControllerRequestStream {}
1752
1753impl futures::stream::FusedStream for Ipv6RoutingTableControllerRequestStream {
1754    fn is_terminated(&self) -> bool {
1755        self.is_terminated
1756    }
1757}
1758
1759impl fidl::endpoints::RequestStream for Ipv6RoutingTableControllerRequestStream {
1760    type Protocol = Ipv6RoutingTableControllerMarker;
1761    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
1762
1763    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1764        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1765    }
1766
1767    fn control_handle(&self) -> Self::ControlHandle {
1768        Ipv6RoutingTableControllerControlHandle { inner: self.inner.clone() }
1769    }
1770
1771    fn into_inner(
1772        self,
1773    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1774    {
1775        (self.inner, self.is_terminated)
1776    }
1777
1778    fn from_inner(
1779        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1780        is_terminated: bool,
1781    ) -> Self {
1782        Self { inner, is_terminated }
1783    }
1784}
1785
1786impl futures::Stream for Ipv6RoutingTableControllerRequestStream {
1787    type Item = Result<Ipv6RoutingTableControllerRequest, fidl::Error>;
1788
1789    fn poll_next(
1790        mut self: std::pin::Pin<&mut Self>,
1791        cx: &mut std::task::Context<'_>,
1792    ) -> std::task::Poll<Option<Self::Item>> {
1793        let this = &mut *self;
1794        if this.inner.check_shutdown(cx) {
1795            this.is_terminated = true;
1796            return std::task::Poll::Ready(None);
1797        }
1798        if this.is_terminated {
1799            panic!("polled Ipv6RoutingTableControllerRequestStream after completion");
1800        }
1801        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1802            |bytes, handles| {
1803                match this.inner.channel().read_etc(cx, bytes, handles) {
1804                    std::task::Poll::Ready(Ok(())) => {}
1805                    std::task::Poll::Pending => return std::task::Poll::Pending,
1806                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1807                        this.is_terminated = true;
1808                        return std::task::Poll::Ready(None);
1809                    }
1810                    std::task::Poll::Ready(Err(e)) => {
1811                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1812                            e.into(),
1813                        ))));
1814                    }
1815                }
1816
1817                // A message has been received from the channel
1818                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1819
1820                std::task::Poll::Ready(Some(match header.ordinal {
1821                0x71ca1f54a716de90 => {
1822                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1823                    let mut req = fidl::new_empty!(Ipv6RoutingTableControllerAddRouteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1824                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv6RoutingTableControllerAddRouteRequest>(&header, _body_bytes, handles, &mut req)?;
1825                    let control_handle = Ipv6RoutingTableControllerControlHandle {
1826                        inner: this.inner.clone(),
1827                    };
1828                    Ok(Ipv6RoutingTableControllerRequest::AddRoute {addresses: req.addresses,
1829route: req.route,
1830
1831                        responder: Ipv6RoutingTableControllerAddRouteResponder {
1832                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1833                            tx_id: header.tx_id,
1834                        },
1835                    })
1836                }
1837                0x35b6c2ce4a7b3f13 => {
1838                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1839                    let mut req = fidl::new_empty!(Ipv6RoutingTableControllerDelRouteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1840                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv6RoutingTableControllerDelRouteRequest>(&header, _body_bytes, handles, &mut req)?;
1841                    let control_handle = Ipv6RoutingTableControllerControlHandle {
1842                        inner: this.inner.clone(),
1843                    };
1844                    Ok(Ipv6RoutingTableControllerRequest::DelRoute {addresses: req.addresses,
1845
1846                        responder: Ipv6RoutingTableControllerDelRouteResponder {
1847                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1848                            tx_id: header.tx_id,
1849                        },
1850                    })
1851                }
1852                0x6d7fa5e9f18ef79f => {
1853                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1854                    let mut req = fidl::new_empty!(Ipv6RoutingTableControllerGetRouteStatsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1855                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv6RoutingTableControllerGetRouteStatsRequest>(&header, _body_bytes, handles, &mut req)?;
1856                    let control_handle = Ipv6RoutingTableControllerControlHandle {
1857                        inner: this.inner.clone(),
1858                    };
1859                    Ok(Ipv6RoutingTableControllerRequest::GetRouteStats {addresses: req.addresses,
1860
1861                        responder: Ipv6RoutingTableControllerGetRouteStatsResponder {
1862                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1863                            tx_id: header.tx_id,
1864                        },
1865                    })
1866                }
1867                0x22a94526a0ea1078 => {
1868                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1869                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1870                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1871                    let control_handle = Ipv6RoutingTableControllerControlHandle {
1872                        inner: this.inner.clone(),
1873                    };
1874                    Ok(Ipv6RoutingTableControllerRequest::WatchRoutingEvents {
1875                        responder: Ipv6RoutingTableControllerWatchRoutingEventsResponder {
1876                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1877                            tx_id: header.tx_id,
1878                        },
1879                    })
1880                }
1881                _ => Err(fidl::Error::UnknownOrdinal {
1882                    ordinal: header.ordinal,
1883                    protocol_name: <Ipv6RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1884                }),
1885            }))
1886            },
1887        )
1888    }
1889}
1890
1891/// The IPv6 multicast routing controller.
1892///
1893/// Closing the client-end of the controller will disable multicast routing and
1894/// clear the multicast routing table.
1895#[derive(Debug)]
1896pub enum Ipv6RoutingTableControllerRequest {
1897    /// Adds a route such that packets matching the addresses will be forwarded
1898    /// accordingly.
1899    ///
1900    /// The provided addresses act as the key for the route; any existing route
1901    /// with the same addresses will be overwritten when this route is
1902    /// installed.
1903    ///
1904    /// If a packet arrives at an interface different from the expected input
1905    /// interface set in the route, the packet will not be forwarded and a
1906    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
1907    /// See [`WatchRoutingEvents`] for more details.
1908    ///
1909    /// + request `addresses` the addresses used to identify a route.
1910    /// + request `route` the multicast route.
1911    AddRoute {
1912        addresses: Ipv6UnicastSourceAndMulticastDestination,
1913        route: Route,
1914        responder: Ipv6RoutingTableControllerAddRouteResponder,
1915    },
1916    /// Delete a route.
1917    ///
1918    /// + request `addresses` the addresses used to identify a route.
1919    DelRoute {
1920        addresses: Ipv6UnicastSourceAndMulticastDestination,
1921        responder: Ipv6RoutingTableControllerDelRouteResponder,
1922    },
1923    /// Get a snapshot of statistics about a specific route.
1924    ///
1925    /// + request `addresses` the addresses used to identify a route.
1926    GetRouteStats {
1927        addresses: Ipv6UnicastSourceAndMulticastDestination,
1928        responder: Ipv6RoutingTableControllerGetRouteStatsResponder,
1929    },
1930    /// Watch for events triggered by multicast packets.
1931    ///
1932    /// The server will queue events to return when this method is called. If no
1933    /// events are ready, the call will block until an event is ready. The
1934    /// server will drop new events if the client is not consuming them fast
1935    /// enough and return the number of events dropped in-between events.
1936    ///
1937    /// It is invalid to call this method while a previous call is pending.
1938    /// Doing so will cause the server end of the protocol to be closed.
1939    ///
1940    /// - response `dropped_events` the number of events that were dropped
1941    ///   _immediately before_ the returned event was queued.
1942    ///   returned event.
1943    /// - response `addresses` the addresses in the multicast packet triggering
1944    ///   the event.
1945    /// - response `input_interface` the interface the multicast packet
1946    ///   triggering the event arrived at.
1947    /// - response `event` the event.
1948    WatchRoutingEvents { responder: Ipv6RoutingTableControllerWatchRoutingEventsResponder },
1949}
1950
1951impl Ipv6RoutingTableControllerRequest {
1952    #[allow(irrefutable_let_patterns)]
1953    pub fn into_add_route(
1954        self,
1955    ) -> Option<(
1956        Ipv6UnicastSourceAndMulticastDestination,
1957        Route,
1958        Ipv6RoutingTableControllerAddRouteResponder,
1959    )> {
1960        if let Ipv6RoutingTableControllerRequest::AddRoute { addresses, route, responder } = self {
1961            Some((addresses, route, responder))
1962        } else {
1963            None
1964        }
1965    }
1966
1967    #[allow(irrefutable_let_patterns)]
1968    pub fn into_del_route(
1969        self,
1970    ) -> Option<(
1971        Ipv6UnicastSourceAndMulticastDestination,
1972        Ipv6RoutingTableControllerDelRouteResponder,
1973    )> {
1974        if let Ipv6RoutingTableControllerRequest::DelRoute { addresses, responder } = self {
1975            Some((addresses, responder))
1976        } else {
1977            None
1978        }
1979    }
1980
1981    #[allow(irrefutable_let_patterns)]
1982    pub fn into_get_route_stats(
1983        self,
1984    ) -> Option<(
1985        Ipv6UnicastSourceAndMulticastDestination,
1986        Ipv6RoutingTableControllerGetRouteStatsResponder,
1987    )> {
1988        if let Ipv6RoutingTableControllerRequest::GetRouteStats { addresses, responder } = self {
1989            Some((addresses, responder))
1990        } else {
1991            None
1992        }
1993    }
1994
1995    #[allow(irrefutable_let_patterns)]
1996    pub fn into_watch_routing_events(
1997        self,
1998    ) -> Option<(Ipv6RoutingTableControllerWatchRoutingEventsResponder)> {
1999        if let Ipv6RoutingTableControllerRequest::WatchRoutingEvents { responder } = self {
2000            Some((responder))
2001        } else {
2002            None
2003        }
2004    }
2005
2006    /// Name of the method defined in FIDL
2007    pub fn method_name(&self) -> &'static str {
2008        match *self {
2009            Ipv6RoutingTableControllerRequest::AddRoute { .. } => "add_route",
2010            Ipv6RoutingTableControllerRequest::DelRoute { .. } => "del_route",
2011            Ipv6RoutingTableControllerRequest::GetRouteStats { .. } => "get_route_stats",
2012            Ipv6RoutingTableControllerRequest::WatchRoutingEvents { .. } => "watch_routing_events",
2013        }
2014    }
2015}
2016
2017#[derive(Debug, Clone)]
2018pub struct Ipv6RoutingTableControllerControlHandle {
2019    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2020}
2021
2022impl Ipv6RoutingTableControllerControlHandle {
2023    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2024        self.inner.shutdown_with_epitaph(status.into())
2025    }
2026}
2027
2028impl fidl::endpoints::ControlHandle for Ipv6RoutingTableControllerControlHandle {
2029    fn shutdown(&self) {
2030        self.inner.shutdown()
2031    }
2032
2033    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2034        self.inner.shutdown_with_epitaph(status)
2035    }
2036
2037    fn is_closed(&self) -> bool {
2038        self.inner.channel().is_closed()
2039    }
2040    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2041        self.inner.channel().on_closed()
2042    }
2043
2044    #[cfg(target_os = "fuchsia")]
2045    fn signal_peer(
2046        &self,
2047        clear_mask: zx::Signals,
2048        set_mask: zx::Signals,
2049    ) -> Result<(), zx_status::Status> {
2050        use fidl::Peered;
2051        self.inner.channel().signal_peer(clear_mask, set_mask)
2052    }
2053}
2054
2055impl Ipv6RoutingTableControllerControlHandle {
2056    pub fn send_on_close(&self, mut error: TableControllerCloseReason) -> Result<(), fidl::Error> {
2057        self.inner.send::<Ipv6RoutingTableControllerOnCloseRequest>(
2058            (error,),
2059            0,
2060            0x2d3a353489d1e0be,
2061            fidl::encoding::DynamicFlags::empty(),
2062        )
2063    }
2064}
2065
2066#[must_use = "FIDL methods require a response to be sent"]
2067#[derive(Debug)]
2068pub struct Ipv6RoutingTableControllerAddRouteResponder {
2069    control_handle: std::mem::ManuallyDrop<Ipv6RoutingTableControllerControlHandle>,
2070    tx_id: u32,
2071}
2072
2073/// Set the the channel to be shutdown (see [`Ipv6RoutingTableControllerControlHandle::shutdown`])
2074/// if the responder is dropped without sending a response, so that the client
2075/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2076impl std::ops::Drop for Ipv6RoutingTableControllerAddRouteResponder {
2077    fn drop(&mut self) {
2078        self.control_handle.shutdown();
2079        // Safety: drops once, never accessed again
2080        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2081    }
2082}
2083
2084impl fidl::endpoints::Responder for Ipv6RoutingTableControllerAddRouteResponder {
2085    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
2086
2087    fn control_handle(&self) -> &Ipv6RoutingTableControllerControlHandle {
2088        &self.control_handle
2089    }
2090
2091    fn drop_without_shutdown(mut self) {
2092        // Safety: drops once, never accessed again due to mem::forget
2093        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2094        // Prevent Drop from running (which would shut down the channel)
2095        std::mem::forget(self);
2096    }
2097}
2098
2099impl Ipv6RoutingTableControllerAddRouteResponder {
2100    /// Sends a response to the FIDL transaction.
2101    ///
2102    /// Sets the channel to shutdown if an error occurs.
2103    pub fn send(
2104        self,
2105        mut result: Result<(), Ipv6RoutingTableControllerAddRouteError>,
2106    ) -> Result<(), fidl::Error> {
2107        let _result = self.send_raw(result);
2108        if _result.is_err() {
2109            self.control_handle.shutdown();
2110        }
2111        self.drop_without_shutdown();
2112        _result
2113    }
2114
2115    /// Similar to "send" but does not shutdown the channel if an error occurs.
2116    pub fn send_no_shutdown_on_err(
2117        self,
2118        mut result: Result<(), Ipv6RoutingTableControllerAddRouteError>,
2119    ) -> Result<(), fidl::Error> {
2120        let _result = self.send_raw(result);
2121        self.drop_without_shutdown();
2122        _result
2123    }
2124
2125    fn send_raw(
2126        &self,
2127        mut result: Result<(), Ipv6RoutingTableControllerAddRouteError>,
2128    ) -> Result<(), fidl::Error> {
2129        self.control_handle.inner.send::<fidl::encoding::ResultType<
2130            fidl::encoding::EmptyStruct,
2131            Ipv6RoutingTableControllerAddRouteError,
2132        >>(
2133            result,
2134            self.tx_id,
2135            0x71ca1f54a716de90,
2136            fidl::encoding::DynamicFlags::empty(),
2137        )
2138    }
2139}
2140
2141#[must_use = "FIDL methods require a response to be sent"]
2142#[derive(Debug)]
2143pub struct Ipv6RoutingTableControllerDelRouteResponder {
2144    control_handle: std::mem::ManuallyDrop<Ipv6RoutingTableControllerControlHandle>,
2145    tx_id: u32,
2146}
2147
2148/// Set the the channel to be shutdown (see [`Ipv6RoutingTableControllerControlHandle::shutdown`])
2149/// if the responder is dropped without sending a response, so that the client
2150/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2151impl std::ops::Drop for Ipv6RoutingTableControllerDelRouteResponder {
2152    fn drop(&mut self) {
2153        self.control_handle.shutdown();
2154        // Safety: drops once, never accessed again
2155        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2156    }
2157}
2158
2159impl fidl::endpoints::Responder for Ipv6RoutingTableControllerDelRouteResponder {
2160    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
2161
2162    fn control_handle(&self) -> &Ipv6RoutingTableControllerControlHandle {
2163        &self.control_handle
2164    }
2165
2166    fn drop_without_shutdown(mut self) {
2167        // Safety: drops once, never accessed again due to mem::forget
2168        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2169        // Prevent Drop from running (which would shut down the channel)
2170        std::mem::forget(self);
2171    }
2172}
2173
2174impl Ipv6RoutingTableControllerDelRouteResponder {
2175    /// Sends a response to the FIDL transaction.
2176    ///
2177    /// Sets the channel to shutdown if an error occurs.
2178    pub fn send(
2179        self,
2180        mut result: Result<(), Ipv6RoutingTableControllerDelRouteError>,
2181    ) -> Result<(), fidl::Error> {
2182        let _result = self.send_raw(result);
2183        if _result.is_err() {
2184            self.control_handle.shutdown();
2185        }
2186        self.drop_without_shutdown();
2187        _result
2188    }
2189
2190    /// Similar to "send" but does not shutdown the channel if an error occurs.
2191    pub fn send_no_shutdown_on_err(
2192        self,
2193        mut result: Result<(), Ipv6RoutingTableControllerDelRouteError>,
2194    ) -> Result<(), fidl::Error> {
2195        let _result = self.send_raw(result);
2196        self.drop_without_shutdown();
2197        _result
2198    }
2199
2200    fn send_raw(
2201        &self,
2202        mut result: Result<(), Ipv6RoutingTableControllerDelRouteError>,
2203    ) -> Result<(), fidl::Error> {
2204        self.control_handle.inner.send::<fidl::encoding::ResultType<
2205            fidl::encoding::EmptyStruct,
2206            Ipv6RoutingTableControllerDelRouteError,
2207        >>(
2208            result,
2209            self.tx_id,
2210            0x35b6c2ce4a7b3f13,
2211            fidl::encoding::DynamicFlags::empty(),
2212        )
2213    }
2214}
2215
2216#[must_use = "FIDL methods require a response to be sent"]
2217#[derive(Debug)]
2218pub struct Ipv6RoutingTableControllerGetRouteStatsResponder {
2219    control_handle: std::mem::ManuallyDrop<Ipv6RoutingTableControllerControlHandle>,
2220    tx_id: u32,
2221}
2222
2223/// Set the the channel to be shutdown (see [`Ipv6RoutingTableControllerControlHandle::shutdown`])
2224/// if the responder is dropped without sending a response, so that the client
2225/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2226impl std::ops::Drop for Ipv6RoutingTableControllerGetRouteStatsResponder {
2227    fn drop(&mut self) {
2228        self.control_handle.shutdown();
2229        // Safety: drops once, never accessed again
2230        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2231    }
2232}
2233
2234impl fidl::endpoints::Responder for Ipv6RoutingTableControllerGetRouteStatsResponder {
2235    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
2236
2237    fn control_handle(&self) -> &Ipv6RoutingTableControllerControlHandle {
2238        &self.control_handle
2239    }
2240
2241    fn drop_without_shutdown(mut self) {
2242        // Safety: drops once, never accessed again due to mem::forget
2243        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2244        // Prevent Drop from running (which would shut down the channel)
2245        std::mem::forget(self);
2246    }
2247}
2248
2249impl Ipv6RoutingTableControllerGetRouteStatsResponder {
2250    /// Sends a response to the FIDL transaction.
2251    ///
2252    /// Sets the channel to shutdown if an error occurs.
2253    pub fn send(
2254        self,
2255        mut result: Result<&RouteStats, Ipv6RoutingTableControllerGetRouteStatsError>,
2256    ) -> Result<(), fidl::Error> {
2257        let _result = self.send_raw(result);
2258        if _result.is_err() {
2259            self.control_handle.shutdown();
2260        }
2261        self.drop_without_shutdown();
2262        _result
2263    }
2264
2265    /// Similar to "send" but does not shutdown the channel if an error occurs.
2266    pub fn send_no_shutdown_on_err(
2267        self,
2268        mut result: Result<&RouteStats, Ipv6RoutingTableControllerGetRouteStatsError>,
2269    ) -> Result<(), fidl::Error> {
2270        let _result = self.send_raw(result);
2271        self.drop_without_shutdown();
2272        _result
2273    }
2274
2275    fn send_raw(
2276        &self,
2277        mut result: Result<&RouteStats, Ipv6RoutingTableControllerGetRouteStatsError>,
2278    ) -> Result<(), fidl::Error> {
2279        self.control_handle.inner.send::<fidl::encoding::ResultType<
2280            Ipv6RoutingTableControllerGetRouteStatsResponse,
2281            Ipv6RoutingTableControllerGetRouteStatsError,
2282        >>(
2283            result.map(|stats| (stats,)),
2284            self.tx_id,
2285            0x6d7fa5e9f18ef79f,
2286            fidl::encoding::DynamicFlags::empty(),
2287        )
2288    }
2289}
2290
2291#[must_use = "FIDL methods require a response to be sent"]
2292#[derive(Debug)]
2293pub struct Ipv6RoutingTableControllerWatchRoutingEventsResponder {
2294    control_handle: std::mem::ManuallyDrop<Ipv6RoutingTableControllerControlHandle>,
2295    tx_id: u32,
2296}
2297
2298/// Set the the channel to be shutdown (see [`Ipv6RoutingTableControllerControlHandle::shutdown`])
2299/// if the responder is dropped without sending a response, so that the client
2300/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2301impl std::ops::Drop for Ipv6RoutingTableControllerWatchRoutingEventsResponder {
2302    fn drop(&mut self) {
2303        self.control_handle.shutdown();
2304        // Safety: drops once, never accessed again
2305        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2306    }
2307}
2308
2309impl fidl::endpoints::Responder for Ipv6RoutingTableControllerWatchRoutingEventsResponder {
2310    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
2311
2312    fn control_handle(&self) -> &Ipv6RoutingTableControllerControlHandle {
2313        &self.control_handle
2314    }
2315
2316    fn drop_without_shutdown(mut self) {
2317        // Safety: drops once, never accessed again due to mem::forget
2318        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2319        // Prevent Drop from running (which would shut down the channel)
2320        std::mem::forget(self);
2321    }
2322}
2323
2324impl Ipv6RoutingTableControllerWatchRoutingEventsResponder {
2325    /// Sends a response to the FIDL transaction.
2326    ///
2327    /// Sets the channel to shutdown if an error occurs.
2328    pub fn send(
2329        self,
2330        mut dropped_events: u64,
2331        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
2332        mut input_interface: u64,
2333        mut event: &RoutingEvent,
2334    ) -> Result<(), fidl::Error> {
2335        let _result = self.send_raw(dropped_events, addresses, input_interface, event);
2336        if _result.is_err() {
2337            self.control_handle.shutdown();
2338        }
2339        self.drop_without_shutdown();
2340        _result
2341    }
2342
2343    /// Similar to "send" but does not shutdown the channel if an error occurs.
2344    pub fn send_no_shutdown_on_err(
2345        self,
2346        mut dropped_events: u64,
2347        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
2348        mut input_interface: u64,
2349        mut event: &RoutingEvent,
2350    ) -> Result<(), fidl::Error> {
2351        let _result = self.send_raw(dropped_events, addresses, input_interface, event);
2352        self.drop_without_shutdown();
2353        _result
2354    }
2355
2356    fn send_raw(
2357        &self,
2358        mut dropped_events: u64,
2359        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
2360        mut input_interface: u64,
2361        mut event: &RoutingEvent,
2362    ) -> Result<(), fidl::Error> {
2363        self.control_handle.inner.send::<Ipv6RoutingTableControllerWatchRoutingEventsResponse>(
2364            (dropped_events, addresses, input_interface, event),
2365            self.tx_id,
2366            0x22a94526a0ea1078,
2367            fidl::encoding::DynamicFlags::empty(),
2368        )
2369    }
2370}
2371
2372mod internal {
2373    use super::*;
2374}