Skip to main content

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        Self { client: fidl::client::sync::Client::new(channel) }
58    }
59
60    pub fn into_channel(self) -> fidl::Channel {
61        self.client.into_channel()
62    }
63
64    /// Waits until an event arrives and returns it. It is safe for other
65    /// threads to make concurrent requests while waiting for an event.
66    pub fn wait_for_event(
67        &self,
68        deadline: zx::MonotonicInstant,
69    ) -> Result<RegulatoryRegionConfiguratorEvent, fidl::Error> {
70        RegulatoryRegionConfiguratorEvent::decode(
71            self.client.wait_for_event::<RegulatoryRegionConfiguratorMarker>(deadline)?,
72        )
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        Self { client: fidl::client::sync::Client::new(channel) }
504    }
505
506    pub fn into_channel(self) -> fidl::Channel {
507        self.client.into_channel()
508    }
509
510    /// Waits until an event arrives and returns it. It is safe for other
511    /// threads to make concurrent requests while waiting for an event.
512    pub fn wait_for_event(
513        &self,
514        deadline: zx::MonotonicInstant,
515    ) -> Result<RegulatoryRegionWatcherEvent, fidl::Error> {
516        RegulatoryRegionWatcherEvent::decode(
517            self.client.wait_for_event::<RegulatoryRegionWatcherMarker>(deadline)?,
518        )
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.client.send_query::<
541            fidl::encoding::EmptyPayload,
542            RegulatoryRegionWatcherGetUpdateResponse,
543            RegulatoryRegionWatcherMarker,
544        >(
545            (),
546            0xaf6dec156c31687,
547            fidl::encoding::DynamicFlags::empty(),
548            ___deadline,
549        )?;
550        Ok(_response.new_region)
551    }
552
553    /// Returns the new RegionCode, when it changes.
554    ///
555    /// Notes:
556    /// * The first call returns immediately.
557    /// * The client is _not_ guaranteed to observe the effects of every call
558    ///   to `SetRegion()`.
559    /// * The client can, however, achieve _eventual_ consistency by always
560    ///   issuing a new request when a request completes.
561    /// * Clients should _not_ issue concurrent requests to this method.
562    ///   * At present, concurrent requests
563    ///     * May yield the same value, or different values.
564    ///     * May complete out-of-order.
565    ///   * In the future, concurrent requests will cause the channel to be
566    ///     closed with `ZX_ERR_BAD_STATE`.
567    ///
568    /// - response `new_region` the current regulatory region.
569    pub fn r#get_region_update(
570        &self,
571        ___deadline: zx::MonotonicInstant,
572    ) -> Result<Option<String>, fidl::Error> {
573        let _response = self.client.send_query::<
574            fidl::encoding::EmptyPayload,
575            RegulatoryRegionWatcherGetRegionUpdateResponse,
576            RegulatoryRegionWatcherMarker,
577        >(
578            (),
579            0x28c47004aed3ff0d,
580            fidl::encoding::DynamicFlags::empty(),
581            ___deadline,
582        )?;
583        Ok(_response.new_region)
584    }
585}
586
587#[cfg(target_os = "fuchsia")]
588impl From<RegulatoryRegionWatcherSynchronousProxy> for zx::NullableHandle {
589    fn from(value: RegulatoryRegionWatcherSynchronousProxy) -> Self {
590        value.into_channel().into()
591    }
592}
593
594#[cfg(target_os = "fuchsia")]
595impl From<fidl::Channel> for RegulatoryRegionWatcherSynchronousProxy {
596    fn from(value: fidl::Channel) -> Self {
597        Self::new(value)
598    }
599}
600
601#[cfg(target_os = "fuchsia")]
602impl fidl::endpoints::FromClient for RegulatoryRegionWatcherSynchronousProxy {
603    type Protocol = RegulatoryRegionWatcherMarker;
604
605    fn from_client(value: fidl::endpoints::ClientEnd<RegulatoryRegionWatcherMarker>) -> Self {
606        Self::new(value.into_channel())
607    }
608}
609
610#[derive(Debug, Clone)]
611pub struct RegulatoryRegionWatcherProxy {
612    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
613}
614
615impl fidl::endpoints::Proxy for RegulatoryRegionWatcherProxy {
616    type Protocol = RegulatoryRegionWatcherMarker;
617
618    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
619        Self::new(inner)
620    }
621
622    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
623        self.client.into_channel().map_err(|client| Self { client })
624    }
625
626    fn as_channel(&self) -> &::fidl::AsyncChannel {
627        self.client.as_channel()
628    }
629}
630
631impl RegulatoryRegionWatcherProxy {
632    /// Create a new Proxy for fuchsia.location.namedplace/RegulatoryRegionWatcher.
633    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
634        let protocol_name =
635            <RegulatoryRegionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
636        Self { client: fidl::client::Client::new(channel, protocol_name) }
637    }
638
639    /// Get a Stream of events from the remote end of the protocol.
640    ///
641    /// # Panics
642    ///
643    /// Panics if the event stream was already taken.
644    pub fn take_event_stream(&self) -> RegulatoryRegionWatcherEventStream {
645        RegulatoryRegionWatcherEventStream { event_receiver: self.client.take_event_receiver() }
646    }
647
648    /// This call is deprecated. Use GetRegionUpdate instead.
649    ///
650    /// Returns the new RegionCode, when it changes.
651    ///
652    /// Notes:
653    /// * The first call returns immediately, if the region is already known.
654    /// * The client is _not_ guaranteed to observe the effects of every call
655    ///   to `SetRegion()`.
656    /// * The client can, however, achieve _eventual_ consistency by always
657    ///   issuing a new request when a request completes.
658    /// * Clients should _not_ issue concurrent requests to this method.
659    ///   * At present, concurrent requests
660    ///     * May yield the same value, or different values.
661    ///     * May complete out-of-order.
662    ///   * In the future, concurrent requests will cause the channel to be
663    ///     closed with `ZX_ERR_BAD_STATE`.
664    ///
665    /// - response `new_region` the current regulatory region.
666    pub fn r#get_update(
667        &self,
668    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
669        RegulatoryRegionWatcherProxyInterface::r#get_update(self)
670    }
671
672    /// Returns the new RegionCode, when it changes.
673    ///
674    /// Notes:
675    /// * The first call returns immediately.
676    /// * The client is _not_ guaranteed to observe the effects of every call
677    ///   to `SetRegion()`.
678    /// * The client can, however, achieve _eventual_ consistency by always
679    ///   issuing a new request when a request completes.
680    /// * Clients should _not_ issue concurrent requests to this method.
681    ///   * At present, concurrent requests
682    ///     * May yield the same value, or different values.
683    ///     * May complete out-of-order.
684    ///   * In the future, concurrent requests will cause the channel to be
685    ///     closed with `ZX_ERR_BAD_STATE`.
686    ///
687    /// - response `new_region` the current regulatory region.
688    pub fn r#get_region_update(
689        &self,
690    ) -> fidl::client::QueryResponseFut<Option<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
691    {
692        RegulatoryRegionWatcherProxyInterface::r#get_region_update(self)
693    }
694}
695
696impl RegulatoryRegionWatcherProxyInterface for RegulatoryRegionWatcherProxy {
697    type GetUpdateResponseFut =
698        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
699    fn r#get_update(&self) -> Self::GetUpdateResponseFut {
700        fn _decode(
701            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
702        ) -> Result<String, fidl::Error> {
703            let _response = fidl::client::decode_transaction_body::<
704                RegulatoryRegionWatcherGetUpdateResponse,
705                fidl::encoding::DefaultFuchsiaResourceDialect,
706                0xaf6dec156c31687,
707            >(_buf?)?;
708            Ok(_response.new_region)
709        }
710        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
711            (),
712            0xaf6dec156c31687,
713            fidl::encoding::DynamicFlags::empty(),
714            _decode,
715        )
716    }
717
718    type GetRegionUpdateResponseFut = fidl::client::QueryResponseFut<
719        Option<String>,
720        fidl::encoding::DefaultFuchsiaResourceDialect,
721    >;
722    fn r#get_region_update(&self) -> Self::GetRegionUpdateResponseFut {
723        fn _decode(
724            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
725        ) -> Result<Option<String>, fidl::Error> {
726            let _response = fidl::client::decode_transaction_body::<
727                RegulatoryRegionWatcherGetRegionUpdateResponse,
728                fidl::encoding::DefaultFuchsiaResourceDialect,
729                0x28c47004aed3ff0d,
730            >(_buf?)?;
731            Ok(_response.new_region)
732        }
733        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Option<String>>(
734            (),
735            0x28c47004aed3ff0d,
736            fidl::encoding::DynamicFlags::empty(),
737            _decode,
738        )
739    }
740}
741
742pub struct RegulatoryRegionWatcherEventStream {
743    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
744}
745
746impl std::marker::Unpin for RegulatoryRegionWatcherEventStream {}
747
748impl futures::stream::FusedStream for RegulatoryRegionWatcherEventStream {
749    fn is_terminated(&self) -> bool {
750        self.event_receiver.is_terminated()
751    }
752}
753
754impl futures::Stream for RegulatoryRegionWatcherEventStream {
755    type Item = Result<RegulatoryRegionWatcherEvent, fidl::Error>;
756
757    fn poll_next(
758        mut self: std::pin::Pin<&mut Self>,
759        cx: &mut std::task::Context<'_>,
760    ) -> std::task::Poll<Option<Self::Item>> {
761        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
762            &mut self.event_receiver,
763            cx
764        )?) {
765            Some(buf) => std::task::Poll::Ready(Some(RegulatoryRegionWatcherEvent::decode(buf))),
766            None => std::task::Poll::Ready(None),
767        }
768    }
769}
770
771#[derive(Debug)]
772pub enum RegulatoryRegionWatcherEvent {}
773
774impl RegulatoryRegionWatcherEvent {
775    /// Decodes a message buffer as a [`RegulatoryRegionWatcherEvent`].
776    fn decode(
777        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
778    ) -> Result<RegulatoryRegionWatcherEvent, fidl::Error> {
779        let (bytes, _handles) = buf.split_mut();
780        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
781        debug_assert_eq!(tx_header.tx_id, 0);
782        match tx_header.ordinal {
783            _ => Err(fidl::Error::UnknownOrdinal {
784                ordinal: tx_header.ordinal,
785                protocol_name:
786                    <RegulatoryRegionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
787            }),
788        }
789    }
790}
791
792/// A Stream of incoming requests for fuchsia.location.namedplace/RegulatoryRegionWatcher.
793pub struct RegulatoryRegionWatcherRequestStream {
794    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
795    is_terminated: bool,
796}
797
798impl std::marker::Unpin for RegulatoryRegionWatcherRequestStream {}
799
800impl futures::stream::FusedStream for RegulatoryRegionWatcherRequestStream {
801    fn is_terminated(&self) -> bool {
802        self.is_terminated
803    }
804}
805
806impl fidl::endpoints::RequestStream for RegulatoryRegionWatcherRequestStream {
807    type Protocol = RegulatoryRegionWatcherMarker;
808    type ControlHandle = RegulatoryRegionWatcherControlHandle;
809
810    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
811        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
812    }
813
814    fn control_handle(&self) -> Self::ControlHandle {
815        RegulatoryRegionWatcherControlHandle { inner: self.inner.clone() }
816    }
817
818    fn into_inner(
819        self,
820    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
821    {
822        (self.inner, self.is_terminated)
823    }
824
825    fn from_inner(
826        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
827        is_terminated: bool,
828    ) -> Self {
829        Self { inner, is_terminated }
830    }
831}
832
833impl futures::Stream for RegulatoryRegionWatcherRequestStream {
834    type Item = Result<RegulatoryRegionWatcherRequest, fidl::Error>;
835
836    fn poll_next(
837        mut self: std::pin::Pin<&mut Self>,
838        cx: &mut std::task::Context<'_>,
839    ) -> std::task::Poll<Option<Self::Item>> {
840        let this = &mut *self;
841        if this.inner.check_shutdown(cx) {
842            this.is_terminated = true;
843            return std::task::Poll::Ready(None);
844        }
845        if this.is_terminated {
846            panic!("polled RegulatoryRegionWatcherRequestStream after completion");
847        }
848        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
849            |bytes, handles| {
850                match this.inner.channel().read_etc(cx, bytes, handles) {
851                    std::task::Poll::Ready(Ok(())) => {}
852                    std::task::Poll::Pending => return std::task::Poll::Pending,
853                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
854                        this.is_terminated = true;
855                        return std::task::Poll::Ready(None);
856                    }
857                    std::task::Poll::Ready(Err(e)) => {
858                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
859                            e.into(),
860                        ))));
861                    }
862                }
863
864                // A message has been received from the channel
865                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
866
867                std::task::Poll::Ready(Some(match header.ordinal {
868                0xaf6dec156c31687 => {
869                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
870                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
871                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
872                    let control_handle = RegulatoryRegionWatcherControlHandle {
873                        inner: this.inner.clone(),
874                    };
875                    Ok(RegulatoryRegionWatcherRequest::GetUpdate {
876                        responder: RegulatoryRegionWatcherGetUpdateResponder {
877                            control_handle: std::mem::ManuallyDrop::new(control_handle),
878                            tx_id: header.tx_id,
879                        },
880                    })
881                }
882                0x28c47004aed3ff0d => {
883                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
884                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
885                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
886                    let control_handle = RegulatoryRegionWatcherControlHandle {
887                        inner: this.inner.clone(),
888                    };
889                    Ok(RegulatoryRegionWatcherRequest::GetRegionUpdate {
890                        responder: RegulatoryRegionWatcherGetRegionUpdateResponder {
891                            control_handle: std::mem::ManuallyDrop::new(control_handle),
892                            tx_id: header.tx_id,
893                        },
894                    })
895                }
896                _ => Err(fidl::Error::UnknownOrdinal {
897                    ordinal: header.ordinal,
898                    protocol_name: <RegulatoryRegionWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
899                }),
900            }))
901            },
902        )
903    }
904}
905
906/// The RegulatoryRegionWatcher protocol provides the mechanism for
907/// radio subsystems to learn the currently applicable regulatory
908/// region, and to be notified when that value changes.
909#[derive(Debug)]
910pub enum RegulatoryRegionWatcherRequest {
911    /// This call is deprecated. Use GetRegionUpdate instead.
912    ///
913    /// Returns the new RegionCode, when it changes.
914    ///
915    /// Notes:
916    /// * The first call returns immediately, if the region is already known.
917    /// * The client is _not_ guaranteed to observe the effects of every call
918    ///   to `SetRegion()`.
919    /// * The client can, however, achieve _eventual_ consistency by always
920    ///   issuing a new request when a request completes.
921    /// * Clients should _not_ issue concurrent requests to this method.
922    ///   * At present, concurrent requests
923    ///     * May yield the same value, or different values.
924    ///     * May complete out-of-order.
925    ///   * In the future, concurrent requests will cause the channel to be
926    ///     closed with `ZX_ERR_BAD_STATE`.
927    ///
928    /// - response `new_region` the current regulatory region.
929    GetUpdate { responder: RegulatoryRegionWatcherGetUpdateResponder },
930    /// Returns the new RegionCode, when it changes.
931    ///
932    /// Notes:
933    /// * The first call returns immediately.
934    /// * The client is _not_ guaranteed to observe the effects of every call
935    ///   to `SetRegion()`.
936    /// * The client can, however, achieve _eventual_ consistency by always
937    ///   issuing a new request when a request completes.
938    /// * Clients should _not_ issue concurrent requests to this method.
939    ///   * At present, concurrent requests
940    ///     * May yield the same value, or different values.
941    ///     * May complete out-of-order.
942    ///   * In the future, concurrent requests will cause the channel to be
943    ///     closed with `ZX_ERR_BAD_STATE`.
944    ///
945    /// - response `new_region` the current regulatory region.
946    GetRegionUpdate { responder: RegulatoryRegionWatcherGetRegionUpdateResponder },
947}
948
949impl RegulatoryRegionWatcherRequest {
950    #[allow(irrefutable_let_patterns)]
951    pub fn into_get_update(self) -> Option<(RegulatoryRegionWatcherGetUpdateResponder)> {
952        if let RegulatoryRegionWatcherRequest::GetUpdate { responder } = self {
953            Some((responder))
954        } else {
955            None
956        }
957    }
958
959    #[allow(irrefutable_let_patterns)]
960    pub fn into_get_region_update(
961        self,
962    ) -> Option<(RegulatoryRegionWatcherGetRegionUpdateResponder)> {
963        if let RegulatoryRegionWatcherRequest::GetRegionUpdate { responder } = self {
964            Some((responder))
965        } else {
966            None
967        }
968    }
969
970    /// Name of the method defined in FIDL
971    pub fn method_name(&self) -> &'static str {
972        match *self {
973            RegulatoryRegionWatcherRequest::GetUpdate { .. } => "get_update",
974            RegulatoryRegionWatcherRequest::GetRegionUpdate { .. } => "get_region_update",
975        }
976    }
977}
978
979#[derive(Debug, Clone)]
980pub struct RegulatoryRegionWatcherControlHandle {
981    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
982}
983
984impl fidl::endpoints::ControlHandle for RegulatoryRegionWatcherControlHandle {
985    fn shutdown(&self) {
986        self.inner.shutdown()
987    }
988
989    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
990        self.inner.shutdown_with_epitaph(status)
991    }
992
993    fn is_closed(&self) -> bool {
994        self.inner.channel().is_closed()
995    }
996    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
997        self.inner.channel().on_closed()
998    }
999
1000    #[cfg(target_os = "fuchsia")]
1001    fn signal_peer(
1002        &self,
1003        clear_mask: zx::Signals,
1004        set_mask: zx::Signals,
1005    ) -> Result<(), zx_status::Status> {
1006        use fidl::Peered;
1007        self.inner.channel().signal_peer(clear_mask, set_mask)
1008    }
1009}
1010
1011impl RegulatoryRegionWatcherControlHandle {}
1012
1013#[must_use = "FIDL methods require a response to be sent"]
1014#[derive(Debug)]
1015pub struct RegulatoryRegionWatcherGetUpdateResponder {
1016    control_handle: std::mem::ManuallyDrop<RegulatoryRegionWatcherControlHandle>,
1017    tx_id: u32,
1018}
1019
1020/// Set the the channel to be shutdown (see [`RegulatoryRegionWatcherControlHandle::shutdown`])
1021/// if the responder is dropped without sending a response, so that the client
1022/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1023impl std::ops::Drop for RegulatoryRegionWatcherGetUpdateResponder {
1024    fn drop(&mut self) {
1025        self.control_handle.shutdown();
1026        // Safety: drops once, never accessed again
1027        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1028    }
1029}
1030
1031impl fidl::endpoints::Responder for RegulatoryRegionWatcherGetUpdateResponder {
1032    type ControlHandle = RegulatoryRegionWatcherControlHandle;
1033
1034    fn control_handle(&self) -> &RegulatoryRegionWatcherControlHandle {
1035        &self.control_handle
1036    }
1037
1038    fn drop_without_shutdown(mut self) {
1039        // Safety: drops once, never accessed again due to mem::forget
1040        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1041        // Prevent Drop from running (which would shut down the channel)
1042        std::mem::forget(self);
1043    }
1044}
1045
1046impl RegulatoryRegionWatcherGetUpdateResponder {
1047    /// Sends a response to the FIDL transaction.
1048    ///
1049    /// Sets the channel to shutdown if an error occurs.
1050    pub fn send(self, mut new_region: &str) -> Result<(), fidl::Error> {
1051        let _result = self.send_raw(new_region);
1052        if _result.is_err() {
1053            self.control_handle.shutdown();
1054        }
1055        self.drop_without_shutdown();
1056        _result
1057    }
1058
1059    /// Similar to "send" but does not shutdown the channel if an error occurs.
1060    pub fn send_no_shutdown_on_err(self, mut new_region: &str) -> Result<(), fidl::Error> {
1061        let _result = self.send_raw(new_region);
1062        self.drop_without_shutdown();
1063        _result
1064    }
1065
1066    fn send_raw(&self, mut new_region: &str) -> Result<(), fidl::Error> {
1067        self.control_handle.inner.send::<RegulatoryRegionWatcherGetUpdateResponse>(
1068            (new_region,),
1069            self.tx_id,
1070            0xaf6dec156c31687,
1071            fidl::encoding::DynamicFlags::empty(),
1072        )
1073    }
1074}
1075
1076#[must_use = "FIDL methods require a response to be sent"]
1077#[derive(Debug)]
1078pub struct RegulatoryRegionWatcherGetRegionUpdateResponder {
1079    control_handle: std::mem::ManuallyDrop<RegulatoryRegionWatcherControlHandle>,
1080    tx_id: u32,
1081}
1082
1083/// Set the the channel to be shutdown (see [`RegulatoryRegionWatcherControlHandle::shutdown`])
1084/// if the responder is dropped without sending a response, so that the client
1085/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1086impl std::ops::Drop for RegulatoryRegionWatcherGetRegionUpdateResponder {
1087    fn drop(&mut self) {
1088        self.control_handle.shutdown();
1089        // Safety: drops once, never accessed again
1090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1091    }
1092}
1093
1094impl fidl::endpoints::Responder for RegulatoryRegionWatcherGetRegionUpdateResponder {
1095    type ControlHandle = RegulatoryRegionWatcherControlHandle;
1096
1097    fn control_handle(&self) -> &RegulatoryRegionWatcherControlHandle {
1098        &self.control_handle
1099    }
1100
1101    fn drop_without_shutdown(mut self) {
1102        // Safety: drops once, never accessed again due to mem::forget
1103        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1104        // Prevent Drop from running (which would shut down the channel)
1105        std::mem::forget(self);
1106    }
1107}
1108
1109impl RegulatoryRegionWatcherGetRegionUpdateResponder {
1110    /// Sends a response to the FIDL transaction.
1111    ///
1112    /// Sets the channel to shutdown if an error occurs.
1113    pub fn send(self, mut new_region: Option<&str>) -> Result<(), fidl::Error> {
1114        let _result = self.send_raw(new_region);
1115        if _result.is_err() {
1116            self.control_handle.shutdown();
1117        }
1118        self.drop_without_shutdown();
1119        _result
1120    }
1121
1122    /// Similar to "send" but does not shutdown the channel if an error occurs.
1123    pub fn send_no_shutdown_on_err(self, mut new_region: Option<&str>) -> Result<(), fidl::Error> {
1124        let _result = self.send_raw(new_region);
1125        self.drop_without_shutdown();
1126        _result
1127    }
1128
1129    fn send_raw(&self, mut new_region: Option<&str>) -> Result<(), fidl::Error> {
1130        self.control_handle.inner.send::<RegulatoryRegionWatcherGetRegionUpdateResponse>(
1131            (new_region,),
1132            self.tx_id,
1133            0x28c47004aed3ff0d,
1134            fidl::encoding::DynamicFlags::empty(),
1135        )
1136    }
1137}
1138
1139mod internal {
1140    use super::*;
1141}