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