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 fdomain_client::fidl::ControlHandle for ControllerControlHandle {
624    fn shutdown(&self) {
625        self.inner.shutdown()
626    }
627
628    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
629        self.inner.shutdown_with_epitaph(status)
630    }
631
632    fn is_closed(&self) -> bool {
633        self.inner.channel().is_closed()
634    }
635    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
636        self.inner.channel().on_closed()
637    }
638}
639
640impl ControllerControlHandle {}
641
642#[must_use = "FIDL methods require a response to be sent"]
643#[derive(Debug)]
644pub struct ControllerAddEntryResponder {
645    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
646    tx_id: u32,
647}
648
649/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
650/// if the responder is dropped without sending a response, so that the client
651/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
652impl std::ops::Drop for ControllerAddEntryResponder {
653    fn drop(&mut self) {
654        self.control_handle.shutdown();
655        // Safety: drops once, never accessed again
656        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
657    }
658}
659
660impl fdomain_client::fidl::Responder for ControllerAddEntryResponder {
661    type ControlHandle = ControllerControlHandle;
662
663    fn control_handle(&self) -> &ControllerControlHandle {
664        &self.control_handle
665    }
666
667    fn drop_without_shutdown(mut self) {
668        // Safety: drops once, never accessed again due to mem::forget
669        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
670        // Prevent Drop from running (which would shut down the channel)
671        std::mem::forget(self);
672    }
673}
674
675impl ControllerAddEntryResponder {
676    /// Sends a response to the FIDL transaction.
677    ///
678    /// Sets the channel to shutdown if an error occurs.
679    pub fn send(self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
680        let _result = self.send_raw(result);
681        if _result.is_err() {
682            self.control_handle.shutdown();
683        }
684        self.drop_without_shutdown();
685        _result
686    }
687
688    /// Similar to "send" but does not shutdown the channel if an error occurs.
689    pub fn send_no_shutdown_on_err(
690        self,
691        mut result: Result<(), ControllerError>,
692    ) -> Result<(), fidl::Error> {
693        let _result = self.send_raw(result);
694        self.drop_without_shutdown();
695        _result
696    }
697
698    fn send_raw(&self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
699        self.control_handle.inner.send::<fidl::encoding::ResultType<
700            fidl::encoding::EmptyStruct,
701            ControllerError,
702        >>(
703            result,
704            self.tx_id,
705            0x778c829580aa23ac,
706            fidl::encoding::DynamicFlags::empty(),
707        )
708    }
709}
710
711#[must_use = "FIDL methods require a response to be sent"]
712#[derive(Debug)]
713pub struct ControllerProbeEntryResponder {
714    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
715    tx_id: u32,
716}
717
718/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
719/// if the responder is dropped without sending a response, so that the client
720/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
721impl std::ops::Drop for ControllerProbeEntryResponder {
722    fn drop(&mut self) {
723        self.control_handle.shutdown();
724        // Safety: drops once, never accessed again
725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
726    }
727}
728
729impl fdomain_client::fidl::Responder for ControllerProbeEntryResponder {
730    type ControlHandle = ControllerControlHandle;
731
732    fn control_handle(&self) -> &ControllerControlHandle {
733        &self.control_handle
734    }
735
736    fn drop_without_shutdown(mut self) {
737        // Safety: drops once, never accessed again due to mem::forget
738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
739        // Prevent Drop from running (which would shut down the channel)
740        std::mem::forget(self);
741    }
742}
743
744impl ControllerProbeEntryResponder {
745    /// Sends a response to the FIDL transaction.
746    ///
747    /// Sets the channel to shutdown if an error occurs.
748    pub fn send(self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
749        let _result = self.send_raw(result);
750        if _result.is_err() {
751            self.control_handle.shutdown();
752        }
753        self.drop_without_shutdown();
754        _result
755    }
756
757    /// Similar to "send" but does not shutdown the channel if an error occurs.
758    pub fn send_no_shutdown_on_err(
759        self,
760        mut result: Result<(), ControllerError>,
761    ) -> Result<(), fidl::Error> {
762        let _result = self.send_raw(result);
763        self.drop_without_shutdown();
764        _result
765    }
766
767    fn send_raw(&self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
768        self.control_handle.inner.send::<fidl::encoding::ResultType<
769            fidl::encoding::EmptyStruct,
770            ControllerError,
771        >>(
772            result,
773            self.tx_id,
774            0x4f71dd58473f58ad,
775            fidl::encoding::DynamicFlags::empty(),
776        )
777    }
778}
779
780#[must_use = "FIDL methods require a response to be sent"]
781#[derive(Debug)]
782pub struct ControllerRemoveEntryResponder {
783    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
784    tx_id: u32,
785}
786
787/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
788/// if the responder is dropped without sending a response, so that the client
789/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
790impl std::ops::Drop for ControllerRemoveEntryResponder {
791    fn drop(&mut self) {
792        self.control_handle.shutdown();
793        // Safety: drops once, never accessed again
794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
795    }
796}
797
798impl fdomain_client::fidl::Responder for ControllerRemoveEntryResponder {
799    type ControlHandle = ControllerControlHandle;
800
801    fn control_handle(&self) -> &ControllerControlHandle {
802        &self.control_handle
803    }
804
805    fn drop_without_shutdown(mut self) {
806        // Safety: drops once, never accessed again due to mem::forget
807        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
808        // Prevent Drop from running (which would shut down the channel)
809        std::mem::forget(self);
810    }
811}
812
813impl ControllerRemoveEntryResponder {
814    /// Sends a response to the FIDL transaction.
815    ///
816    /// Sets the channel to shutdown if an error occurs.
817    pub fn send(self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
818        let _result = self.send_raw(result);
819        if _result.is_err() {
820            self.control_handle.shutdown();
821        }
822        self.drop_without_shutdown();
823        _result
824    }
825
826    /// Similar to "send" but does not shutdown the channel if an error occurs.
827    pub fn send_no_shutdown_on_err(
828        self,
829        mut result: Result<(), ControllerError>,
830    ) -> Result<(), fidl::Error> {
831        let _result = self.send_raw(result);
832        self.drop_without_shutdown();
833        _result
834    }
835
836    fn send_raw(&self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
837        self.control_handle.inner.send::<fidl::encoding::ResultType<
838            fidl::encoding::EmptyStruct,
839            ControllerError,
840        >>(
841            result,
842            self.tx_id,
843            0xfd0b52f53a0f815,
844            fidl::encoding::DynamicFlags::empty(),
845        )
846    }
847}
848
849#[must_use = "FIDL methods require a response to be sent"]
850#[derive(Debug)]
851pub struct ControllerClearEntriesResponder {
852    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
853    tx_id: u32,
854}
855
856/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
857/// if the responder is dropped without sending a response, so that the client
858/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
859impl std::ops::Drop for ControllerClearEntriesResponder {
860    fn drop(&mut self) {
861        self.control_handle.shutdown();
862        // Safety: drops once, never accessed again
863        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
864    }
865}
866
867impl fdomain_client::fidl::Responder for ControllerClearEntriesResponder {
868    type ControlHandle = ControllerControlHandle;
869
870    fn control_handle(&self) -> &ControllerControlHandle {
871        &self.control_handle
872    }
873
874    fn drop_without_shutdown(mut self) {
875        // Safety: drops once, never accessed again due to mem::forget
876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877        // Prevent Drop from running (which would shut down the channel)
878        std::mem::forget(self);
879    }
880}
881
882impl ControllerClearEntriesResponder {
883    /// Sends a response to the FIDL transaction.
884    ///
885    /// Sets the channel to shutdown if an error occurs.
886    pub fn send(self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
887        let _result = self.send_raw(result);
888        if _result.is_err() {
889            self.control_handle.shutdown();
890        }
891        self.drop_without_shutdown();
892        _result
893    }
894
895    /// Similar to "send" but does not shutdown the channel if an error occurs.
896    pub fn send_no_shutdown_on_err(
897        self,
898        mut result: Result<(), ControllerError>,
899    ) -> Result<(), fidl::Error> {
900        let _result = self.send_raw(result);
901        self.drop_without_shutdown();
902        _result
903    }
904
905    fn send_raw(&self, mut result: Result<(), ControllerError>) -> Result<(), fidl::Error> {
906        self.control_handle.inner.send::<fidl::encoding::ResultType<
907            fidl::encoding::EmptyStruct,
908            ControllerError,
909        >>(
910            result,
911            self.tx_id,
912            0x33e53d9769a999d,
913            fidl::encoding::DynamicFlags::empty(),
914        )
915    }
916}
917
918#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
919pub struct EntryIteratorMarker;
920
921impl fdomain_client::fidl::ProtocolMarker for EntryIteratorMarker {
922    type Proxy = EntryIteratorProxy;
923    type RequestStream = EntryIteratorRequestStream;
924
925    const DEBUG_NAME: &'static str = "(anonymous) EntryIterator";
926}
927
928pub trait EntryIteratorProxyInterface: Send + Sync {
929    type GetNextResponseFut: std::future::Future<Output = Result<Vec<EntryIteratorItem>, fidl::Error>>
930        + Send;
931    fn r#get_next(&self) -> Self::GetNextResponseFut;
932}
933
934#[derive(Debug, Clone)]
935pub struct EntryIteratorProxy {
936    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
937}
938
939impl fdomain_client::fidl::Proxy for EntryIteratorProxy {
940    type Protocol = EntryIteratorMarker;
941
942    fn from_channel(inner: fdomain_client::Channel) -> Self {
943        Self::new(inner)
944    }
945
946    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
947        self.client.into_channel().map_err(|client| Self { client })
948    }
949
950    fn as_channel(&self) -> &fdomain_client::Channel {
951        self.client.as_channel()
952    }
953}
954
955impl EntryIteratorProxy {
956    /// Create a new Proxy for fuchsia.net.neighbor/EntryIterator.
957    pub fn new(channel: fdomain_client::Channel) -> Self {
958        let protocol_name =
959            <EntryIteratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
960        Self { client: fidl::client::Client::new(channel, protocol_name) }
961    }
962
963    /// Get a Stream of events from the remote end of the protocol.
964    ///
965    /// # Panics
966    ///
967    /// Panics if the event stream was already taken.
968    pub fn take_event_stream(&self) -> EntryIteratorEventStream {
969        EntryIteratorEventStream { event_receiver: self.client.take_event_receiver() }
970    }
971
972    /// Take items from the iterator. If no items are available, block until one
973    /// is; otherwise, return immediately with items queued since the last
974    /// invocation.
975    ///
976    /// This does not guarantee that, when blocking, only one item will be
977    /// returned; implementations may debounce or batch events.
978    ///
979    /// Clients should only have one call of this method at a time; a second
980    /// call to this method while a call is already pending will cause the
981    /// server end of the protocol to be closed.
982    ///
983    /// - response `events` a list of events that occurred since the last
984    ///     invocation of this method.
985    pub fn r#get_next(
986        &self,
987    ) -> fidl::client::QueryResponseFut<
988        Vec<EntryIteratorItem>,
989        fdomain_client::fidl::FDomainResourceDialect,
990    > {
991        EntryIteratorProxyInterface::r#get_next(self)
992    }
993}
994
995impl EntryIteratorProxyInterface for EntryIteratorProxy {
996    type GetNextResponseFut = fidl::client::QueryResponseFut<
997        Vec<EntryIteratorItem>,
998        fdomain_client::fidl::FDomainResourceDialect,
999    >;
1000    fn r#get_next(&self) -> Self::GetNextResponseFut {
1001        fn _decode(
1002            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1003        ) -> Result<Vec<EntryIteratorItem>, fidl::Error> {
1004            let _response = fidl::client::decode_transaction_body::<
1005                EntryIteratorGetNextResponse,
1006                fdomain_client::fidl::FDomainResourceDialect,
1007                0x6d03407803da8647,
1008            >(_buf?)?;
1009            Ok(_response.events)
1010        }
1011        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<EntryIteratorItem>>(
1012            (),
1013            0x6d03407803da8647,
1014            fidl::encoding::DynamicFlags::empty(),
1015            _decode,
1016        )
1017    }
1018}
1019
1020pub struct EntryIteratorEventStream {
1021    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1022}
1023
1024impl std::marker::Unpin for EntryIteratorEventStream {}
1025
1026impl futures::stream::FusedStream for EntryIteratorEventStream {
1027    fn is_terminated(&self) -> bool {
1028        self.event_receiver.is_terminated()
1029    }
1030}
1031
1032impl futures::Stream for EntryIteratorEventStream {
1033    type Item = Result<EntryIteratorEvent, fidl::Error>;
1034
1035    fn poll_next(
1036        mut self: std::pin::Pin<&mut Self>,
1037        cx: &mut std::task::Context<'_>,
1038    ) -> std::task::Poll<Option<Self::Item>> {
1039        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1040            &mut self.event_receiver,
1041            cx
1042        )?) {
1043            Some(buf) => std::task::Poll::Ready(Some(EntryIteratorEvent::decode(buf))),
1044            None => std::task::Poll::Ready(None),
1045        }
1046    }
1047}
1048
1049#[derive(Debug)]
1050pub enum EntryIteratorEvent {}
1051
1052impl EntryIteratorEvent {
1053    /// Decodes a message buffer as a [`EntryIteratorEvent`].
1054    fn decode(
1055        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1056    ) -> Result<EntryIteratorEvent, fidl::Error> {
1057        let (bytes, _handles) = buf.split_mut();
1058        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1059        debug_assert_eq!(tx_header.tx_id, 0);
1060        match tx_header.ordinal {
1061            _ => Err(fidl::Error::UnknownOrdinal {
1062                ordinal: tx_header.ordinal,
1063                protocol_name:
1064                    <EntryIteratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1065            }),
1066        }
1067    }
1068}
1069
1070/// A Stream of incoming requests for fuchsia.net.neighbor/EntryIterator.
1071pub struct EntryIteratorRequestStream {
1072    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1073    is_terminated: bool,
1074}
1075
1076impl std::marker::Unpin for EntryIteratorRequestStream {}
1077
1078impl futures::stream::FusedStream for EntryIteratorRequestStream {
1079    fn is_terminated(&self) -> bool {
1080        self.is_terminated
1081    }
1082}
1083
1084impl fdomain_client::fidl::RequestStream for EntryIteratorRequestStream {
1085    type Protocol = EntryIteratorMarker;
1086    type ControlHandle = EntryIteratorControlHandle;
1087
1088    fn from_channel(channel: fdomain_client::Channel) -> Self {
1089        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1090    }
1091
1092    fn control_handle(&self) -> Self::ControlHandle {
1093        EntryIteratorControlHandle { inner: self.inner.clone() }
1094    }
1095
1096    fn into_inner(
1097        self,
1098    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1099    {
1100        (self.inner, self.is_terminated)
1101    }
1102
1103    fn from_inner(
1104        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1105        is_terminated: bool,
1106    ) -> Self {
1107        Self { inner, is_terminated }
1108    }
1109}
1110
1111impl futures::Stream for EntryIteratorRequestStream {
1112    type Item = Result<EntryIteratorRequest, fidl::Error>;
1113
1114    fn poll_next(
1115        mut self: std::pin::Pin<&mut Self>,
1116        cx: &mut std::task::Context<'_>,
1117    ) -> std::task::Poll<Option<Self::Item>> {
1118        let this = &mut *self;
1119        if this.inner.check_shutdown(cx) {
1120            this.is_terminated = true;
1121            return std::task::Poll::Ready(None);
1122        }
1123        if this.is_terminated {
1124            panic!("polled EntryIteratorRequestStream after completion");
1125        }
1126        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1127            |bytes, handles| {
1128                match this.inner.channel().read_etc(cx, bytes, handles) {
1129                    std::task::Poll::Ready(Ok(())) => {}
1130                    std::task::Poll::Pending => return std::task::Poll::Pending,
1131                    std::task::Poll::Ready(Err(None)) => {
1132                        this.is_terminated = true;
1133                        return std::task::Poll::Ready(None);
1134                    }
1135                    std::task::Poll::Ready(Err(Some(e))) => {
1136                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1137                            e.into(),
1138                        ))));
1139                    }
1140                }
1141
1142                // A message has been received from the channel
1143                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1144
1145                std::task::Poll::Ready(Some(match header.ordinal {
1146                0x6d03407803da8647 => {
1147                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1148                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1149                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1150                    let control_handle = EntryIteratorControlHandle {
1151                        inner: this.inner.clone(),
1152                    };
1153                    Ok(EntryIteratorRequest::GetNext {
1154                        responder: EntryIteratorGetNextResponder {
1155                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1156                            tx_id: header.tx_id,
1157                        },
1158                    })
1159                }
1160                _ => Err(fidl::Error::UnknownOrdinal {
1161                    ordinal: header.ordinal,
1162                    protocol_name: <EntryIteratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1163                }),
1164            }))
1165            },
1166        )
1167    }
1168}
1169
1170/// Returns entries and events from the neighbor table. Clients can open an
1171/// iterator using the [`fuchsia.net.neighbor/View.EntryIterator`] method.
1172///
1173/// An atomic snapshot of the neighbor table is queued for clients upon opening
1174/// an EntryIterator. This snapshot consists of `existing` entries followed by
1175/// an [`IdleEvent`]. No other types of events will be sent before an
1176/// [`IdleEvent`].
1177#[derive(Debug)]
1178pub enum EntryIteratorRequest {
1179    /// Take items from the iterator. If no items are available, block until one
1180    /// is; otherwise, return immediately with items queued since the last
1181    /// invocation.
1182    ///
1183    /// This does not guarantee that, when blocking, only one item will be
1184    /// returned; implementations may debounce or batch events.
1185    ///
1186    /// Clients should only have one call of this method at a time; a second
1187    /// call to this method while a call is already pending will cause the
1188    /// server end of the protocol to be closed.
1189    ///
1190    /// - response `events` a list of events that occurred since the last
1191    ///     invocation of this method.
1192    GetNext { responder: EntryIteratorGetNextResponder },
1193}
1194
1195impl EntryIteratorRequest {
1196    #[allow(irrefutable_let_patterns)]
1197    pub fn into_get_next(self) -> Option<(EntryIteratorGetNextResponder)> {
1198        if let EntryIteratorRequest::GetNext { responder } = self {
1199            Some((responder))
1200        } else {
1201            None
1202        }
1203    }
1204
1205    /// Name of the method defined in FIDL
1206    pub fn method_name(&self) -> &'static str {
1207        match *self {
1208            EntryIteratorRequest::GetNext { .. } => "get_next",
1209        }
1210    }
1211}
1212
1213#[derive(Debug, Clone)]
1214pub struct EntryIteratorControlHandle {
1215    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1216}
1217
1218impl fdomain_client::fidl::ControlHandle for EntryIteratorControlHandle {
1219    fn shutdown(&self) {
1220        self.inner.shutdown()
1221    }
1222
1223    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1224        self.inner.shutdown_with_epitaph(status)
1225    }
1226
1227    fn is_closed(&self) -> bool {
1228        self.inner.channel().is_closed()
1229    }
1230    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1231        self.inner.channel().on_closed()
1232    }
1233}
1234
1235impl EntryIteratorControlHandle {}
1236
1237#[must_use = "FIDL methods require a response to be sent"]
1238#[derive(Debug)]
1239pub struct EntryIteratorGetNextResponder {
1240    control_handle: std::mem::ManuallyDrop<EntryIteratorControlHandle>,
1241    tx_id: u32,
1242}
1243
1244/// Set the the channel to be shutdown (see [`EntryIteratorControlHandle::shutdown`])
1245/// if the responder is dropped without sending a response, so that the client
1246/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1247impl std::ops::Drop for EntryIteratorGetNextResponder {
1248    fn drop(&mut self) {
1249        self.control_handle.shutdown();
1250        // Safety: drops once, never accessed again
1251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1252    }
1253}
1254
1255impl fdomain_client::fidl::Responder for EntryIteratorGetNextResponder {
1256    type ControlHandle = EntryIteratorControlHandle;
1257
1258    fn control_handle(&self) -> &EntryIteratorControlHandle {
1259        &self.control_handle
1260    }
1261
1262    fn drop_without_shutdown(mut self) {
1263        // Safety: drops once, never accessed again due to mem::forget
1264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1265        // Prevent Drop from running (which would shut down the channel)
1266        std::mem::forget(self);
1267    }
1268}
1269
1270impl EntryIteratorGetNextResponder {
1271    /// Sends a response to the FIDL transaction.
1272    ///
1273    /// Sets the channel to shutdown if an error occurs.
1274    pub fn send(self, mut events: &[EntryIteratorItem]) -> Result<(), fidl::Error> {
1275        let _result = self.send_raw(events);
1276        if _result.is_err() {
1277            self.control_handle.shutdown();
1278        }
1279        self.drop_without_shutdown();
1280        _result
1281    }
1282
1283    /// Similar to "send" but does not shutdown the channel if an error occurs.
1284    pub fn send_no_shutdown_on_err(
1285        self,
1286        mut events: &[EntryIteratorItem],
1287    ) -> Result<(), fidl::Error> {
1288        let _result = self.send_raw(events);
1289        self.drop_without_shutdown();
1290        _result
1291    }
1292
1293    fn send_raw(&self, mut events: &[EntryIteratorItem]) -> Result<(), fidl::Error> {
1294        self.control_handle.inner.send::<EntryIteratorGetNextResponse>(
1295            (events,),
1296            self.tx_id,
1297            0x6d03407803da8647,
1298            fidl::encoding::DynamicFlags::empty(),
1299        )
1300    }
1301}
1302
1303#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1304pub struct ViewMarker;
1305
1306impl fdomain_client::fidl::ProtocolMarker for ViewMarker {
1307    type Proxy = ViewProxy;
1308    type RequestStream = ViewRequestStream;
1309
1310    const DEBUG_NAME: &'static str = "fuchsia.net.neighbor.View";
1311}
1312impl fdomain_client::fidl::DiscoverableProtocolMarker for ViewMarker {}
1313
1314pub trait ViewProxyInterface: Send + Sync {
1315    fn r#open_entry_iterator(
1316        &self,
1317        it: fdomain_client::fidl::ServerEnd<EntryIteratorMarker>,
1318        options: &EntryIteratorOptions,
1319    ) -> Result<(), fidl::Error>;
1320}
1321
1322#[derive(Debug, Clone)]
1323pub struct ViewProxy {
1324    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1325}
1326
1327impl fdomain_client::fidl::Proxy for ViewProxy {
1328    type Protocol = ViewMarker;
1329
1330    fn from_channel(inner: fdomain_client::Channel) -> Self {
1331        Self::new(inner)
1332    }
1333
1334    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1335        self.client.into_channel().map_err(|client| Self { client })
1336    }
1337
1338    fn as_channel(&self) -> &fdomain_client::Channel {
1339        self.client.as_channel()
1340    }
1341}
1342
1343impl ViewProxy {
1344    /// Create a new Proxy for fuchsia.net.neighbor/View.
1345    pub fn new(channel: fdomain_client::Channel) -> Self {
1346        let protocol_name = <ViewMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1347        Self { client: fidl::client::Client::new(channel, protocol_name) }
1348    }
1349
1350    /// Get a Stream of events from the remote end of the protocol.
1351    ///
1352    /// # Panics
1353    ///
1354    /// Panics if the event stream was already taken.
1355    pub fn take_event_stream(&self) -> ViewEventStream {
1356        ViewEventStream { event_receiver: self.client.take_event_receiver() }
1357    }
1358
1359    /// Open a connection to an [`EntryIterator`] for listing existing entries
1360    /// and optionally watching for state changes.
1361    ///
1362    /// + request `it` grants access to the [`EntryIterator`].
1363    /// + request `options` specifies the behavior of the [`EntryIterator`].
1364    pub fn r#open_entry_iterator(
1365        &self,
1366        mut it: fdomain_client::fidl::ServerEnd<EntryIteratorMarker>,
1367        mut options: &EntryIteratorOptions,
1368    ) -> Result<(), fidl::Error> {
1369        ViewProxyInterface::r#open_entry_iterator(self, it, options)
1370    }
1371}
1372
1373impl ViewProxyInterface for ViewProxy {
1374    fn r#open_entry_iterator(
1375        &self,
1376        mut it: fdomain_client::fidl::ServerEnd<EntryIteratorMarker>,
1377        mut options: &EntryIteratorOptions,
1378    ) -> Result<(), fidl::Error> {
1379        self.client.send::<ViewOpenEntryIteratorRequest>(
1380            (it, options),
1381            0x3c9531929383e911,
1382            fidl::encoding::DynamicFlags::empty(),
1383        )
1384    }
1385}
1386
1387pub struct ViewEventStream {
1388    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1389}
1390
1391impl std::marker::Unpin for ViewEventStream {}
1392
1393impl futures::stream::FusedStream for ViewEventStream {
1394    fn is_terminated(&self) -> bool {
1395        self.event_receiver.is_terminated()
1396    }
1397}
1398
1399impl futures::Stream for ViewEventStream {
1400    type Item = Result<ViewEvent, fidl::Error>;
1401
1402    fn poll_next(
1403        mut self: std::pin::Pin<&mut Self>,
1404        cx: &mut std::task::Context<'_>,
1405    ) -> std::task::Poll<Option<Self::Item>> {
1406        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1407            &mut self.event_receiver,
1408            cx
1409        )?) {
1410            Some(buf) => std::task::Poll::Ready(Some(ViewEvent::decode(buf))),
1411            None => std::task::Poll::Ready(None),
1412        }
1413    }
1414}
1415
1416#[derive(Debug)]
1417pub enum ViewEvent {}
1418
1419impl ViewEvent {
1420    /// Decodes a message buffer as a [`ViewEvent`].
1421    fn decode(
1422        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1423    ) -> Result<ViewEvent, fidl::Error> {
1424        let (bytes, _handles) = buf.split_mut();
1425        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1426        debug_assert_eq!(tx_header.tx_id, 0);
1427        match tx_header.ordinal {
1428            _ => Err(fidl::Error::UnknownOrdinal {
1429                ordinal: tx_header.ordinal,
1430                protocol_name: <ViewMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1431            }),
1432        }
1433    }
1434}
1435
1436/// A Stream of incoming requests for fuchsia.net.neighbor/View.
1437pub struct ViewRequestStream {
1438    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1439    is_terminated: bool,
1440}
1441
1442impl std::marker::Unpin for ViewRequestStream {}
1443
1444impl futures::stream::FusedStream for ViewRequestStream {
1445    fn is_terminated(&self) -> bool {
1446        self.is_terminated
1447    }
1448}
1449
1450impl fdomain_client::fidl::RequestStream for ViewRequestStream {
1451    type Protocol = ViewMarker;
1452    type ControlHandle = ViewControlHandle;
1453
1454    fn from_channel(channel: fdomain_client::Channel) -> Self {
1455        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1456    }
1457
1458    fn control_handle(&self) -> Self::ControlHandle {
1459        ViewControlHandle { inner: self.inner.clone() }
1460    }
1461
1462    fn into_inner(
1463        self,
1464    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1465    {
1466        (self.inner, self.is_terminated)
1467    }
1468
1469    fn from_inner(
1470        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1471        is_terminated: bool,
1472    ) -> Self {
1473        Self { inner, is_terminated }
1474    }
1475}
1476
1477impl futures::Stream for ViewRequestStream {
1478    type Item = Result<ViewRequest, fidl::Error>;
1479
1480    fn poll_next(
1481        mut self: std::pin::Pin<&mut Self>,
1482        cx: &mut std::task::Context<'_>,
1483    ) -> std::task::Poll<Option<Self::Item>> {
1484        let this = &mut *self;
1485        if this.inner.check_shutdown(cx) {
1486            this.is_terminated = true;
1487            return std::task::Poll::Ready(None);
1488        }
1489        if this.is_terminated {
1490            panic!("polled ViewRequestStream after completion");
1491        }
1492        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1493            |bytes, handles| {
1494                match this.inner.channel().read_etc(cx, bytes, handles) {
1495                    std::task::Poll::Ready(Ok(())) => {}
1496                    std::task::Poll::Pending => return std::task::Poll::Pending,
1497                    std::task::Poll::Ready(Err(None)) => {
1498                        this.is_terminated = true;
1499                        return std::task::Poll::Ready(None);
1500                    }
1501                    std::task::Poll::Ready(Err(Some(e))) => {
1502                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1503                            e.into(),
1504                        ))));
1505                    }
1506                }
1507
1508                // A message has been received from the channel
1509                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1510
1511                std::task::Poll::Ready(Some(match header.ordinal {
1512                    0x3c9531929383e911 => {
1513                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1514                        let mut req = fidl::new_empty!(
1515                            ViewOpenEntryIteratorRequest,
1516                            fdomain_client::fidl::FDomainResourceDialect
1517                        );
1518                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ViewOpenEntryIteratorRequest>(&header, _body_bytes, handles, &mut req)?;
1519                        let control_handle = ViewControlHandle { inner: this.inner.clone() };
1520                        Ok(ViewRequest::OpenEntryIterator {
1521                            it: req.it,
1522                            options: req.options,
1523
1524                            control_handle,
1525                        })
1526                    }
1527                    _ => Err(fidl::Error::UnknownOrdinal {
1528                        ordinal: header.ordinal,
1529                        protocol_name:
1530                            <ViewMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1531                    }),
1532                }))
1533            },
1534        )
1535    }
1536}
1537
1538/// Inspect the neighbor table.
1539#[derive(Debug)]
1540pub enum ViewRequest {
1541    /// Open a connection to an [`EntryIterator`] for listing existing entries
1542    /// and optionally watching for state changes.
1543    ///
1544    /// + request `it` grants access to the [`EntryIterator`].
1545    /// + request `options` specifies the behavior of the [`EntryIterator`].
1546    OpenEntryIterator {
1547        it: fdomain_client::fidl::ServerEnd<EntryIteratorMarker>,
1548        options: EntryIteratorOptions,
1549        control_handle: ViewControlHandle,
1550    },
1551}
1552
1553impl ViewRequest {
1554    #[allow(irrefutable_let_patterns)]
1555    pub fn into_open_entry_iterator(
1556        self,
1557    ) -> Option<(
1558        fdomain_client::fidl::ServerEnd<EntryIteratorMarker>,
1559        EntryIteratorOptions,
1560        ViewControlHandle,
1561    )> {
1562        if let ViewRequest::OpenEntryIterator { it, options, control_handle } = self {
1563            Some((it, options, control_handle))
1564        } else {
1565            None
1566        }
1567    }
1568
1569    /// Name of the method defined in FIDL
1570    pub fn method_name(&self) -> &'static str {
1571        match *self {
1572            ViewRequest::OpenEntryIterator { .. } => "open_entry_iterator",
1573        }
1574    }
1575}
1576
1577#[derive(Debug, Clone)]
1578pub struct ViewControlHandle {
1579    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1580}
1581
1582impl fdomain_client::fidl::ControlHandle for ViewControlHandle {
1583    fn shutdown(&self) {
1584        self.inner.shutdown()
1585    }
1586
1587    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1588        self.inner.shutdown_with_epitaph(status)
1589    }
1590
1591    fn is_closed(&self) -> bool {
1592        self.inner.channel().is_closed()
1593    }
1594    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1595        self.inner.channel().on_closed()
1596    }
1597}
1598
1599impl ViewControlHandle {}
1600
1601mod internal {
1602    use super::*;
1603
1604    impl fidl::encoding::ResourceTypeMarker for ViewOpenEntryIteratorRequest {
1605        type Borrowed<'a> = &'a mut Self;
1606        fn take_or_borrow<'a>(
1607            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1608        ) -> Self::Borrowed<'a> {
1609            value
1610        }
1611    }
1612
1613    unsafe impl fidl::encoding::TypeMarker for ViewOpenEntryIteratorRequest {
1614        type Owned = Self;
1615
1616        #[inline(always)]
1617        fn inline_align(_context: fidl::encoding::Context) -> usize {
1618            8
1619        }
1620
1621        #[inline(always)]
1622        fn inline_size(_context: fidl::encoding::Context) -> usize {
1623            24
1624        }
1625    }
1626
1627    unsafe impl
1628        fidl::encoding::Encode<
1629            ViewOpenEntryIteratorRequest,
1630            fdomain_client::fidl::FDomainResourceDialect,
1631        > for &mut ViewOpenEntryIteratorRequest
1632    {
1633        #[inline]
1634        unsafe fn encode(
1635            self,
1636            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1637            offset: usize,
1638            _depth: fidl::encoding::Depth,
1639        ) -> fidl::Result<()> {
1640            encoder.debug_check_bounds::<ViewOpenEntryIteratorRequest>(offset);
1641            // Delegate to tuple encoding.
1642            fidl::encoding::Encode::<ViewOpenEntryIteratorRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
1643                (
1644                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<EntryIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.it),
1645                    <EntryIteratorOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
1646                ),
1647                encoder, offset, _depth
1648            )
1649        }
1650    }
1651    unsafe impl<
1652        T0: fidl::encoding::Encode<
1653                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<EntryIteratorMarker>>,
1654                fdomain_client::fidl::FDomainResourceDialect,
1655            >,
1656        T1: fidl::encoding::Encode<EntryIteratorOptions, fdomain_client::fidl::FDomainResourceDialect>,
1657    >
1658        fidl::encoding::Encode<
1659            ViewOpenEntryIteratorRequest,
1660            fdomain_client::fidl::FDomainResourceDialect,
1661        > for (T0, T1)
1662    {
1663        #[inline]
1664        unsafe fn encode(
1665            self,
1666            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1667            offset: usize,
1668            depth: fidl::encoding::Depth,
1669        ) -> fidl::Result<()> {
1670            encoder.debug_check_bounds::<ViewOpenEntryIteratorRequest>(offset);
1671            // Zero out padding regions. There's no need to apply masks
1672            // because the unmasked parts will be overwritten by fields.
1673            unsafe {
1674                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1675                (ptr as *mut u64).write_unaligned(0);
1676            }
1677            // Write the fields.
1678            self.0.encode(encoder, offset + 0, depth)?;
1679            self.1.encode(encoder, offset + 8, depth)?;
1680            Ok(())
1681        }
1682    }
1683
1684    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1685        for ViewOpenEntryIteratorRequest
1686    {
1687        #[inline(always)]
1688        fn new_empty() -> Self {
1689            Self {
1690                it: fidl::new_empty!(
1691                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<EntryIteratorMarker>>,
1692                    fdomain_client::fidl::FDomainResourceDialect
1693                ),
1694                options: fidl::new_empty!(
1695                    EntryIteratorOptions,
1696                    fdomain_client::fidl::FDomainResourceDialect
1697                ),
1698            }
1699        }
1700
1701        #[inline]
1702        unsafe fn decode(
1703            &mut self,
1704            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1705            offset: usize,
1706            _depth: fidl::encoding::Depth,
1707        ) -> fidl::Result<()> {
1708            decoder.debug_check_bounds::<Self>(offset);
1709            // Verify that padding bytes are zero.
1710            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1711            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1712            let mask = 0xffffffff00000000u64;
1713            let maskedval = padval & mask;
1714            if maskedval != 0 {
1715                return Err(fidl::Error::NonZeroPadding {
1716                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1717                });
1718            }
1719            fidl::decode!(
1720                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<EntryIteratorMarker>>,
1721                fdomain_client::fidl::FDomainResourceDialect,
1722                &mut self.it,
1723                decoder,
1724                offset + 0,
1725                _depth
1726            )?;
1727            fidl::decode!(
1728                EntryIteratorOptions,
1729                fdomain_client::fidl::FDomainResourceDialect,
1730                &mut self.options,
1731                decoder,
1732                offset + 8,
1733                _depth
1734            )?;
1735            Ok(())
1736        }
1737    }
1738}