fidl_fuchsia_wlan_product_deprecatedconfiguration/
fidl_fuchsia_wlan_product_deprecatedconfiguration.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_wlan_product_deprecatedconfiguration_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeprecatedConfiguratorMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeprecatedConfiguratorMarker {
18    type Proxy = DeprecatedConfiguratorProxy;
19    type RequestStream = DeprecatedConfiguratorRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = DeprecatedConfiguratorSynchronousProxy;
22
23    const DEBUG_NAME: &'static str =
24        "fuchsia.wlan.product.deprecatedconfiguration.DeprecatedConfigurator";
25}
26impl fidl::endpoints::DiscoverableProtocolMarker for DeprecatedConfiguratorMarker {}
27pub type DeprecatedConfiguratorSuggestAccessPointMacAddressResult =
28    Result<(), SuggestMacAddressError>;
29
30pub trait DeprecatedConfiguratorProxyInterface: Send + Sync {
31    type SuggestAccessPointMacAddressResponseFut: std::future::Future<
32            Output = Result<DeprecatedConfiguratorSuggestAccessPointMacAddressResult, fidl::Error>,
33        > + Send;
34    fn r#suggest_access_point_mac_address(
35        &self,
36        mac: &fidl_fuchsia_net::MacAddress,
37    ) -> Self::SuggestAccessPointMacAddressResponseFut;
38}
39#[derive(Debug)]
40#[cfg(target_os = "fuchsia")]
41pub struct DeprecatedConfiguratorSynchronousProxy {
42    client: fidl::client::sync::Client,
43}
44
45#[cfg(target_os = "fuchsia")]
46impl fidl::endpoints::SynchronousProxy for DeprecatedConfiguratorSynchronousProxy {
47    type Proxy = DeprecatedConfiguratorProxy;
48    type Protocol = DeprecatedConfiguratorMarker;
49
50    fn from_channel(inner: fidl::Channel) -> Self {
51        Self::new(inner)
52    }
53
54    fn into_channel(self) -> fidl::Channel {
55        self.client.into_channel()
56    }
57
58    fn as_channel(&self) -> &fidl::Channel {
59        self.client.as_channel()
60    }
61}
62
63#[cfg(target_os = "fuchsia")]
64impl DeprecatedConfiguratorSynchronousProxy {
65    pub fn new(channel: fidl::Channel) -> Self {
66        let protocol_name =
67            <DeprecatedConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
68        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
69    }
70
71    pub fn into_channel(self) -> fidl::Channel {
72        self.client.into_channel()
73    }
74
75    /// Waits until an event arrives and returns it. It is safe for other
76    /// threads to make concurrent requests while waiting for an event.
77    pub fn wait_for_event(
78        &self,
79        deadline: zx::MonotonicInstant,
80    ) -> Result<DeprecatedConfiguratorEvent, fidl::Error> {
81        DeprecatedConfiguratorEvent::decode(self.client.wait_for_event(deadline)?)
82    }
83
84    /// Suggests a MAC address for [`fuchsia.wlan.policy/AccessPointProvider`] to use when creating
85    /// new soft access point interfaces and notifies when the request is complete.
86    pub fn r#suggest_access_point_mac_address(
87        &self,
88        mut mac: &fidl_fuchsia_net::MacAddress,
89        ___deadline: zx::MonotonicInstant,
90    ) -> Result<DeprecatedConfiguratorSuggestAccessPointMacAddressResult, fidl::Error> {
91        let _response = self.client.send_query::<
92            DeprecatedConfiguratorSuggestAccessPointMacAddressRequest,
93            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, SuggestMacAddressError>,
94        >(
95            (mac,),
96            0x4dedf25064024f8c,
97            fidl::encoding::DynamicFlags::empty(),
98            ___deadline,
99        )?;
100        Ok(_response.map(|x| x))
101    }
102}
103
104#[derive(Debug, Clone)]
105pub struct DeprecatedConfiguratorProxy {
106    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
107}
108
109impl fidl::endpoints::Proxy for DeprecatedConfiguratorProxy {
110    type Protocol = DeprecatedConfiguratorMarker;
111
112    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
113        Self::new(inner)
114    }
115
116    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
117        self.client.into_channel().map_err(|client| Self { client })
118    }
119
120    fn as_channel(&self) -> &::fidl::AsyncChannel {
121        self.client.as_channel()
122    }
123}
124
125impl DeprecatedConfiguratorProxy {
126    /// Create a new Proxy for fuchsia.wlan.product.deprecatedconfiguration/DeprecatedConfigurator.
127    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
128        let protocol_name =
129            <DeprecatedConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
130        Self { client: fidl::client::Client::new(channel, protocol_name) }
131    }
132
133    /// Get a Stream of events from the remote end of the protocol.
134    ///
135    /// # Panics
136    ///
137    /// Panics if the event stream was already taken.
138    pub fn take_event_stream(&self) -> DeprecatedConfiguratorEventStream {
139        DeprecatedConfiguratorEventStream { event_receiver: self.client.take_event_receiver() }
140    }
141
142    /// Suggests a MAC address for [`fuchsia.wlan.policy/AccessPointProvider`] to use when creating
143    /// new soft access point interfaces and notifies when the request is complete.
144    pub fn r#suggest_access_point_mac_address(
145        &self,
146        mut mac: &fidl_fuchsia_net::MacAddress,
147    ) -> fidl::client::QueryResponseFut<
148        DeprecatedConfiguratorSuggestAccessPointMacAddressResult,
149        fidl::encoding::DefaultFuchsiaResourceDialect,
150    > {
151        DeprecatedConfiguratorProxyInterface::r#suggest_access_point_mac_address(self, mac)
152    }
153}
154
155impl DeprecatedConfiguratorProxyInterface for DeprecatedConfiguratorProxy {
156    type SuggestAccessPointMacAddressResponseFut = fidl::client::QueryResponseFut<
157        DeprecatedConfiguratorSuggestAccessPointMacAddressResult,
158        fidl::encoding::DefaultFuchsiaResourceDialect,
159    >;
160    fn r#suggest_access_point_mac_address(
161        &self,
162        mut mac: &fidl_fuchsia_net::MacAddress,
163    ) -> Self::SuggestAccessPointMacAddressResponseFut {
164        fn _decode(
165            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
166        ) -> Result<DeprecatedConfiguratorSuggestAccessPointMacAddressResult, fidl::Error> {
167            let _response = fidl::client::decode_transaction_body::<
168                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, SuggestMacAddressError>,
169                fidl::encoding::DefaultFuchsiaResourceDialect,
170                0x4dedf25064024f8c,
171            >(_buf?)?;
172            Ok(_response.map(|x| x))
173        }
174        self.client.send_query_and_decode::<
175            DeprecatedConfiguratorSuggestAccessPointMacAddressRequest,
176            DeprecatedConfiguratorSuggestAccessPointMacAddressResult,
177        >(
178            (mac,),
179            0x4dedf25064024f8c,
180            fidl::encoding::DynamicFlags::empty(),
181            _decode,
182        )
183    }
184}
185
186pub struct DeprecatedConfiguratorEventStream {
187    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
188}
189
190impl std::marker::Unpin for DeprecatedConfiguratorEventStream {}
191
192impl futures::stream::FusedStream for DeprecatedConfiguratorEventStream {
193    fn is_terminated(&self) -> bool {
194        self.event_receiver.is_terminated()
195    }
196}
197
198impl futures::Stream for DeprecatedConfiguratorEventStream {
199    type Item = Result<DeprecatedConfiguratorEvent, fidl::Error>;
200
201    fn poll_next(
202        mut self: std::pin::Pin<&mut Self>,
203        cx: &mut std::task::Context<'_>,
204    ) -> std::task::Poll<Option<Self::Item>> {
205        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
206            &mut self.event_receiver,
207            cx
208        )?) {
209            Some(buf) => std::task::Poll::Ready(Some(DeprecatedConfiguratorEvent::decode(buf))),
210            None => std::task::Poll::Ready(None),
211        }
212    }
213}
214
215#[derive(Debug)]
216pub enum DeprecatedConfiguratorEvent {}
217
218impl DeprecatedConfiguratorEvent {
219    /// Decodes a message buffer as a [`DeprecatedConfiguratorEvent`].
220    fn decode(
221        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
222    ) -> Result<DeprecatedConfiguratorEvent, fidl::Error> {
223        let (bytes, _handles) = buf.split_mut();
224        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
225        debug_assert_eq!(tx_header.tx_id, 0);
226        match tx_header.ordinal {
227            _ => Err(fidl::Error::UnknownOrdinal {
228                ordinal: tx_header.ordinal,
229                protocol_name:
230                    <DeprecatedConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
231            }),
232        }
233    }
234}
235
236/// A Stream of incoming requests for fuchsia.wlan.product.deprecatedconfiguration/DeprecatedConfigurator.
237pub struct DeprecatedConfiguratorRequestStream {
238    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
239    is_terminated: bool,
240}
241
242impl std::marker::Unpin for DeprecatedConfiguratorRequestStream {}
243
244impl futures::stream::FusedStream for DeprecatedConfiguratorRequestStream {
245    fn is_terminated(&self) -> bool {
246        self.is_terminated
247    }
248}
249
250impl fidl::endpoints::RequestStream for DeprecatedConfiguratorRequestStream {
251    type Protocol = DeprecatedConfiguratorMarker;
252    type ControlHandle = DeprecatedConfiguratorControlHandle;
253
254    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
255        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
256    }
257
258    fn control_handle(&self) -> Self::ControlHandle {
259        DeprecatedConfiguratorControlHandle { inner: self.inner.clone() }
260    }
261
262    fn into_inner(
263        self,
264    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
265    {
266        (self.inner, self.is_terminated)
267    }
268
269    fn from_inner(
270        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
271        is_terminated: bool,
272    ) -> Self {
273        Self { inner, is_terminated }
274    }
275}
276
277impl futures::Stream for DeprecatedConfiguratorRequestStream {
278    type Item = Result<DeprecatedConfiguratorRequest, fidl::Error>;
279
280    fn poll_next(
281        mut self: std::pin::Pin<&mut Self>,
282        cx: &mut std::task::Context<'_>,
283    ) -> std::task::Poll<Option<Self::Item>> {
284        let this = &mut *self;
285        if this.inner.check_shutdown(cx) {
286            this.is_terminated = true;
287            return std::task::Poll::Ready(None);
288        }
289        if this.is_terminated {
290            panic!("polled DeprecatedConfiguratorRequestStream after completion");
291        }
292        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
293            |bytes, handles| {
294                match this.inner.channel().read_etc(cx, bytes, handles) {
295                    std::task::Poll::Ready(Ok(())) => {}
296                    std::task::Poll::Pending => return std::task::Poll::Pending,
297                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
298                        this.is_terminated = true;
299                        return std::task::Poll::Ready(None);
300                    }
301                    std::task::Poll::Ready(Err(e)) => {
302                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
303                            e.into(),
304                        ))))
305                    }
306                }
307
308                // A message has been received from the channel
309                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
310
311                std::task::Poll::Ready(Some(match header.ordinal {
312                0x4dedf25064024f8c => {
313                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
314                    let mut req = fidl::new_empty!(DeprecatedConfiguratorSuggestAccessPointMacAddressRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
315                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeprecatedConfiguratorSuggestAccessPointMacAddressRequest>(&header, _body_bytes, handles, &mut req)?;
316                    let control_handle = DeprecatedConfiguratorControlHandle {
317                        inner: this.inner.clone(),
318                    };
319                    Ok(DeprecatedConfiguratorRequest::SuggestAccessPointMacAddress {mac: req.mac,
320
321                        responder: DeprecatedConfiguratorSuggestAccessPointMacAddressResponder {
322                            control_handle: std::mem::ManuallyDrop::new(control_handle),
323                            tx_id: header.tx_id,
324                        },
325                    })
326                }
327                _ => Err(fidl::Error::UnknownOrdinal {
328                    ordinal: header.ordinal,
329                    protocol_name: <DeprecatedConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
330                }),
331            }))
332            },
333        )
334    }
335}
336
337/// Allows for the configuration of WLAN devices to support legacy applications.
338#[derive(Debug)]
339pub enum DeprecatedConfiguratorRequest {
340    /// Suggests a MAC address for [`fuchsia.wlan.policy/AccessPointProvider`] to use when creating
341    /// new soft access point interfaces and notifies when the request is complete.
342    SuggestAccessPointMacAddress {
343        mac: fidl_fuchsia_net::MacAddress,
344        responder: DeprecatedConfiguratorSuggestAccessPointMacAddressResponder,
345    },
346}
347
348impl DeprecatedConfiguratorRequest {
349    #[allow(irrefutable_let_patterns)]
350    pub fn into_suggest_access_point_mac_address(
351        self,
352    ) -> Option<(
353        fidl_fuchsia_net::MacAddress,
354        DeprecatedConfiguratorSuggestAccessPointMacAddressResponder,
355    )> {
356        if let DeprecatedConfiguratorRequest::SuggestAccessPointMacAddress { mac, responder } = self
357        {
358            Some((mac, responder))
359        } else {
360            None
361        }
362    }
363
364    /// Name of the method defined in FIDL
365    pub fn method_name(&self) -> &'static str {
366        match *self {
367            DeprecatedConfiguratorRequest::SuggestAccessPointMacAddress { .. } => {
368                "suggest_access_point_mac_address"
369            }
370        }
371    }
372}
373
374#[derive(Debug, Clone)]
375pub struct DeprecatedConfiguratorControlHandle {
376    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
377}
378
379impl fidl::endpoints::ControlHandle for DeprecatedConfiguratorControlHandle {
380    fn shutdown(&self) {
381        self.inner.shutdown()
382    }
383    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
384        self.inner.shutdown_with_epitaph(status)
385    }
386
387    fn is_closed(&self) -> bool {
388        self.inner.channel().is_closed()
389    }
390    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
391        self.inner.channel().on_closed()
392    }
393
394    #[cfg(target_os = "fuchsia")]
395    fn signal_peer(
396        &self,
397        clear_mask: zx::Signals,
398        set_mask: zx::Signals,
399    ) -> Result<(), zx_status::Status> {
400        use fidl::Peered;
401        self.inner.channel().signal_peer(clear_mask, set_mask)
402    }
403}
404
405impl DeprecatedConfiguratorControlHandle {}
406
407#[must_use = "FIDL methods require a response to be sent"]
408#[derive(Debug)]
409pub struct DeprecatedConfiguratorSuggestAccessPointMacAddressResponder {
410    control_handle: std::mem::ManuallyDrop<DeprecatedConfiguratorControlHandle>,
411    tx_id: u32,
412}
413
414/// Set the the channel to be shutdown (see [`DeprecatedConfiguratorControlHandle::shutdown`])
415/// if the responder is dropped without sending a response, so that the client
416/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
417impl std::ops::Drop for DeprecatedConfiguratorSuggestAccessPointMacAddressResponder {
418    fn drop(&mut self) {
419        self.control_handle.shutdown();
420        // Safety: drops once, never accessed again
421        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
422    }
423}
424
425impl fidl::endpoints::Responder for DeprecatedConfiguratorSuggestAccessPointMacAddressResponder {
426    type ControlHandle = DeprecatedConfiguratorControlHandle;
427
428    fn control_handle(&self) -> &DeprecatedConfiguratorControlHandle {
429        &self.control_handle
430    }
431
432    fn drop_without_shutdown(mut self) {
433        // Safety: drops once, never accessed again due to mem::forget
434        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
435        // Prevent Drop from running (which would shut down the channel)
436        std::mem::forget(self);
437    }
438}
439
440impl DeprecatedConfiguratorSuggestAccessPointMacAddressResponder {
441    /// Sends a response to the FIDL transaction.
442    ///
443    /// Sets the channel to shutdown if an error occurs.
444    pub fn send(self, mut result: Result<(), SuggestMacAddressError>) -> Result<(), fidl::Error> {
445        let _result = self.send_raw(result);
446        if _result.is_err() {
447            self.control_handle.shutdown();
448        }
449        self.drop_without_shutdown();
450        _result
451    }
452
453    /// Similar to "send" but does not shutdown the channel if an error occurs.
454    pub fn send_no_shutdown_on_err(
455        self,
456        mut result: Result<(), SuggestMacAddressError>,
457    ) -> Result<(), fidl::Error> {
458        let _result = self.send_raw(result);
459        self.drop_without_shutdown();
460        _result
461    }
462
463    fn send_raw(&self, mut result: Result<(), SuggestMacAddressError>) -> Result<(), fidl::Error> {
464        self.control_handle.inner.send::<fidl::encoding::ResultType<
465            fidl::encoding::EmptyStruct,
466            SuggestMacAddressError,
467        >>(
468            result,
469            self.tx_id,
470            0x4dedf25064024f8c,
471            fidl::encoding::DynamicFlags::empty(),
472        )
473    }
474}
475
476mod internal {
477    use super::*;
478}