fidl_fuchsia_location_namedplace/
fidl_fuchsia_location_namedplace.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_location_namedplace__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct RegulatoryRegionConfiguratorMarker;
16
17impl fidl::endpoints::ProtocolMarker for RegulatoryRegionConfiguratorMarker {
18    type Proxy = RegulatoryRegionConfiguratorProxy;
19    type RequestStream = RegulatoryRegionConfiguratorRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = RegulatoryRegionConfiguratorSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.location.namedplace.RegulatoryRegionConfigurator";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for RegulatoryRegionConfiguratorMarker {}
26
27pub trait RegulatoryRegionConfiguratorProxyInterface: Send + Sync {
28    fn r#set_region(&self, region: &str) -> Result<(), fidl::Error>;
29}
30#[derive(Debug)]
31#[cfg(target_os = "fuchsia")]
32pub struct RegulatoryRegionConfiguratorSynchronousProxy {
33    client: fidl::client::sync::Client,
34}
35
36#[cfg(target_os = "fuchsia")]
37impl fidl::endpoints::SynchronousProxy for RegulatoryRegionConfiguratorSynchronousProxy {
38    type Proxy = RegulatoryRegionConfiguratorProxy;
39    type Protocol = RegulatoryRegionConfiguratorMarker;
40
41    fn from_channel(inner: fidl::Channel) -> Self {
42        Self::new(inner)
43    }
44
45    fn into_channel(self) -> fidl::Channel {
46        self.client.into_channel()
47    }
48
49    fn as_channel(&self) -> &fidl::Channel {
50        self.client.as_channel()
51    }
52}
53
54#[cfg(target_os = "fuchsia")]
55impl RegulatoryRegionConfiguratorSynchronousProxy {
56    pub fn new(channel: fidl::Channel) -> Self {
57        let protocol_name =
58            <RegulatoryRegionConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
59        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
60    }
61
62    pub fn into_channel(self) -> fidl::Channel {
63        self.client.into_channel()
64    }
65
66    /// Waits until an event arrives and returns it. It is safe for other
67    /// threads to make concurrent requests while waiting for an event.
68    pub fn wait_for_event(
69        &self,
70        deadline: zx::MonotonicInstant,
71    ) -> Result<RegulatoryRegionConfiguratorEvent, fidl::Error> {
72        RegulatoryRegionConfiguratorEvent::decode(self.client.wait_for_event(deadline)?)
73    }
74
75    /// Sets the region.
76    ///
77    /// Clients should take care that their calls to this API arrive in a
78    /// well-defined order. For example, when using Zircon channels as the
79    /// underlying transport, the code below may not behave as intended.
80    ///
81    /// ```c++
82    /// // DANGER: The service may receive "BB" before "AA".
83    /// service1 = Open(RegulatoryRegionConfigurator);
84    /// service1.SetRegion("AA");
85    /// service1.Close();
86    /// service2 = Open(RegulatoryRegionConfigurator);
87    /// service2.SetRegion("BB");
88    /// service2.Close();
89    /// ```
90    ///
91    /// A client can avoid this problem by holding a single channel open to
92    /// the service, for the lifetime of the client.
93    ///
94    /// ```c++
95    /// // We use a single channel to ensure that calls arrive in a
96    /// // well-defined order.
97    /// service = Open(RegulatoryRegionConfigurator);
98    /// service.SetRegion("AA");
99    /// service.SetRegion("BB");
100    /// ```
101    ///
102    /// + request `region` the current regulatory region.
103    pub fn r#set_region(&self, mut region: &str) -> Result<(), fidl::Error> {
104        self.client.send::<RegulatoryRegionConfiguratorSetRegionRequest>(
105            (region,),
106            0x677e15debe2d6910,
107            fidl::encoding::DynamicFlags::empty(),
108        )
109    }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<RegulatoryRegionConfiguratorSynchronousProxy> for zx::NullableHandle {
114    fn from(value: RegulatoryRegionConfiguratorSynchronousProxy) -> Self {
115        value.into_channel().into()
116    }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<fidl::Channel> for RegulatoryRegionConfiguratorSynchronousProxy {
121    fn from(value: fidl::Channel) -> Self {
122        Self::new(value)
123    }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl fidl::endpoints::FromClient for RegulatoryRegionConfiguratorSynchronousProxy {
128    type Protocol = RegulatoryRegionConfiguratorMarker;
129
130    fn from_client(value: fidl::endpoints::ClientEnd<RegulatoryRegionConfiguratorMarker>) -> Self {
131        Self::new(value.into_channel())
132    }
133}
134
135#[derive(Debug, Clone)]
136pub struct RegulatoryRegionConfiguratorProxy {
137    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
138}
139
140impl fidl::endpoints::Proxy for RegulatoryRegionConfiguratorProxy {
141    type Protocol = RegulatoryRegionConfiguratorMarker;
142
143    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
144        Self::new(inner)
145    }
146
147    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
148        self.client.into_channel().map_err(|client| Self { client })
149    }
150
151    fn as_channel(&self) -> &::fidl::AsyncChannel {
152        self.client.as_channel()
153    }
154}
155
156impl RegulatoryRegionConfiguratorProxy {
157    /// Create a new Proxy for fuchsia.location.namedplace/RegulatoryRegionConfigurator.
158    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
159        let protocol_name =
160            <RegulatoryRegionConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
161        Self { client: fidl::client::Client::new(channel, protocol_name) }
162    }
163
164    /// Get a Stream of events from the remote end of the protocol.
165    ///
166    /// # Panics
167    ///
168    /// Panics if the event stream was already taken.
169    pub fn take_event_stream(&self) -> RegulatoryRegionConfiguratorEventStream {
170        RegulatoryRegionConfiguratorEventStream {
171            event_receiver: self.client.take_event_receiver(),
172        }
173    }
174
175    /// Sets the region.
176    ///
177    /// Clients should take care that their calls to this API arrive in a
178    /// well-defined order. For example, when using Zircon channels as the
179    /// underlying transport, the code below may not behave as intended.
180    ///
181    /// ```c++
182    /// // DANGER: The service may receive "BB" before "AA".
183    /// service1 = Open(RegulatoryRegionConfigurator);
184    /// service1.SetRegion("AA");
185    /// service1.Close();
186    /// service2 = Open(RegulatoryRegionConfigurator);
187    /// service2.SetRegion("BB");
188    /// service2.Close();
189    /// ```
190    ///
191    /// A client can avoid this problem by holding a single channel open to
192    /// the service, for the lifetime of the client.
193    ///
194    /// ```c++
195    /// // We use a single channel to ensure that calls arrive in a
196    /// // well-defined order.
197    /// service = Open(RegulatoryRegionConfigurator);
198    /// service.SetRegion("AA");
199    /// service.SetRegion("BB");
200    /// ```
201    ///
202    /// + request `region` the current regulatory region.
203    pub fn r#set_region(&self, mut region: &str) -> Result<(), fidl::Error> {
204        RegulatoryRegionConfiguratorProxyInterface::r#set_region(self, region)
205    }
206}
207
208impl RegulatoryRegionConfiguratorProxyInterface for RegulatoryRegionConfiguratorProxy {
209    fn r#set_region(&self, mut region: &str) -> Result<(), fidl::Error> {
210        self.client.send::<RegulatoryRegionConfiguratorSetRegionRequest>(
211            (region,),
212            0x677e15debe2d6910,
213            fidl::encoding::DynamicFlags::empty(),
214        )
215    }
216}
217
218pub struct RegulatoryRegionConfiguratorEventStream {
219    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
220}
221
222impl std::marker::Unpin for RegulatoryRegionConfiguratorEventStream {}
223
224impl futures::stream::FusedStream for RegulatoryRegionConfiguratorEventStream {
225    fn is_terminated(&self) -> bool {
226        self.event_receiver.is_terminated()
227    }
228}
229
230impl futures::Stream for RegulatoryRegionConfiguratorEventStream {
231    type Item = Result<RegulatoryRegionConfiguratorEvent, fidl::Error>;
232
233    fn poll_next(
234        mut self: std::pin::Pin<&mut Self>,
235        cx: &mut std::task::Context<'_>,
236    ) -> std::task::Poll<Option<Self::Item>> {
237        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
238            &mut self.event_receiver,
239            cx
240        )?) {
241            Some(buf) => {
242                std::task::Poll::Ready(Some(RegulatoryRegionConfiguratorEvent::decode(buf)))
243            }
244            None => std::task::Poll::Ready(None),
245        }
246    }
247}
248
249#[derive(Debug)]
250pub enum RegulatoryRegionConfiguratorEvent {}
251
252impl RegulatoryRegionConfiguratorEvent {
253    /// Decodes a message buffer as a [`RegulatoryRegionConfiguratorEvent`].
254    fn decode(
255        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
256    ) -> Result<RegulatoryRegionConfiguratorEvent, fidl::Error> {
257        let (bytes, _handles) = buf.split_mut();
258        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
259        debug_assert_eq!(tx_header.tx_id, 0);
260        match tx_header.ordinal {
261            _ => Err(fidl::Error::UnknownOrdinal {
262                ordinal: tx_header.ordinal,
263                protocol_name: <RegulatoryRegionConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
264            })
265        }
266    }
267}
268
269/// A Stream of incoming requests for fuchsia.location.namedplace/RegulatoryRegionConfigurator.
270pub struct RegulatoryRegionConfiguratorRequestStream {
271    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
272    is_terminated: bool,
273}
274
275impl std::marker::Unpin for RegulatoryRegionConfiguratorRequestStream {}
276
277impl futures::stream::FusedStream for RegulatoryRegionConfiguratorRequestStream {
278    fn is_terminated(&self) -> bool {
279        self.is_terminated
280    }
281}
282
283impl fidl::endpoints::RequestStream for RegulatoryRegionConfiguratorRequestStream {
284    type Protocol = RegulatoryRegionConfiguratorMarker;
285    type ControlHandle = RegulatoryRegionConfiguratorControlHandle;
286
287    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
288        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
289    }
290
291    fn control_handle(&self) -> Self::ControlHandle {
292        RegulatoryRegionConfiguratorControlHandle { inner: self.inner.clone() }
293    }
294
295    fn into_inner(
296        self,
297    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
298    {
299        (self.inner, self.is_terminated)
300    }
301
302    fn from_inner(
303        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
304        is_terminated: bool,
305    ) -> Self {
306        Self { inner, is_terminated }
307    }
308}
309
310impl futures::Stream for RegulatoryRegionConfiguratorRequestStream {
311    type Item = Result<RegulatoryRegionConfiguratorRequest, fidl::Error>;
312
313    fn poll_next(
314        mut self: std::pin::Pin<&mut Self>,
315        cx: &mut std::task::Context<'_>,
316    ) -> std::task::Poll<Option<Self::Item>> {
317        let this = &mut *self;
318        if this.inner.check_shutdown(cx) {
319            this.is_terminated = true;
320            return std::task::Poll::Ready(None);
321        }
322        if this.is_terminated {
323            panic!("polled RegulatoryRegionConfiguratorRequestStream after completion");
324        }
325        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
326            |bytes, handles| {
327                match this.inner.channel().read_etc(cx, bytes, handles) {
328                    std::task::Poll::Ready(Ok(())) => {}
329                    std::task::Poll::Pending => return std::task::Poll::Pending,
330                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
331                        this.is_terminated = true;
332                        return std::task::Poll::Ready(None);
333                    }
334                    std::task::Poll::Ready(Err(e)) => {
335                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
336                            e.into(),
337                        ))));
338                    }
339                }
340
341                // A message has been received from the channel
342                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
343
344                std::task::Poll::Ready(Some(match header.ordinal {
345                0x677e15debe2d6910 => {
346                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
347                    let mut req = fidl::new_empty!(RegulatoryRegionConfiguratorSetRegionRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
348                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegulatoryRegionConfiguratorSetRegionRequest>(&header, _body_bytes, handles, &mut req)?;
349                    let control_handle = RegulatoryRegionConfiguratorControlHandle {
350                        inner: this.inner.clone(),
351                    };
352                    Ok(RegulatoryRegionConfiguratorRequest::SetRegion {region: req.region,
353
354                        control_handle,
355                    })
356                }
357                _ => Err(fidl::Error::UnknownOrdinal {
358                    ordinal: header.ordinal,
359                    protocol_name: <RegulatoryRegionConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
360                }),
361            }))
362            },
363        )
364    }
365}
366
367/// The RegulatoryRegionConfigurator protocol provides mechanisms to
368/// inform Location Services of the inputs that should be used to
369/// determine the regulatory region whose rules should govern the
370/// operation of radios on the system.
371#[derive(Debug)]
372pub enum RegulatoryRegionConfiguratorRequest {
373    /// Sets the region.
374    ///
375    /// Clients should take care that their calls to this API arrive in a
376    /// well-defined order. For example, when using Zircon channels as the
377    /// underlying transport, the code below may not behave as intended.
378    ///
379    /// ```c++
380    /// // DANGER: The service may receive "BB" before "AA".
381    /// service1 = Open(RegulatoryRegionConfigurator);
382    /// service1.SetRegion("AA");
383    /// service1.Close();
384    /// service2 = Open(RegulatoryRegionConfigurator);
385    /// service2.SetRegion("BB");
386    /// service2.Close();
387    /// ```
388    ///
389    /// A client can avoid this problem by holding a single channel open to
390    /// the service, for the lifetime of the client.
391    ///
392    /// ```c++
393    /// // We use a single channel to ensure that calls arrive in a
394    /// // well-defined order.
395    /// service = Open(RegulatoryRegionConfigurator);
396    /// service.SetRegion("AA");
397    /// service.SetRegion("BB");
398    /// ```
399    ///
400    /// + request `region` the current regulatory region.
401    SetRegion { region: String, control_handle: RegulatoryRegionConfiguratorControlHandle },
402}
403
404impl RegulatoryRegionConfiguratorRequest {
405    #[allow(irrefutable_let_patterns)]
406    pub fn into_set_region(self) -> Option<(String, RegulatoryRegionConfiguratorControlHandle)> {
407        if let RegulatoryRegionConfiguratorRequest::SetRegion { region, control_handle } = self {
408            Some((region, control_handle))
409        } else {
410            None
411        }
412    }
413
414    /// Name of the method defined in FIDL
415    pub fn method_name(&self) -> &'static str {
416        match *self {
417            RegulatoryRegionConfiguratorRequest::SetRegion { .. } => "set_region",
418        }
419    }
420}
421
422#[derive(Debug, Clone)]
423pub struct RegulatoryRegionConfiguratorControlHandle {
424    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
425}
426
427impl fidl::endpoints::ControlHandle for RegulatoryRegionConfiguratorControlHandle {
428    fn shutdown(&self) {
429        self.inner.shutdown()
430    }
431
432    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
433        self.inner.shutdown_with_epitaph(status)
434    }
435
436    fn is_closed(&self) -> bool {
437        self.inner.channel().is_closed()
438    }
439    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
440        self.inner.channel().on_closed()
441    }
442
443    #[cfg(target_os = "fuchsia")]
444    fn signal_peer(
445        &self,
446        clear_mask: zx::Signals,
447        set_mask: zx::Signals,
448    ) -> Result<(), zx_status::Status> {
449        use fidl::Peered;
450        self.inner.channel().signal_peer(clear_mask, set_mask)
451    }
452}
453
454impl RegulatoryRegionConfiguratorControlHandle {}
455
456#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
457pub struct RegulatoryRegionWatcherMarker;
458
459impl fidl::endpoints::ProtocolMarker for RegulatoryRegionWatcherMarker {
460    type Proxy = RegulatoryRegionWatcherProxy;
461    type RequestStream = RegulatoryRegionWatcherRequestStream;
462    #[cfg(target_os = "fuchsia")]
463    type SynchronousProxy = RegulatoryRegionWatcherSynchronousProxy;
464
465    const DEBUG_NAME: &'static str = "fuchsia.location.namedplace.RegulatoryRegionWatcher";
466}
467impl fidl::endpoints::DiscoverableProtocolMarker for RegulatoryRegionWatcherMarker {}
468
469pub trait RegulatoryRegionWatcherProxyInterface: Send + Sync {
470    type GetUpdateResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
471    fn r#get_update(&self) -> Self::GetUpdateResponseFut;
472    type GetRegionUpdateResponseFut: std::future::Future<Output = Result<Option<String>, fidl::Error>>
473        + Send;
474    fn r#get_region_update(&self) -> Self::GetRegionUpdateResponseFut;
475}
476#[derive(Debug)]
477#[cfg(target_os = "fuchsia")]
478pub struct RegulatoryRegionWatcherSynchronousProxy {
479    client: fidl::client::sync::Client,
480}
481
482#[cfg(target_os = "fuchsia")]
483impl fidl::endpoints::SynchronousProxy for RegulatoryRegionWatcherSynchronousProxy {
484    type Proxy = RegulatoryRegionWatcherProxy;
485    type Protocol = RegulatoryRegionWatcherMarker;
486
487    fn from_channel(inner: fidl::Channel) -> Self {
488        Self::new(inner)
489    }
490
491    fn into_channel(self) -> fidl::Channel {
492        self.client.into_channel()
493    }
494
495    fn as_channel(&self) -> &fidl::Channel {
496        self.client.as_channel()
497    }
498}
499
500#[cfg(target_os = "fuchsia")]
501impl RegulatoryRegionWatcherSynchronousProxy {
502    pub fn new(channel: fidl::Channel) -> Self {
503        let protocol_name =
504            <RegulatoryRegionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
505        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
506    }
507
508    pub fn into_channel(self) -> fidl::Channel {
509        self.client.into_channel()
510    }
511
512    /// Waits until an event arrives and returns it. It is safe for other
513    /// threads to make concurrent requests while waiting for an event.
514    pub fn wait_for_event(
515        &self,
516        deadline: zx::MonotonicInstant,
517    ) -> Result<RegulatoryRegionWatcherEvent, fidl::Error> {
518        RegulatoryRegionWatcherEvent::decode(self.client.wait_for_event(deadline)?)
519    }
520
521    /// This call is deprecated. Use GetRegionUpdate instead.
522    ///
523    /// Returns the new RegionCode, when it changes.
524    ///
525    /// Notes:
526    /// * The first call returns immediately, if the region is already known.
527    /// * The client is _not_ guaranteed to observe the effects of every call
528    ///   to `SetRegion()`.
529    /// * The client can, however, achieve _eventual_ consistency by always
530    ///   issuing a new request when a request completes.
531    /// * Clients should _not_ issue concurrent requests to this method.
532    ///   * At present, concurrent requests
533    ///     * May yield the same value, or different values.
534    ///     * May complete out-of-order.
535    ///   * In the future, concurrent requests will cause the channel to be
536    ///     closed with `ZX_ERR_BAD_STATE`.
537    ///
538    /// - response `new_region` the current regulatory region.
539    pub fn r#get_update(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
540        let _response = self
541            .client
542            .send_query::<fidl::encoding::EmptyPayload, RegulatoryRegionWatcherGetUpdateResponse>(
543                (),
544                0xaf6dec156c31687,
545                fidl::encoding::DynamicFlags::empty(),
546                ___deadline,
547            )?;
548        Ok(_response.new_region)
549    }
550
551    /// Returns the new RegionCode, when it changes.
552    ///
553    /// Notes:
554    /// * The first call returns immediately.
555    /// * The client is _not_ guaranteed to observe the effects of every call
556    ///   to `SetRegion()`.
557    /// * The client can, however, achieve _eventual_ consistency by always
558    ///   issuing a new request when a request completes.
559    /// * Clients should _not_ issue concurrent requests to this method.
560    ///   * At present, concurrent requests
561    ///     * May yield the same value, or different values.
562    ///     * May complete out-of-order.
563    ///   * In the future, concurrent requests will cause the channel to be
564    ///     closed with `ZX_ERR_BAD_STATE`.
565    ///
566    /// - response `new_region` the current regulatory region.
567    pub fn r#get_region_update(
568        &self,
569        ___deadline: zx::MonotonicInstant,
570    ) -> Result<Option<String>, fidl::Error> {
571        let _response = self.client.send_query::<
572            fidl::encoding::EmptyPayload,
573            RegulatoryRegionWatcherGetRegionUpdateResponse,
574        >(
575            (),
576            0x28c47004aed3ff0d,
577            fidl::encoding::DynamicFlags::empty(),
578            ___deadline,
579        )?;
580        Ok(_response.new_region)
581    }
582}
583
584#[cfg(target_os = "fuchsia")]
585impl From<RegulatoryRegionWatcherSynchronousProxy> for zx::NullableHandle {
586    fn from(value: RegulatoryRegionWatcherSynchronousProxy) -> Self {
587        value.into_channel().into()
588    }
589}
590
591#[cfg(target_os = "fuchsia")]
592impl From<fidl::Channel> for RegulatoryRegionWatcherSynchronousProxy {
593    fn from(value: fidl::Channel) -> Self {
594        Self::new(value)
595    }
596}
597
598#[cfg(target_os = "fuchsia")]
599impl fidl::endpoints::FromClient for RegulatoryRegionWatcherSynchronousProxy {
600    type Protocol = RegulatoryRegionWatcherMarker;
601
602    fn from_client(value: fidl::endpoints::ClientEnd<RegulatoryRegionWatcherMarker>) -> Self {
603        Self::new(value.into_channel())
604    }
605}
606
607#[derive(Debug, Clone)]
608pub struct RegulatoryRegionWatcherProxy {
609    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
610}
611
612impl fidl::endpoints::Proxy for RegulatoryRegionWatcherProxy {
613    type Protocol = RegulatoryRegionWatcherMarker;
614
615    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
616        Self::new(inner)
617    }
618
619    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
620        self.client.into_channel().map_err(|client| Self { client })
621    }
622
623    fn as_channel(&self) -> &::fidl::AsyncChannel {
624        self.client.as_channel()
625    }
626}
627
628impl RegulatoryRegionWatcherProxy {
629    /// Create a new Proxy for fuchsia.location.namedplace/RegulatoryRegionWatcher.
630    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
631        let protocol_name =
632            <RegulatoryRegionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
633        Self { client: fidl::client::Client::new(channel, protocol_name) }
634    }
635
636    /// Get a Stream of events from the remote end of the protocol.
637    ///
638    /// # Panics
639    ///
640    /// Panics if the event stream was already taken.
641    pub fn take_event_stream(&self) -> RegulatoryRegionWatcherEventStream {
642        RegulatoryRegionWatcherEventStream { event_receiver: self.client.take_event_receiver() }
643    }
644
645    /// This call is deprecated. Use GetRegionUpdate instead.
646    ///
647    /// Returns the new RegionCode, when it changes.
648    ///
649    /// Notes:
650    /// * The first call returns immediately, if the region is already known.
651    /// * The client is _not_ guaranteed to observe the effects of every call
652    ///   to `SetRegion()`.
653    /// * The client can, however, achieve _eventual_ consistency by always
654    ///   issuing a new request when a request completes.
655    /// * Clients should _not_ issue concurrent requests to this method.
656    ///   * At present, concurrent requests
657    ///     * May yield the same value, or different values.
658    ///     * May complete out-of-order.
659    ///   * In the future, concurrent requests will cause the channel to be
660    ///     closed with `ZX_ERR_BAD_STATE`.
661    ///
662    /// - response `new_region` the current regulatory region.
663    pub fn r#get_update(
664        &self,
665    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
666        RegulatoryRegionWatcherProxyInterface::r#get_update(self)
667    }
668
669    /// Returns the new RegionCode, when it changes.
670    ///
671    /// Notes:
672    /// * The first call returns immediately.
673    /// * The client is _not_ guaranteed to observe the effects of every call
674    ///   to `SetRegion()`.
675    /// * The client can, however, achieve _eventual_ consistency by always
676    ///   issuing a new request when a request completes.
677    /// * Clients should _not_ issue concurrent requests to this method.
678    ///   * At present, concurrent requests
679    ///     * May yield the same value, or different values.
680    ///     * May complete out-of-order.
681    ///   * In the future, concurrent requests will cause the channel to be
682    ///     closed with `ZX_ERR_BAD_STATE`.
683    ///
684    /// - response `new_region` the current regulatory region.
685    pub fn r#get_region_update(
686        &self,
687    ) -> fidl::client::QueryResponseFut<Option<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
688    {
689        RegulatoryRegionWatcherProxyInterface::r#get_region_update(self)
690    }
691}
692
693impl RegulatoryRegionWatcherProxyInterface for RegulatoryRegionWatcherProxy {
694    type GetUpdateResponseFut =
695        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
696    fn r#get_update(&self) -> Self::GetUpdateResponseFut {
697        fn _decode(
698            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
699        ) -> Result<String, fidl::Error> {
700            let _response = fidl::client::decode_transaction_body::<
701                RegulatoryRegionWatcherGetUpdateResponse,
702                fidl::encoding::DefaultFuchsiaResourceDialect,
703                0xaf6dec156c31687,
704            >(_buf?)?;
705            Ok(_response.new_region)
706        }
707        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
708            (),
709            0xaf6dec156c31687,
710            fidl::encoding::DynamicFlags::empty(),
711            _decode,
712        )
713    }
714
715    type GetRegionUpdateResponseFut = fidl::client::QueryResponseFut<
716        Option<String>,
717        fidl::encoding::DefaultFuchsiaResourceDialect,
718    >;
719    fn r#get_region_update(&self) -> Self::GetRegionUpdateResponseFut {
720        fn _decode(
721            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
722        ) -> Result<Option<String>, fidl::Error> {
723            let _response = fidl::client::decode_transaction_body::<
724                RegulatoryRegionWatcherGetRegionUpdateResponse,
725                fidl::encoding::DefaultFuchsiaResourceDialect,
726                0x28c47004aed3ff0d,
727            >(_buf?)?;
728            Ok(_response.new_region)
729        }
730        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Option<String>>(
731            (),
732            0x28c47004aed3ff0d,
733            fidl::encoding::DynamicFlags::empty(),
734            _decode,
735        )
736    }
737}
738
739pub struct RegulatoryRegionWatcherEventStream {
740    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
741}
742
743impl std::marker::Unpin for RegulatoryRegionWatcherEventStream {}
744
745impl futures::stream::FusedStream for RegulatoryRegionWatcherEventStream {
746    fn is_terminated(&self) -> bool {
747        self.event_receiver.is_terminated()
748    }
749}
750
751impl futures::Stream for RegulatoryRegionWatcherEventStream {
752    type Item = Result<RegulatoryRegionWatcherEvent, fidl::Error>;
753
754    fn poll_next(
755        mut self: std::pin::Pin<&mut Self>,
756        cx: &mut std::task::Context<'_>,
757    ) -> std::task::Poll<Option<Self::Item>> {
758        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
759            &mut self.event_receiver,
760            cx
761        )?) {
762            Some(buf) => std::task::Poll::Ready(Some(RegulatoryRegionWatcherEvent::decode(buf))),
763            None => std::task::Poll::Ready(None),
764        }
765    }
766}
767
768#[derive(Debug)]
769pub enum RegulatoryRegionWatcherEvent {}
770
771impl RegulatoryRegionWatcherEvent {
772    /// Decodes a message buffer as a [`RegulatoryRegionWatcherEvent`].
773    fn decode(
774        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
775    ) -> Result<RegulatoryRegionWatcherEvent, fidl::Error> {
776        let (bytes, _handles) = buf.split_mut();
777        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
778        debug_assert_eq!(tx_header.tx_id, 0);
779        match tx_header.ordinal {
780            _ => Err(fidl::Error::UnknownOrdinal {
781                ordinal: tx_header.ordinal,
782                protocol_name:
783                    <RegulatoryRegionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
784            }),
785        }
786    }
787}
788
789/// A Stream of incoming requests for fuchsia.location.namedplace/RegulatoryRegionWatcher.
790pub struct RegulatoryRegionWatcherRequestStream {
791    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
792    is_terminated: bool,
793}
794
795impl std::marker::Unpin for RegulatoryRegionWatcherRequestStream {}
796
797impl futures::stream::FusedStream for RegulatoryRegionWatcherRequestStream {
798    fn is_terminated(&self) -> bool {
799        self.is_terminated
800    }
801}
802
803impl fidl::endpoints::RequestStream for RegulatoryRegionWatcherRequestStream {
804    type Protocol = RegulatoryRegionWatcherMarker;
805    type ControlHandle = RegulatoryRegionWatcherControlHandle;
806
807    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
808        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
809    }
810
811    fn control_handle(&self) -> Self::ControlHandle {
812        RegulatoryRegionWatcherControlHandle { inner: self.inner.clone() }
813    }
814
815    fn into_inner(
816        self,
817    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
818    {
819        (self.inner, self.is_terminated)
820    }
821
822    fn from_inner(
823        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
824        is_terminated: bool,
825    ) -> Self {
826        Self { inner, is_terminated }
827    }
828}
829
830impl futures::Stream for RegulatoryRegionWatcherRequestStream {
831    type Item = Result<RegulatoryRegionWatcherRequest, fidl::Error>;
832
833    fn poll_next(
834        mut self: std::pin::Pin<&mut Self>,
835        cx: &mut std::task::Context<'_>,
836    ) -> std::task::Poll<Option<Self::Item>> {
837        let this = &mut *self;
838        if this.inner.check_shutdown(cx) {
839            this.is_terminated = true;
840            return std::task::Poll::Ready(None);
841        }
842        if this.is_terminated {
843            panic!("polled RegulatoryRegionWatcherRequestStream after completion");
844        }
845        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
846            |bytes, handles| {
847                match this.inner.channel().read_etc(cx, bytes, handles) {
848                    std::task::Poll::Ready(Ok(())) => {}
849                    std::task::Poll::Pending => return std::task::Poll::Pending,
850                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
851                        this.is_terminated = true;
852                        return std::task::Poll::Ready(None);
853                    }
854                    std::task::Poll::Ready(Err(e)) => {
855                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
856                            e.into(),
857                        ))));
858                    }
859                }
860
861                // A message has been received from the channel
862                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
863
864                std::task::Poll::Ready(Some(match header.ordinal {
865                0xaf6dec156c31687 => {
866                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
867                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
868                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
869                    let control_handle = RegulatoryRegionWatcherControlHandle {
870                        inner: this.inner.clone(),
871                    };
872                    Ok(RegulatoryRegionWatcherRequest::GetUpdate {
873                        responder: RegulatoryRegionWatcherGetUpdateResponder {
874                            control_handle: std::mem::ManuallyDrop::new(control_handle),
875                            tx_id: header.tx_id,
876                        },
877                    })
878                }
879                0x28c47004aed3ff0d => {
880                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
881                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
882                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
883                    let control_handle = RegulatoryRegionWatcherControlHandle {
884                        inner: this.inner.clone(),
885                    };
886                    Ok(RegulatoryRegionWatcherRequest::GetRegionUpdate {
887                        responder: RegulatoryRegionWatcherGetRegionUpdateResponder {
888                            control_handle: std::mem::ManuallyDrop::new(control_handle),
889                            tx_id: header.tx_id,
890                        },
891                    })
892                }
893                _ => Err(fidl::Error::UnknownOrdinal {
894                    ordinal: header.ordinal,
895                    protocol_name: <RegulatoryRegionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
896                }),
897            }))
898            },
899        )
900    }
901}
902
903/// The RegulatoryRegionWatcher protocol provides the mechanism for
904/// radio subsystems to learn the currently applicable regulatory
905/// region, and to be notified when that value changes.
906#[derive(Debug)]
907pub enum RegulatoryRegionWatcherRequest {
908    /// This call is deprecated. Use GetRegionUpdate instead.
909    ///
910    /// Returns the new RegionCode, when it changes.
911    ///
912    /// Notes:
913    /// * The first call returns immediately, if the region is already known.
914    /// * The client is _not_ guaranteed to observe the effects of every call
915    ///   to `SetRegion()`.
916    /// * The client can, however, achieve _eventual_ consistency by always
917    ///   issuing a new request when a request completes.
918    /// * Clients should _not_ issue concurrent requests to this method.
919    ///   * At present, concurrent requests
920    ///     * May yield the same value, or different values.
921    ///     * May complete out-of-order.
922    ///   * In the future, concurrent requests will cause the channel to be
923    ///     closed with `ZX_ERR_BAD_STATE`.
924    ///
925    /// - response `new_region` the current regulatory region.
926    GetUpdate { responder: RegulatoryRegionWatcherGetUpdateResponder },
927    /// Returns the new RegionCode, when it changes.
928    ///
929    /// Notes:
930    /// * The first call returns immediately.
931    /// * The client is _not_ guaranteed to observe the effects of every call
932    ///   to `SetRegion()`.
933    /// * The client can, however, achieve _eventual_ consistency by always
934    ///   issuing a new request when a request completes.
935    /// * Clients should _not_ issue concurrent requests to this method.
936    ///   * At present, concurrent requests
937    ///     * May yield the same value, or different values.
938    ///     * May complete out-of-order.
939    ///   * In the future, concurrent requests will cause the channel to be
940    ///     closed with `ZX_ERR_BAD_STATE`.
941    ///
942    /// - response `new_region` the current regulatory region.
943    GetRegionUpdate { responder: RegulatoryRegionWatcherGetRegionUpdateResponder },
944}
945
946impl RegulatoryRegionWatcherRequest {
947    #[allow(irrefutable_let_patterns)]
948    pub fn into_get_update(self) -> Option<(RegulatoryRegionWatcherGetUpdateResponder)> {
949        if let RegulatoryRegionWatcherRequest::GetUpdate { responder } = self {
950            Some((responder))
951        } else {
952            None
953        }
954    }
955
956    #[allow(irrefutable_let_patterns)]
957    pub fn into_get_region_update(
958        self,
959    ) -> Option<(RegulatoryRegionWatcherGetRegionUpdateResponder)> {
960        if let RegulatoryRegionWatcherRequest::GetRegionUpdate { responder } = self {
961            Some((responder))
962        } else {
963            None
964        }
965    }
966
967    /// Name of the method defined in FIDL
968    pub fn method_name(&self) -> &'static str {
969        match *self {
970            RegulatoryRegionWatcherRequest::GetUpdate { .. } => "get_update",
971            RegulatoryRegionWatcherRequest::GetRegionUpdate { .. } => "get_region_update",
972        }
973    }
974}
975
976#[derive(Debug, Clone)]
977pub struct RegulatoryRegionWatcherControlHandle {
978    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
979}
980
981impl fidl::endpoints::ControlHandle for RegulatoryRegionWatcherControlHandle {
982    fn shutdown(&self) {
983        self.inner.shutdown()
984    }
985
986    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
987        self.inner.shutdown_with_epitaph(status)
988    }
989
990    fn is_closed(&self) -> bool {
991        self.inner.channel().is_closed()
992    }
993    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
994        self.inner.channel().on_closed()
995    }
996
997    #[cfg(target_os = "fuchsia")]
998    fn signal_peer(
999        &self,
1000        clear_mask: zx::Signals,
1001        set_mask: zx::Signals,
1002    ) -> Result<(), zx_status::Status> {
1003        use fidl::Peered;
1004        self.inner.channel().signal_peer(clear_mask, set_mask)
1005    }
1006}
1007
1008impl RegulatoryRegionWatcherControlHandle {}
1009
1010#[must_use = "FIDL methods require a response to be sent"]
1011#[derive(Debug)]
1012pub struct RegulatoryRegionWatcherGetUpdateResponder {
1013    control_handle: std::mem::ManuallyDrop<RegulatoryRegionWatcherControlHandle>,
1014    tx_id: u32,
1015}
1016
1017/// Set the the channel to be shutdown (see [`RegulatoryRegionWatcherControlHandle::shutdown`])
1018/// if the responder is dropped without sending a response, so that the client
1019/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1020impl std::ops::Drop for RegulatoryRegionWatcherGetUpdateResponder {
1021    fn drop(&mut self) {
1022        self.control_handle.shutdown();
1023        // Safety: drops once, never accessed again
1024        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1025    }
1026}
1027
1028impl fidl::endpoints::Responder for RegulatoryRegionWatcherGetUpdateResponder {
1029    type ControlHandle = RegulatoryRegionWatcherControlHandle;
1030
1031    fn control_handle(&self) -> &RegulatoryRegionWatcherControlHandle {
1032        &self.control_handle
1033    }
1034
1035    fn drop_without_shutdown(mut self) {
1036        // Safety: drops once, never accessed again due to mem::forget
1037        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1038        // Prevent Drop from running (which would shut down the channel)
1039        std::mem::forget(self);
1040    }
1041}
1042
1043impl RegulatoryRegionWatcherGetUpdateResponder {
1044    /// Sends a response to the FIDL transaction.
1045    ///
1046    /// Sets the channel to shutdown if an error occurs.
1047    pub fn send(self, mut new_region: &str) -> Result<(), fidl::Error> {
1048        let _result = self.send_raw(new_region);
1049        if _result.is_err() {
1050            self.control_handle.shutdown();
1051        }
1052        self.drop_without_shutdown();
1053        _result
1054    }
1055
1056    /// Similar to "send" but does not shutdown the channel if an error occurs.
1057    pub fn send_no_shutdown_on_err(self, mut new_region: &str) -> Result<(), fidl::Error> {
1058        let _result = self.send_raw(new_region);
1059        self.drop_without_shutdown();
1060        _result
1061    }
1062
1063    fn send_raw(&self, mut new_region: &str) -> Result<(), fidl::Error> {
1064        self.control_handle.inner.send::<RegulatoryRegionWatcherGetUpdateResponse>(
1065            (new_region,),
1066            self.tx_id,
1067            0xaf6dec156c31687,
1068            fidl::encoding::DynamicFlags::empty(),
1069        )
1070    }
1071}
1072
1073#[must_use = "FIDL methods require a response to be sent"]
1074#[derive(Debug)]
1075pub struct RegulatoryRegionWatcherGetRegionUpdateResponder {
1076    control_handle: std::mem::ManuallyDrop<RegulatoryRegionWatcherControlHandle>,
1077    tx_id: u32,
1078}
1079
1080/// Set the the channel to be shutdown (see [`RegulatoryRegionWatcherControlHandle::shutdown`])
1081/// if the responder is dropped without sending a response, so that the client
1082/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1083impl std::ops::Drop for RegulatoryRegionWatcherGetRegionUpdateResponder {
1084    fn drop(&mut self) {
1085        self.control_handle.shutdown();
1086        // Safety: drops once, never accessed again
1087        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1088    }
1089}
1090
1091impl fidl::endpoints::Responder for RegulatoryRegionWatcherGetRegionUpdateResponder {
1092    type ControlHandle = RegulatoryRegionWatcherControlHandle;
1093
1094    fn control_handle(&self) -> &RegulatoryRegionWatcherControlHandle {
1095        &self.control_handle
1096    }
1097
1098    fn drop_without_shutdown(mut self) {
1099        // Safety: drops once, never accessed again due to mem::forget
1100        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1101        // Prevent Drop from running (which would shut down the channel)
1102        std::mem::forget(self);
1103    }
1104}
1105
1106impl RegulatoryRegionWatcherGetRegionUpdateResponder {
1107    /// Sends a response to the FIDL transaction.
1108    ///
1109    /// Sets the channel to shutdown if an error occurs.
1110    pub fn send(self, mut new_region: Option<&str>) -> Result<(), fidl::Error> {
1111        let _result = self.send_raw(new_region);
1112        if _result.is_err() {
1113            self.control_handle.shutdown();
1114        }
1115        self.drop_without_shutdown();
1116        _result
1117    }
1118
1119    /// Similar to "send" but does not shutdown the channel if an error occurs.
1120    pub fn send_no_shutdown_on_err(self, mut new_region: Option<&str>) -> Result<(), fidl::Error> {
1121        let _result = self.send_raw(new_region);
1122        self.drop_without_shutdown();
1123        _result
1124    }
1125
1126    fn send_raw(&self, mut new_region: Option<&str>) -> Result<(), fidl::Error> {
1127        self.control_handle.inner.send::<RegulatoryRegionWatcherGetRegionUpdateResponse>(
1128            (new_region,),
1129            self.tx_id,
1130            0x28c47004aed3ff0d,
1131            fidl::encoding::DynamicFlags::empty(),
1132        )
1133    }
1134}
1135
1136mod internal {
1137    use super::*;
1138}