Skip to main content

fidl_fuchsia_net_neighbor/
fidl_fuchsia_net_neighbor.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_neighbor_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ViewOpenEntryIteratorRequest {
16    pub it: fidl::endpoints::ServerEnd<EntryIteratorMarker>,
17    /// Options for modifying the behavior of an [`EntryIterator`].
18    pub options: EntryIteratorOptions,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22    for ViewOpenEntryIteratorRequest
23{
24}
25
26#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
27pub struct ControllerMarker;
28
29impl fidl::endpoints::ProtocolMarker for ControllerMarker {
30    type Proxy = ControllerProxy;
31    type RequestStream = ControllerRequestStream;
32    #[cfg(target_os = "fuchsia")]
33    type SynchronousProxy = ControllerSynchronousProxy;
34
35    const DEBUG_NAME: &'static str = "fuchsia.net.neighbor.Controller";
36}
37impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
38pub type ControllerAddEntryResult = Result<(), ControllerError>;
39pub type ControllerProbeEntryResult = Result<(), ControllerError>;
40pub type ControllerRemoveEntryResult = Result<(), ControllerError>;
41pub type ControllerClearEntriesResult = Result<(), ControllerError>;
42
43pub trait ControllerProxyInterface: Send + Sync {
44    type AddEntryResponseFut: std::future::Future<Output = Result<ControllerAddEntryResult, fidl::Error>>
45        + Send;
46    fn r#add_entry(
47        &self,
48        interface: u64,
49        neighbor: &fidl_fuchsia_net::IpAddress,
50        mac: &fidl_fuchsia_net::MacAddress,
51    ) -> Self::AddEntryResponseFut;
52    type ProbeEntryResponseFut: std::future::Future<Output = Result<ControllerProbeEntryResult, fidl::Error>>
53        + Send;
54    fn r#probe_entry(
55        &self,
56        interface: u64,
57        neighbor: &fidl_fuchsia_net::IpAddress,
58    ) -> Self::ProbeEntryResponseFut;
59    type RemoveEntryResponseFut: std::future::Future<Output = Result<ControllerRemoveEntryResult, fidl::Error>>
60        + Send;
61    fn r#remove_entry(
62        &self,
63        interface: u64,
64        neighbor: &fidl_fuchsia_net::IpAddress,
65    ) -> Self::RemoveEntryResponseFut;
66    type ClearEntriesResponseFut: std::future::Future<Output = Result<ControllerClearEntriesResult, fidl::Error>>
67        + Send;
68    fn r#clear_entries(
69        &self,
70        interface: u64,
71        ip_version: fidl_fuchsia_net::IpVersion,
72    ) -> Self::ClearEntriesResponseFut;
73}
74#[derive(Debug)]
75#[cfg(target_os = "fuchsia")]
76pub struct ControllerSynchronousProxy {
77    client: fidl::client::sync::Client,
78}
79
80#[cfg(target_os = "fuchsia")]
81impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
82    type Proxy = ControllerProxy;
83    type Protocol = ControllerMarker;
84
85    fn from_channel(inner: fidl::Channel) -> Self {
86        Self::new(inner)
87    }
88
89    fn into_channel(self) -> fidl::Channel {
90        self.client.into_channel()
91    }
92
93    fn as_channel(&self) -> &fidl::Channel {
94        self.client.as_channel()
95    }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl ControllerSynchronousProxy {
100    pub fn new(channel: fidl::Channel) -> Self {
101        Self { client: fidl::client::sync::Client::new(channel) }
102    }
103
104    pub fn into_channel(self) -> fidl::Channel {
105        self.client.into_channel()
106    }
107
108    /// Waits until an event arrives and returns it. It is safe for other
109    /// threads to make concurrent requests while waiting for an event.
110    pub fn wait_for_event(
111        &self,
112        deadline: zx::MonotonicInstant,
113    ) -> Result<ControllerEvent, fidl::Error> {
114        ControllerEvent::decode(self.client.wait_for_event::<ControllerMarker>(deadline)?)
115    }
116
117    /// Create a static entry. If a conflict is found, overwrite the existing
118    /// entry. Conflicts occur when two entries have the same interface
119    /// identifier and IP address.
120    ///
121    /// + request `interface` identifier for the interface used for
122    ///     communicating with the neighbor.
123    /// + request `neighbor` IP address of the neighbor.
124    /// + request `mac` MAC address of the neighbor.
125    pub fn r#add_entry(
126        &self,
127        mut interface: u64,
128        mut neighbor: &fidl_fuchsia_net::IpAddress,
129        mut mac: &fidl_fuchsia_net::MacAddress,
130        ___deadline: zx::MonotonicInstant,
131    ) -> Result<ControllerAddEntryResult, fidl::Error> {
132        let _response = self.client.send_query::<
133            ControllerAddEntryRequest,
134            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControllerError>,
135            ControllerMarker,
136        >(
137            (interface, neighbor, mac,),
138            0x778c829580aa23ac,
139            fidl::encoding::DynamicFlags::empty(),
140            ___deadline,
141        )?;
142        Ok(_response.map(|x| x))
143    }
144
145    /// Probe the reachability of an entry in the neighbor table.
146    ///
147    /// If the entry is static it will be converted into a dynamic entry and may
148    /// eventually be discarded if no longer in active use.
149    ///
150    /// + request `interface` identifier for the interface used for
151    ///     communicating with the neighbor.
152    /// + request `neighbor` IP address of the neighbor.
153    pub fn r#probe_entry(
154        &self,
155        mut interface: u64,
156        mut neighbor: &fidl_fuchsia_net::IpAddress,
157        ___deadline: zx::MonotonicInstant,
158    ) -> Result<ControllerProbeEntryResult, fidl::Error> {
159        let _response = self.client.send_query::<
160            ControllerProbeEntryRequest,
161            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControllerError>,
162            ControllerMarker,
163        >(
164            (interface, neighbor,),
165            0x4f71dd58473f58ad,
166            fidl::encoding::DynamicFlags::empty(),
167            ___deadline,
168        )?;
169        Ok(_response.map(|x| x))
170    }
171
172    /// Delete a dynamic or static entry.
173    ///
174    /// + request `interface` identifier for the interface associated with the
175    ///     entry to be deleted.
176    /// + request `neighbor` IP address of the entry to be deleted.
177    pub fn r#remove_entry(
178        &self,
179        mut interface: u64,
180        mut neighbor: &fidl_fuchsia_net::IpAddress,
181        ___deadline: zx::MonotonicInstant,
182    ) -> Result<ControllerRemoveEntryResult, fidl::Error> {
183        let _response = self.client.send_query::<
184            ControllerRemoveEntryRequest,
185            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControllerError>,
186            ControllerMarker,
187        >(
188            (interface, neighbor,),
189            0xfd0b52f53a0f815,
190            fidl::encoding::DynamicFlags::empty(),
191            ___deadline,
192        )?;
193        Ok(_response.map(|x| x))
194    }
195
196    /// Delete all dynamic and static entries belonging to an interface.
197    ///
198    /// + request `interface` identifier for the interface associated with the
199    ///     entries to be deleted.
200    /// + request `ip_version` the IP version to clear entries from.
201    pub fn r#clear_entries(
202        &self,
203        mut interface: u64,
204        mut ip_version: fidl_fuchsia_net::IpVersion,
205        ___deadline: zx::MonotonicInstant,
206    ) -> Result<ControllerClearEntriesResult, fidl::Error> {
207        let _response = self.client.send_query::<
208            ControllerClearEntriesRequest,
209            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControllerError>,
210            ControllerMarker,
211        >(
212            (interface, ip_version,),
213            0x33e53d9769a999d,
214            fidl::encoding::DynamicFlags::empty(),
215            ___deadline,
216        )?;
217        Ok(_response.map(|x| x))
218    }
219}
220
221#[cfg(target_os = "fuchsia")]
222impl From<ControllerSynchronousProxy> for zx::NullableHandle {
223    fn from(value: ControllerSynchronousProxy) -> Self {
224        value.into_channel().into()
225    }
226}
227
228#[cfg(target_os = "fuchsia")]
229impl From<fidl::Channel> for ControllerSynchronousProxy {
230    fn from(value: fidl::Channel) -> Self {
231        Self::new(value)
232    }
233}
234
235#[cfg(target_os = "fuchsia")]
236impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
237    type Protocol = ControllerMarker;
238
239    fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
240        Self::new(value.into_channel())
241    }
242}
243
244#[derive(Debug, Clone)]
245pub struct ControllerProxy {
246    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
247}
248
249impl fidl::endpoints::Proxy for ControllerProxy {
250    type Protocol = ControllerMarker;
251
252    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
253        Self::new(inner)
254    }
255
256    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
257        self.client.into_channel().map_err(|client| Self { client })
258    }
259
260    fn as_channel(&self) -> &::fidl::AsyncChannel {
261        self.client.as_channel()
262    }
263}
264
265impl ControllerProxy {
266    /// Create a new Proxy for fuchsia.net.neighbor/Controller.
267    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
268        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
269        Self { client: fidl::client::Client::new(channel, protocol_name) }
270    }
271
272    /// Get a Stream of events from the remote end of the protocol.
273    ///
274    /// # Panics
275    ///
276    /// Panics if the event stream was already taken.
277    pub fn take_event_stream(&self) -> ControllerEventStream {
278        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
279    }
280
281    /// Create a static entry. If a conflict is found, overwrite the existing
282    /// entry. Conflicts occur when two entries have the same interface
283    /// identifier and IP address.
284    ///
285    /// + request `interface` identifier for the interface used for
286    ///     communicating with the neighbor.
287    /// + request `neighbor` IP address of the neighbor.
288    /// + request `mac` MAC address of the neighbor.
289    pub fn r#add_entry(
290        &self,
291        mut interface: u64,
292        mut neighbor: &fidl_fuchsia_net::IpAddress,
293        mut mac: &fidl_fuchsia_net::MacAddress,
294    ) -> fidl::client::QueryResponseFut<
295        ControllerAddEntryResult,
296        fidl::encoding::DefaultFuchsiaResourceDialect,
297    > {
298        ControllerProxyInterface::r#add_entry(self, interface, neighbor, mac)
299    }
300
301    /// Probe the reachability of an entry in the neighbor table.
302    ///
303    /// If the entry is static it will be converted into a dynamic entry and may
304    /// eventually be discarded if no longer in active use.
305    ///
306    /// + request `interface` identifier for the interface used for
307    ///     communicating with the neighbor.
308    /// + request `neighbor` IP address of the neighbor.
309    pub fn r#probe_entry(
310        &self,
311        mut interface: u64,
312        mut neighbor: &fidl_fuchsia_net::IpAddress,
313    ) -> fidl::client::QueryResponseFut<
314        ControllerProbeEntryResult,
315        fidl::encoding::DefaultFuchsiaResourceDialect,
316    > {
317        ControllerProxyInterface::r#probe_entry(self, interface, neighbor)
318    }
319
320    /// Delete a dynamic or static entry.
321    ///
322    /// + request `interface` identifier for the interface associated with the
323    ///     entry to be deleted.
324    /// + request `neighbor` IP address of the entry to be deleted.
325    pub fn r#remove_entry(
326        &self,
327        mut interface: u64,
328        mut neighbor: &fidl_fuchsia_net::IpAddress,
329    ) -> fidl::client::QueryResponseFut<
330        ControllerRemoveEntryResult,
331        fidl::encoding::DefaultFuchsiaResourceDialect,
332    > {
333        ControllerProxyInterface::r#remove_entry(self, interface, neighbor)
334    }
335
336    /// Delete all dynamic and static entries belonging to an interface.
337    ///
338    /// + request `interface` identifier for the interface associated with the
339    ///     entries to be deleted.
340    /// + request `ip_version` the IP version to clear entries from.
341    pub fn r#clear_entries(
342        &self,
343        mut interface: u64,
344        mut ip_version: fidl_fuchsia_net::IpVersion,
345    ) -> fidl::client::QueryResponseFut<
346        ControllerClearEntriesResult,
347        fidl::encoding::DefaultFuchsiaResourceDialect,
348    > {
349        ControllerProxyInterface::r#clear_entries(self, interface, ip_version)
350    }
351}
352
353impl ControllerProxyInterface for ControllerProxy {
354    type AddEntryResponseFut = fidl::client::QueryResponseFut<
355        ControllerAddEntryResult,
356        fidl::encoding::DefaultFuchsiaResourceDialect,
357    >;
358    fn r#add_entry(
359        &self,
360        mut interface: u64,
361        mut neighbor: &fidl_fuchsia_net::IpAddress,
362        mut mac: &fidl_fuchsia_net::MacAddress,
363    ) -> Self::AddEntryResponseFut {
364        fn _decode(
365            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
366        ) -> Result<ControllerAddEntryResult, fidl::Error> {
367            let _response = fidl::client::decode_transaction_body::<
368                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControllerError>,
369                fidl::encoding::DefaultFuchsiaResourceDialect,
370                0x778c829580aa23ac,
371            >(_buf?)?;
372            Ok(_response.map(|x| x))
373        }
374        self.client.send_query_and_decode::<ControllerAddEntryRequest, ControllerAddEntryResult>(
375            (interface, neighbor, mac),
376            0x778c829580aa23ac,
377            fidl::encoding::DynamicFlags::empty(),
378            _decode,
379        )
380    }
381
382    type ProbeEntryResponseFut = fidl::client::QueryResponseFut<
383        ControllerProbeEntryResult,
384        fidl::encoding::DefaultFuchsiaResourceDialect,
385    >;
386    fn r#probe_entry(
387        &self,
388        mut interface: u64,
389        mut neighbor: &fidl_fuchsia_net::IpAddress,
390    ) -> Self::ProbeEntryResponseFut {
391        fn _decode(
392            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
393        ) -> Result<ControllerProbeEntryResult, fidl::Error> {
394            let _response = fidl::client::decode_transaction_body::<
395                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControllerError>,
396                fidl::encoding::DefaultFuchsiaResourceDialect,
397                0x4f71dd58473f58ad,
398            >(_buf?)?;
399            Ok(_response.map(|x| x))
400        }
401        self.client
402            .send_query_and_decode::<ControllerProbeEntryRequest, ControllerProbeEntryResult>(
403                (interface, neighbor),
404                0x4f71dd58473f58ad,
405                fidl::encoding::DynamicFlags::empty(),
406                _decode,
407            )
408    }
409
410    type RemoveEntryResponseFut = fidl::client::QueryResponseFut<
411        ControllerRemoveEntryResult,
412        fidl::encoding::DefaultFuchsiaResourceDialect,
413    >;
414    fn r#remove_entry(
415        &self,
416        mut interface: u64,
417        mut neighbor: &fidl_fuchsia_net::IpAddress,
418    ) -> Self::RemoveEntryResponseFut {
419        fn _decode(
420            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
421        ) -> Result<ControllerRemoveEntryResult, fidl::Error> {
422            let _response = fidl::client::decode_transaction_body::<
423                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControllerError>,
424                fidl::encoding::DefaultFuchsiaResourceDialect,
425                0xfd0b52f53a0f815,
426            >(_buf?)?;
427            Ok(_response.map(|x| x))
428        }
429        self.client
430            .send_query_and_decode::<ControllerRemoveEntryRequest, ControllerRemoveEntryResult>(
431                (interface, neighbor),
432                0xfd0b52f53a0f815,
433                fidl::encoding::DynamicFlags::empty(),
434                _decode,
435            )
436    }
437
438    type ClearEntriesResponseFut = fidl::client::QueryResponseFut<
439        ControllerClearEntriesResult,
440        fidl::encoding::DefaultFuchsiaResourceDialect,
441    >;
442    fn r#clear_entries(
443        &self,
444        mut interface: u64,
445        mut ip_version: fidl_fuchsia_net::IpVersion,
446    ) -> Self::ClearEntriesResponseFut {
447        fn _decode(
448            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
449        ) -> Result<ControllerClearEntriesResult, fidl::Error> {
450            let _response = fidl::client::decode_transaction_body::<
451                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ControllerError>,
452                fidl::encoding::DefaultFuchsiaResourceDialect,
453                0x33e53d9769a999d,
454            >(_buf?)?;
455            Ok(_response.map(|x| x))
456        }
457        self.client
458            .send_query_and_decode::<ControllerClearEntriesRequest, ControllerClearEntriesResult>(
459                (interface, ip_version),
460                0x33e53d9769a999d,
461                fidl::encoding::DynamicFlags::empty(),
462                _decode,
463            )
464    }
465}
466
467pub struct ControllerEventStream {
468    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
469}
470
471impl std::marker::Unpin for ControllerEventStream {}
472
473impl futures::stream::FusedStream for ControllerEventStream {
474    fn is_terminated(&self) -> bool {
475        self.event_receiver.is_terminated()
476    }
477}
478
479impl futures::Stream for ControllerEventStream {
480    type Item = Result<ControllerEvent, fidl::Error>;
481
482    fn poll_next(
483        mut self: std::pin::Pin<&mut Self>,
484        cx: &mut std::task::Context<'_>,
485    ) -> std::task::Poll<Option<Self::Item>> {
486        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
487            &mut self.event_receiver,
488            cx
489        )?) {
490            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
491            None => std::task::Poll::Ready(None),
492        }
493    }
494}
495
496#[derive(Debug)]
497pub enum ControllerEvent {}
498
499impl ControllerEvent {
500    /// Decodes a message buffer as a [`ControllerEvent`].
501    fn decode(
502        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
503    ) -> Result<ControllerEvent, fidl::Error> {
504        let (bytes, _handles) = buf.split_mut();
505        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
506        debug_assert_eq!(tx_header.tx_id, 0);
507        match tx_header.ordinal {
508            _ => Err(fidl::Error::UnknownOrdinal {
509                ordinal: tx_header.ordinal,
510                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
511            }),
512        }
513    }
514}
515
516/// A Stream of incoming requests for fuchsia.net.neighbor/Controller.
517pub struct ControllerRequestStream {
518    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
519    is_terminated: bool,
520}
521
522impl std::marker::Unpin for ControllerRequestStream {}
523
524impl futures::stream::FusedStream for ControllerRequestStream {
525    fn is_terminated(&self) -> bool {
526        self.is_terminated
527    }
528}
529
530impl fidl::endpoints::RequestStream for ControllerRequestStream {
531    type Protocol = ControllerMarker;
532    type ControlHandle = ControllerControlHandle;
533
534    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
535        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
536    }
537
538    fn control_handle(&self) -> Self::ControlHandle {
539        ControllerControlHandle { inner: self.inner.clone() }
540    }
541
542    fn into_inner(
543        self,
544    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
545    {
546        (self.inner, self.is_terminated)
547    }
548
549    fn from_inner(
550        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
551        is_terminated: bool,
552    ) -> Self {
553        Self { inner, is_terminated }
554    }
555}
556
557impl futures::Stream for ControllerRequestStream {
558    type Item = Result<ControllerRequest, fidl::Error>;
559
560    fn poll_next(
561        mut self: std::pin::Pin<&mut Self>,
562        cx: &mut std::task::Context<'_>,
563    ) -> std::task::Poll<Option<Self::Item>> {
564        let this = &mut *self;
565        if this.inner.check_shutdown(cx) {
566            this.is_terminated = true;
567            return std::task::Poll::Ready(None);
568        }
569        if this.is_terminated {
570            panic!("polled ControllerRequestStream after completion");
571        }
572        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
573            |bytes, handles| {
574                match this.inner.channel().read_etc(cx, bytes, handles) {
575                    std::task::Poll::Ready(Ok(())) => {}
576                    std::task::Poll::Pending => return std::task::Poll::Pending,
577                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
578                        this.is_terminated = true;
579                        return std::task::Poll::Ready(None);
580                    }
581                    std::task::Poll::Ready(Err(e)) => {
582                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
583                            e.into(),
584                        ))));
585                    }
586                }
587
588                // A message has been received from the channel
589                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
590
591                std::task::Poll::Ready(Some(match header.ordinal {
592                    0x778c829580aa23ac => {
593                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
594                        let mut req = fidl::new_empty!(
595                            ControllerAddEntryRequest,
596                            fidl::encoding::DefaultFuchsiaResourceDialect
597                        );
598                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerAddEntryRequest>(&header, _body_bytes, handles, &mut req)?;
599                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
600                        Ok(ControllerRequest::AddEntry {
601                            interface: req.interface,
602                            neighbor: req.neighbor,
603                            mac: req.mac,
604
605                            responder: ControllerAddEntryResponder {
606                                control_handle: std::mem::ManuallyDrop::new(control_handle),
607                                tx_id: header.tx_id,
608                            },
609                        })
610                    }
611                    0x4f71dd58473f58ad => {
612                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
613                        let mut req = fidl::new_empty!(
614                            ControllerProbeEntryRequest,
615                            fidl::encoding::DefaultFuchsiaResourceDialect
616                        );
617                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerProbeEntryRequest>(&header, _body_bytes, handles, &mut req)?;
618                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
619                        Ok(ControllerRequest::ProbeEntry {
620                            interface: req.interface,
621                            neighbor: req.neighbor,
622
623                            responder: ControllerProbeEntryResponder {
624                                control_handle: std::mem::ManuallyDrop::new(control_handle),
625                                tx_id: header.tx_id,
626                            },
627                        })
628                    }
629                    0xfd0b52f53a0f815 => {
630                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
631                        let mut req = fidl::new_empty!(
632                            ControllerRemoveEntryRequest,
633                            fidl::encoding::DefaultFuchsiaResourceDialect
634                        );
635                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerRemoveEntryRequest>(&header, _body_bytes, handles, &mut req)?;
636                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
637                        Ok(ControllerRequest::RemoveEntry {
638                            interface: req.interface,
639                            neighbor: req.neighbor,
640
641                            responder: ControllerRemoveEntryResponder {
642                                control_handle: std::mem::ManuallyDrop::new(control_handle),
643                                tx_id: header.tx_id,
644                            },
645                        })
646                    }
647                    0x33e53d9769a999d => {
648                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
649                        let mut req = fidl::new_empty!(
650                            ControllerClearEntriesRequest,
651                            fidl::encoding::DefaultFuchsiaResourceDialect
652                        );
653                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerClearEntriesRequest>(&header, _body_bytes, handles, &mut req)?;
654                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
655                        Ok(ControllerRequest::ClearEntries {
656                            interface: req.interface,
657                            ip_version: req.ip_version,
658
659                            responder: ControllerClearEntriesResponder {
660                                control_handle: std::mem::ManuallyDrop::new(control_handle),
661                                tx_id: header.tx_id,
662                            },
663                        })
664                    }
665                    _ => Err(fidl::Error::UnknownOrdinal {
666                        ordinal: header.ordinal,
667                        protocol_name:
668                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
669                    }),
670                }))
671            },
672        )
673    }
674}
675
676/// Modify the neighbor table.
677#[derive(Debug)]
678pub enum ControllerRequest {
679    /// Create a static entry. If a conflict is found, overwrite the existing
680    /// entry. Conflicts occur when two entries have the same interface
681    /// identifier and IP address.
682    ///
683    /// + request `interface` identifier for the interface used for
684    ///     communicating with the neighbor.
685    /// + request `neighbor` IP address of the neighbor.
686    /// + request `mac` MAC address of the neighbor.
687    AddEntry {
688        interface: u64,
689        neighbor: fidl_fuchsia_net::IpAddress,
690        mac: fidl_fuchsia_net::MacAddress,
691        responder: ControllerAddEntryResponder,
692    },
693    /// Probe the reachability of an entry in the neighbor table.
694    ///
695    /// If the entry is static it will be converted into a dynamic entry and may
696    /// eventually be discarded if no longer in active use.
697    ///
698    /// + request `interface` identifier for the interface used for
699    ///     communicating with the neighbor.
700    /// + request `neighbor` IP address of the neighbor.
701    ProbeEntry {
702        interface: u64,
703        neighbor: fidl_fuchsia_net::IpAddress,
704        responder: ControllerProbeEntryResponder,
705    },
706    /// Delete a dynamic or static entry.
707    ///
708    /// + request `interface` identifier for the interface associated with the
709    ///     entry to be deleted.
710    /// + request `neighbor` IP address of the entry to be deleted.
711    RemoveEntry {
712        interface: u64,
713        neighbor: fidl_fuchsia_net::IpAddress,
714        responder: ControllerRemoveEntryResponder,
715    },
716    /// Delete all dynamic and static entries belonging to an interface.
717    ///
718    /// + request `interface` identifier for the interface associated with the
719    ///     entries to be deleted.
720    /// + request `ip_version` the IP version to clear entries from.
721    ClearEntries {
722        interface: u64,
723        ip_version: fidl_fuchsia_net::IpVersion,
724        responder: ControllerClearEntriesResponder,
725    },
726}
727
728impl ControllerRequest {
729    #[allow(irrefutable_let_patterns)]
730    pub fn into_add_entry(
731        self,
732    ) -> Option<(
733        u64,
734        fidl_fuchsia_net::IpAddress,
735        fidl_fuchsia_net::MacAddress,
736        ControllerAddEntryResponder,
737    )> {
738        if let ControllerRequest::AddEntry { interface, neighbor, mac, responder } = self {
739            Some((interface, neighbor, mac, responder))
740        } else {
741            None
742        }
743    }
744
745    #[allow(irrefutable_let_patterns)]
746    pub fn into_probe_entry(
747        self,
748    ) -> Option<(u64, fidl_fuchsia_net::IpAddress, ControllerProbeEntryResponder)> {
749        if let ControllerRequest::ProbeEntry { interface, neighbor, responder } = self {
750            Some((interface, neighbor, responder))
751        } else {
752            None
753        }
754    }
755
756    #[allow(irrefutable_let_patterns)]
757    pub fn into_remove_entry(
758        self,
759    ) -> Option<(u64, fidl_fuchsia_net::IpAddress, ControllerRemoveEntryResponder)> {
760        if let ControllerRequest::RemoveEntry { interface, neighbor, responder } = self {
761            Some((interface, neighbor, responder))
762        } else {
763            None
764        }
765    }
766
767    #[allow(irrefutable_let_patterns)]
768    pub fn into_clear_entries(
769        self,
770    ) -> Option<(u64, fidl_fuchsia_net::IpVersion, ControllerClearEntriesResponder)> {
771        if let ControllerRequest::ClearEntries { interface, ip_version, responder } = self {
772            Some((interface, ip_version, responder))
773        } else {
774            None
775        }
776    }
777
778    /// Name of the method defined in FIDL
779    pub fn method_name(&self) -> &'static str {
780        match *self {
781            ControllerRequest::AddEntry { .. } => "add_entry",
782            ControllerRequest::ProbeEntry { .. } => "probe_entry",
783            ControllerRequest::RemoveEntry { .. } => "remove_entry",
784            ControllerRequest::ClearEntries { .. } => "clear_entries",
785        }
786    }
787}
788
789#[derive(Debug, Clone)]
790pub struct ControllerControlHandle {
791    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
792}
793
794impl ControllerControlHandle {
795    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
796        self.inner.shutdown_with_epitaph(status.into())
797    }
798}
799
800impl fidl::endpoints::ControlHandle for ControllerControlHandle {
801    fn shutdown(&self) {
802        self.inner.shutdown()
803    }
804
805    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
806        self.inner.shutdown_with_epitaph(status)
807    }
808
809    fn is_closed(&self) -> bool {
810        self.inner.channel().is_closed()
811    }
812    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
813        self.inner.channel().on_closed()
814    }
815
816    #[cfg(target_os = "fuchsia")]
817    fn signal_peer(
818        &self,
819        clear_mask: zx::Signals,
820        set_mask: zx::Signals,
821    ) -> Result<(), zx_status::Status> {
822        use fidl::Peered;
823        self.inner.channel().signal_peer(clear_mask, set_mask)
824    }
825}
826
827impl ControllerControlHandle {}
828
829#[must_use = "FIDL methods require a response to be sent"]
830#[derive(Debug)]
831pub struct ControllerAddEntryResponder {
832    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
833    tx_id: u32,
834}
835
836/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
837/// if the responder is dropped without sending a response, so that the client
838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
839impl std::ops::Drop for ControllerAddEntryResponder {
840    fn drop(&mut self) {
841        self.control_handle.shutdown();
842        // Safety: drops once, never accessed again
843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
844    }
845}
846
847impl fidl::endpoints::Responder for ControllerAddEntryResponder {
848    type ControlHandle = ControllerControlHandle;
849
850    fn control_handle(&self) -> &ControllerControlHandle {
851        &self.control_handle
852    }
853
854    fn drop_without_shutdown(mut self) {
855        // Safety: drops once, never accessed again due to mem::forget
856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
857        // Prevent Drop from running (which would shut down the channel)
858        std::mem::forget(self);
859    }
860}
861
862impl ControllerAddEntryResponder {
863    /// Sends a response to the FIDL transaction.
864    ///
865    /// Sets the channel to shutdown if an error occurs.
866    pub fn send(self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
867        let _result = self.send_raw(result);
868        if _result.is_err() {
869            self.control_handle.shutdown();
870        }
871        self.drop_without_shutdown();
872        _result
873    }
874
875    /// Similar to "send" but does not shutdown the channel if an error occurs.
876    pub fn send_no_shutdown_on_err(
877        self,
878        mut result: Result<(), ControllerError>,
879    ) -> Result<(), fidl::Error> {
880        let _result = self.send_raw(result);
881        self.drop_without_shutdown();
882        _result
883    }
884
885    fn send_raw(&self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
886        self.control_handle.inner.send::<fidl::encoding::ResultType<
887            fidl::encoding::EmptyStruct,
888            ControllerError,
889        >>(
890            result,
891            self.tx_id,
892            0x778c829580aa23ac,
893            fidl::encoding::DynamicFlags::empty(),
894        )
895    }
896}
897
898#[must_use = "FIDL methods require a response to be sent"]
899#[derive(Debug)]
900pub struct ControllerProbeEntryResponder {
901    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
902    tx_id: u32,
903}
904
905/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
906/// if the responder is dropped without sending a response, so that the client
907/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
908impl std::ops::Drop for ControllerProbeEntryResponder {
909    fn drop(&mut self) {
910        self.control_handle.shutdown();
911        // Safety: drops once, never accessed again
912        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
913    }
914}
915
916impl fidl::endpoints::Responder for ControllerProbeEntryResponder {
917    type ControlHandle = ControllerControlHandle;
918
919    fn control_handle(&self) -> &ControllerControlHandle {
920        &self.control_handle
921    }
922
923    fn drop_without_shutdown(mut self) {
924        // Safety: drops once, never accessed again due to mem::forget
925        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
926        // Prevent Drop from running (which would shut down the channel)
927        std::mem::forget(self);
928    }
929}
930
931impl ControllerProbeEntryResponder {
932    /// Sends a response to the FIDL transaction.
933    ///
934    /// Sets the channel to shutdown if an error occurs.
935    pub fn send(self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
936        let _result = self.send_raw(result);
937        if _result.is_err() {
938            self.control_handle.shutdown();
939        }
940        self.drop_without_shutdown();
941        _result
942    }
943
944    /// Similar to "send" but does not shutdown the channel if an error occurs.
945    pub fn send_no_shutdown_on_err(
946        self,
947        mut result: Result<(), ControllerError>,
948    ) -> Result<(), fidl::Error> {
949        let _result = self.send_raw(result);
950        self.drop_without_shutdown();
951        _result
952    }
953
954    fn send_raw(&self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
955        self.control_handle.inner.send::<fidl::encoding::ResultType<
956            fidl::encoding::EmptyStruct,
957            ControllerError,
958        >>(
959            result,
960            self.tx_id,
961            0x4f71dd58473f58ad,
962            fidl::encoding::DynamicFlags::empty(),
963        )
964    }
965}
966
967#[must_use = "FIDL methods require a response to be sent"]
968#[derive(Debug)]
969pub struct ControllerRemoveEntryResponder {
970    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
971    tx_id: u32,
972}
973
974/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
975/// if the responder is dropped without sending a response, so that the client
976/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
977impl std::ops::Drop for ControllerRemoveEntryResponder {
978    fn drop(&mut self) {
979        self.control_handle.shutdown();
980        // Safety: drops once, never accessed again
981        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
982    }
983}
984
985impl fidl::endpoints::Responder for ControllerRemoveEntryResponder {
986    type ControlHandle = ControllerControlHandle;
987
988    fn control_handle(&self) -> &ControllerControlHandle {
989        &self.control_handle
990    }
991
992    fn drop_without_shutdown(mut self) {
993        // Safety: drops once, never accessed again due to mem::forget
994        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
995        // Prevent Drop from running (which would shut down the channel)
996        std::mem::forget(self);
997    }
998}
999
1000impl ControllerRemoveEntryResponder {
1001    /// Sends a response to the FIDL transaction.
1002    ///
1003    /// Sets the channel to shutdown if an error occurs.
1004    pub fn send(self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
1005        let _result = self.send_raw(result);
1006        if _result.is_err() {
1007            self.control_handle.shutdown();
1008        }
1009        self.drop_without_shutdown();
1010        _result
1011    }
1012
1013    /// Similar to "send" but does not shutdown the channel if an error occurs.
1014    pub fn send_no_shutdown_on_err(
1015        self,
1016        mut result: Result<(), ControllerError>,
1017    ) -> Result<(), fidl::Error> {
1018        let _result = self.send_raw(result);
1019        self.drop_without_shutdown();
1020        _result
1021    }
1022
1023    fn send_raw(&self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
1024        self.control_handle.inner.send::<fidl::encoding::ResultType<
1025            fidl::encoding::EmptyStruct,
1026            ControllerError,
1027        >>(
1028            result,
1029            self.tx_id,
1030            0xfd0b52f53a0f815,
1031            fidl::encoding::DynamicFlags::empty(),
1032        )
1033    }
1034}
1035
1036#[must_use = "FIDL methods require a response to be sent"]
1037#[derive(Debug)]
1038pub struct ControllerClearEntriesResponder {
1039    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1040    tx_id: u32,
1041}
1042
1043/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1044/// if the responder is dropped without sending a response, so that the client
1045/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1046impl std::ops::Drop for ControllerClearEntriesResponder {
1047    fn drop(&mut self) {
1048        self.control_handle.shutdown();
1049        // Safety: drops once, never accessed again
1050        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1051    }
1052}
1053
1054impl fidl::endpoints::Responder for ControllerClearEntriesResponder {
1055    type ControlHandle = ControllerControlHandle;
1056
1057    fn control_handle(&self) -> &ControllerControlHandle {
1058        &self.control_handle
1059    }
1060
1061    fn drop_without_shutdown(mut self) {
1062        // Safety: drops once, never accessed again due to mem::forget
1063        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1064        // Prevent Drop from running (which would shut down the channel)
1065        std::mem::forget(self);
1066    }
1067}
1068
1069impl ControllerClearEntriesResponder {
1070    /// Sends a response to the FIDL transaction.
1071    ///
1072    /// Sets the channel to shutdown if an error occurs.
1073    pub fn send(self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
1074        let _result = self.send_raw(result);
1075        if _result.is_err() {
1076            self.control_handle.shutdown();
1077        }
1078        self.drop_without_shutdown();
1079        _result
1080    }
1081
1082    /// Similar to "send" but does not shutdown the channel if an error occurs.
1083    pub fn send_no_shutdown_on_err(
1084        self,
1085        mut result: Result<(), ControllerError>,
1086    ) -> Result<(), fidl::Error> {
1087        let _result = self.send_raw(result);
1088        self.drop_without_shutdown();
1089        _result
1090    }
1091
1092    fn send_raw(&self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
1093        self.control_handle.inner.send::<fidl::encoding::ResultType<
1094            fidl::encoding::EmptyStruct,
1095            ControllerError,
1096        >>(
1097            result,
1098            self.tx_id,
1099            0x33e53d9769a999d,
1100            fidl::encoding::DynamicFlags::empty(),
1101        )
1102    }
1103}
1104
1105#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1106pub struct EntryIteratorMarker;
1107
1108impl fidl::endpoints::ProtocolMarker for EntryIteratorMarker {
1109    type Proxy = EntryIteratorProxy;
1110    type RequestStream = EntryIteratorRequestStream;
1111    #[cfg(target_os = "fuchsia")]
1112    type SynchronousProxy = EntryIteratorSynchronousProxy;
1113
1114    const DEBUG_NAME: &'static str = "(anonymous) EntryIterator";
1115}
1116
1117pub trait EntryIteratorProxyInterface: Send + Sync {
1118    type GetNextResponseFut: std::future::Future<Output = Result<Vec<EntryIteratorItem>, fidl::Error>>
1119        + Send;
1120    fn r#get_next(&self) -> Self::GetNextResponseFut;
1121}
1122#[derive(Debug)]
1123#[cfg(target_os = "fuchsia")]
1124pub struct EntryIteratorSynchronousProxy {
1125    client: fidl::client::sync::Client,
1126}
1127
1128#[cfg(target_os = "fuchsia")]
1129impl fidl::endpoints::SynchronousProxy for EntryIteratorSynchronousProxy {
1130    type Proxy = EntryIteratorProxy;
1131    type Protocol = EntryIteratorMarker;
1132
1133    fn from_channel(inner: fidl::Channel) -> Self {
1134        Self::new(inner)
1135    }
1136
1137    fn into_channel(self) -> fidl::Channel {
1138        self.client.into_channel()
1139    }
1140
1141    fn as_channel(&self) -> &fidl::Channel {
1142        self.client.as_channel()
1143    }
1144}
1145
1146#[cfg(target_os = "fuchsia")]
1147impl EntryIteratorSynchronousProxy {
1148    pub fn new(channel: fidl::Channel) -> Self {
1149        Self { client: fidl::client::sync::Client::new(channel) }
1150    }
1151
1152    pub fn into_channel(self) -> fidl::Channel {
1153        self.client.into_channel()
1154    }
1155
1156    /// Waits until an event arrives and returns it. It is safe for other
1157    /// threads to make concurrent requests while waiting for an event.
1158    pub fn wait_for_event(
1159        &self,
1160        deadline: zx::MonotonicInstant,
1161    ) -> Result<EntryIteratorEvent, fidl::Error> {
1162        EntryIteratorEvent::decode(self.client.wait_for_event::<EntryIteratorMarker>(deadline)?)
1163    }
1164
1165    /// Take items from the iterator. If no items are available, block until one
1166    /// is; otherwise, return immediately with items queued since the last
1167    /// invocation.
1168    ///
1169    /// This does not guarantee that, when blocking, only one item will be
1170    /// returned; implementations may debounce or batch events.
1171    ///
1172    /// Clients should only have one call of this method at a time; a second
1173    /// call to this method while a call is already pending will cause the
1174    /// server end of the protocol to be closed.
1175    ///
1176    /// - response `events` a list of events that occurred since the last
1177    ///     invocation of this method.
1178    pub fn r#get_next(
1179        &self,
1180        ___deadline: zx::MonotonicInstant,
1181    ) -> Result<Vec<EntryIteratorItem>, fidl::Error> {
1182        let _response = self.client.send_query::<
1183            fidl::encoding::EmptyPayload,
1184            EntryIteratorGetNextResponse,
1185            EntryIteratorMarker,
1186        >(
1187            (),
1188            0x6d03407803da8647,
1189            fidl::encoding::DynamicFlags::empty(),
1190            ___deadline,
1191        )?;
1192        Ok(_response.events)
1193    }
1194}
1195
1196#[cfg(target_os = "fuchsia")]
1197impl From<EntryIteratorSynchronousProxy> for zx::NullableHandle {
1198    fn from(value: EntryIteratorSynchronousProxy) -> Self {
1199        value.into_channel().into()
1200    }
1201}
1202
1203#[cfg(target_os = "fuchsia")]
1204impl From<fidl::Channel> for EntryIteratorSynchronousProxy {
1205    fn from(value: fidl::Channel) -> Self {
1206        Self::new(value)
1207    }
1208}
1209
1210#[cfg(target_os = "fuchsia")]
1211impl fidl::endpoints::FromClient for EntryIteratorSynchronousProxy {
1212    type Protocol = EntryIteratorMarker;
1213
1214    fn from_client(value: fidl::endpoints::ClientEnd<EntryIteratorMarker>) -> Self {
1215        Self::new(value.into_channel())
1216    }
1217}
1218
1219#[derive(Debug, Clone)]
1220pub struct EntryIteratorProxy {
1221    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1222}
1223
1224impl fidl::endpoints::Proxy for EntryIteratorProxy {
1225    type Protocol = EntryIteratorMarker;
1226
1227    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1228        Self::new(inner)
1229    }
1230
1231    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1232        self.client.into_channel().map_err(|client| Self { client })
1233    }
1234
1235    fn as_channel(&self) -> &::fidl::AsyncChannel {
1236        self.client.as_channel()
1237    }
1238}
1239
1240impl EntryIteratorProxy {
1241    /// Create a new Proxy for fuchsia.net.neighbor/EntryIterator.
1242    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1243        let protocol_name = <EntryIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1244        Self { client: fidl::client::Client::new(channel, protocol_name) }
1245    }
1246
1247    /// Get a Stream of events from the remote end of the protocol.
1248    ///
1249    /// # Panics
1250    ///
1251    /// Panics if the event stream was already taken.
1252    pub fn take_event_stream(&self) -> EntryIteratorEventStream {
1253        EntryIteratorEventStream { event_receiver: self.client.take_event_receiver() }
1254    }
1255
1256    /// Take items from the iterator. If no items are available, block until one
1257    /// is; otherwise, return immediately with items queued since the last
1258    /// invocation.
1259    ///
1260    /// This does not guarantee that, when blocking, only one item will be
1261    /// returned; implementations may debounce or batch events.
1262    ///
1263    /// Clients should only have one call of this method at a time; a second
1264    /// call to this method while a call is already pending will cause the
1265    /// server end of the protocol to be closed.
1266    ///
1267    /// - response `events` a list of events that occurred since the last
1268    ///     invocation of this method.
1269    pub fn r#get_next(
1270        &self,
1271    ) -> fidl::client::QueryResponseFut<
1272        Vec<EntryIteratorItem>,
1273        fidl::encoding::DefaultFuchsiaResourceDialect,
1274    > {
1275        EntryIteratorProxyInterface::r#get_next(self)
1276    }
1277}
1278
1279impl EntryIteratorProxyInterface for EntryIteratorProxy {
1280    type GetNextResponseFut = fidl::client::QueryResponseFut<
1281        Vec<EntryIteratorItem>,
1282        fidl::encoding::DefaultFuchsiaResourceDialect,
1283    >;
1284    fn r#get_next(&self) -> Self::GetNextResponseFut {
1285        fn _decode(
1286            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1287        ) -> Result<Vec<EntryIteratorItem>, fidl::Error> {
1288            let _response = fidl::client::decode_transaction_body::<
1289                EntryIteratorGetNextResponse,
1290                fidl::encoding::DefaultFuchsiaResourceDialect,
1291                0x6d03407803da8647,
1292            >(_buf?)?;
1293            Ok(_response.events)
1294        }
1295        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<EntryIteratorItem>>(
1296            (),
1297            0x6d03407803da8647,
1298            fidl::encoding::DynamicFlags::empty(),
1299            _decode,
1300        )
1301    }
1302}
1303
1304pub struct EntryIteratorEventStream {
1305    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1306}
1307
1308impl std::marker::Unpin for EntryIteratorEventStream {}
1309
1310impl futures::stream::FusedStream for EntryIteratorEventStream {
1311    fn is_terminated(&self) -> bool {
1312        self.event_receiver.is_terminated()
1313    }
1314}
1315
1316impl futures::Stream for EntryIteratorEventStream {
1317    type Item = Result<EntryIteratorEvent, fidl::Error>;
1318
1319    fn poll_next(
1320        mut self: std::pin::Pin<&mut Self>,
1321        cx: &mut std::task::Context<'_>,
1322    ) -> std::task::Poll<Option<Self::Item>> {
1323        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1324            &mut self.event_receiver,
1325            cx
1326        )?) {
1327            Some(buf) => std::task::Poll::Ready(Some(EntryIteratorEvent::decode(buf))),
1328            None => std::task::Poll::Ready(None),
1329        }
1330    }
1331}
1332
1333#[derive(Debug)]
1334pub enum EntryIteratorEvent {}
1335
1336impl EntryIteratorEvent {
1337    /// Decodes a message buffer as a [`EntryIteratorEvent`].
1338    fn decode(
1339        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1340    ) -> Result<EntryIteratorEvent, fidl::Error> {
1341        let (bytes, _handles) = buf.split_mut();
1342        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1343        debug_assert_eq!(tx_header.tx_id, 0);
1344        match tx_header.ordinal {
1345            _ => Err(fidl::Error::UnknownOrdinal {
1346                ordinal: tx_header.ordinal,
1347                protocol_name: <EntryIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1348            }),
1349        }
1350    }
1351}
1352
1353/// A Stream of incoming requests for fuchsia.net.neighbor/EntryIterator.
1354pub struct EntryIteratorRequestStream {
1355    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1356    is_terminated: bool,
1357}
1358
1359impl std::marker::Unpin for EntryIteratorRequestStream {}
1360
1361impl futures::stream::FusedStream for EntryIteratorRequestStream {
1362    fn is_terminated(&self) -> bool {
1363        self.is_terminated
1364    }
1365}
1366
1367impl fidl::endpoints::RequestStream for EntryIteratorRequestStream {
1368    type Protocol = EntryIteratorMarker;
1369    type ControlHandle = EntryIteratorControlHandle;
1370
1371    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1372        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1373    }
1374
1375    fn control_handle(&self) -> Self::ControlHandle {
1376        EntryIteratorControlHandle { inner: self.inner.clone() }
1377    }
1378
1379    fn into_inner(
1380        self,
1381    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1382    {
1383        (self.inner, self.is_terminated)
1384    }
1385
1386    fn from_inner(
1387        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1388        is_terminated: bool,
1389    ) -> Self {
1390        Self { inner, is_terminated }
1391    }
1392}
1393
1394impl futures::Stream for EntryIteratorRequestStream {
1395    type Item = Result<EntryIteratorRequest, fidl::Error>;
1396
1397    fn poll_next(
1398        mut self: std::pin::Pin<&mut Self>,
1399        cx: &mut std::task::Context<'_>,
1400    ) -> std::task::Poll<Option<Self::Item>> {
1401        let this = &mut *self;
1402        if this.inner.check_shutdown(cx) {
1403            this.is_terminated = true;
1404            return std::task::Poll::Ready(None);
1405        }
1406        if this.is_terminated {
1407            panic!("polled EntryIteratorRequestStream after completion");
1408        }
1409        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1410            |bytes, handles| {
1411                match this.inner.channel().read_etc(cx, bytes, handles) {
1412                    std::task::Poll::Ready(Ok(())) => {}
1413                    std::task::Poll::Pending => return std::task::Poll::Pending,
1414                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1415                        this.is_terminated = true;
1416                        return std::task::Poll::Ready(None);
1417                    }
1418                    std::task::Poll::Ready(Err(e)) => {
1419                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1420                            e.into(),
1421                        ))));
1422                    }
1423                }
1424
1425                // A message has been received from the channel
1426                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1427
1428                std::task::Poll::Ready(Some(match header.ordinal {
1429                    0x6d03407803da8647 => {
1430                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1431                        let mut req = fidl::new_empty!(
1432                            fidl::encoding::EmptyPayload,
1433                            fidl::encoding::DefaultFuchsiaResourceDialect
1434                        );
1435                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1436                        let control_handle =
1437                            EntryIteratorControlHandle { inner: this.inner.clone() };
1438                        Ok(EntryIteratorRequest::GetNext {
1439                            responder: EntryIteratorGetNextResponder {
1440                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1441                                tx_id: header.tx_id,
1442                            },
1443                        })
1444                    }
1445                    _ => Err(fidl::Error::UnknownOrdinal {
1446                        ordinal: header.ordinal,
1447                        protocol_name:
1448                            <EntryIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1449                    }),
1450                }))
1451            },
1452        )
1453    }
1454}
1455
1456/// Returns entries and events from the neighbor table. Clients can open an
1457/// iterator using the [`fuchsia.net.neighbor/View.EntryIterator`] method.
1458///
1459/// An atomic snapshot of the neighbor table is queued for clients upon opening
1460/// an EntryIterator. This snapshot consists of `existing` entries followed by
1461/// an [`IdleEvent`]. No other types of events will be sent before an
1462/// [`IdleEvent`].
1463#[derive(Debug)]
1464pub enum EntryIteratorRequest {
1465    /// Take items from the iterator. If no items are available, block until one
1466    /// is; otherwise, return immediately with items queued since the last
1467    /// invocation.
1468    ///
1469    /// This does not guarantee that, when blocking, only one item will be
1470    /// returned; implementations may debounce or batch events.
1471    ///
1472    /// Clients should only have one call of this method at a time; a second
1473    /// call to this method while a call is already pending will cause the
1474    /// server end of the protocol to be closed.
1475    ///
1476    /// - response `events` a list of events that occurred since the last
1477    ///     invocation of this method.
1478    GetNext { responder: EntryIteratorGetNextResponder },
1479}
1480
1481impl EntryIteratorRequest {
1482    #[allow(irrefutable_let_patterns)]
1483    pub fn into_get_next(self) -> Option<(EntryIteratorGetNextResponder)> {
1484        if let EntryIteratorRequest::GetNext { responder } = self {
1485            Some((responder))
1486        } else {
1487            None
1488        }
1489    }
1490
1491    /// Name of the method defined in FIDL
1492    pub fn method_name(&self) -> &'static str {
1493        match *self {
1494            EntryIteratorRequest::GetNext { .. } => "get_next",
1495        }
1496    }
1497}
1498
1499#[derive(Debug, Clone)]
1500pub struct EntryIteratorControlHandle {
1501    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1502}
1503
1504impl EntryIteratorControlHandle {
1505    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1506        self.inner.shutdown_with_epitaph(status.into())
1507    }
1508}
1509
1510impl fidl::endpoints::ControlHandle for EntryIteratorControlHandle {
1511    fn shutdown(&self) {
1512        self.inner.shutdown()
1513    }
1514
1515    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1516        self.inner.shutdown_with_epitaph(status)
1517    }
1518
1519    fn is_closed(&self) -> bool {
1520        self.inner.channel().is_closed()
1521    }
1522    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1523        self.inner.channel().on_closed()
1524    }
1525
1526    #[cfg(target_os = "fuchsia")]
1527    fn signal_peer(
1528        &self,
1529        clear_mask: zx::Signals,
1530        set_mask: zx::Signals,
1531    ) -> Result<(), zx_status::Status> {
1532        use fidl::Peered;
1533        self.inner.channel().signal_peer(clear_mask, set_mask)
1534    }
1535}
1536
1537impl EntryIteratorControlHandle {}
1538
1539#[must_use = "FIDL methods require a response to be sent"]
1540#[derive(Debug)]
1541pub struct EntryIteratorGetNextResponder {
1542    control_handle: std::mem::ManuallyDrop<EntryIteratorControlHandle>,
1543    tx_id: u32,
1544}
1545
1546/// Set the the channel to be shutdown (see [`EntryIteratorControlHandle::shutdown`])
1547/// if the responder is dropped without sending a response, so that the client
1548/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1549impl std::ops::Drop for EntryIteratorGetNextResponder {
1550    fn drop(&mut self) {
1551        self.control_handle.shutdown();
1552        // Safety: drops once, never accessed again
1553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1554    }
1555}
1556
1557impl fidl::endpoints::Responder for EntryIteratorGetNextResponder {
1558    type ControlHandle = EntryIteratorControlHandle;
1559
1560    fn control_handle(&self) -> &EntryIteratorControlHandle {
1561        &self.control_handle
1562    }
1563
1564    fn drop_without_shutdown(mut self) {
1565        // Safety: drops once, never accessed again due to mem::forget
1566        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1567        // Prevent Drop from running (which would shut down the channel)
1568        std::mem::forget(self);
1569    }
1570}
1571
1572impl EntryIteratorGetNextResponder {
1573    /// Sends a response to the FIDL transaction.
1574    ///
1575    /// Sets the channel to shutdown if an error occurs.
1576    pub fn send(self, mut events: &[EntryIteratorItem]) -> Result<(), fidl::Error> {
1577        let _result = self.send_raw(events);
1578        if _result.is_err() {
1579            self.control_handle.shutdown();
1580        }
1581        self.drop_without_shutdown();
1582        _result
1583    }
1584
1585    /// Similar to "send" but does not shutdown the channel if an error occurs.
1586    pub fn send_no_shutdown_on_err(
1587        self,
1588        mut events: &[EntryIteratorItem],
1589    ) -> Result<(), fidl::Error> {
1590        let _result = self.send_raw(events);
1591        self.drop_without_shutdown();
1592        _result
1593    }
1594
1595    fn send_raw(&self, mut events: &[EntryIteratorItem]) -> Result<(), fidl::Error> {
1596        self.control_handle.inner.send::<EntryIteratorGetNextResponse>(
1597            (events,),
1598            self.tx_id,
1599            0x6d03407803da8647,
1600            fidl::encoding::DynamicFlags::empty(),
1601        )
1602    }
1603}
1604
1605#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1606pub struct ViewMarker;
1607
1608impl fidl::endpoints::ProtocolMarker for ViewMarker {
1609    type Proxy = ViewProxy;
1610    type RequestStream = ViewRequestStream;
1611    #[cfg(target_os = "fuchsia")]
1612    type SynchronousProxy = ViewSynchronousProxy;
1613
1614    const DEBUG_NAME: &'static str = "fuchsia.net.neighbor.View";
1615}
1616impl fidl::endpoints::DiscoverableProtocolMarker for ViewMarker {}
1617
1618pub trait ViewProxyInterface: Send + Sync {
1619    fn r#open_entry_iterator(
1620        &self,
1621        it: fidl::endpoints::ServerEnd<EntryIteratorMarker>,
1622        options: &EntryIteratorOptions,
1623    ) -> Result<(), fidl::Error>;
1624}
1625#[derive(Debug)]
1626#[cfg(target_os = "fuchsia")]
1627pub struct ViewSynchronousProxy {
1628    client: fidl::client::sync::Client,
1629}
1630
1631#[cfg(target_os = "fuchsia")]
1632impl fidl::endpoints::SynchronousProxy for ViewSynchronousProxy {
1633    type Proxy = ViewProxy;
1634    type Protocol = ViewMarker;
1635
1636    fn from_channel(inner: fidl::Channel) -> Self {
1637        Self::new(inner)
1638    }
1639
1640    fn into_channel(self) -> fidl::Channel {
1641        self.client.into_channel()
1642    }
1643
1644    fn as_channel(&self) -> &fidl::Channel {
1645        self.client.as_channel()
1646    }
1647}
1648
1649#[cfg(target_os = "fuchsia")]
1650impl ViewSynchronousProxy {
1651    pub fn new(channel: fidl::Channel) -> Self {
1652        Self { client: fidl::client::sync::Client::new(channel) }
1653    }
1654
1655    pub fn into_channel(self) -> fidl::Channel {
1656        self.client.into_channel()
1657    }
1658
1659    /// Waits until an event arrives and returns it. It is safe for other
1660    /// threads to make concurrent requests while waiting for an event.
1661    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<ViewEvent, fidl::Error> {
1662        ViewEvent::decode(self.client.wait_for_event::<ViewMarker>(deadline)?)
1663    }
1664
1665    /// Open a connection to an [`EntryIterator`] for listing existing entries
1666    /// and optionally watching for state changes.
1667    ///
1668    /// + request `it` grants access to the [`EntryIterator`].
1669    /// + request `options` specifies the behavior of the [`EntryIterator`].
1670    pub fn r#open_entry_iterator(
1671        &self,
1672        mut it: fidl::endpoints::ServerEnd<EntryIteratorMarker>,
1673        mut options: &EntryIteratorOptions,
1674    ) -> Result<(), fidl::Error> {
1675        self.client.send::<ViewOpenEntryIteratorRequest>(
1676            (it, options),
1677            0x3c9531929383e911,
1678            fidl::encoding::DynamicFlags::empty(),
1679        )
1680    }
1681}
1682
1683#[cfg(target_os = "fuchsia")]
1684impl From<ViewSynchronousProxy> for zx::NullableHandle {
1685    fn from(value: ViewSynchronousProxy) -> Self {
1686        value.into_channel().into()
1687    }
1688}
1689
1690#[cfg(target_os = "fuchsia")]
1691impl From<fidl::Channel> for ViewSynchronousProxy {
1692    fn from(value: fidl::Channel) -> Self {
1693        Self::new(value)
1694    }
1695}
1696
1697#[cfg(target_os = "fuchsia")]
1698impl fidl::endpoints::FromClient for ViewSynchronousProxy {
1699    type Protocol = ViewMarker;
1700
1701    fn from_client(value: fidl::endpoints::ClientEnd<ViewMarker>) -> Self {
1702        Self::new(value.into_channel())
1703    }
1704}
1705
1706#[derive(Debug, Clone)]
1707pub struct ViewProxy {
1708    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1709}
1710
1711impl fidl::endpoints::Proxy for ViewProxy {
1712    type Protocol = ViewMarker;
1713
1714    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1715        Self::new(inner)
1716    }
1717
1718    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1719        self.client.into_channel().map_err(|client| Self { client })
1720    }
1721
1722    fn as_channel(&self) -> &::fidl::AsyncChannel {
1723        self.client.as_channel()
1724    }
1725}
1726
1727impl ViewProxy {
1728    /// Create a new Proxy for fuchsia.net.neighbor/View.
1729    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1730        let protocol_name = <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1731        Self { client: fidl::client::Client::new(channel, protocol_name) }
1732    }
1733
1734    /// Get a Stream of events from the remote end of the protocol.
1735    ///
1736    /// # Panics
1737    ///
1738    /// Panics if the event stream was already taken.
1739    pub fn take_event_stream(&self) -> ViewEventStream {
1740        ViewEventStream { event_receiver: self.client.take_event_receiver() }
1741    }
1742
1743    /// Open a connection to an [`EntryIterator`] for listing existing entries
1744    /// and optionally watching for state changes.
1745    ///
1746    /// + request `it` grants access to the [`EntryIterator`].
1747    /// + request `options` specifies the behavior of the [`EntryIterator`].
1748    pub fn r#open_entry_iterator(
1749        &self,
1750        mut it: fidl::endpoints::ServerEnd<EntryIteratorMarker>,
1751        mut options: &EntryIteratorOptions,
1752    ) -> Result<(), fidl::Error> {
1753        ViewProxyInterface::r#open_entry_iterator(self, it, options)
1754    }
1755}
1756
1757impl ViewProxyInterface for ViewProxy {
1758    fn r#open_entry_iterator(
1759        &self,
1760        mut it: fidl::endpoints::ServerEnd<EntryIteratorMarker>,
1761        mut options: &EntryIteratorOptions,
1762    ) -> Result<(), fidl::Error> {
1763        self.client.send::<ViewOpenEntryIteratorRequest>(
1764            (it, options),
1765            0x3c9531929383e911,
1766            fidl::encoding::DynamicFlags::empty(),
1767        )
1768    }
1769}
1770
1771pub struct ViewEventStream {
1772    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1773}
1774
1775impl std::marker::Unpin for ViewEventStream {}
1776
1777impl futures::stream::FusedStream for ViewEventStream {
1778    fn is_terminated(&self) -> bool {
1779        self.event_receiver.is_terminated()
1780    }
1781}
1782
1783impl futures::Stream for ViewEventStream {
1784    type Item = Result<ViewEvent, fidl::Error>;
1785
1786    fn poll_next(
1787        mut self: std::pin::Pin<&mut Self>,
1788        cx: &mut std::task::Context<'_>,
1789    ) -> std::task::Poll<Option<Self::Item>> {
1790        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1791            &mut self.event_receiver,
1792            cx
1793        )?) {
1794            Some(buf) => std::task::Poll::Ready(Some(ViewEvent::decode(buf))),
1795            None => std::task::Poll::Ready(None),
1796        }
1797    }
1798}
1799
1800#[derive(Debug)]
1801pub enum ViewEvent {}
1802
1803impl ViewEvent {
1804    /// Decodes a message buffer as a [`ViewEvent`].
1805    fn decode(
1806        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1807    ) -> Result<ViewEvent, fidl::Error> {
1808        let (bytes, _handles) = buf.split_mut();
1809        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1810        debug_assert_eq!(tx_header.tx_id, 0);
1811        match tx_header.ordinal {
1812            _ => Err(fidl::Error::UnknownOrdinal {
1813                ordinal: tx_header.ordinal,
1814                protocol_name: <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1815            }),
1816        }
1817    }
1818}
1819
1820/// A Stream of incoming requests for fuchsia.net.neighbor/View.
1821pub struct ViewRequestStream {
1822    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1823    is_terminated: bool,
1824}
1825
1826impl std::marker::Unpin for ViewRequestStream {}
1827
1828impl futures::stream::FusedStream for ViewRequestStream {
1829    fn is_terminated(&self) -> bool {
1830        self.is_terminated
1831    }
1832}
1833
1834impl fidl::endpoints::RequestStream for ViewRequestStream {
1835    type Protocol = ViewMarker;
1836    type ControlHandle = ViewControlHandle;
1837
1838    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1839        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1840    }
1841
1842    fn control_handle(&self) -> Self::ControlHandle {
1843        ViewControlHandle { inner: self.inner.clone() }
1844    }
1845
1846    fn into_inner(
1847        self,
1848    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1849    {
1850        (self.inner, self.is_terminated)
1851    }
1852
1853    fn from_inner(
1854        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1855        is_terminated: bool,
1856    ) -> Self {
1857        Self { inner, is_terminated }
1858    }
1859}
1860
1861impl futures::Stream for ViewRequestStream {
1862    type Item = Result<ViewRequest, fidl::Error>;
1863
1864    fn poll_next(
1865        mut self: std::pin::Pin<&mut Self>,
1866        cx: &mut std::task::Context<'_>,
1867    ) -> std::task::Poll<Option<Self::Item>> {
1868        let this = &mut *self;
1869        if this.inner.check_shutdown(cx) {
1870            this.is_terminated = true;
1871            return std::task::Poll::Ready(None);
1872        }
1873        if this.is_terminated {
1874            panic!("polled ViewRequestStream after completion");
1875        }
1876        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1877            |bytes, handles| {
1878                match this.inner.channel().read_etc(cx, bytes, handles) {
1879                    std::task::Poll::Ready(Ok(())) => {}
1880                    std::task::Poll::Pending => return std::task::Poll::Pending,
1881                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1882                        this.is_terminated = true;
1883                        return std::task::Poll::Ready(None);
1884                    }
1885                    std::task::Poll::Ready(Err(e)) => {
1886                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1887                            e.into(),
1888                        ))));
1889                    }
1890                }
1891
1892                // A message has been received from the channel
1893                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1894
1895                std::task::Poll::Ready(Some(match header.ordinal {
1896                    0x3c9531929383e911 => {
1897                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1898                        let mut req = fidl::new_empty!(
1899                            ViewOpenEntryIteratorRequest,
1900                            fidl::encoding::DefaultFuchsiaResourceDialect
1901                        );
1902                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewOpenEntryIteratorRequest>(&header, _body_bytes, handles, &mut req)?;
1903                        let control_handle = ViewControlHandle { inner: this.inner.clone() };
1904                        Ok(ViewRequest::OpenEntryIterator {
1905                            it: req.it,
1906                            options: req.options,
1907
1908                            control_handle,
1909                        })
1910                    }
1911                    _ => Err(fidl::Error::UnknownOrdinal {
1912                        ordinal: header.ordinal,
1913                        protocol_name: <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1914                    }),
1915                }))
1916            },
1917        )
1918    }
1919}
1920
1921/// Inspect the neighbor table.
1922#[derive(Debug)]
1923pub enum ViewRequest {
1924    /// Open a connection to an [`EntryIterator`] for listing existing entries
1925    /// and optionally watching for state changes.
1926    ///
1927    /// + request `it` grants access to the [`EntryIterator`].
1928    /// + request `options` specifies the behavior of the [`EntryIterator`].
1929    OpenEntryIterator {
1930        it: fidl::endpoints::ServerEnd<EntryIteratorMarker>,
1931        options: EntryIteratorOptions,
1932        control_handle: ViewControlHandle,
1933    },
1934}
1935
1936impl ViewRequest {
1937    #[allow(irrefutable_let_patterns)]
1938    pub fn into_open_entry_iterator(
1939        self,
1940    ) -> Option<(
1941        fidl::endpoints::ServerEnd<EntryIteratorMarker>,
1942        EntryIteratorOptions,
1943        ViewControlHandle,
1944    )> {
1945        if let ViewRequest::OpenEntryIterator { it, options, control_handle } = self {
1946            Some((it, options, control_handle))
1947        } else {
1948            None
1949        }
1950    }
1951
1952    /// Name of the method defined in FIDL
1953    pub fn method_name(&self) -> &'static str {
1954        match *self {
1955            ViewRequest::OpenEntryIterator { .. } => "open_entry_iterator",
1956        }
1957    }
1958}
1959
1960#[derive(Debug, Clone)]
1961pub struct ViewControlHandle {
1962    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1963}
1964
1965impl ViewControlHandle {
1966    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1967        self.inner.shutdown_with_epitaph(status.into())
1968    }
1969}
1970
1971impl fidl::endpoints::ControlHandle for ViewControlHandle {
1972    fn shutdown(&self) {
1973        self.inner.shutdown()
1974    }
1975
1976    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1977        self.inner.shutdown_with_epitaph(status)
1978    }
1979
1980    fn is_closed(&self) -> bool {
1981        self.inner.channel().is_closed()
1982    }
1983    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1984        self.inner.channel().on_closed()
1985    }
1986
1987    #[cfg(target_os = "fuchsia")]
1988    fn signal_peer(
1989        &self,
1990        clear_mask: zx::Signals,
1991        set_mask: zx::Signals,
1992    ) -> Result<(), zx_status::Status> {
1993        use fidl::Peered;
1994        self.inner.channel().signal_peer(clear_mask, set_mask)
1995    }
1996}
1997
1998impl ViewControlHandle {}
1999
2000mod internal {
2001    use super::*;
2002
2003    impl fidl::encoding::ResourceTypeMarker for ViewOpenEntryIteratorRequest {
2004        type Borrowed<'a> = &'a mut Self;
2005        fn take_or_borrow<'a>(
2006            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2007        ) -> Self::Borrowed<'a> {
2008            value
2009        }
2010    }
2011
2012    unsafe impl fidl::encoding::TypeMarker for ViewOpenEntryIteratorRequest {
2013        type Owned = Self;
2014
2015        #[inline(always)]
2016        fn inline_align(_context: fidl::encoding::Context) -> usize {
2017            8
2018        }
2019
2020        #[inline(always)]
2021        fn inline_size(_context: fidl::encoding::Context) -> usize {
2022            24
2023        }
2024    }
2025
2026    unsafe impl
2027        fidl::encoding::Encode<
2028            ViewOpenEntryIteratorRequest,
2029            fidl::encoding::DefaultFuchsiaResourceDialect,
2030        > for &mut ViewOpenEntryIteratorRequest
2031    {
2032        #[inline]
2033        unsafe fn encode(
2034            self,
2035            encoder: &mut fidl::encoding::Encoder<
2036                '_,
2037                fidl::encoding::DefaultFuchsiaResourceDialect,
2038            >,
2039            offset: usize,
2040            _depth: fidl::encoding::Depth,
2041        ) -> fidl::Result<()> {
2042            encoder.debug_check_bounds::<ViewOpenEntryIteratorRequest>(offset);
2043            // Delegate to tuple encoding.
2044            fidl::encoding::Encode::<ViewOpenEntryIteratorRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2045                (
2046                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EntryIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.it),
2047                    <EntryIteratorOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
2048                ),
2049                encoder, offset, _depth
2050            )
2051        }
2052    }
2053    unsafe impl<
2054        T0: fidl::encoding::Encode<
2055                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EntryIteratorMarker>>,
2056                fidl::encoding::DefaultFuchsiaResourceDialect,
2057            >,
2058        T1: fidl::encoding::Encode<EntryIteratorOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
2059    >
2060        fidl::encoding::Encode<
2061            ViewOpenEntryIteratorRequest,
2062            fidl::encoding::DefaultFuchsiaResourceDialect,
2063        > for (T0, T1)
2064    {
2065        #[inline]
2066        unsafe fn encode(
2067            self,
2068            encoder: &mut fidl::encoding::Encoder<
2069                '_,
2070                fidl::encoding::DefaultFuchsiaResourceDialect,
2071            >,
2072            offset: usize,
2073            depth: fidl::encoding::Depth,
2074        ) -> fidl::Result<()> {
2075            encoder.debug_check_bounds::<ViewOpenEntryIteratorRequest>(offset);
2076            // Zero out padding regions. There's no need to apply masks
2077            // because the unmasked parts will be overwritten by fields.
2078            unsafe {
2079                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2080                (ptr as *mut u64).write_unaligned(0);
2081            }
2082            // Write the fields.
2083            self.0.encode(encoder, offset + 0, depth)?;
2084            self.1.encode(encoder, offset + 8, depth)?;
2085            Ok(())
2086        }
2087    }
2088
2089    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2090        for ViewOpenEntryIteratorRequest
2091    {
2092        #[inline(always)]
2093        fn new_empty() -> Self {
2094            Self {
2095                it: fidl::new_empty!(
2096                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EntryIteratorMarker>>,
2097                    fidl::encoding::DefaultFuchsiaResourceDialect
2098                ),
2099                options: fidl::new_empty!(
2100                    EntryIteratorOptions,
2101                    fidl::encoding::DefaultFuchsiaResourceDialect
2102                ),
2103            }
2104        }
2105
2106        #[inline]
2107        unsafe fn decode(
2108            &mut self,
2109            decoder: &mut fidl::encoding::Decoder<
2110                '_,
2111                fidl::encoding::DefaultFuchsiaResourceDialect,
2112            >,
2113            offset: usize,
2114            _depth: fidl::encoding::Depth,
2115        ) -> fidl::Result<()> {
2116            decoder.debug_check_bounds::<Self>(offset);
2117            // Verify that padding bytes are zero.
2118            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2119            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2120            let mask = 0xffffffff00000000u64;
2121            let maskedval = padval & mask;
2122            if maskedval != 0 {
2123                return Err(fidl::Error::NonZeroPadding {
2124                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2125                });
2126            }
2127            fidl::decode!(
2128                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EntryIteratorMarker>>,
2129                fidl::encoding::DefaultFuchsiaResourceDialect,
2130                &mut self.it,
2131                decoder,
2132                offset + 0,
2133                _depth
2134            )?;
2135            fidl::decode!(
2136                EntryIteratorOptions,
2137                fidl::encoding::DefaultFuchsiaResourceDialect,
2138                &mut self.options,
2139                decoder,
2140                offset + 8,
2141                _depth
2142            )?;
2143            Ok(())
2144        }
2145    }
2146}