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