Skip to main content

fidl_fuchsia_net_policy_socketproxy/
fidl_fuchsia_net_policy_socketproxy.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_socketproxy_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct NetworkRegistryMarker;
16
17impl fidl::endpoints::ProtocolMarker for NetworkRegistryMarker {
18    type Proxy = NetworkRegistryProxy;
19    type RequestStream = NetworkRegistryRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = NetworkRegistrySynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.net.policy.socketproxy.NetworkRegistry";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for NetworkRegistryMarker {}
26pub type NetworkRegistrySetDefaultResult = Result<(), NetworkRegistrySetDefaultError>;
27pub type NetworkRegistryAddResult = Result<(), NetworkRegistryAddError>;
28pub type NetworkRegistryUpdateResult = Result<(), NetworkRegistryUpdateError>;
29pub type NetworkRegistryRemoveResult = Result<(), NetworkRegistryRemoveError>;
30
31pub trait NetworkRegistryProxyInterface: Send + Sync {
32    type SetDefaultResponseFut: std::future::Future<Output = Result<NetworkRegistrySetDefaultResult, fidl::Error>>
33        + Send;
34    fn r#set_default(
35        &self,
36        network_id: &fidl_fuchsia_posix_socket::OptionalUint32,
37    ) -> Self::SetDefaultResponseFut;
38    type AddResponseFut: std::future::Future<Output = Result<NetworkRegistryAddResult, fidl::Error>>
39        + Send;
40    fn r#add(&self, network: &Network) -> Self::AddResponseFut;
41    type UpdateResponseFut: std::future::Future<Output = Result<NetworkRegistryUpdateResult, fidl::Error>>
42        + Send;
43    fn r#update(&self, network: &Network) -> Self::UpdateResponseFut;
44    type RemoveResponseFut: std::future::Future<Output = Result<NetworkRegistryRemoveResult, fidl::Error>>
45        + Send;
46    fn r#remove(&self, network_id: u32) -> Self::RemoveResponseFut;
47}
48#[derive(Debug)]
49#[cfg(target_os = "fuchsia")]
50pub struct NetworkRegistrySynchronousProxy {
51    client: fidl::client::sync::Client,
52}
53
54#[cfg(target_os = "fuchsia")]
55impl fidl::endpoints::SynchronousProxy for NetworkRegistrySynchronousProxy {
56    type Proxy = NetworkRegistryProxy;
57    type Protocol = NetworkRegistryMarker;
58
59    fn from_channel(inner: fidl::Channel) -> Self {
60        Self::new(inner)
61    }
62
63    fn into_channel(self) -> fidl::Channel {
64        self.client.into_channel()
65    }
66
67    fn as_channel(&self) -> &fidl::Channel {
68        self.client.as_channel()
69    }
70}
71
72#[cfg(target_os = "fuchsia")]
73impl NetworkRegistrySynchronousProxy {
74    pub fn new(channel: fidl::Channel) -> Self {
75        Self { client: fidl::client::sync::Client::new(channel) }
76    }
77
78    pub fn into_channel(self) -> fidl::Channel {
79        self.client.into_channel()
80    }
81
82    /// Waits until an event arrives and returns it. It is safe for other
83    /// threads to make concurrent requests while waiting for an event.
84    pub fn wait_for_event(
85        &self,
86        deadline: zx::MonotonicInstant,
87    ) -> Result<NetworkRegistryEvent, fidl::Error> {
88        NetworkRegistryEvent::decode(self.client.wait_for_event::<NetworkRegistryMarker>(deadline)?)
89    }
90
91    /// Sets the default network.
92    ///
93    /// The network must have previously been registered by a call to `Add`.
94    pub fn r#set_default(
95        &self,
96        mut network_id: &fidl_fuchsia_posix_socket::OptionalUint32,
97        ___deadline: zx::MonotonicInstant,
98    ) -> Result<NetworkRegistrySetDefaultResult, fidl::Error> {
99        let _response =
100            self.client.send_query::<NetworkRegistrySetDefaultRequest, fidl::encoding::ResultType<
101                fidl::encoding::EmptyStruct,
102                NetworkRegistrySetDefaultError,
103            >, NetworkRegistryMarker>(
104                (network_id,),
105                0x787930c67b8cf82c,
106                fidl::encoding::DynamicFlags::empty(),
107                ___deadline,
108            )?;
109        Ok(_response.map(|x| x))
110    }
111
112    /// Add a new network.
113    ///
114    /// This call will not return until the DNS servers have been successfully
115    /// updated in netcfg.
116    pub fn r#add(
117        &self,
118        mut network: &Network,
119        ___deadline: zx::MonotonicInstant,
120    ) -> Result<NetworkRegistryAddResult, fidl::Error> {
121        let _response =
122            self.client.send_query::<NetworkRegistryAddRequest, fidl::encoding::ResultType<
123                fidl::encoding::EmptyStruct,
124                NetworkRegistryAddError,
125            >, NetworkRegistryMarker>(
126                (network,),
127                0x197e70a1cbeab3ad,
128                fidl::encoding::DynamicFlags::empty(),
129                ___deadline,
130            )?;
131        Ok(_response.map(|x| x))
132    }
133
134    /// Update a previously Added network.
135    ///
136    /// This call will not return until the DNS servers have been
137    /// successfully updated in netcfg.
138    pub fn r#update(
139        &self,
140        mut network: &Network,
141        ___deadline: zx::MonotonicInstant,
142    ) -> Result<NetworkRegistryUpdateResult, fidl::Error> {
143        let _response =
144            self.client.send_query::<NetworkRegistryUpdateRequest, fidl::encoding::ResultType<
145                fidl::encoding::EmptyStruct,
146                NetworkRegistryUpdateError,
147            >, NetworkRegistryMarker>(
148                (network,),
149                0x3bc790ae5418ff0e,
150                fidl::encoding::DynamicFlags::empty(),
151                ___deadline,
152            )?;
153        Ok(_response.map(|x| x))
154    }
155
156    /// Remove a previously Added network.
157    ///
158    /// This call will not return until the DNS servers have been
159    /// successfully updated in netcfg.
160    pub fn r#remove(
161        &self,
162        mut network_id: u32,
163        ___deadline: zx::MonotonicInstant,
164    ) -> Result<NetworkRegistryRemoveResult, fidl::Error> {
165        let _response =
166            self.client.send_query::<NetworkRegistryRemoveRequest, fidl::encoding::ResultType<
167                fidl::encoding::EmptyStruct,
168                NetworkRegistryRemoveError,
169            >, NetworkRegistryMarker>(
170                (network_id,),
171                0x1302df41dca6379e,
172                fidl::encoding::DynamicFlags::empty(),
173                ___deadline,
174            )?;
175        Ok(_response.map(|x| x))
176    }
177}
178
179#[cfg(target_os = "fuchsia")]
180impl From<NetworkRegistrySynchronousProxy> for zx::NullableHandle {
181    fn from(value: NetworkRegistrySynchronousProxy) -> Self {
182        value.into_channel().into()
183    }
184}
185
186#[cfg(target_os = "fuchsia")]
187impl From<fidl::Channel> for NetworkRegistrySynchronousProxy {
188    fn from(value: fidl::Channel) -> Self {
189        Self::new(value)
190    }
191}
192
193#[cfg(target_os = "fuchsia")]
194impl fidl::endpoints::FromClient for NetworkRegistrySynchronousProxy {
195    type Protocol = NetworkRegistryMarker;
196
197    fn from_client(value: fidl::endpoints::ClientEnd<NetworkRegistryMarker>) -> Self {
198        Self::new(value.into_channel())
199    }
200}
201
202#[derive(Debug, Clone)]
203pub struct NetworkRegistryProxy {
204    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
205}
206
207impl fidl::endpoints::Proxy for NetworkRegistryProxy {
208    type Protocol = NetworkRegistryMarker;
209
210    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
211        Self::new(inner)
212    }
213
214    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
215        self.client.into_channel().map_err(|client| Self { client })
216    }
217
218    fn as_channel(&self) -> &::fidl::AsyncChannel {
219        self.client.as_channel()
220    }
221}
222
223impl NetworkRegistryProxy {
224    /// Create a new Proxy for fuchsia.net.policy.socketproxy/NetworkRegistry.
225    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
226        let protocol_name = <NetworkRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
227        Self { client: fidl::client::Client::new(channel, protocol_name) }
228    }
229
230    /// Get a Stream of events from the remote end of the protocol.
231    ///
232    /// # Panics
233    ///
234    /// Panics if the event stream was already taken.
235    pub fn take_event_stream(&self) -> NetworkRegistryEventStream {
236        NetworkRegistryEventStream { event_receiver: self.client.take_event_receiver() }
237    }
238
239    /// Sets the default network.
240    ///
241    /// The network must have previously been registered by a call to `Add`.
242    pub fn r#set_default(
243        &self,
244        mut network_id: &fidl_fuchsia_posix_socket::OptionalUint32,
245    ) -> fidl::client::QueryResponseFut<
246        NetworkRegistrySetDefaultResult,
247        fidl::encoding::DefaultFuchsiaResourceDialect,
248    > {
249        NetworkRegistryProxyInterface::r#set_default(self, network_id)
250    }
251
252    /// Add a new network.
253    ///
254    /// This call will not return until the DNS servers have been successfully
255    /// updated in netcfg.
256    pub fn r#add(
257        &self,
258        mut network: &Network,
259    ) -> fidl::client::QueryResponseFut<
260        NetworkRegistryAddResult,
261        fidl::encoding::DefaultFuchsiaResourceDialect,
262    > {
263        NetworkRegistryProxyInterface::r#add(self, network)
264    }
265
266    /// Update a previously Added network.
267    ///
268    /// This call will not return until the DNS servers have been
269    /// successfully updated in netcfg.
270    pub fn r#update(
271        &self,
272        mut network: &Network,
273    ) -> fidl::client::QueryResponseFut<
274        NetworkRegistryUpdateResult,
275        fidl::encoding::DefaultFuchsiaResourceDialect,
276    > {
277        NetworkRegistryProxyInterface::r#update(self, network)
278    }
279
280    /// Remove a previously Added network.
281    ///
282    /// This call will not return until the DNS servers have been
283    /// successfully updated in netcfg.
284    pub fn r#remove(
285        &self,
286        mut network_id: u32,
287    ) -> fidl::client::QueryResponseFut<
288        NetworkRegistryRemoveResult,
289        fidl::encoding::DefaultFuchsiaResourceDialect,
290    > {
291        NetworkRegistryProxyInterface::r#remove(self, network_id)
292    }
293}
294
295impl NetworkRegistryProxyInterface for NetworkRegistryProxy {
296    type SetDefaultResponseFut = fidl::client::QueryResponseFut<
297        NetworkRegistrySetDefaultResult,
298        fidl::encoding::DefaultFuchsiaResourceDialect,
299    >;
300    fn r#set_default(
301        &self,
302        mut network_id: &fidl_fuchsia_posix_socket::OptionalUint32,
303    ) -> Self::SetDefaultResponseFut {
304        fn _decode(
305            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
306        ) -> Result<NetworkRegistrySetDefaultResult, fidl::Error> {
307            let _response = fidl::client::decode_transaction_body::<
308                fidl::encoding::ResultType<
309                    fidl::encoding::EmptyStruct,
310                    NetworkRegistrySetDefaultError,
311                >,
312                fidl::encoding::DefaultFuchsiaResourceDialect,
313                0x787930c67b8cf82c,
314            >(_buf?)?;
315            Ok(_response.map(|x| x))
316        }
317        self.client.send_query_and_decode::<
318            NetworkRegistrySetDefaultRequest,
319            NetworkRegistrySetDefaultResult,
320        >(
321            (network_id,),
322            0x787930c67b8cf82c,
323            fidl::encoding::DynamicFlags::empty(),
324            _decode,
325        )
326    }
327
328    type AddResponseFut = fidl::client::QueryResponseFut<
329        NetworkRegistryAddResult,
330        fidl::encoding::DefaultFuchsiaResourceDialect,
331    >;
332    fn r#add(&self, mut network: &Network) -> Self::AddResponseFut {
333        fn _decode(
334            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
335        ) -> Result<NetworkRegistryAddResult, fidl::Error> {
336            let _response = fidl::client::decode_transaction_body::<
337                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, NetworkRegistryAddError>,
338                fidl::encoding::DefaultFuchsiaResourceDialect,
339                0x197e70a1cbeab3ad,
340            >(_buf?)?;
341            Ok(_response.map(|x| x))
342        }
343        self.client.send_query_and_decode::<NetworkRegistryAddRequest, NetworkRegistryAddResult>(
344            (network,),
345            0x197e70a1cbeab3ad,
346            fidl::encoding::DynamicFlags::empty(),
347            _decode,
348        )
349    }
350
351    type UpdateResponseFut = fidl::client::QueryResponseFut<
352        NetworkRegistryUpdateResult,
353        fidl::encoding::DefaultFuchsiaResourceDialect,
354    >;
355    fn r#update(&self, mut network: &Network) -> Self::UpdateResponseFut {
356        fn _decode(
357            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
358        ) -> Result<NetworkRegistryUpdateResult, fidl::Error> {
359            let _response = fidl::client::decode_transaction_body::<
360                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, NetworkRegistryUpdateError>,
361                fidl::encoding::DefaultFuchsiaResourceDialect,
362                0x3bc790ae5418ff0e,
363            >(_buf?)?;
364            Ok(_response.map(|x| x))
365        }
366        self.client
367            .send_query_and_decode::<NetworkRegistryUpdateRequest, NetworkRegistryUpdateResult>(
368                (network,),
369                0x3bc790ae5418ff0e,
370                fidl::encoding::DynamicFlags::empty(),
371                _decode,
372            )
373    }
374
375    type RemoveResponseFut = fidl::client::QueryResponseFut<
376        NetworkRegistryRemoveResult,
377        fidl::encoding::DefaultFuchsiaResourceDialect,
378    >;
379    fn r#remove(&self, mut network_id: u32) -> Self::RemoveResponseFut {
380        fn _decode(
381            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
382        ) -> Result<NetworkRegistryRemoveResult, fidl::Error> {
383            let _response = fidl::client::decode_transaction_body::<
384                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, NetworkRegistryRemoveError>,
385                fidl::encoding::DefaultFuchsiaResourceDialect,
386                0x1302df41dca6379e,
387            >(_buf?)?;
388            Ok(_response.map(|x| x))
389        }
390        self.client
391            .send_query_and_decode::<NetworkRegistryRemoveRequest, NetworkRegistryRemoveResult>(
392                (network_id,),
393                0x1302df41dca6379e,
394                fidl::encoding::DynamicFlags::empty(),
395                _decode,
396            )
397    }
398}
399
400pub struct NetworkRegistryEventStream {
401    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
402}
403
404impl std::marker::Unpin for NetworkRegistryEventStream {}
405
406impl futures::stream::FusedStream for NetworkRegistryEventStream {
407    fn is_terminated(&self) -> bool {
408        self.event_receiver.is_terminated()
409    }
410}
411
412impl futures::Stream for NetworkRegistryEventStream {
413    type Item = Result<NetworkRegistryEvent, fidl::Error>;
414
415    fn poll_next(
416        mut self: std::pin::Pin<&mut Self>,
417        cx: &mut std::task::Context<'_>,
418    ) -> std::task::Poll<Option<Self::Item>> {
419        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
420            &mut self.event_receiver,
421            cx
422        )?) {
423            Some(buf) => std::task::Poll::Ready(Some(NetworkRegistryEvent::decode(buf))),
424            None => std::task::Poll::Ready(None),
425        }
426    }
427}
428
429#[derive(Debug)]
430pub enum NetworkRegistryEvent {}
431
432impl NetworkRegistryEvent {
433    /// Decodes a message buffer as a [`NetworkRegistryEvent`].
434    fn decode(
435        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
436    ) -> Result<NetworkRegistryEvent, fidl::Error> {
437        let (bytes, _handles) = buf.split_mut();
438        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
439        debug_assert_eq!(tx_header.tx_id, 0);
440        match tx_header.ordinal {
441            _ => Err(fidl::Error::UnknownOrdinal {
442                ordinal: tx_header.ordinal,
443                protocol_name:
444                    <NetworkRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
445            }),
446        }
447    }
448}
449
450/// A Stream of incoming requests for fuchsia.net.policy.socketproxy/NetworkRegistry.
451pub struct NetworkRegistryRequestStream {
452    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
453    is_terminated: bool,
454}
455
456impl std::marker::Unpin for NetworkRegistryRequestStream {}
457
458impl futures::stream::FusedStream for NetworkRegistryRequestStream {
459    fn is_terminated(&self) -> bool {
460        self.is_terminated
461    }
462}
463
464impl fidl::endpoints::RequestStream for NetworkRegistryRequestStream {
465    type Protocol = NetworkRegistryMarker;
466    type ControlHandle = NetworkRegistryControlHandle;
467
468    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
469        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
470    }
471
472    fn control_handle(&self) -> Self::ControlHandle {
473        NetworkRegistryControlHandle { inner: self.inner.clone() }
474    }
475
476    fn into_inner(
477        self,
478    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
479    {
480        (self.inner, self.is_terminated)
481    }
482
483    fn from_inner(
484        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
485        is_terminated: bool,
486    ) -> Self {
487        Self { inner, is_terminated }
488    }
489}
490
491impl futures::Stream for NetworkRegistryRequestStream {
492    type Item = Result<NetworkRegistryRequest, fidl::Error>;
493
494    fn poll_next(
495        mut self: std::pin::Pin<&mut Self>,
496        cx: &mut std::task::Context<'_>,
497    ) -> std::task::Poll<Option<Self::Item>> {
498        let this = &mut *self;
499        if this.inner.check_shutdown(cx) {
500            this.is_terminated = true;
501            return std::task::Poll::Ready(None);
502        }
503        if this.is_terminated {
504            panic!("polled NetworkRegistryRequestStream after completion");
505        }
506        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
507            |bytes, handles| {
508                match this.inner.channel().read_etc(cx, bytes, handles) {
509                    std::task::Poll::Ready(Ok(())) => {}
510                    std::task::Poll::Pending => return std::task::Poll::Pending,
511                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
512                        this.is_terminated = true;
513                        return std::task::Poll::Ready(None);
514                    }
515                    std::task::Poll::Ready(Err(e)) => {
516                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
517                            e.into(),
518                        ))));
519                    }
520                }
521
522                // A message has been received from the channel
523                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
524
525                std::task::Poll::Ready(Some(match header.ordinal {
526                    0x787930c67b8cf82c => {
527                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
528                        let mut req = fidl::new_empty!(
529                            NetworkRegistrySetDefaultRequest,
530                            fidl::encoding::DefaultFuchsiaResourceDialect
531                        );
532                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRegistrySetDefaultRequest>(&header, _body_bytes, handles, &mut req)?;
533                        let control_handle =
534                            NetworkRegistryControlHandle { inner: this.inner.clone() };
535                        Ok(NetworkRegistryRequest::SetDefault {
536                            network_id: req.network_id,
537
538                            responder: NetworkRegistrySetDefaultResponder {
539                                control_handle: std::mem::ManuallyDrop::new(control_handle),
540                                tx_id: header.tx_id,
541                            },
542                        })
543                    }
544                    0x197e70a1cbeab3ad => {
545                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
546                        let mut req = fidl::new_empty!(
547                            NetworkRegistryAddRequest,
548                            fidl::encoding::DefaultFuchsiaResourceDialect
549                        );
550                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRegistryAddRequest>(&header, _body_bytes, handles, &mut req)?;
551                        let control_handle =
552                            NetworkRegistryControlHandle { inner: this.inner.clone() };
553                        Ok(NetworkRegistryRequest::Add {
554                            network: req.network,
555
556                            responder: NetworkRegistryAddResponder {
557                                control_handle: std::mem::ManuallyDrop::new(control_handle),
558                                tx_id: header.tx_id,
559                            },
560                        })
561                    }
562                    0x3bc790ae5418ff0e => {
563                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
564                        let mut req = fidl::new_empty!(
565                            NetworkRegistryUpdateRequest,
566                            fidl::encoding::DefaultFuchsiaResourceDialect
567                        );
568                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRegistryUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
569                        let control_handle =
570                            NetworkRegistryControlHandle { inner: this.inner.clone() };
571                        Ok(NetworkRegistryRequest::Update {
572                            network: req.network,
573
574                            responder: NetworkRegistryUpdateResponder {
575                                control_handle: std::mem::ManuallyDrop::new(control_handle),
576                                tx_id: header.tx_id,
577                            },
578                        })
579                    }
580                    0x1302df41dca6379e => {
581                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
582                        let mut req = fidl::new_empty!(
583                            NetworkRegistryRemoveRequest,
584                            fidl::encoding::DefaultFuchsiaResourceDialect
585                        );
586                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NetworkRegistryRemoveRequest>(&header, _body_bytes, handles, &mut req)?;
587                        let control_handle =
588                            NetworkRegistryControlHandle { inner: this.inner.clone() };
589                        Ok(NetworkRegistryRequest::Remove {
590                            network_id: req.network_id,
591
592                            responder: NetworkRegistryRemoveResponder {
593                                control_handle: std::mem::ManuallyDrop::new(control_handle),
594                                tx_id: header.tx_id,
595                            },
596                        })
597                    }
598                    _ => Err(fidl::Error::UnknownOrdinal {
599                        ordinal: header.ordinal,
600                        protocol_name:
601                            <NetworkRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
602                    }),
603                }))
604            },
605        )
606    }
607}
608
609#[derive(Debug)]
610pub enum NetworkRegistryRequest {
611    /// Sets the default network.
612    ///
613    /// The network must have previously been registered by a call to `Add`.
614    SetDefault {
615        network_id: fidl_fuchsia_posix_socket::OptionalUint32,
616        responder: NetworkRegistrySetDefaultResponder,
617    },
618    /// Add a new network.
619    ///
620    /// This call will not return until the DNS servers have been successfully
621    /// updated in netcfg.
622    Add { network: Network, responder: NetworkRegistryAddResponder },
623    /// Update a previously Added network.
624    ///
625    /// This call will not return until the DNS servers have been
626    /// successfully updated in netcfg.
627    Update { network: Network, responder: NetworkRegistryUpdateResponder },
628    /// Remove a previously Added network.
629    ///
630    /// This call will not return until the DNS servers have been
631    /// successfully updated in netcfg.
632    Remove { network_id: u32, responder: NetworkRegistryRemoveResponder },
633}
634
635impl NetworkRegistryRequest {
636    #[allow(irrefutable_let_patterns)]
637    pub fn into_set_default(
638        self,
639    ) -> Option<(fidl_fuchsia_posix_socket::OptionalUint32, NetworkRegistrySetDefaultResponder)>
640    {
641        if let NetworkRegistryRequest::SetDefault { network_id, responder } = self {
642            Some((network_id, responder))
643        } else {
644            None
645        }
646    }
647
648    #[allow(irrefutable_let_patterns)]
649    pub fn into_add(self) -> Option<(Network, NetworkRegistryAddResponder)> {
650        if let NetworkRegistryRequest::Add { network, responder } = self {
651            Some((network, responder))
652        } else {
653            None
654        }
655    }
656
657    #[allow(irrefutable_let_patterns)]
658    pub fn into_update(self) -> Option<(Network, NetworkRegistryUpdateResponder)> {
659        if let NetworkRegistryRequest::Update { network, responder } = self {
660            Some((network, responder))
661        } else {
662            None
663        }
664    }
665
666    #[allow(irrefutable_let_patterns)]
667    pub fn into_remove(self) -> Option<(u32, NetworkRegistryRemoveResponder)> {
668        if let NetworkRegistryRequest::Remove { network_id, responder } = self {
669            Some((network_id, responder))
670        } else {
671            None
672        }
673    }
674
675    /// Name of the method defined in FIDL
676    pub fn method_name(&self) -> &'static str {
677        match *self {
678            NetworkRegistryRequest::SetDefault { .. } => "set_default",
679            NetworkRegistryRequest::Add { .. } => "add",
680            NetworkRegistryRequest::Update { .. } => "update",
681            NetworkRegistryRequest::Remove { .. } => "remove",
682        }
683    }
684}
685
686#[derive(Debug, Clone)]
687pub struct NetworkRegistryControlHandle {
688    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
689}
690
691impl NetworkRegistryControlHandle {
692    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
693        self.inner.shutdown_with_epitaph(status.into())
694    }
695}
696
697impl fidl::endpoints::ControlHandle for NetworkRegistryControlHandle {
698    fn shutdown(&self) {
699        self.inner.shutdown()
700    }
701
702    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
703        self.inner.shutdown_with_epitaph(status)
704    }
705
706    fn is_closed(&self) -> bool {
707        self.inner.channel().is_closed()
708    }
709    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
710        self.inner.channel().on_closed()
711    }
712
713    #[cfg(target_os = "fuchsia")]
714    fn signal_peer(
715        &self,
716        clear_mask: zx::Signals,
717        set_mask: zx::Signals,
718    ) -> Result<(), zx_status::Status> {
719        use fidl::Peered;
720        self.inner.channel().signal_peer(clear_mask, set_mask)
721    }
722}
723
724impl NetworkRegistryControlHandle {}
725
726#[must_use = "FIDL methods require a response to be sent"]
727#[derive(Debug)]
728pub struct NetworkRegistrySetDefaultResponder {
729    control_handle: std::mem::ManuallyDrop<NetworkRegistryControlHandle>,
730    tx_id: u32,
731}
732
733/// Set the the channel to be shutdown (see [`NetworkRegistryControlHandle::shutdown`])
734/// if the responder is dropped without sending a response, so that the client
735/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
736impl std::ops::Drop for NetworkRegistrySetDefaultResponder {
737    fn drop(&mut self) {
738        self.control_handle.shutdown();
739        // Safety: drops once, never accessed again
740        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
741    }
742}
743
744impl fidl::endpoints::Responder for NetworkRegistrySetDefaultResponder {
745    type ControlHandle = NetworkRegistryControlHandle;
746
747    fn control_handle(&self) -> &NetworkRegistryControlHandle {
748        &self.control_handle
749    }
750
751    fn drop_without_shutdown(mut self) {
752        // Safety: drops once, never accessed again due to mem::forget
753        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
754        // Prevent Drop from running (which would shut down the channel)
755        std::mem::forget(self);
756    }
757}
758
759impl NetworkRegistrySetDefaultResponder {
760    /// Sends a response to the FIDL transaction.
761    ///
762    /// Sets the channel to shutdown if an error occurs.
763    pub fn send(
764        self,
765        mut result: Result<(), NetworkRegistrySetDefaultError>,
766    ) -> Result<(), fidl::Error> {
767        let _result = self.send_raw(result);
768        if _result.is_err() {
769            self.control_handle.shutdown();
770        }
771        self.drop_without_shutdown();
772        _result
773    }
774
775    /// Similar to "send" but does not shutdown the channel if an error occurs.
776    pub fn send_no_shutdown_on_err(
777        self,
778        mut result: Result<(), NetworkRegistrySetDefaultError>,
779    ) -> Result<(), fidl::Error> {
780        let _result = self.send_raw(result);
781        self.drop_without_shutdown();
782        _result
783    }
784
785    fn send_raw(
786        &self,
787        mut result: Result<(), NetworkRegistrySetDefaultError>,
788    ) -> Result<(), fidl::Error> {
789        self.control_handle.inner.send::<fidl::encoding::ResultType<
790            fidl::encoding::EmptyStruct,
791            NetworkRegistrySetDefaultError,
792        >>(
793            result,
794            self.tx_id,
795            0x787930c67b8cf82c,
796            fidl::encoding::DynamicFlags::empty(),
797        )
798    }
799}
800
801#[must_use = "FIDL methods require a response to be sent"]
802#[derive(Debug)]
803pub struct NetworkRegistryAddResponder {
804    control_handle: std::mem::ManuallyDrop<NetworkRegistryControlHandle>,
805    tx_id: u32,
806}
807
808/// Set the the channel to be shutdown (see [`NetworkRegistryControlHandle::shutdown`])
809/// if the responder is dropped without sending a response, so that the client
810/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
811impl std::ops::Drop for NetworkRegistryAddResponder {
812    fn drop(&mut self) {
813        self.control_handle.shutdown();
814        // Safety: drops once, never accessed again
815        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
816    }
817}
818
819impl fidl::endpoints::Responder for NetworkRegistryAddResponder {
820    type ControlHandle = NetworkRegistryControlHandle;
821
822    fn control_handle(&self) -> &NetworkRegistryControlHandle {
823        &self.control_handle
824    }
825
826    fn drop_without_shutdown(mut self) {
827        // Safety: drops once, never accessed again due to mem::forget
828        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
829        // Prevent Drop from running (which would shut down the channel)
830        std::mem::forget(self);
831    }
832}
833
834impl NetworkRegistryAddResponder {
835    /// Sends a response to the FIDL transaction.
836    ///
837    /// Sets the channel to shutdown if an error occurs.
838    pub fn send(self, mut result: Result<(), NetworkRegistryAddError>) -> Result<(), fidl::Error> {
839        let _result = self.send_raw(result);
840        if _result.is_err() {
841            self.control_handle.shutdown();
842        }
843        self.drop_without_shutdown();
844        _result
845    }
846
847    /// Similar to "send" but does not shutdown the channel if an error occurs.
848    pub fn send_no_shutdown_on_err(
849        self,
850        mut result: Result<(), NetworkRegistryAddError>,
851    ) -> Result<(), fidl::Error> {
852        let _result = self.send_raw(result);
853        self.drop_without_shutdown();
854        _result
855    }
856
857    fn send_raw(&self, mut result: Result<(), NetworkRegistryAddError>) -> Result<(), fidl::Error> {
858        self.control_handle.inner.send::<fidl::encoding::ResultType<
859            fidl::encoding::EmptyStruct,
860            NetworkRegistryAddError,
861        >>(
862            result,
863            self.tx_id,
864            0x197e70a1cbeab3ad,
865            fidl::encoding::DynamicFlags::empty(),
866        )
867    }
868}
869
870#[must_use = "FIDL methods require a response to be sent"]
871#[derive(Debug)]
872pub struct NetworkRegistryUpdateResponder {
873    control_handle: std::mem::ManuallyDrop<NetworkRegistryControlHandle>,
874    tx_id: u32,
875}
876
877/// Set the the channel to be shutdown (see [`NetworkRegistryControlHandle::shutdown`])
878/// if the responder is dropped without sending a response, so that the client
879/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
880impl std::ops::Drop for NetworkRegistryUpdateResponder {
881    fn drop(&mut self) {
882        self.control_handle.shutdown();
883        // Safety: drops once, never accessed again
884        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
885    }
886}
887
888impl fidl::endpoints::Responder for NetworkRegistryUpdateResponder {
889    type ControlHandle = NetworkRegistryControlHandle;
890
891    fn control_handle(&self) -> &NetworkRegistryControlHandle {
892        &self.control_handle
893    }
894
895    fn drop_without_shutdown(mut self) {
896        // Safety: drops once, never accessed again due to mem::forget
897        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
898        // Prevent Drop from running (which would shut down the channel)
899        std::mem::forget(self);
900    }
901}
902
903impl NetworkRegistryUpdateResponder {
904    /// Sends a response to the FIDL transaction.
905    ///
906    /// Sets the channel to shutdown if an error occurs.
907    pub fn send(
908        self,
909        mut result: Result<(), NetworkRegistryUpdateError>,
910    ) -> Result<(), fidl::Error> {
911        let _result = self.send_raw(result);
912        if _result.is_err() {
913            self.control_handle.shutdown();
914        }
915        self.drop_without_shutdown();
916        _result
917    }
918
919    /// Similar to "send" but does not shutdown the channel if an error occurs.
920    pub fn send_no_shutdown_on_err(
921        self,
922        mut result: Result<(), NetworkRegistryUpdateError>,
923    ) -> Result<(), fidl::Error> {
924        let _result = self.send_raw(result);
925        self.drop_without_shutdown();
926        _result
927    }
928
929    fn send_raw(
930        &self,
931        mut result: Result<(), NetworkRegistryUpdateError>,
932    ) -> Result<(), fidl::Error> {
933        self.control_handle.inner.send::<fidl::encoding::ResultType<
934            fidl::encoding::EmptyStruct,
935            NetworkRegistryUpdateError,
936        >>(
937            result,
938            self.tx_id,
939            0x3bc790ae5418ff0e,
940            fidl::encoding::DynamicFlags::empty(),
941        )
942    }
943}
944
945#[must_use = "FIDL methods require a response to be sent"]
946#[derive(Debug)]
947pub struct NetworkRegistryRemoveResponder {
948    control_handle: std::mem::ManuallyDrop<NetworkRegistryControlHandle>,
949    tx_id: u32,
950}
951
952/// Set the the channel to be shutdown (see [`NetworkRegistryControlHandle::shutdown`])
953/// if the responder is dropped without sending a response, so that the client
954/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
955impl std::ops::Drop for NetworkRegistryRemoveResponder {
956    fn drop(&mut self) {
957        self.control_handle.shutdown();
958        // Safety: drops once, never accessed again
959        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
960    }
961}
962
963impl fidl::endpoints::Responder for NetworkRegistryRemoveResponder {
964    type ControlHandle = NetworkRegistryControlHandle;
965
966    fn control_handle(&self) -> &NetworkRegistryControlHandle {
967        &self.control_handle
968    }
969
970    fn drop_without_shutdown(mut self) {
971        // Safety: drops once, never accessed again due to mem::forget
972        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
973        // Prevent Drop from running (which would shut down the channel)
974        std::mem::forget(self);
975    }
976}
977
978impl NetworkRegistryRemoveResponder {
979    /// Sends a response to the FIDL transaction.
980    ///
981    /// Sets the channel to shutdown if an error occurs.
982    pub fn send(
983        self,
984        mut result: Result<(), NetworkRegistryRemoveError>,
985    ) -> Result<(), fidl::Error> {
986        let _result = self.send_raw(result);
987        if _result.is_err() {
988            self.control_handle.shutdown();
989        }
990        self.drop_without_shutdown();
991        _result
992    }
993
994    /// Similar to "send" but does not shutdown the channel if an error occurs.
995    pub fn send_no_shutdown_on_err(
996        self,
997        mut result: Result<(), NetworkRegistryRemoveError>,
998    ) -> Result<(), fidl::Error> {
999        let _result = self.send_raw(result);
1000        self.drop_without_shutdown();
1001        _result
1002    }
1003
1004    fn send_raw(
1005        &self,
1006        mut result: Result<(), NetworkRegistryRemoveError>,
1007    ) -> Result<(), fidl::Error> {
1008        self.control_handle.inner.send::<fidl::encoding::ResultType<
1009            fidl::encoding::EmptyStruct,
1010            NetworkRegistryRemoveError,
1011        >>(
1012            result,
1013            self.tx_id,
1014            0x1302df41dca6379e,
1015            fidl::encoding::DynamicFlags::empty(),
1016        )
1017    }
1018}
1019
1020mod internal {
1021    use super::*;
1022}