Skip to main content

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