Skip to main content

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