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 fidl::endpoints::ControlHandle for Ipv4RoutingTableControllerControlHandle {
844    fn shutdown(&self) {
845        self.inner.shutdown()
846    }
847
848    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
849        self.inner.shutdown_with_epitaph(status)
850    }
851
852    fn is_closed(&self) -> bool {
853        self.inner.channel().is_closed()
854    }
855    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
856        self.inner.channel().on_closed()
857    }
858
859    #[cfg(target_os = "fuchsia")]
860    fn signal_peer(
861        &self,
862        clear_mask: zx::Signals,
863        set_mask: zx::Signals,
864    ) -> Result<(), zx_status::Status> {
865        use fidl::Peered;
866        self.inner.channel().signal_peer(clear_mask, set_mask)
867    }
868}
869
870impl Ipv4RoutingTableControllerControlHandle {
871    pub fn send_on_close(&self, mut error: TableControllerCloseReason) -> Result<(), fidl::Error> {
872        self.inner.send::<Ipv4RoutingTableControllerOnCloseRequest>(
873            (error,),
874            0,
875            0x3dec49c6c2070f14,
876            fidl::encoding::DynamicFlags::empty(),
877        )
878    }
879}
880
881#[must_use = "FIDL methods require a response to be sent"]
882#[derive(Debug)]
883pub struct Ipv4RoutingTableControllerAddRouteResponder {
884    control_handle: std::mem::ManuallyDrop<Ipv4RoutingTableControllerControlHandle>,
885    tx_id: u32,
886}
887
888/// Set the the channel to be shutdown (see [`Ipv4RoutingTableControllerControlHandle::shutdown`])
889/// if the responder is dropped without sending a response, so that the client
890/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
891impl std::ops::Drop for Ipv4RoutingTableControllerAddRouteResponder {
892    fn drop(&mut self) {
893        self.control_handle.shutdown();
894        // Safety: drops once, never accessed again
895        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
896    }
897}
898
899impl fidl::endpoints::Responder for Ipv4RoutingTableControllerAddRouteResponder {
900    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
901
902    fn control_handle(&self) -> &Ipv4RoutingTableControllerControlHandle {
903        &self.control_handle
904    }
905
906    fn drop_without_shutdown(mut self) {
907        // Safety: drops once, never accessed again due to mem::forget
908        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
909        // Prevent Drop from running (which would shut down the channel)
910        std::mem::forget(self);
911    }
912}
913
914impl Ipv4RoutingTableControllerAddRouteResponder {
915    /// Sends a response to the FIDL transaction.
916    ///
917    /// Sets the channel to shutdown if an error occurs.
918    pub fn send(
919        self,
920        mut result: Result<(), Ipv4RoutingTableControllerAddRouteError>,
921    ) -> Result<(), fidl::Error> {
922        let _result = self.send_raw(result);
923        if _result.is_err() {
924            self.control_handle.shutdown();
925        }
926        self.drop_without_shutdown();
927        _result
928    }
929
930    /// Similar to "send" but does not shutdown the channel if an error occurs.
931    pub fn send_no_shutdown_on_err(
932        self,
933        mut result: Result<(), Ipv4RoutingTableControllerAddRouteError>,
934    ) -> Result<(), fidl::Error> {
935        let _result = self.send_raw(result);
936        self.drop_without_shutdown();
937        _result
938    }
939
940    fn send_raw(
941        &self,
942        mut result: Result<(), Ipv4RoutingTableControllerAddRouteError>,
943    ) -> Result<(), fidl::Error> {
944        self.control_handle.inner.send::<fidl::encoding::ResultType<
945            fidl::encoding::EmptyStruct,
946            Ipv4RoutingTableControllerAddRouteError,
947        >>(
948            result,
949            self.tx_id,
950            0x6098a90553ef1aed,
951            fidl::encoding::DynamicFlags::empty(),
952        )
953    }
954}
955
956#[must_use = "FIDL methods require a response to be sent"]
957#[derive(Debug)]
958pub struct Ipv4RoutingTableControllerDelRouteResponder {
959    control_handle: std::mem::ManuallyDrop<Ipv4RoutingTableControllerControlHandle>,
960    tx_id: u32,
961}
962
963/// Set the the channel to be shutdown (see [`Ipv4RoutingTableControllerControlHandle::shutdown`])
964/// if the responder is dropped without sending a response, so that the client
965/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
966impl std::ops::Drop for Ipv4RoutingTableControllerDelRouteResponder {
967    fn drop(&mut self) {
968        self.control_handle.shutdown();
969        // Safety: drops once, never accessed again
970        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
971    }
972}
973
974impl fidl::endpoints::Responder for Ipv4RoutingTableControllerDelRouteResponder {
975    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
976
977    fn control_handle(&self) -> &Ipv4RoutingTableControllerControlHandle {
978        &self.control_handle
979    }
980
981    fn drop_without_shutdown(mut self) {
982        // Safety: drops once, never accessed again due to mem::forget
983        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
984        // Prevent Drop from running (which would shut down the channel)
985        std::mem::forget(self);
986    }
987}
988
989impl Ipv4RoutingTableControllerDelRouteResponder {
990    /// Sends a response to the FIDL transaction.
991    ///
992    /// Sets the channel to shutdown if an error occurs.
993    pub fn send(
994        self,
995        mut result: Result<(), Ipv4RoutingTableControllerDelRouteError>,
996    ) -> Result<(), fidl::Error> {
997        let _result = self.send_raw(result);
998        if _result.is_err() {
999            self.control_handle.shutdown();
1000        }
1001        self.drop_without_shutdown();
1002        _result
1003    }
1004
1005    /// Similar to "send" but does not shutdown the channel if an error occurs.
1006    pub fn send_no_shutdown_on_err(
1007        self,
1008        mut result: Result<(), Ipv4RoutingTableControllerDelRouteError>,
1009    ) -> Result<(), fidl::Error> {
1010        let _result = self.send_raw(result);
1011        self.drop_without_shutdown();
1012        _result
1013    }
1014
1015    fn send_raw(
1016        &self,
1017        mut result: Result<(), Ipv4RoutingTableControllerDelRouteError>,
1018    ) -> Result<(), fidl::Error> {
1019        self.control_handle.inner.send::<fidl::encoding::ResultType<
1020            fidl::encoding::EmptyStruct,
1021            Ipv4RoutingTableControllerDelRouteError,
1022        >>(
1023            result,
1024            self.tx_id,
1025            0x14a0727b797aff74,
1026            fidl::encoding::DynamicFlags::empty(),
1027        )
1028    }
1029}
1030
1031#[must_use = "FIDL methods require a response to be sent"]
1032#[derive(Debug)]
1033pub struct Ipv4RoutingTableControllerGetRouteStatsResponder {
1034    control_handle: std::mem::ManuallyDrop<Ipv4RoutingTableControllerControlHandle>,
1035    tx_id: u32,
1036}
1037
1038/// Set the the channel to be shutdown (see [`Ipv4RoutingTableControllerControlHandle::shutdown`])
1039/// if the responder is dropped without sending a response, so that the client
1040/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1041impl std::ops::Drop for Ipv4RoutingTableControllerGetRouteStatsResponder {
1042    fn drop(&mut self) {
1043        self.control_handle.shutdown();
1044        // Safety: drops once, never accessed again
1045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1046    }
1047}
1048
1049impl fidl::endpoints::Responder for Ipv4RoutingTableControllerGetRouteStatsResponder {
1050    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
1051
1052    fn control_handle(&self) -> &Ipv4RoutingTableControllerControlHandle {
1053        &self.control_handle
1054    }
1055
1056    fn drop_without_shutdown(mut self) {
1057        // Safety: drops once, never accessed again due to mem::forget
1058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1059        // Prevent Drop from running (which would shut down the channel)
1060        std::mem::forget(self);
1061    }
1062}
1063
1064impl Ipv4RoutingTableControllerGetRouteStatsResponder {
1065    /// Sends a response to the FIDL transaction.
1066    ///
1067    /// Sets the channel to shutdown if an error occurs.
1068    pub fn send(
1069        self,
1070        mut result: Result<&RouteStats, Ipv4RoutingTableControllerGetRouteStatsError>,
1071    ) -> Result<(), fidl::Error> {
1072        let _result = self.send_raw(result);
1073        if _result.is_err() {
1074            self.control_handle.shutdown();
1075        }
1076        self.drop_without_shutdown();
1077        _result
1078    }
1079
1080    /// Similar to "send" but does not shutdown the channel if an error occurs.
1081    pub fn send_no_shutdown_on_err(
1082        self,
1083        mut result: Result<&RouteStats, Ipv4RoutingTableControllerGetRouteStatsError>,
1084    ) -> Result<(), fidl::Error> {
1085        let _result = self.send_raw(result);
1086        self.drop_without_shutdown();
1087        _result
1088    }
1089
1090    fn send_raw(
1091        &self,
1092        mut result: Result<&RouteStats, Ipv4RoutingTableControllerGetRouteStatsError>,
1093    ) -> Result<(), fidl::Error> {
1094        self.control_handle.inner.send::<fidl::encoding::ResultType<
1095            Ipv4RoutingTableControllerGetRouteStatsResponse,
1096            Ipv4RoutingTableControllerGetRouteStatsError,
1097        >>(
1098            result.map(|stats| (stats,)),
1099            self.tx_id,
1100            0x176ad8488370c1e9,
1101            fidl::encoding::DynamicFlags::empty(),
1102        )
1103    }
1104}
1105
1106#[must_use = "FIDL methods require a response to be sent"]
1107#[derive(Debug)]
1108pub struct Ipv4RoutingTableControllerWatchRoutingEventsResponder {
1109    control_handle: std::mem::ManuallyDrop<Ipv4RoutingTableControllerControlHandle>,
1110    tx_id: u32,
1111}
1112
1113/// Set the the channel to be shutdown (see [`Ipv4RoutingTableControllerControlHandle::shutdown`])
1114/// if the responder is dropped without sending a response, so that the client
1115/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1116impl std::ops::Drop for Ipv4RoutingTableControllerWatchRoutingEventsResponder {
1117    fn drop(&mut self) {
1118        self.control_handle.shutdown();
1119        // Safety: drops once, never accessed again
1120        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1121    }
1122}
1123
1124impl fidl::endpoints::Responder for Ipv4RoutingTableControllerWatchRoutingEventsResponder {
1125    type ControlHandle = Ipv4RoutingTableControllerControlHandle;
1126
1127    fn control_handle(&self) -> &Ipv4RoutingTableControllerControlHandle {
1128        &self.control_handle
1129    }
1130
1131    fn drop_without_shutdown(mut self) {
1132        // Safety: drops once, never accessed again due to mem::forget
1133        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1134        // Prevent Drop from running (which would shut down the channel)
1135        std::mem::forget(self);
1136    }
1137}
1138
1139impl Ipv4RoutingTableControllerWatchRoutingEventsResponder {
1140    /// Sends a response to the FIDL transaction.
1141    ///
1142    /// Sets the channel to shutdown if an error occurs.
1143    pub fn send(
1144        self,
1145        mut dropped_events: u64,
1146        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
1147        mut input_interface: u64,
1148        mut event: &RoutingEvent,
1149    ) -> Result<(), fidl::Error> {
1150        let _result = self.send_raw(dropped_events, addresses, input_interface, event);
1151        if _result.is_err() {
1152            self.control_handle.shutdown();
1153        }
1154        self.drop_without_shutdown();
1155        _result
1156    }
1157
1158    /// Similar to "send" but does not shutdown the channel if an error occurs.
1159    pub fn send_no_shutdown_on_err(
1160        self,
1161        mut dropped_events: u64,
1162        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
1163        mut input_interface: u64,
1164        mut event: &RoutingEvent,
1165    ) -> Result<(), fidl::Error> {
1166        let _result = self.send_raw(dropped_events, addresses, input_interface, event);
1167        self.drop_without_shutdown();
1168        _result
1169    }
1170
1171    fn send_raw(
1172        &self,
1173        mut dropped_events: u64,
1174        mut addresses: &Ipv4UnicastSourceAndMulticastDestination,
1175        mut input_interface: u64,
1176        mut event: &RoutingEvent,
1177    ) -> Result<(), fidl::Error> {
1178        self.control_handle.inner.send::<Ipv4RoutingTableControllerWatchRoutingEventsResponse>(
1179            (dropped_events, addresses, input_interface, event),
1180            self.tx_id,
1181            0x3e4336c50718d7f9,
1182            fidl::encoding::DynamicFlags::empty(),
1183        )
1184    }
1185}
1186
1187#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1188pub struct Ipv6RoutingTableControllerMarker;
1189
1190impl fidl::endpoints::ProtocolMarker for Ipv6RoutingTableControllerMarker {
1191    type Proxy = Ipv6RoutingTableControllerProxy;
1192    type RequestStream = Ipv6RoutingTableControllerRequestStream;
1193    #[cfg(target_os = "fuchsia")]
1194    type SynchronousProxy = Ipv6RoutingTableControllerSynchronousProxy;
1195
1196    const DEBUG_NAME: &'static str = "fuchsia.net.multicast.admin.Ipv6RoutingTableController";
1197}
1198impl fidl::endpoints::DiscoverableProtocolMarker for Ipv6RoutingTableControllerMarker {}
1199pub type Ipv6RoutingTableControllerAddRouteResult =
1200    Result<(), Ipv6RoutingTableControllerAddRouteError>;
1201pub type Ipv6RoutingTableControllerDelRouteResult =
1202    Result<(), Ipv6RoutingTableControllerDelRouteError>;
1203pub type Ipv6RoutingTableControllerGetRouteStatsResult =
1204    Result<RouteStats, Ipv6RoutingTableControllerGetRouteStatsError>;
1205
1206pub trait Ipv6RoutingTableControllerProxyInterface: Send + Sync {
1207    type AddRouteResponseFut: std::future::Future<Output = Result<Ipv6RoutingTableControllerAddRouteResult, fidl::Error>>
1208        + Send;
1209    fn r#add_route(
1210        &self,
1211        addresses: &Ipv6UnicastSourceAndMulticastDestination,
1212        route: &Route,
1213    ) -> Self::AddRouteResponseFut;
1214    type DelRouteResponseFut: std::future::Future<Output = Result<Ipv6RoutingTableControllerDelRouteResult, fidl::Error>>
1215        + Send;
1216    fn r#del_route(
1217        &self,
1218        addresses: &Ipv6UnicastSourceAndMulticastDestination,
1219    ) -> Self::DelRouteResponseFut;
1220    type GetRouteStatsResponseFut: std::future::Future<
1221            Output = Result<Ipv6RoutingTableControllerGetRouteStatsResult, fidl::Error>,
1222        > + Send;
1223    fn r#get_route_stats(
1224        &self,
1225        addresses: &Ipv6UnicastSourceAndMulticastDestination,
1226    ) -> Self::GetRouteStatsResponseFut;
1227    type WatchRoutingEventsResponseFut: std::future::Future<
1228            Output = Result<
1229                (u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent),
1230                fidl::Error,
1231            >,
1232        > + Send;
1233    fn r#watch_routing_events(&self) -> Self::WatchRoutingEventsResponseFut;
1234}
1235#[derive(Debug)]
1236#[cfg(target_os = "fuchsia")]
1237pub struct Ipv6RoutingTableControllerSynchronousProxy {
1238    client: fidl::client::sync::Client,
1239}
1240
1241#[cfg(target_os = "fuchsia")]
1242impl fidl::endpoints::SynchronousProxy for Ipv6RoutingTableControllerSynchronousProxy {
1243    type Proxy = Ipv6RoutingTableControllerProxy;
1244    type Protocol = Ipv6RoutingTableControllerMarker;
1245
1246    fn from_channel(inner: fidl::Channel) -> Self {
1247        Self::new(inner)
1248    }
1249
1250    fn into_channel(self) -> fidl::Channel {
1251        self.client.into_channel()
1252    }
1253
1254    fn as_channel(&self) -> &fidl::Channel {
1255        self.client.as_channel()
1256    }
1257}
1258
1259#[cfg(target_os = "fuchsia")]
1260impl Ipv6RoutingTableControllerSynchronousProxy {
1261    pub fn new(channel: fidl::Channel) -> Self {
1262        Self { client: fidl::client::sync::Client::new(channel) }
1263    }
1264
1265    pub fn into_channel(self) -> fidl::Channel {
1266        self.client.into_channel()
1267    }
1268
1269    /// Waits until an event arrives and returns it. It is safe for other
1270    /// threads to make concurrent requests while waiting for an event.
1271    pub fn wait_for_event(
1272        &self,
1273        deadline: zx::MonotonicInstant,
1274    ) -> Result<Ipv6RoutingTableControllerEvent, fidl::Error> {
1275        Ipv6RoutingTableControllerEvent::decode(
1276            self.client.wait_for_event::<Ipv6RoutingTableControllerMarker>(deadline)?,
1277        )
1278    }
1279
1280    /// Adds a route such that packets matching the addresses will be forwarded
1281    /// accordingly.
1282    ///
1283    /// The provided addresses act as the key for the route; any existing route
1284    /// with the same addresses will be overwritten when this route is
1285    /// installed.
1286    ///
1287    /// If a packet arrives at an interface different from the expected input
1288    /// interface set in the route, the packet will not be forwarded and a
1289    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
1290    /// See [`WatchRoutingEvents`] for more details.
1291    ///
1292    /// + request `addresses` the addresses used to identify a route.
1293    /// + request `route` the multicast route.
1294    pub fn r#add_route(
1295        &self,
1296        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1297        mut route: &Route,
1298        ___deadline: zx::MonotonicInstant,
1299    ) -> Result<Ipv6RoutingTableControllerAddRouteResult, fidl::Error> {
1300        let _response = self
1301            .client
1302            .send_query::<Ipv6RoutingTableControllerAddRouteRequest, fidl::encoding::ResultType<
1303                fidl::encoding::EmptyStruct,
1304                Ipv6RoutingTableControllerAddRouteError,
1305            >, Ipv6RoutingTableControllerMarker>(
1306                (addresses, route),
1307                0x71ca1f54a716de90,
1308                fidl::encoding::DynamicFlags::empty(),
1309                ___deadline,
1310            )?;
1311        Ok(_response.map(|x| x))
1312    }
1313
1314    /// Delete a route.
1315    ///
1316    /// + request `addresses` the addresses used to identify a route.
1317    pub fn r#del_route(
1318        &self,
1319        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1320        ___deadline: zx::MonotonicInstant,
1321    ) -> Result<Ipv6RoutingTableControllerDelRouteResult, fidl::Error> {
1322        let _response = self
1323            .client
1324            .send_query::<Ipv6RoutingTableControllerDelRouteRequest, fidl::encoding::ResultType<
1325                fidl::encoding::EmptyStruct,
1326                Ipv6RoutingTableControllerDelRouteError,
1327            >, Ipv6RoutingTableControllerMarker>(
1328                (addresses,),
1329                0x35b6c2ce4a7b3f13,
1330                fidl::encoding::DynamicFlags::empty(),
1331                ___deadline,
1332            )?;
1333        Ok(_response.map(|x| x))
1334    }
1335
1336    /// Get a snapshot of statistics about a specific route.
1337    ///
1338    /// + request `addresses` the addresses used to identify a route.
1339    pub fn r#get_route_stats(
1340        &self,
1341        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1342        ___deadline: zx::MonotonicInstant,
1343    ) -> Result<Ipv6RoutingTableControllerGetRouteStatsResult, fidl::Error> {
1344        let _response = self.client.send_query::<
1345            Ipv6RoutingTableControllerGetRouteStatsRequest,
1346            fidl::encoding::ResultType<Ipv6RoutingTableControllerGetRouteStatsResponse, Ipv6RoutingTableControllerGetRouteStatsError>,
1347            Ipv6RoutingTableControllerMarker,
1348        >(
1349            (addresses,),
1350            0x6d7fa5e9f18ef79f,
1351            fidl::encoding::DynamicFlags::empty(),
1352            ___deadline,
1353        )?;
1354        Ok(_response.map(|x| x.stats))
1355    }
1356
1357    /// Watch for events triggered by multicast packets.
1358    ///
1359    /// The server will queue events to return when this method is called. If no
1360    /// events are ready, the call will block until an event is ready. The
1361    /// server will drop new events if the client is not consuming them fast
1362    /// enough and return the number of events dropped in-between events.
1363    ///
1364    /// It is invalid to call this method while a previous call is pending.
1365    /// Doing so will cause the server end of the protocol to be closed.
1366    ///
1367    /// - response `dropped_events` the number of events that were dropped
1368    ///   _immediately before_ the returned event was queued.
1369    ///   returned event.
1370    /// - response `addresses` the addresses in the multicast packet triggering
1371    ///   the event.
1372    /// - response `input_interface` the interface the multicast packet
1373    ///   triggering the event arrived at.
1374    /// - response `event` the event.
1375    pub fn r#watch_routing_events(
1376        &self,
1377        ___deadline: zx::MonotonicInstant,
1378    ) -> Result<(u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent), fidl::Error>
1379    {
1380        let _response = self.client.send_query::<
1381            fidl::encoding::EmptyPayload,
1382            Ipv6RoutingTableControllerWatchRoutingEventsResponse,
1383            Ipv6RoutingTableControllerMarker,
1384        >(
1385            (),
1386            0x22a94526a0ea1078,
1387            fidl::encoding::DynamicFlags::empty(),
1388            ___deadline,
1389        )?;
1390        Ok((
1391            _response.dropped_events,
1392            _response.addresses,
1393            _response.input_interface,
1394            _response.event,
1395        ))
1396    }
1397}
1398
1399#[cfg(target_os = "fuchsia")]
1400impl From<Ipv6RoutingTableControllerSynchronousProxy> for zx::NullableHandle {
1401    fn from(value: Ipv6RoutingTableControllerSynchronousProxy) -> Self {
1402        value.into_channel().into()
1403    }
1404}
1405
1406#[cfg(target_os = "fuchsia")]
1407impl From<fidl::Channel> for Ipv6RoutingTableControllerSynchronousProxy {
1408    fn from(value: fidl::Channel) -> Self {
1409        Self::new(value)
1410    }
1411}
1412
1413#[cfg(target_os = "fuchsia")]
1414impl fidl::endpoints::FromClient for Ipv6RoutingTableControllerSynchronousProxy {
1415    type Protocol = Ipv6RoutingTableControllerMarker;
1416
1417    fn from_client(value: fidl::endpoints::ClientEnd<Ipv6RoutingTableControllerMarker>) -> Self {
1418        Self::new(value.into_channel())
1419    }
1420}
1421
1422#[derive(Debug, Clone)]
1423pub struct Ipv6RoutingTableControllerProxy {
1424    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1425}
1426
1427impl fidl::endpoints::Proxy for Ipv6RoutingTableControllerProxy {
1428    type Protocol = Ipv6RoutingTableControllerMarker;
1429
1430    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1431        Self::new(inner)
1432    }
1433
1434    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1435        self.client.into_channel().map_err(|client| Self { client })
1436    }
1437
1438    fn as_channel(&self) -> &::fidl::AsyncChannel {
1439        self.client.as_channel()
1440    }
1441}
1442
1443impl Ipv6RoutingTableControllerProxy {
1444    /// Create a new Proxy for fuchsia.net.multicast.admin/Ipv6RoutingTableController.
1445    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1446        let protocol_name =
1447            <Ipv6RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1448        Self { client: fidl::client::Client::new(channel, protocol_name) }
1449    }
1450
1451    /// Get a Stream of events from the remote end of the protocol.
1452    ///
1453    /// # Panics
1454    ///
1455    /// Panics if the event stream was already taken.
1456    pub fn take_event_stream(&self) -> Ipv6RoutingTableControllerEventStream {
1457        Ipv6RoutingTableControllerEventStream { event_receiver: self.client.take_event_receiver() }
1458    }
1459
1460    /// Adds a route such that packets matching the addresses will be forwarded
1461    /// accordingly.
1462    ///
1463    /// The provided addresses act as the key for the route; any existing route
1464    /// with the same addresses will be overwritten when this route is
1465    /// installed.
1466    ///
1467    /// If a packet arrives at an interface different from the expected input
1468    /// interface set in the route, the packet will not be forwarded and a
1469    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
1470    /// See [`WatchRoutingEvents`] for more details.
1471    ///
1472    /// + request `addresses` the addresses used to identify a route.
1473    /// + request `route` the multicast route.
1474    pub fn r#add_route(
1475        &self,
1476        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1477        mut route: &Route,
1478    ) -> fidl::client::QueryResponseFut<
1479        Ipv6RoutingTableControllerAddRouteResult,
1480        fidl::encoding::DefaultFuchsiaResourceDialect,
1481    > {
1482        Ipv6RoutingTableControllerProxyInterface::r#add_route(self, addresses, route)
1483    }
1484
1485    /// Delete a route.
1486    ///
1487    /// + request `addresses` the addresses used to identify a route.
1488    pub fn r#del_route(
1489        &self,
1490        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1491    ) -> fidl::client::QueryResponseFut<
1492        Ipv6RoutingTableControllerDelRouteResult,
1493        fidl::encoding::DefaultFuchsiaResourceDialect,
1494    > {
1495        Ipv6RoutingTableControllerProxyInterface::r#del_route(self, addresses)
1496    }
1497
1498    /// Get a snapshot of statistics about a specific route.
1499    ///
1500    /// + request `addresses` the addresses used to identify a route.
1501    pub fn r#get_route_stats(
1502        &self,
1503        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1504    ) -> fidl::client::QueryResponseFut<
1505        Ipv6RoutingTableControllerGetRouteStatsResult,
1506        fidl::encoding::DefaultFuchsiaResourceDialect,
1507    > {
1508        Ipv6RoutingTableControllerProxyInterface::r#get_route_stats(self, addresses)
1509    }
1510
1511    /// Watch for events triggered by multicast packets.
1512    ///
1513    /// The server will queue events to return when this method is called. If no
1514    /// events are ready, the call will block until an event is ready. The
1515    /// server will drop new events if the client is not consuming them fast
1516    /// enough and return the number of events dropped in-between events.
1517    ///
1518    /// It is invalid to call this method while a previous call is pending.
1519    /// Doing so will cause the server end of the protocol to be closed.
1520    ///
1521    /// - response `dropped_events` the number of events that were dropped
1522    ///   _immediately before_ the returned event was queued.
1523    ///   returned event.
1524    /// - response `addresses` the addresses in the multicast packet triggering
1525    ///   the event.
1526    /// - response `input_interface` the interface the multicast packet
1527    ///   triggering the event arrived at.
1528    /// - response `event` the event.
1529    pub fn r#watch_routing_events(
1530        &self,
1531    ) -> fidl::client::QueryResponseFut<
1532        (u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent),
1533        fidl::encoding::DefaultFuchsiaResourceDialect,
1534    > {
1535        Ipv6RoutingTableControllerProxyInterface::r#watch_routing_events(self)
1536    }
1537}
1538
1539impl Ipv6RoutingTableControllerProxyInterface for Ipv6RoutingTableControllerProxy {
1540    type AddRouteResponseFut = fidl::client::QueryResponseFut<
1541        Ipv6RoutingTableControllerAddRouteResult,
1542        fidl::encoding::DefaultFuchsiaResourceDialect,
1543    >;
1544    fn r#add_route(
1545        &self,
1546        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1547        mut route: &Route,
1548    ) -> Self::AddRouteResponseFut {
1549        fn _decode(
1550            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1551        ) -> Result<Ipv6RoutingTableControllerAddRouteResult, fidl::Error> {
1552            let _response = fidl::client::decode_transaction_body::<
1553                fidl::encoding::ResultType<
1554                    fidl::encoding::EmptyStruct,
1555                    Ipv6RoutingTableControllerAddRouteError,
1556                >,
1557                fidl::encoding::DefaultFuchsiaResourceDialect,
1558                0x71ca1f54a716de90,
1559            >(_buf?)?;
1560            Ok(_response.map(|x| x))
1561        }
1562        self.client.send_query_and_decode::<
1563            Ipv6RoutingTableControllerAddRouteRequest,
1564            Ipv6RoutingTableControllerAddRouteResult,
1565        >(
1566            (addresses, route,),
1567            0x71ca1f54a716de90,
1568            fidl::encoding::DynamicFlags::empty(),
1569            _decode,
1570        )
1571    }
1572
1573    type DelRouteResponseFut = fidl::client::QueryResponseFut<
1574        Ipv6RoutingTableControllerDelRouteResult,
1575        fidl::encoding::DefaultFuchsiaResourceDialect,
1576    >;
1577    fn r#del_route(
1578        &self,
1579        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1580    ) -> Self::DelRouteResponseFut {
1581        fn _decode(
1582            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1583        ) -> Result<Ipv6RoutingTableControllerDelRouteResult, fidl::Error> {
1584            let _response = fidl::client::decode_transaction_body::<
1585                fidl::encoding::ResultType<
1586                    fidl::encoding::EmptyStruct,
1587                    Ipv6RoutingTableControllerDelRouteError,
1588                >,
1589                fidl::encoding::DefaultFuchsiaResourceDialect,
1590                0x35b6c2ce4a7b3f13,
1591            >(_buf?)?;
1592            Ok(_response.map(|x| x))
1593        }
1594        self.client.send_query_and_decode::<
1595            Ipv6RoutingTableControllerDelRouteRequest,
1596            Ipv6RoutingTableControllerDelRouteResult,
1597        >(
1598            (addresses,),
1599            0x35b6c2ce4a7b3f13,
1600            fidl::encoding::DynamicFlags::empty(),
1601            _decode,
1602        )
1603    }
1604
1605    type GetRouteStatsResponseFut = fidl::client::QueryResponseFut<
1606        Ipv6RoutingTableControllerGetRouteStatsResult,
1607        fidl::encoding::DefaultFuchsiaResourceDialect,
1608    >;
1609    fn r#get_route_stats(
1610        &self,
1611        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
1612    ) -> Self::GetRouteStatsResponseFut {
1613        fn _decode(
1614            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1615        ) -> Result<Ipv6RoutingTableControllerGetRouteStatsResult, fidl::Error> {
1616            let _response = fidl::client::decode_transaction_body::<
1617                fidl::encoding::ResultType<
1618                    Ipv6RoutingTableControllerGetRouteStatsResponse,
1619                    Ipv6RoutingTableControllerGetRouteStatsError,
1620                >,
1621                fidl::encoding::DefaultFuchsiaResourceDialect,
1622                0x6d7fa5e9f18ef79f,
1623            >(_buf?)?;
1624            Ok(_response.map(|x| x.stats))
1625        }
1626        self.client.send_query_and_decode::<
1627            Ipv6RoutingTableControllerGetRouteStatsRequest,
1628            Ipv6RoutingTableControllerGetRouteStatsResult,
1629        >(
1630            (addresses,),
1631            0x6d7fa5e9f18ef79f,
1632            fidl::encoding::DynamicFlags::empty(),
1633            _decode,
1634        )
1635    }
1636
1637    type WatchRoutingEventsResponseFut = fidl::client::QueryResponseFut<
1638        (u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent),
1639        fidl::encoding::DefaultFuchsiaResourceDialect,
1640    >;
1641    fn r#watch_routing_events(&self) -> Self::WatchRoutingEventsResponseFut {
1642        fn _decode(
1643            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1644        ) -> Result<(u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent), fidl::Error>
1645        {
1646            let _response = fidl::client::decode_transaction_body::<
1647                Ipv6RoutingTableControllerWatchRoutingEventsResponse,
1648                fidl::encoding::DefaultFuchsiaResourceDialect,
1649                0x22a94526a0ea1078,
1650            >(_buf?)?;
1651            Ok((
1652                _response.dropped_events,
1653                _response.addresses,
1654                _response.input_interface,
1655                _response.event,
1656            ))
1657        }
1658        self.client.send_query_and_decode::<
1659            fidl::encoding::EmptyPayload,
1660            (u64, Ipv6UnicastSourceAndMulticastDestination, u64, RoutingEvent),
1661        >(
1662            (),
1663            0x22a94526a0ea1078,
1664            fidl::encoding::DynamicFlags::empty(),
1665            _decode,
1666        )
1667    }
1668}
1669
1670pub struct Ipv6RoutingTableControllerEventStream {
1671    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1672}
1673
1674impl std::marker::Unpin for Ipv6RoutingTableControllerEventStream {}
1675
1676impl futures::stream::FusedStream for Ipv6RoutingTableControllerEventStream {
1677    fn is_terminated(&self) -> bool {
1678        self.event_receiver.is_terminated()
1679    }
1680}
1681
1682impl futures::Stream for Ipv6RoutingTableControllerEventStream {
1683    type Item = Result<Ipv6RoutingTableControllerEvent, fidl::Error>;
1684
1685    fn poll_next(
1686        mut self: std::pin::Pin<&mut Self>,
1687        cx: &mut std::task::Context<'_>,
1688    ) -> std::task::Poll<Option<Self::Item>> {
1689        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1690            &mut self.event_receiver,
1691            cx
1692        )?) {
1693            Some(buf) => std::task::Poll::Ready(Some(Ipv6RoutingTableControllerEvent::decode(buf))),
1694            None => std::task::Poll::Ready(None),
1695        }
1696    }
1697}
1698
1699#[derive(Debug)]
1700pub enum Ipv6RoutingTableControllerEvent {
1701    OnClose { error: TableControllerCloseReason },
1702}
1703
1704impl Ipv6RoutingTableControllerEvent {
1705    #[allow(irrefutable_let_patterns)]
1706    pub fn into_on_close(self) -> Option<TableControllerCloseReason> {
1707        if let Ipv6RoutingTableControllerEvent::OnClose { error } = self {
1708            Some((error))
1709        } else {
1710            None
1711        }
1712    }
1713
1714    /// Decodes a message buffer as a [`Ipv6RoutingTableControllerEvent`].
1715    fn decode(
1716        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1717    ) -> Result<Ipv6RoutingTableControllerEvent, fidl::Error> {
1718        let (bytes, _handles) = buf.split_mut();
1719        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1720        debug_assert_eq!(tx_header.tx_id, 0);
1721        match tx_header.ordinal {
1722            0x2d3a353489d1e0be => {
1723                let mut out = fidl::new_empty!(Ipv6RoutingTableControllerOnCloseRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1724                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv6RoutingTableControllerOnCloseRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1725                Ok((
1726                    Ipv6RoutingTableControllerEvent::OnClose {error: out.error,
1727
1728                    }
1729                ))
1730            }
1731            _ => Err(fidl::Error::UnknownOrdinal {
1732                ordinal: tx_header.ordinal,
1733                protocol_name: <Ipv6RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1734            })
1735        }
1736    }
1737}
1738
1739/// A Stream of incoming requests for fuchsia.net.multicast.admin/Ipv6RoutingTableController.
1740pub struct Ipv6RoutingTableControllerRequestStream {
1741    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1742    is_terminated: bool,
1743}
1744
1745impl std::marker::Unpin for Ipv6RoutingTableControllerRequestStream {}
1746
1747impl futures::stream::FusedStream for Ipv6RoutingTableControllerRequestStream {
1748    fn is_terminated(&self) -> bool {
1749        self.is_terminated
1750    }
1751}
1752
1753impl fidl::endpoints::RequestStream for Ipv6RoutingTableControllerRequestStream {
1754    type Protocol = Ipv6RoutingTableControllerMarker;
1755    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
1756
1757    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1758        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1759    }
1760
1761    fn control_handle(&self) -> Self::ControlHandle {
1762        Ipv6RoutingTableControllerControlHandle { inner: self.inner.clone() }
1763    }
1764
1765    fn into_inner(
1766        self,
1767    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1768    {
1769        (self.inner, self.is_terminated)
1770    }
1771
1772    fn from_inner(
1773        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1774        is_terminated: bool,
1775    ) -> Self {
1776        Self { inner, is_terminated }
1777    }
1778}
1779
1780impl futures::Stream for Ipv6RoutingTableControllerRequestStream {
1781    type Item = Result<Ipv6RoutingTableControllerRequest, fidl::Error>;
1782
1783    fn poll_next(
1784        mut self: std::pin::Pin<&mut Self>,
1785        cx: &mut std::task::Context<'_>,
1786    ) -> std::task::Poll<Option<Self::Item>> {
1787        let this = &mut *self;
1788        if this.inner.check_shutdown(cx) {
1789            this.is_terminated = true;
1790            return std::task::Poll::Ready(None);
1791        }
1792        if this.is_terminated {
1793            panic!("polled Ipv6RoutingTableControllerRequestStream after completion");
1794        }
1795        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1796            |bytes, handles| {
1797                match this.inner.channel().read_etc(cx, bytes, handles) {
1798                    std::task::Poll::Ready(Ok(())) => {}
1799                    std::task::Poll::Pending => return std::task::Poll::Pending,
1800                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1801                        this.is_terminated = true;
1802                        return std::task::Poll::Ready(None);
1803                    }
1804                    std::task::Poll::Ready(Err(e)) => {
1805                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1806                            e.into(),
1807                        ))));
1808                    }
1809                }
1810
1811                // A message has been received from the channel
1812                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1813
1814                std::task::Poll::Ready(Some(match header.ordinal {
1815                0x71ca1f54a716de90 => {
1816                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1817                    let mut req = fidl::new_empty!(Ipv6RoutingTableControllerAddRouteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1818                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv6RoutingTableControllerAddRouteRequest>(&header, _body_bytes, handles, &mut req)?;
1819                    let control_handle = Ipv6RoutingTableControllerControlHandle {
1820                        inner: this.inner.clone(),
1821                    };
1822                    Ok(Ipv6RoutingTableControllerRequest::AddRoute {addresses: req.addresses,
1823route: req.route,
1824
1825                        responder: Ipv6RoutingTableControllerAddRouteResponder {
1826                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1827                            tx_id: header.tx_id,
1828                        },
1829                    })
1830                }
1831                0x35b6c2ce4a7b3f13 => {
1832                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1833                    let mut req = fidl::new_empty!(Ipv6RoutingTableControllerDelRouteRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1834                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv6RoutingTableControllerDelRouteRequest>(&header, _body_bytes, handles, &mut req)?;
1835                    let control_handle = Ipv6RoutingTableControllerControlHandle {
1836                        inner: this.inner.clone(),
1837                    };
1838                    Ok(Ipv6RoutingTableControllerRequest::DelRoute {addresses: req.addresses,
1839
1840                        responder: Ipv6RoutingTableControllerDelRouteResponder {
1841                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1842                            tx_id: header.tx_id,
1843                        },
1844                    })
1845                }
1846                0x6d7fa5e9f18ef79f => {
1847                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1848                    let mut req = fidl::new_empty!(Ipv6RoutingTableControllerGetRouteStatsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1849                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Ipv6RoutingTableControllerGetRouteStatsRequest>(&header, _body_bytes, handles, &mut req)?;
1850                    let control_handle = Ipv6RoutingTableControllerControlHandle {
1851                        inner: this.inner.clone(),
1852                    };
1853                    Ok(Ipv6RoutingTableControllerRequest::GetRouteStats {addresses: req.addresses,
1854
1855                        responder: Ipv6RoutingTableControllerGetRouteStatsResponder {
1856                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1857                            tx_id: header.tx_id,
1858                        },
1859                    })
1860                }
1861                0x22a94526a0ea1078 => {
1862                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1863                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
1864                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1865                    let control_handle = Ipv6RoutingTableControllerControlHandle {
1866                        inner: this.inner.clone(),
1867                    };
1868                    Ok(Ipv6RoutingTableControllerRequest::WatchRoutingEvents {
1869                        responder: Ipv6RoutingTableControllerWatchRoutingEventsResponder {
1870                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1871                            tx_id: header.tx_id,
1872                        },
1873                    })
1874                }
1875                _ => Err(fidl::Error::UnknownOrdinal {
1876                    ordinal: header.ordinal,
1877                    protocol_name: <Ipv6RoutingTableControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1878                }),
1879            }))
1880            },
1881        )
1882    }
1883}
1884
1885/// The IPv6 multicast routing controller.
1886///
1887/// Closing the client-end of the controller will disable multicast routing and
1888/// clear the multicast routing table.
1889#[derive(Debug)]
1890pub enum Ipv6RoutingTableControllerRequest {
1891    /// Adds a route such that packets matching the addresses will be forwarded
1892    /// accordingly.
1893    ///
1894    /// The provided addresses act as the key for the route; any existing route
1895    /// with the same addresses will be overwritten when this route is
1896    /// installed.
1897    ///
1898    /// If a packet arrives at an interface different from the expected input
1899    /// interface set in the route, the packet will not be forwarded and a
1900    /// [`RoutingEvent.wrong_input_interface`] event will be sent to the client.
1901    /// See [`WatchRoutingEvents`] for more details.
1902    ///
1903    /// + request `addresses` the addresses used to identify a route.
1904    /// + request `route` the multicast route.
1905    AddRoute {
1906        addresses: Ipv6UnicastSourceAndMulticastDestination,
1907        route: Route,
1908        responder: Ipv6RoutingTableControllerAddRouteResponder,
1909    },
1910    /// Delete a route.
1911    ///
1912    /// + request `addresses` the addresses used to identify a route.
1913    DelRoute {
1914        addresses: Ipv6UnicastSourceAndMulticastDestination,
1915        responder: Ipv6RoutingTableControllerDelRouteResponder,
1916    },
1917    /// Get a snapshot of statistics about a specific route.
1918    ///
1919    /// + request `addresses` the addresses used to identify a route.
1920    GetRouteStats {
1921        addresses: Ipv6UnicastSourceAndMulticastDestination,
1922        responder: Ipv6RoutingTableControllerGetRouteStatsResponder,
1923    },
1924    /// Watch for events triggered by multicast packets.
1925    ///
1926    /// The server will queue events to return when this method is called. If no
1927    /// events are ready, the call will block until an event is ready. The
1928    /// server will drop new events if the client is not consuming them fast
1929    /// enough and return the number of events dropped in-between events.
1930    ///
1931    /// It is invalid to call this method while a previous call is pending.
1932    /// Doing so will cause the server end of the protocol to be closed.
1933    ///
1934    /// - response `dropped_events` the number of events that were dropped
1935    ///   _immediately before_ the returned event was queued.
1936    ///   returned event.
1937    /// - response `addresses` the addresses in the multicast packet triggering
1938    ///   the event.
1939    /// - response `input_interface` the interface the multicast packet
1940    ///   triggering the event arrived at.
1941    /// - response `event` the event.
1942    WatchRoutingEvents { responder: Ipv6RoutingTableControllerWatchRoutingEventsResponder },
1943}
1944
1945impl Ipv6RoutingTableControllerRequest {
1946    #[allow(irrefutable_let_patterns)]
1947    pub fn into_add_route(
1948        self,
1949    ) -> Option<(
1950        Ipv6UnicastSourceAndMulticastDestination,
1951        Route,
1952        Ipv6RoutingTableControllerAddRouteResponder,
1953    )> {
1954        if let Ipv6RoutingTableControllerRequest::AddRoute { addresses, route, responder } = self {
1955            Some((addresses, route, responder))
1956        } else {
1957            None
1958        }
1959    }
1960
1961    #[allow(irrefutable_let_patterns)]
1962    pub fn into_del_route(
1963        self,
1964    ) -> Option<(
1965        Ipv6UnicastSourceAndMulticastDestination,
1966        Ipv6RoutingTableControllerDelRouteResponder,
1967    )> {
1968        if let Ipv6RoutingTableControllerRequest::DelRoute { addresses, responder } = self {
1969            Some((addresses, responder))
1970        } else {
1971            None
1972        }
1973    }
1974
1975    #[allow(irrefutable_let_patterns)]
1976    pub fn into_get_route_stats(
1977        self,
1978    ) -> Option<(
1979        Ipv6UnicastSourceAndMulticastDestination,
1980        Ipv6RoutingTableControllerGetRouteStatsResponder,
1981    )> {
1982        if let Ipv6RoutingTableControllerRequest::GetRouteStats { addresses, responder } = self {
1983            Some((addresses, responder))
1984        } else {
1985            None
1986        }
1987    }
1988
1989    #[allow(irrefutable_let_patterns)]
1990    pub fn into_watch_routing_events(
1991        self,
1992    ) -> Option<(Ipv6RoutingTableControllerWatchRoutingEventsResponder)> {
1993        if let Ipv6RoutingTableControllerRequest::WatchRoutingEvents { responder } = self {
1994            Some((responder))
1995        } else {
1996            None
1997        }
1998    }
1999
2000    /// Name of the method defined in FIDL
2001    pub fn method_name(&self) -> &'static str {
2002        match *self {
2003            Ipv6RoutingTableControllerRequest::AddRoute { .. } => "add_route",
2004            Ipv6RoutingTableControllerRequest::DelRoute { .. } => "del_route",
2005            Ipv6RoutingTableControllerRequest::GetRouteStats { .. } => "get_route_stats",
2006            Ipv6RoutingTableControllerRequest::WatchRoutingEvents { .. } => "watch_routing_events",
2007        }
2008    }
2009}
2010
2011#[derive(Debug, Clone)]
2012pub struct Ipv6RoutingTableControllerControlHandle {
2013    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2014}
2015
2016impl fidl::endpoints::ControlHandle for Ipv6RoutingTableControllerControlHandle {
2017    fn shutdown(&self) {
2018        self.inner.shutdown()
2019    }
2020
2021    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2022        self.inner.shutdown_with_epitaph(status)
2023    }
2024
2025    fn is_closed(&self) -> bool {
2026        self.inner.channel().is_closed()
2027    }
2028    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2029        self.inner.channel().on_closed()
2030    }
2031
2032    #[cfg(target_os = "fuchsia")]
2033    fn signal_peer(
2034        &self,
2035        clear_mask: zx::Signals,
2036        set_mask: zx::Signals,
2037    ) -> Result<(), zx_status::Status> {
2038        use fidl::Peered;
2039        self.inner.channel().signal_peer(clear_mask, set_mask)
2040    }
2041}
2042
2043impl Ipv6RoutingTableControllerControlHandle {
2044    pub fn send_on_close(&self, mut error: TableControllerCloseReason) -> Result<(), fidl::Error> {
2045        self.inner.send::<Ipv6RoutingTableControllerOnCloseRequest>(
2046            (error,),
2047            0,
2048            0x2d3a353489d1e0be,
2049            fidl::encoding::DynamicFlags::empty(),
2050        )
2051    }
2052}
2053
2054#[must_use = "FIDL methods require a response to be sent"]
2055#[derive(Debug)]
2056pub struct Ipv6RoutingTableControllerAddRouteResponder {
2057    control_handle: std::mem::ManuallyDrop<Ipv6RoutingTableControllerControlHandle>,
2058    tx_id: u32,
2059}
2060
2061/// Set the the channel to be shutdown (see [`Ipv6RoutingTableControllerControlHandle::shutdown`])
2062/// if the responder is dropped without sending a response, so that the client
2063/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2064impl std::ops::Drop for Ipv6RoutingTableControllerAddRouteResponder {
2065    fn drop(&mut self) {
2066        self.control_handle.shutdown();
2067        // Safety: drops once, never accessed again
2068        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2069    }
2070}
2071
2072impl fidl::endpoints::Responder for Ipv6RoutingTableControllerAddRouteResponder {
2073    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
2074
2075    fn control_handle(&self) -> &Ipv6RoutingTableControllerControlHandle {
2076        &self.control_handle
2077    }
2078
2079    fn drop_without_shutdown(mut self) {
2080        // Safety: drops once, never accessed again due to mem::forget
2081        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2082        // Prevent Drop from running (which would shut down the channel)
2083        std::mem::forget(self);
2084    }
2085}
2086
2087impl Ipv6RoutingTableControllerAddRouteResponder {
2088    /// Sends a response to the FIDL transaction.
2089    ///
2090    /// Sets the channel to shutdown if an error occurs.
2091    pub fn send(
2092        self,
2093        mut result: Result<(), Ipv6RoutingTableControllerAddRouteError>,
2094    ) -> Result<(), fidl::Error> {
2095        let _result = self.send_raw(result);
2096        if _result.is_err() {
2097            self.control_handle.shutdown();
2098        }
2099        self.drop_without_shutdown();
2100        _result
2101    }
2102
2103    /// Similar to "send" but does not shutdown the channel if an error occurs.
2104    pub fn send_no_shutdown_on_err(
2105        self,
2106        mut result: Result<(), Ipv6RoutingTableControllerAddRouteError>,
2107    ) -> Result<(), fidl::Error> {
2108        let _result = self.send_raw(result);
2109        self.drop_without_shutdown();
2110        _result
2111    }
2112
2113    fn send_raw(
2114        &self,
2115        mut result: Result<(), Ipv6RoutingTableControllerAddRouteError>,
2116    ) -> Result<(), fidl::Error> {
2117        self.control_handle.inner.send::<fidl::encoding::ResultType<
2118            fidl::encoding::EmptyStruct,
2119            Ipv6RoutingTableControllerAddRouteError,
2120        >>(
2121            result,
2122            self.tx_id,
2123            0x71ca1f54a716de90,
2124            fidl::encoding::DynamicFlags::empty(),
2125        )
2126    }
2127}
2128
2129#[must_use = "FIDL methods require a response to be sent"]
2130#[derive(Debug)]
2131pub struct Ipv6RoutingTableControllerDelRouteResponder {
2132    control_handle: std::mem::ManuallyDrop<Ipv6RoutingTableControllerControlHandle>,
2133    tx_id: u32,
2134}
2135
2136/// Set the the channel to be shutdown (see [`Ipv6RoutingTableControllerControlHandle::shutdown`])
2137/// if the responder is dropped without sending a response, so that the client
2138/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2139impl std::ops::Drop for Ipv6RoutingTableControllerDelRouteResponder {
2140    fn drop(&mut self) {
2141        self.control_handle.shutdown();
2142        // Safety: drops once, never accessed again
2143        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2144    }
2145}
2146
2147impl fidl::endpoints::Responder for Ipv6RoutingTableControllerDelRouteResponder {
2148    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
2149
2150    fn control_handle(&self) -> &Ipv6RoutingTableControllerControlHandle {
2151        &self.control_handle
2152    }
2153
2154    fn drop_without_shutdown(mut self) {
2155        // Safety: drops once, never accessed again due to mem::forget
2156        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2157        // Prevent Drop from running (which would shut down the channel)
2158        std::mem::forget(self);
2159    }
2160}
2161
2162impl Ipv6RoutingTableControllerDelRouteResponder {
2163    /// Sends a response to the FIDL transaction.
2164    ///
2165    /// Sets the channel to shutdown if an error occurs.
2166    pub fn send(
2167        self,
2168        mut result: Result<(), Ipv6RoutingTableControllerDelRouteError>,
2169    ) -> Result<(), fidl::Error> {
2170        let _result = self.send_raw(result);
2171        if _result.is_err() {
2172            self.control_handle.shutdown();
2173        }
2174        self.drop_without_shutdown();
2175        _result
2176    }
2177
2178    /// Similar to "send" but does not shutdown the channel if an error occurs.
2179    pub fn send_no_shutdown_on_err(
2180        self,
2181        mut result: Result<(), Ipv6RoutingTableControllerDelRouteError>,
2182    ) -> Result<(), fidl::Error> {
2183        let _result = self.send_raw(result);
2184        self.drop_without_shutdown();
2185        _result
2186    }
2187
2188    fn send_raw(
2189        &self,
2190        mut result: Result<(), Ipv6RoutingTableControllerDelRouteError>,
2191    ) -> Result<(), fidl::Error> {
2192        self.control_handle.inner.send::<fidl::encoding::ResultType<
2193            fidl::encoding::EmptyStruct,
2194            Ipv6RoutingTableControllerDelRouteError,
2195        >>(
2196            result,
2197            self.tx_id,
2198            0x35b6c2ce4a7b3f13,
2199            fidl::encoding::DynamicFlags::empty(),
2200        )
2201    }
2202}
2203
2204#[must_use = "FIDL methods require a response to be sent"]
2205#[derive(Debug)]
2206pub struct Ipv6RoutingTableControllerGetRouteStatsResponder {
2207    control_handle: std::mem::ManuallyDrop<Ipv6RoutingTableControllerControlHandle>,
2208    tx_id: u32,
2209}
2210
2211/// Set the the channel to be shutdown (see [`Ipv6RoutingTableControllerControlHandle::shutdown`])
2212/// if the responder is dropped without sending a response, so that the client
2213/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2214impl std::ops::Drop for Ipv6RoutingTableControllerGetRouteStatsResponder {
2215    fn drop(&mut self) {
2216        self.control_handle.shutdown();
2217        // Safety: drops once, never accessed again
2218        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2219    }
2220}
2221
2222impl fidl::endpoints::Responder for Ipv6RoutingTableControllerGetRouteStatsResponder {
2223    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
2224
2225    fn control_handle(&self) -> &Ipv6RoutingTableControllerControlHandle {
2226        &self.control_handle
2227    }
2228
2229    fn drop_without_shutdown(mut self) {
2230        // Safety: drops once, never accessed again due to mem::forget
2231        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2232        // Prevent Drop from running (which would shut down the channel)
2233        std::mem::forget(self);
2234    }
2235}
2236
2237impl Ipv6RoutingTableControllerGetRouteStatsResponder {
2238    /// Sends a response to the FIDL transaction.
2239    ///
2240    /// Sets the channel to shutdown if an error occurs.
2241    pub fn send(
2242        self,
2243        mut result: Result<&RouteStats, Ipv6RoutingTableControllerGetRouteStatsError>,
2244    ) -> Result<(), fidl::Error> {
2245        let _result = self.send_raw(result);
2246        if _result.is_err() {
2247            self.control_handle.shutdown();
2248        }
2249        self.drop_without_shutdown();
2250        _result
2251    }
2252
2253    /// Similar to "send" but does not shutdown the channel if an error occurs.
2254    pub fn send_no_shutdown_on_err(
2255        self,
2256        mut result: Result<&RouteStats, Ipv6RoutingTableControllerGetRouteStatsError>,
2257    ) -> Result<(), fidl::Error> {
2258        let _result = self.send_raw(result);
2259        self.drop_without_shutdown();
2260        _result
2261    }
2262
2263    fn send_raw(
2264        &self,
2265        mut result: Result<&RouteStats, Ipv6RoutingTableControllerGetRouteStatsError>,
2266    ) -> Result<(), fidl::Error> {
2267        self.control_handle.inner.send::<fidl::encoding::ResultType<
2268            Ipv6RoutingTableControllerGetRouteStatsResponse,
2269            Ipv6RoutingTableControllerGetRouteStatsError,
2270        >>(
2271            result.map(|stats| (stats,)),
2272            self.tx_id,
2273            0x6d7fa5e9f18ef79f,
2274            fidl::encoding::DynamicFlags::empty(),
2275        )
2276    }
2277}
2278
2279#[must_use = "FIDL methods require a response to be sent"]
2280#[derive(Debug)]
2281pub struct Ipv6RoutingTableControllerWatchRoutingEventsResponder {
2282    control_handle: std::mem::ManuallyDrop<Ipv6RoutingTableControllerControlHandle>,
2283    tx_id: u32,
2284}
2285
2286/// Set the the channel to be shutdown (see [`Ipv6RoutingTableControllerControlHandle::shutdown`])
2287/// if the responder is dropped without sending a response, so that the client
2288/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2289impl std::ops::Drop for Ipv6RoutingTableControllerWatchRoutingEventsResponder {
2290    fn drop(&mut self) {
2291        self.control_handle.shutdown();
2292        // Safety: drops once, never accessed again
2293        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2294    }
2295}
2296
2297impl fidl::endpoints::Responder for Ipv6RoutingTableControllerWatchRoutingEventsResponder {
2298    type ControlHandle = Ipv6RoutingTableControllerControlHandle;
2299
2300    fn control_handle(&self) -> &Ipv6RoutingTableControllerControlHandle {
2301        &self.control_handle
2302    }
2303
2304    fn drop_without_shutdown(mut self) {
2305        // Safety: drops once, never accessed again due to mem::forget
2306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2307        // Prevent Drop from running (which would shut down the channel)
2308        std::mem::forget(self);
2309    }
2310}
2311
2312impl Ipv6RoutingTableControllerWatchRoutingEventsResponder {
2313    /// Sends a response to the FIDL transaction.
2314    ///
2315    /// Sets the channel to shutdown if an error occurs.
2316    pub fn send(
2317        self,
2318        mut dropped_events: u64,
2319        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
2320        mut input_interface: u64,
2321        mut event: &RoutingEvent,
2322    ) -> Result<(), fidl::Error> {
2323        let _result = self.send_raw(dropped_events, addresses, input_interface, event);
2324        if _result.is_err() {
2325            self.control_handle.shutdown();
2326        }
2327        self.drop_without_shutdown();
2328        _result
2329    }
2330
2331    /// Similar to "send" but does not shutdown the channel if an error occurs.
2332    pub fn send_no_shutdown_on_err(
2333        self,
2334        mut dropped_events: u64,
2335        mut addresses: &Ipv6UnicastSourceAndMulticastDestination,
2336        mut input_interface: u64,
2337        mut event: &RoutingEvent,
2338    ) -> Result<(), fidl::Error> {
2339        let _result = self.send_raw(dropped_events, addresses, input_interface, event);
2340        self.drop_without_shutdown();
2341        _result
2342    }
2343
2344    fn send_raw(
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        self.control_handle.inner.send::<Ipv6RoutingTableControllerWatchRoutingEventsResponse>(
2352            (dropped_events, addresses, input_interface, event),
2353            self.tx_id,
2354            0x22a94526a0ea1078,
2355            fidl::encoding::DynamicFlags::empty(),
2356        )
2357    }
2358}
2359
2360mod internal {
2361    use super::*;
2362}