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