Skip to main content

fidl_fuchsia_net_ndp/
fidl_fuchsia_net_ndp.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_net_ndp_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest {
16    pub option_watcher: fidl::endpoints::ServerEnd<OptionWatcherMarker>,
17    pub params: RouterAdvertisementOptionWatcherParams,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct OptionWatcherMarker;
27
28impl fidl::endpoints::ProtocolMarker for OptionWatcherMarker {
29    type Proxy = OptionWatcherProxy;
30    type RequestStream = OptionWatcherRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = OptionWatcherSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "(anonymous) OptionWatcher";
35}
36
37pub trait OptionWatcherProxyInterface: Send + Sync {
38    type ProbeResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
39    fn r#probe(&self) -> Self::ProbeResponseFut;
40    type WatchOptionsResponseFut: std::future::Future<Output = Result<(Vec<OptionWatchEntry>, u32), fidl::Error>>
41        + Send;
42    fn r#watch_options(&self) -> Self::WatchOptionsResponseFut;
43}
44#[derive(Debug)]
45#[cfg(target_os = "fuchsia")]
46pub struct OptionWatcherSynchronousProxy {
47    client: fidl::client::sync::Client,
48}
49
50#[cfg(target_os = "fuchsia")]
51impl fidl::endpoints::SynchronousProxy for OptionWatcherSynchronousProxy {
52    type Proxy = OptionWatcherProxy;
53    type Protocol = OptionWatcherMarker;
54
55    fn from_channel(inner: fidl::Channel) -> Self {
56        Self::new(inner)
57    }
58
59    fn into_channel(self) -> fidl::Channel {
60        self.client.into_channel()
61    }
62
63    fn as_channel(&self) -> &fidl::Channel {
64        self.client.as_channel()
65    }
66}
67
68#[cfg(target_os = "fuchsia")]
69impl OptionWatcherSynchronousProxy {
70    pub fn new(channel: fidl::Channel) -> Self {
71        Self { client: fidl::client::sync::Client::new(channel) }
72    }
73
74    pub fn into_channel(self) -> fidl::Channel {
75        self.client.into_channel()
76    }
77
78    /// Waits until an event arrives and returns it. It is safe for other
79    /// threads to make concurrent requests while waiting for an event.
80    pub fn wait_for_event(
81        &self,
82        deadline: zx::MonotonicInstant,
83    ) -> Result<OptionWatcherEvent, fidl::Error> {
84        OptionWatcherEvent::decode(self.client.wait_for_event::<OptionWatcherMarker>(deadline)?)
85    }
86
87    /// Probes for completion of watcher construction.
88    ///
89    /// Returns once the watcher has been registered. Any NDP options received
90    /// in router advertisements after this returns are guaranteed to be
91    /// observed by the watcher, assuming that they meet the watcher's interest
92    /// criteria and that the watcher does not lag too far behind in consuming
93    /// yielded options.
94    pub fn r#probe(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
95        let _response = self.client.send_query::<
96            fidl::encoding::EmptyPayload,
97            fidl::encoding::EmptyPayload,
98            OptionWatcherMarker,
99        >(
100            (),
101            0x11ef2cfafa567e8d,
102            fidl::encoding::DynamicFlags::empty(),
103            ___deadline,
104        )?;
105        Ok(_response)
106    }
107
108    /// The hanging get method for receiving batches of NDP options.
109    ///
110    /// The batching behavior is left as an implementation detail. Not all
111    /// options in a batch are guaranteed to have been received within the same
112    /// NDP message, from the same source, or via the same interface.
113    ///
114    /// Clients should only have one call of this method at a time; a second
115    /// call to this method while a call is already pending will cause the
116    /// server end of the protocol to be closed.
117    ///
118    /// The server may at its discretion drop options instead of yielding them
119    /// if the watcher takes too long to request them via `WatchOptions`.
120    pub fn r#watch_options(
121        &self,
122        ___deadline: zx::MonotonicInstant,
123    ) -> Result<(Vec<OptionWatchEntry>, u32), fidl::Error> {
124        let _response = self.client.send_query::<
125            fidl::encoding::EmptyPayload,
126            OptionWatcherWatchOptionsResponse,
127            OptionWatcherMarker,
128        >(
129            (),
130            0x6d7b8e3d3f84faf5,
131            fidl::encoding::DynamicFlags::empty(),
132            ___deadline,
133        )?;
134        Ok((_response.options, _response.dropped))
135    }
136}
137
138#[cfg(target_os = "fuchsia")]
139impl From<OptionWatcherSynchronousProxy> for zx::NullableHandle {
140    fn from(value: OptionWatcherSynchronousProxy) -> Self {
141        value.into_channel().into()
142    }
143}
144
145#[cfg(target_os = "fuchsia")]
146impl From<fidl::Channel> for OptionWatcherSynchronousProxy {
147    fn from(value: fidl::Channel) -> Self {
148        Self::new(value)
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl fidl::endpoints::FromClient for OptionWatcherSynchronousProxy {
154    type Protocol = OptionWatcherMarker;
155
156    fn from_client(value: fidl::endpoints::ClientEnd<OptionWatcherMarker>) -> Self {
157        Self::new(value.into_channel())
158    }
159}
160
161#[derive(Debug, Clone)]
162pub struct OptionWatcherProxy {
163    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
164}
165
166impl fidl::endpoints::Proxy for OptionWatcherProxy {
167    type Protocol = OptionWatcherMarker;
168
169    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
170        Self::new(inner)
171    }
172
173    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
174        self.client.into_channel().map_err(|client| Self { client })
175    }
176
177    fn as_channel(&self) -> &::fidl::AsyncChannel {
178        self.client.as_channel()
179    }
180}
181
182impl OptionWatcherProxy {
183    /// Create a new Proxy for fuchsia.net.ndp/OptionWatcher.
184    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
185        let protocol_name = <OptionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
186        Self { client: fidl::client::Client::new(channel, protocol_name) }
187    }
188
189    /// Get a Stream of events from the remote end of the protocol.
190    ///
191    /// # Panics
192    ///
193    /// Panics if the event stream was already taken.
194    pub fn take_event_stream(&self) -> OptionWatcherEventStream {
195        OptionWatcherEventStream { event_receiver: self.client.take_event_receiver() }
196    }
197
198    /// Probes for completion of watcher construction.
199    ///
200    /// Returns once the watcher has been registered. Any NDP options received
201    /// in router advertisements after this returns are guaranteed to be
202    /// observed by the watcher, assuming that they meet the watcher's interest
203    /// criteria and that the watcher does not lag too far behind in consuming
204    /// yielded options.
205    pub fn r#probe(
206        &self,
207    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
208        OptionWatcherProxyInterface::r#probe(self)
209    }
210
211    /// The hanging get method for receiving batches of NDP options.
212    ///
213    /// The batching behavior is left as an implementation detail. Not all
214    /// options in a batch are guaranteed to have been received within the same
215    /// NDP message, from the same source, or via the same interface.
216    ///
217    /// Clients should only have one call of this method at a time; a second
218    /// call to this method while a call is already pending will cause the
219    /// server end of the protocol to be closed.
220    ///
221    /// The server may at its discretion drop options instead of yielding them
222    /// if the watcher takes too long to request them via `WatchOptions`.
223    pub fn r#watch_options(
224        &self,
225    ) -> fidl::client::QueryResponseFut<
226        (Vec<OptionWatchEntry>, u32),
227        fidl::encoding::DefaultFuchsiaResourceDialect,
228    > {
229        OptionWatcherProxyInterface::r#watch_options(self)
230    }
231}
232
233impl OptionWatcherProxyInterface for OptionWatcherProxy {
234    type ProbeResponseFut =
235        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
236    fn r#probe(&self) -> Self::ProbeResponseFut {
237        fn _decode(
238            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
239        ) -> Result<(), fidl::Error> {
240            let _response = fidl::client::decode_transaction_body::<
241                fidl::encoding::EmptyPayload,
242                fidl::encoding::DefaultFuchsiaResourceDialect,
243                0x11ef2cfafa567e8d,
244            >(_buf?)?;
245            Ok(_response)
246        }
247        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
248            (),
249            0x11ef2cfafa567e8d,
250            fidl::encoding::DynamicFlags::empty(),
251            _decode,
252        )
253    }
254
255    type WatchOptionsResponseFut = fidl::client::QueryResponseFut<
256        (Vec<OptionWatchEntry>, u32),
257        fidl::encoding::DefaultFuchsiaResourceDialect,
258    >;
259    fn r#watch_options(&self) -> Self::WatchOptionsResponseFut {
260        fn _decode(
261            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
262        ) -> Result<(Vec<OptionWatchEntry>, u32), fidl::Error> {
263            let _response = fidl::client::decode_transaction_body::<
264                OptionWatcherWatchOptionsResponse,
265                fidl::encoding::DefaultFuchsiaResourceDialect,
266                0x6d7b8e3d3f84faf5,
267            >(_buf?)?;
268            Ok((_response.options, _response.dropped))
269        }
270        self.client
271            .send_query_and_decode::<fidl::encoding::EmptyPayload, (Vec<OptionWatchEntry>, u32)>(
272                (),
273                0x6d7b8e3d3f84faf5,
274                fidl::encoding::DynamicFlags::empty(),
275                _decode,
276            )
277    }
278}
279
280pub struct OptionWatcherEventStream {
281    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
282}
283
284impl std::marker::Unpin for OptionWatcherEventStream {}
285
286impl futures::stream::FusedStream for OptionWatcherEventStream {
287    fn is_terminated(&self) -> bool {
288        self.event_receiver.is_terminated()
289    }
290}
291
292impl futures::Stream for OptionWatcherEventStream {
293    type Item = Result<OptionWatcherEvent, fidl::Error>;
294
295    fn poll_next(
296        mut self: std::pin::Pin<&mut Self>,
297        cx: &mut std::task::Context<'_>,
298    ) -> std::task::Poll<Option<Self::Item>> {
299        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
300            &mut self.event_receiver,
301            cx
302        )?) {
303            Some(buf) => std::task::Poll::Ready(Some(OptionWatcherEvent::decode(buf))),
304            None => std::task::Poll::Ready(None),
305        }
306    }
307}
308
309#[derive(Debug)]
310pub enum OptionWatcherEvent {}
311
312impl OptionWatcherEvent {
313    /// Decodes a message buffer as a [`OptionWatcherEvent`].
314    fn decode(
315        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
316    ) -> Result<OptionWatcherEvent, fidl::Error> {
317        let (bytes, _handles) = buf.split_mut();
318        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
319        debug_assert_eq!(tx_header.tx_id, 0);
320        match tx_header.ordinal {
321            _ => Err(fidl::Error::UnknownOrdinal {
322                ordinal: tx_header.ordinal,
323                protocol_name: <OptionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
324            }),
325        }
326    }
327}
328
329/// A Stream of incoming requests for fuchsia.net.ndp/OptionWatcher.
330pub struct OptionWatcherRequestStream {
331    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
332    is_terminated: bool,
333}
334
335impl std::marker::Unpin for OptionWatcherRequestStream {}
336
337impl futures::stream::FusedStream for OptionWatcherRequestStream {
338    fn is_terminated(&self) -> bool {
339        self.is_terminated
340    }
341}
342
343impl fidl::endpoints::RequestStream for OptionWatcherRequestStream {
344    type Protocol = OptionWatcherMarker;
345    type ControlHandle = OptionWatcherControlHandle;
346
347    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
348        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
349    }
350
351    fn control_handle(&self) -> Self::ControlHandle {
352        OptionWatcherControlHandle { inner: self.inner.clone() }
353    }
354
355    fn into_inner(
356        self,
357    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
358    {
359        (self.inner, self.is_terminated)
360    }
361
362    fn from_inner(
363        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
364        is_terminated: bool,
365    ) -> Self {
366        Self { inner, is_terminated }
367    }
368}
369
370impl futures::Stream for OptionWatcherRequestStream {
371    type Item = Result<OptionWatcherRequest, fidl::Error>;
372
373    fn poll_next(
374        mut self: std::pin::Pin<&mut Self>,
375        cx: &mut std::task::Context<'_>,
376    ) -> std::task::Poll<Option<Self::Item>> {
377        let this = &mut *self;
378        if this.inner.check_shutdown(cx) {
379            this.is_terminated = true;
380            return std::task::Poll::Ready(None);
381        }
382        if this.is_terminated {
383            panic!("polled OptionWatcherRequestStream after completion");
384        }
385        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
386            |bytes, handles| {
387                match this.inner.channel().read_etc(cx, bytes, handles) {
388                    std::task::Poll::Ready(Ok(())) => {}
389                    std::task::Poll::Pending => return std::task::Poll::Pending,
390                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
391                        this.is_terminated = true;
392                        return std::task::Poll::Ready(None);
393                    }
394                    std::task::Poll::Ready(Err(e)) => {
395                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
396                            e.into(),
397                        ))));
398                    }
399                }
400
401                // A message has been received from the channel
402                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
403
404                std::task::Poll::Ready(Some(match header.ordinal {
405                    0x11ef2cfafa567e8d => {
406                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
407                        let mut req = fidl::new_empty!(
408                            fidl::encoding::EmptyPayload,
409                            fidl::encoding::DefaultFuchsiaResourceDialect
410                        );
411                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
412                        let control_handle =
413                            OptionWatcherControlHandle { inner: this.inner.clone() };
414                        Ok(OptionWatcherRequest::Probe {
415                            responder: OptionWatcherProbeResponder {
416                                control_handle: std::mem::ManuallyDrop::new(control_handle),
417                                tx_id: header.tx_id,
418                            },
419                        })
420                    }
421                    0x6d7b8e3d3f84faf5 => {
422                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
423                        let mut req = fidl::new_empty!(
424                            fidl::encoding::EmptyPayload,
425                            fidl::encoding::DefaultFuchsiaResourceDialect
426                        );
427                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
428                        let control_handle =
429                            OptionWatcherControlHandle { inner: this.inner.clone() };
430                        Ok(OptionWatcherRequest::WatchOptions {
431                            responder: OptionWatcherWatchOptionsResponder {
432                                control_handle: std::mem::ManuallyDrop::new(control_handle),
433                                tx_id: header.tx_id,
434                            },
435                        })
436                    }
437                    _ => Err(fidl::Error::UnknownOrdinal {
438                        ordinal: header.ordinal,
439                        protocol_name:
440                            <OptionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
441                    }),
442                }))
443            },
444        )
445    }
446}
447
448/// An NDP option watcher.
449#[derive(Debug)]
450pub enum OptionWatcherRequest {
451    /// Probes for completion of watcher construction.
452    ///
453    /// Returns once the watcher has been registered. Any NDP options received
454    /// in router advertisements after this returns are guaranteed to be
455    /// observed by the watcher, assuming that they meet the watcher's interest
456    /// criteria and that the watcher does not lag too far behind in consuming
457    /// yielded options.
458    Probe { responder: OptionWatcherProbeResponder },
459    /// The hanging get method for receiving batches of NDP options.
460    ///
461    /// The batching behavior is left as an implementation detail. Not all
462    /// options in a batch are guaranteed to have been received within the same
463    /// NDP message, from the same source, or via the same interface.
464    ///
465    /// Clients should only have one call of this method at a time; a second
466    /// call to this method while a call is already pending will cause the
467    /// server end of the protocol to be closed.
468    ///
469    /// The server may at its discretion drop options instead of yielding them
470    /// if the watcher takes too long to request them via `WatchOptions`.
471    WatchOptions { responder: OptionWatcherWatchOptionsResponder },
472}
473
474impl OptionWatcherRequest {
475    #[allow(irrefutable_let_patterns)]
476    pub fn into_probe(self) -> Option<(OptionWatcherProbeResponder)> {
477        if let OptionWatcherRequest::Probe { responder } = self { Some((responder)) } else { None }
478    }
479
480    #[allow(irrefutable_let_patterns)]
481    pub fn into_watch_options(self) -> Option<(OptionWatcherWatchOptionsResponder)> {
482        if let OptionWatcherRequest::WatchOptions { responder } = self {
483            Some((responder))
484        } else {
485            None
486        }
487    }
488
489    /// Name of the method defined in FIDL
490    pub fn method_name(&self) -> &'static str {
491        match *self {
492            OptionWatcherRequest::Probe { .. } => "probe",
493            OptionWatcherRequest::WatchOptions { .. } => "watch_options",
494        }
495    }
496}
497
498#[derive(Debug, Clone)]
499pub struct OptionWatcherControlHandle {
500    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
501}
502
503impl OptionWatcherControlHandle {
504    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
505        self.inner.shutdown_with_epitaph(status.into())
506    }
507}
508
509impl fidl::endpoints::ControlHandle for OptionWatcherControlHandle {
510    fn shutdown(&self) {
511        self.inner.shutdown()
512    }
513
514    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
515        self.inner.shutdown_with_epitaph(status)
516    }
517
518    fn is_closed(&self) -> bool {
519        self.inner.channel().is_closed()
520    }
521    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
522        self.inner.channel().on_closed()
523    }
524
525    #[cfg(target_os = "fuchsia")]
526    fn signal_peer(
527        &self,
528        clear_mask: zx::Signals,
529        set_mask: zx::Signals,
530    ) -> Result<(), zx_status::Status> {
531        use fidl::Peered;
532        self.inner.channel().signal_peer(clear_mask, set_mask)
533    }
534}
535
536impl OptionWatcherControlHandle {}
537
538#[must_use = "FIDL methods require a response to be sent"]
539#[derive(Debug)]
540pub struct OptionWatcherProbeResponder {
541    control_handle: std::mem::ManuallyDrop<OptionWatcherControlHandle>,
542    tx_id: u32,
543}
544
545/// Set the the channel to be shutdown (see [`OptionWatcherControlHandle::shutdown`])
546/// if the responder is dropped without sending a response, so that the client
547/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
548impl std::ops::Drop for OptionWatcherProbeResponder {
549    fn drop(&mut self) {
550        self.control_handle.shutdown();
551        // Safety: drops once, never accessed again
552        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
553    }
554}
555
556impl fidl::endpoints::Responder for OptionWatcherProbeResponder {
557    type ControlHandle = OptionWatcherControlHandle;
558
559    fn control_handle(&self) -> &OptionWatcherControlHandle {
560        &self.control_handle
561    }
562
563    fn drop_without_shutdown(mut self) {
564        // Safety: drops once, never accessed again due to mem::forget
565        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
566        // Prevent Drop from running (which would shut down the channel)
567        std::mem::forget(self);
568    }
569}
570
571impl OptionWatcherProbeResponder {
572    /// Sends a response to the FIDL transaction.
573    ///
574    /// Sets the channel to shutdown if an error occurs.
575    pub fn send(self) -> Result<(), fidl::Error> {
576        let _result = self.send_raw();
577        if _result.is_err() {
578            self.control_handle.shutdown();
579        }
580        self.drop_without_shutdown();
581        _result
582    }
583
584    /// Similar to "send" but does not shutdown the channel if an error occurs.
585    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
586        let _result = self.send_raw();
587        self.drop_without_shutdown();
588        _result
589    }
590
591    fn send_raw(&self) -> Result<(), fidl::Error> {
592        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
593            (),
594            self.tx_id,
595            0x11ef2cfafa567e8d,
596            fidl::encoding::DynamicFlags::empty(),
597        )
598    }
599}
600
601#[must_use = "FIDL methods require a response to be sent"]
602#[derive(Debug)]
603pub struct OptionWatcherWatchOptionsResponder {
604    control_handle: std::mem::ManuallyDrop<OptionWatcherControlHandle>,
605    tx_id: u32,
606}
607
608/// Set the the channel to be shutdown (see [`OptionWatcherControlHandle::shutdown`])
609/// if the responder is dropped without sending a response, so that the client
610/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
611impl std::ops::Drop for OptionWatcherWatchOptionsResponder {
612    fn drop(&mut self) {
613        self.control_handle.shutdown();
614        // Safety: drops once, never accessed again
615        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
616    }
617}
618
619impl fidl::endpoints::Responder for OptionWatcherWatchOptionsResponder {
620    type ControlHandle = OptionWatcherControlHandle;
621
622    fn control_handle(&self) -> &OptionWatcherControlHandle {
623        &self.control_handle
624    }
625
626    fn drop_without_shutdown(mut self) {
627        // Safety: drops once, never accessed again due to mem::forget
628        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
629        // Prevent Drop from running (which would shut down the channel)
630        std::mem::forget(self);
631    }
632}
633
634impl OptionWatcherWatchOptionsResponder {
635    /// Sends a response to the FIDL transaction.
636    ///
637    /// Sets the channel to shutdown if an error occurs.
638    pub fn send(
639        self,
640        mut options: &[OptionWatchEntry],
641        mut dropped: u32,
642    ) -> Result<(), fidl::Error> {
643        let _result = self.send_raw(options, dropped);
644        if _result.is_err() {
645            self.control_handle.shutdown();
646        }
647        self.drop_without_shutdown();
648        _result
649    }
650
651    /// Similar to "send" but does not shutdown the channel if an error occurs.
652    pub fn send_no_shutdown_on_err(
653        self,
654        mut options: &[OptionWatchEntry],
655        mut dropped: u32,
656    ) -> Result<(), fidl::Error> {
657        let _result = self.send_raw(options, dropped);
658        self.drop_without_shutdown();
659        _result
660    }
661
662    fn send_raw(
663        &self,
664        mut options: &[OptionWatchEntry],
665        mut dropped: u32,
666    ) -> Result<(), fidl::Error> {
667        self.control_handle.inner.send::<OptionWatcherWatchOptionsResponse>(
668            (options, dropped),
669            self.tx_id,
670            0x6d7b8e3d3f84faf5,
671            fidl::encoding::DynamicFlags::empty(),
672        )
673    }
674}
675
676#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
677pub struct RouterAdvertisementOptionWatcherProviderMarker;
678
679impl fidl::endpoints::ProtocolMarker for RouterAdvertisementOptionWatcherProviderMarker {
680    type Proxy = RouterAdvertisementOptionWatcherProviderProxy;
681    type RequestStream = RouterAdvertisementOptionWatcherProviderRequestStream;
682    #[cfg(target_os = "fuchsia")]
683    type SynchronousProxy = RouterAdvertisementOptionWatcherProviderSynchronousProxy;
684
685    const DEBUG_NAME: &'static str = "fuchsia.net.ndp.RouterAdvertisementOptionWatcherProvider";
686}
687impl fidl::endpoints::DiscoverableProtocolMarker
688    for RouterAdvertisementOptionWatcherProviderMarker
689{
690}
691
692pub trait RouterAdvertisementOptionWatcherProviderProxyInterface: Send + Sync {
693    fn r#new_router_advertisement_option_watcher(
694        &self,
695        option_watcher: fidl::endpoints::ServerEnd<OptionWatcherMarker>,
696        params: &RouterAdvertisementOptionWatcherParams,
697    ) -> Result<(), fidl::Error>;
698}
699#[derive(Debug)]
700#[cfg(target_os = "fuchsia")]
701pub struct RouterAdvertisementOptionWatcherProviderSynchronousProxy {
702    client: fidl::client::sync::Client,
703}
704
705#[cfg(target_os = "fuchsia")]
706impl fidl::endpoints::SynchronousProxy
707    for RouterAdvertisementOptionWatcherProviderSynchronousProxy
708{
709    type Proxy = RouterAdvertisementOptionWatcherProviderProxy;
710    type Protocol = RouterAdvertisementOptionWatcherProviderMarker;
711
712    fn from_channel(inner: fidl::Channel) -> Self {
713        Self::new(inner)
714    }
715
716    fn into_channel(self) -> fidl::Channel {
717        self.client.into_channel()
718    }
719
720    fn as_channel(&self) -> &fidl::Channel {
721        self.client.as_channel()
722    }
723}
724
725#[cfg(target_os = "fuchsia")]
726impl RouterAdvertisementOptionWatcherProviderSynchronousProxy {
727    pub fn new(channel: fidl::Channel) -> Self {
728        Self { client: fidl::client::sync::Client::new(channel) }
729    }
730
731    pub fn into_channel(self) -> fidl::Channel {
732        self.client.into_channel()
733    }
734
735    /// Waits until an event arrives and returns it. It is safe for other
736    /// threads to make concurrent requests while waiting for an event.
737    pub fn wait_for_event(
738        &self,
739        deadline: zx::MonotonicInstant,
740    ) -> Result<RouterAdvertisementOptionWatcherProviderEvent, fidl::Error> {
741        RouterAdvertisementOptionWatcherProviderEvent::decode(
742            self.client
743                .wait_for_event::<RouterAdvertisementOptionWatcherProviderMarker>(deadline)?,
744        )
745    }
746
747    /// Constructs a new watcher that yields NDP options received from router
748    /// advertisement messages as described in [RFC 4861 section
749    /// 4.2](https://datatracker.ietf.org/doc/html/rfc4861#section-4.2).
750    pub fn r#new_router_advertisement_option_watcher(
751        &self,
752        mut option_watcher: fidl::endpoints::ServerEnd<OptionWatcherMarker>,
753        mut params: &RouterAdvertisementOptionWatcherParams,
754    ) -> Result<(), fidl::Error> {
755        self.client.send::<RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest>(
756            (option_watcher, params,),
757            0x2a90a8bd5fd2bbf4,
758            fidl::encoding::DynamicFlags::empty(),
759        )
760    }
761}
762
763#[cfg(target_os = "fuchsia")]
764impl From<RouterAdvertisementOptionWatcherProviderSynchronousProxy> for zx::NullableHandle {
765    fn from(value: RouterAdvertisementOptionWatcherProviderSynchronousProxy) -> Self {
766        value.into_channel().into()
767    }
768}
769
770#[cfg(target_os = "fuchsia")]
771impl From<fidl::Channel> for RouterAdvertisementOptionWatcherProviderSynchronousProxy {
772    fn from(value: fidl::Channel) -> Self {
773        Self::new(value)
774    }
775}
776
777#[cfg(target_os = "fuchsia")]
778impl fidl::endpoints::FromClient for RouterAdvertisementOptionWatcherProviderSynchronousProxy {
779    type Protocol = RouterAdvertisementOptionWatcherProviderMarker;
780
781    fn from_client(
782        value: fidl::endpoints::ClientEnd<RouterAdvertisementOptionWatcherProviderMarker>,
783    ) -> Self {
784        Self::new(value.into_channel())
785    }
786}
787
788#[derive(Debug, Clone)]
789pub struct RouterAdvertisementOptionWatcherProviderProxy {
790    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
791}
792
793impl fidl::endpoints::Proxy for RouterAdvertisementOptionWatcherProviderProxy {
794    type Protocol = RouterAdvertisementOptionWatcherProviderMarker;
795
796    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
797        Self::new(inner)
798    }
799
800    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
801        self.client.into_channel().map_err(|client| Self { client })
802    }
803
804    fn as_channel(&self) -> &::fidl::AsyncChannel {
805        self.client.as_channel()
806    }
807}
808
809impl RouterAdvertisementOptionWatcherProviderProxy {
810    /// Create a new Proxy for fuchsia.net.ndp/RouterAdvertisementOptionWatcherProvider.
811    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
812        let protocol_name = <RouterAdvertisementOptionWatcherProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
813        Self { client: fidl::client::Client::new(channel, protocol_name) }
814    }
815
816    /// Get a Stream of events from the remote end of the protocol.
817    ///
818    /// # Panics
819    ///
820    /// Panics if the event stream was already taken.
821    pub fn take_event_stream(&self) -> RouterAdvertisementOptionWatcherProviderEventStream {
822        RouterAdvertisementOptionWatcherProviderEventStream {
823            event_receiver: self.client.take_event_receiver(),
824        }
825    }
826
827    /// Constructs a new watcher that yields NDP options received from router
828    /// advertisement messages as described in [RFC 4861 section
829    /// 4.2](https://datatracker.ietf.org/doc/html/rfc4861#section-4.2).
830    pub fn r#new_router_advertisement_option_watcher(
831        &self,
832        mut option_watcher: fidl::endpoints::ServerEnd<OptionWatcherMarker>,
833        mut params: &RouterAdvertisementOptionWatcherParams,
834    ) -> Result<(), fidl::Error> {
835        RouterAdvertisementOptionWatcherProviderProxyInterface::r#new_router_advertisement_option_watcher(self,
836            option_watcher,
837            params,
838        )
839    }
840}
841
842impl RouterAdvertisementOptionWatcherProviderProxyInterface
843    for RouterAdvertisementOptionWatcherProviderProxy
844{
845    fn r#new_router_advertisement_option_watcher(
846        &self,
847        mut option_watcher: fidl::endpoints::ServerEnd<OptionWatcherMarker>,
848        mut params: &RouterAdvertisementOptionWatcherParams,
849    ) -> Result<(), fidl::Error> {
850        self.client.send::<RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest>(
851            (option_watcher, params,),
852            0x2a90a8bd5fd2bbf4,
853            fidl::encoding::DynamicFlags::empty(),
854        )
855    }
856}
857
858pub struct RouterAdvertisementOptionWatcherProviderEventStream {
859    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
860}
861
862impl std::marker::Unpin for RouterAdvertisementOptionWatcherProviderEventStream {}
863
864impl futures::stream::FusedStream for RouterAdvertisementOptionWatcherProviderEventStream {
865    fn is_terminated(&self) -> bool {
866        self.event_receiver.is_terminated()
867    }
868}
869
870impl futures::Stream for RouterAdvertisementOptionWatcherProviderEventStream {
871    type Item = Result<RouterAdvertisementOptionWatcherProviderEvent, fidl::Error>;
872
873    fn poll_next(
874        mut self: std::pin::Pin<&mut Self>,
875        cx: &mut std::task::Context<'_>,
876    ) -> std::task::Poll<Option<Self::Item>> {
877        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
878            &mut self.event_receiver,
879            cx
880        )?) {
881            Some(buf) => std::task::Poll::Ready(Some(
882                RouterAdvertisementOptionWatcherProviderEvent::decode(buf),
883            )),
884            None => std::task::Poll::Ready(None),
885        }
886    }
887}
888
889#[derive(Debug)]
890pub enum RouterAdvertisementOptionWatcherProviderEvent {}
891
892impl RouterAdvertisementOptionWatcherProviderEvent {
893    /// Decodes a message buffer as a [`RouterAdvertisementOptionWatcherProviderEvent`].
894    fn decode(
895        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
896    ) -> Result<RouterAdvertisementOptionWatcherProviderEvent, fidl::Error> {
897        let (bytes, _handles) = buf.split_mut();
898        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
899        debug_assert_eq!(tx_header.tx_id, 0);
900        match tx_header.ordinal {
901            _ => Err(fidl::Error::UnknownOrdinal {
902                ordinal: tx_header.ordinal,
903                protocol_name: <RouterAdvertisementOptionWatcherProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
904            })
905        }
906    }
907}
908
909/// A Stream of incoming requests for fuchsia.net.ndp/RouterAdvertisementOptionWatcherProvider.
910pub struct RouterAdvertisementOptionWatcherProviderRequestStream {
911    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
912    is_terminated: bool,
913}
914
915impl std::marker::Unpin for RouterAdvertisementOptionWatcherProviderRequestStream {}
916
917impl futures::stream::FusedStream for RouterAdvertisementOptionWatcherProviderRequestStream {
918    fn is_terminated(&self) -> bool {
919        self.is_terminated
920    }
921}
922
923impl fidl::endpoints::RequestStream for RouterAdvertisementOptionWatcherProviderRequestStream {
924    type Protocol = RouterAdvertisementOptionWatcherProviderMarker;
925    type ControlHandle = RouterAdvertisementOptionWatcherProviderControlHandle;
926
927    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
928        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
929    }
930
931    fn control_handle(&self) -> Self::ControlHandle {
932        RouterAdvertisementOptionWatcherProviderControlHandle { inner: self.inner.clone() }
933    }
934
935    fn into_inner(
936        self,
937    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
938    {
939        (self.inner, self.is_terminated)
940    }
941
942    fn from_inner(
943        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
944        is_terminated: bool,
945    ) -> Self {
946        Self { inner, is_terminated }
947    }
948}
949
950impl futures::Stream for RouterAdvertisementOptionWatcherProviderRequestStream {
951    type Item = Result<RouterAdvertisementOptionWatcherProviderRequest, fidl::Error>;
952
953    fn poll_next(
954        mut self: std::pin::Pin<&mut Self>,
955        cx: &mut std::task::Context<'_>,
956    ) -> std::task::Poll<Option<Self::Item>> {
957        let this = &mut *self;
958        if this.inner.check_shutdown(cx) {
959            this.is_terminated = true;
960            return std::task::Poll::Ready(None);
961        }
962        if this.is_terminated {
963            panic!("polled RouterAdvertisementOptionWatcherProviderRequestStream after completion");
964        }
965        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
966            |bytes, handles| {
967                match this.inner.channel().read_etc(cx, bytes, handles) {
968                    std::task::Poll::Ready(Ok(())) => {}
969                    std::task::Poll::Pending => return std::task::Poll::Pending,
970                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
971                        this.is_terminated = true;
972                        return std::task::Poll::Ready(None);
973                    }
974                    std::task::Poll::Ready(Err(e)) => {
975                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
976                            e.into(),
977                        ))));
978                    }
979                }
980
981                // A message has been received from the channel
982                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
983
984                std::task::Poll::Ready(Some(match header.ordinal {
985                0x2a90a8bd5fd2bbf4 => {
986                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
987                    let mut req = fidl::new_empty!(RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
988                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
989                    let control_handle = RouterAdvertisementOptionWatcherProviderControlHandle {
990                        inner: this.inner.clone(),
991                    };
992                    Ok(RouterAdvertisementOptionWatcherProviderRequest::NewRouterAdvertisementOptionWatcher {option_watcher: req.option_watcher,
993params: req.params,
994
995                        control_handle,
996                    })
997                }
998                _ => Err(fidl::Error::UnknownOrdinal {
999                    ordinal: header.ordinal,
1000                    protocol_name: <RouterAdvertisementOptionWatcherProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1001                }),
1002            }))
1003            },
1004        )
1005    }
1006}
1007
1008/// Provides watchers for NDP options observed via router advertisements.
1009///
1010/// ## Privacy note
1011///
1012/// This protocol provides access to the raw bytes of NDP options, which can
1013/// contain privileged information such as the hardware addresses of the user's
1014/// host device or other devices on the network. Thus, care should be taken with
1015/// where this protocol is made available.
1016#[derive(Debug)]
1017pub enum RouterAdvertisementOptionWatcherProviderRequest {
1018    /// Constructs a new watcher that yields NDP options received from router
1019    /// advertisement messages as described in [RFC 4861 section
1020    /// 4.2](https://datatracker.ietf.org/doc/html/rfc4861#section-4.2).
1021    NewRouterAdvertisementOptionWatcher {
1022        option_watcher: fidl::endpoints::ServerEnd<OptionWatcherMarker>,
1023        params: RouterAdvertisementOptionWatcherParams,
1024        control_handle: RouterAdvertisementOptionWatcherProviderControlHandle,
1025    },
1026}
1027
1028impl RouterAdvertisementOptionWatcherProviderRequest {
1029    #[allow(irrefutable_let_patterns)]
1030    pub fn into_new_router_advertisement_option_watcher(
1031        self,
1032    ) -> Option<(
1033        fidl::endpoints::ServerEnd<OptionWatcherMarker>,
1034        RouterAdvertisementOptionWatcherParams,
1035        RouterAdvertisementOptionWatcherProviderControlHandle,
1036    )> {
1037        if let RouterAdvertisementOptionWatcherProviderRequest::NewRouterAdvertisementOptionWatcher {
1038            option_watcher,
1039            params,
1040            control_handle,
1041        } = self {
1042            Some((option_watcher,params,
1043                control_handle))
1044        } else {
1045            None
1046        }
1047    }
1048
1049    /// Name of the method defined in FIDL
1050    pub fn method_name(&self) -> &'static str {
1051        match *self {
1052            RouterAdvertisementOptionWatcherProviderRequest::NewRouterAdvertisementOptionWatcher{..} => "new_router_advertisement_option_watcher",
1053        }
1054    }
1055}
1056
1057#[derive(Debug, Clone)]
1058pub struct RouterAdvertisementOptionWatcherProviderControlHandle {
1059    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1060}
1061
1062impl RouterAdvertisementOptionWatcherProviderControlHandle {
1063    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1064        self.inner.shutdown_with_epitaph(status.into())
1065    }
1066}
1067
1068impl fidl::endpoints::ControlHandle for RouterAdvertisementOptionWatcherProviderControlHandle {
1069    fn shutdown(&self) {
1070        self.inner.shutdown()
1071    }
1072
1073    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1074        self.inner.shutdown_with_epitaph(status)
1075    }
1076
1077    fn is_closed(&self) -> bool {
1078        self.inner.channel().is_closed()
1079    }
1080    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1081        self.inner.channel().on_closed()
1082    }
1083
1084    #[cfg(target_os = "fuchsia")]
1085    fn signal_peer(
1086        &self,
1087        clear_mask: zx::Signals,
1088        set_mask: zx::Signals,
1089    ) -> Result<(), zx_status::Status> {
1090        use fidl::Peered;
1091        self.inner.channel().signal_peer(clear_mask, set_mask)
1092    }
1093}
1094
1095impl RouterAdvertisementOptionWatcherProviderControlHandle {}
1096
1097mod internal {
1098    use super::*;
1099
1100    impl fidl::encoding::ResourceTypeMarker
1101        for RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest
1102    {
1103        type Borrowed<'a> = &'a mut Self;
1104        fn take_or_borrow<'a>(
1105            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1106        ) -> Self::Borrowed<'a> {
1107            value
1108        }
1109    }
1110
1111    unsafe impl fidl::encoding::TypeMarker
1112        for RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest
1113    {
1114        type Owned = Self;
1115
1116        #[inline(always)]
1117        fn inline_align(_context: fidl::encoding::Context) -> usize {
1118            8
1119        }
1120
1121        #[inline(always)]
1122        fn inline_size(_context: fidl::encoding::Context) -> usize {
1123            24
1124        }
1125    }
1126
1127    unsafe impl
1128        fidl::encoding::Encode<
1129            RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest,
1130            fidl::encoding::DefaultFuchsiaResourceDialect,
1131        >
1132        for &mut RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest
1133    {
1134        #[inline]
1135        unsafe fn encode(
1136            self,
1137            encoder: &mut fidl::encoding::Encoder<
1138                '_,
1139                fidl::encoding::DefaultFuchsiaResourceDialect,
1140            >,
1141            offset: usize,
1142            _depth: fidl::encoding::Depth,
1143        ) -> fidl::Result<()> {
1144            encoder.debug_check_bounds::<RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest>(offset);
1145            // Delegate to tuple encoding.
1146            fidl::encoding::Encode::<RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1147                (
1148                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<OptionWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.option_watcher),
1149                    <RouterAdvertisementOptionWatcherParams as fidl::encoding::ValueTypeMarker>::borrow(&self.params),
1150                ),
1151                encoder, offset, _depth
1152            )
1153        }
1154    }
1155    unsafe impl<
1156        T0: fidl::encoding::Encode<
1157                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<OptionWatcherMarker>>,
1158                fidl::encoding::DefaultFuchsiaResourceDialect,
1159            >,
1160        T1: fidl::encoding::Encode<
1161                RouterAdvertisementOptionWatcherParams,
1162                fidl::encoding::DefaultFuchsiaResourceDialect,
1163            >,
1164    >
1165        fidl::encoding::Encode<
1166            RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest,
1167            fidl::encoding::DefaultFuchsiaResourceDialect,
1168        > for (T0, T1)
1169    {
1170        #[inline]
1171        unsafe fn encode(
1172            self,
1173            encoder: &mut fidl::encoding::Encoder<
1174                '_,
1175                fidl::encoding::DefaultFuchsiaResourceDialect,
1176            >,
1177            offset: usize,
1178            depth: fidl::encoding::Depth,
1179        ) -> fidl::Result<()> {
1180            encoder.debug_check_bounds::<RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest>(offset);
1181            // Zero out padding regions. There's no need to apply masks
1182            // because the unmasked parts will be overwritten by fields.
1183            unsafe {
1184                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1185                (ptr as *mut u64).write_unaligned(0);
1186            }
1187            // Write the fields.
1188            self.0.encode(encoder, offset + 0, depth)?;
1189            self.1.encode(encoder, offset + 8, depth)?;
1190            Ok(())
1191        }
1192    }
1193
1194    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1195        for RouterAdvertisementOptionWatcherProviderNewRouterAdvertisementOptionWatcherRequest
1196    {
1197        #[inline(always)]
1198        fn new_empty() -> Self {
1199            Self {
1200                option_watcher: fidl::new_empty!(
1201                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<OptionWatcherMarker>>,
1202                    fidl::encoding::DefaultFuchsiaResourceDialect
1203                ),
1204                params: fidl::new_empty!(
1205                    RouterAdvertisementOptionWatcherParams,
1206                    fidl::encoding::DefaultFuchsiaResourceDialect
1207                ),
1208            }
1209        }
1210
1211        #[inline]
1212        unsafe fn decode(
1213            &mut self,
1214            decoder: &mut fidl::encoding::Decoder<
1215                '_,
1216                fidl::encoding::DefaultFuchsiaResourceDialect,
1217            >,
1218            offset: usize,
1219            _depth: fidl::encoding::Depth,
1220        ) -> fidl::Result<()> {
1221            decoder.debug_check_bounds::<Self>(offset);
1222            // Verify that padding bytes are zero.
1223            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1224            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1225            let mask = 0xffffffff00000000u64;
1226            let maskedval = padval & mask;
1227            if maskedval != 0 {
1228                return Err(fidl::Error::NonZeroPadding {
1229                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1230                });
1231            }
1232            fidl::decode!(
1233                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<OptionWatcherMarker>>,
1234                fidl::encoding::DefaultFuchsiaResourceDialect,
1235                &mut self.option_watcher,
1236                decoder,
1237                offset + 0,
1238                _depth
1239            )?;
1240            fidl::decode!(
1241                RouterAdvertisementOptionWatcherParams,
1242                fidl::encoding::DefaultFuchsiaResourceDialect,
1243                &mut self.params,
1244                decoder,
1245                offset + 8,
1246                _depth
1247            )?;
1248            Ok(())
1249        }
1250    }
1251}