fidl_fuchsia_location_position/
fidl_fuchsia_location_position.rs
1#![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_position_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct EmergencyProviderMarker;
16
17impl fidl::endpoints::ProtocolMarker for EmergencyProviderMarker {
18 type Proxy = EmergencyProviderProxy;
19 type RequestStream = EmergencyProviderRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = EmergencyProviderSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.location.position.EmergencyProvider";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for EmergencyProviderMarker {}
26pub type EmergencyProviderGetCurrentResult = Result<Position, fidl_fuchsia_location::Error>;
27
28pub trait EmergencyProviderProxyInterface: Send + Sync {
29 type GetCurrentResponseFut: std::future::Future<Output = Result<EmergencyProviderGetCurrentResult, fidl::Error>>
30 + Send;
31 fn r#get_current(&self) -> Self::GetCurrentResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct EmergencyProviderSynchronousProxy {
36 client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for EmergencyProviderSynchronousProxy {
41 type Proxy = EmergencyProviderProxy;
42 type Protocol = EmergencyProviderMarker;
43
44 fn from_channel(inner: fidl::Channel) -> Self {
45 Self::new(inner)
46 }
47
48 fn into_channel(self) -> fidl::Channel {
49 self.client.into_channel()
50 }
51
52 fn as_channel(&self) -> &fidl::Channel {
53 self.client.as_channel()
54 }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl EmergencyProviderSynchronousProxy {
59 pub fn new(channel: fidl::Channel) -> Self {
60 let protocol_name =
61 <EmergencyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
62 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
63 }
64
65 pub fn into_channel(self) -> fidl::Channel {
66 self.client.into_channel()
67 }
68
69 pub fn wait_for_event(
72 &self,
73 deadline: zx::MonotonicInstant,
74 ) -> Result<EmergencyProviderEvent, fidl::Error> {
75 EmergencyProviderEvent::decode(self.client.wait_for_event(deadline)?)
76 }
77
78 pub fn r#get_current(
80 &self,
81 ___deadline: zx::MonotonicInstant,
82 ) -> Result<EmergencyProviderGetCurrentResult, fidl::Error> {
83 let _response = self
84 .client
85 .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
86 EmergencyProviderGetCurrentResponse,
87 fidl_fuchsia_location::Error,
88 >>(
89 (), 0x69243da09135d131, fidl::encoding::DynamicFlags::empty(), ___deadline
90 )?;
91 Ok(_response.map(|x| x.position))
92 }
93}
94
95#[cfg(target_os = "fuchsia")]
96impl From<EmergencyProviderSynchronousProxy> for zx::Handle {
97 fn from(value: EmergencyProviderSynchronousProxy) -> Self {
98 value.into_channel().into()
99 }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl From<fidl::Channel> for EmergencyProviderSynchronousProxy {
104 fn from(value: fidl::Channel) -> Self {
105 Self::new(value)
106 }
107}
108
109#[derive(Debug, Clone)]
110pub struct EmergencyProviderProxy {
111 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
112}
113
114impl fidl::endpoints::Proxy for EmergencyProviderProxy {
115 type Protocol = EmergencyProviderMarker;
116
117 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
118 Self::new(inner)
119 }
120
121 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
122 self.client.into_channel().map_err(|client| Self { client })
123 }
124
125 fn as_channel(&self) -> &::fidl::AsyncChannel {
126 self.client.as_channel()
127 }
128}
129
130impl EmergencyProviderProxy {
131 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
133 let protocol_name =
134 <EmergencyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
135 Self { client: fidl::client::Client::new(channel, protocol_name) }
136 }
137
138 pub fn take_event_stream(&self) -> EmergencyProviderEventStream {
144 EmergencyProviderEventStream { event_receiver: self.client.take_event_receiver() }
145 }
146
147 pub fn r#get_current(
149 &self,
150 ) -> fidl::client::QueryResponseFut<
151 EmergencyProviderGetCurrentResult,
152 fidl::encoding::DefaultFuchsiaResourceDialect,
153 > {
154 EmergencyProviderProxyInterface::r#get_current(self)
155 }
156}
157
158impl EmergencyProviderProxyInterface for EmergencyProviderProxy {
159 type GetCurrentResponseFut = fidl::client::QueryResponseFut<
160 EmergencyProviderGetCurrentResult,
161 fidl::encoding::DefaultFuchsiaResourceDialect,
162 >;
163 fn r#get_current(&self) -> Self::GetCurrentResponseFut {
164 fn _decode(
165 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
166 ) -> Result<EmergencyProviderGetCurrentResult, fidl::Error> {
167 let _response = fidl::client::decode_transaction_body::<
168 fidl::encoding::ResultType<
169 EmergencyProviderGetCurrentResponse,
170 fidl_fuchsia_location::Error,
171 >,
172 fidl::encoding::DefaultFuchsiaResourceDialect,
173 0x69243da09135d131,
174 >(_buf?)?;
175 Ok(_response.map(|x| x.position))
176 }
177 self.client.send_query_and_decode::<
178 fidl::encoding::EmptyPayload,
179 EmergencyProviderGetCurrentResult,
180 >(
181 (),
182 0x69243da09135d131,
183 fidl::encoding::DynamicFlags::empty(),
184 _decode,
185 )
186 }
187}
188
189pub struct EmergencyProviderEventStream {
190 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
191}
192
193impl std::marker::Unpin for EmergencyProviderEventStream {}
194
195impl futures::stream::FusedStream for EmergencyProviderEventStream {
196 fn is_terminated(&self) -> bool {
197 self.event_receiver.is_terminated()
198 }
199}
200
201impl futures::Stream for EmergencyProviderEventStream {
202 type Item = Result<EmergencyProviderEvent, fidl::Error>;
203
204 fn poll_next(
205 mut self: std::pin::Pin<&mut Self>,
206 cx: &mut std::task::Context<'_>,
207 ) -> std::task::Poll<Option<Self::Item>> {
208 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
209 &mut self.event_receiver,
210 cx
211 )?) {
212 Some(buf) => std::task::Poll::Ready(Some(EmergencyProviderEvent::decode(buf))),
213 None => std::task::Poll::Ready(None),
214 }
215 }
216}
217
218#[derive(Debug)]
219pub enum EmergencyProviderEvent {}
220
221impl EmergencyProviderEvent {
222 fn decode(
224 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
225 ) -> Result<EmergencyProviderEvent, fidl::Error> {
226 let (bytes, _handles) = buf.split_mut();
227 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
228 debug_assert_eq!(tx_header.tx_id, 0);
229 match tx_header.ordinal {
230 _ => Err(fidl::Error::UnknownOrdinal {
231 ordinal: tx_header.ordinal,
232 protocol_name:
233 <EmergencyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
234 }),
235 }
236 }
237}
238
239pub struct EmergencyProviderRequestStream {
241 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
242 is_terminated: bool,
243}
244
245impl std::marker::Unpin for EmergencyProviderRequestStream {}
246
247impl futures::stream::FusedStream for EmergencyProviderRequestStream {
248 fn is_terminated(&self) -> bool {
249 self.is_terminated
250 }
251}
252
253impl fidl::endpoints::RequestStream for EmergencyProviderRequestStream {
254 type Protocol = EmergencyProviderMarker;
255 type ControlHandle = EmergencyProviderControlHandle;
256
257 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
258 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
259 }
260
261 fn control_handle(&self) -> Self::ControlHandle {
262 EmergencyProviderControlHandle { inner: self.inner.clone() }
263 }
264
265 fn into_inner(
266 self,
267 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
268 {
269 (self.inner, self.is_terminated)
270 }
271
272 fn from_inner(
273 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
274 is_terminated: bool,
275 ) -> Self {
276 Self { inner, is_terminated }
277 }
278}
279
280impl futures::Stream for EmergencyProviderRequestStream {
281 type Item = Result<EmergencyProviderRequest, fidl::Error>;
282
283 fn poll_next(
284 mut self: std::pin::Pin<&mut Self>,
285 cx: &mut std::task::Context<'_>,
286 ) -> std::task::Poll<Option<Self::Item>> {
287 let this = &mut *self;
288 if this.inner.check_shutdown(cx) {
289 this.is_terminated = true;
290 return std::task::Poll::Ready(None);
291 }
292 if this.is_terminated {
293 panic!("polled EmergencyProviderRequestStream after completion");
294 }
295 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
296 |bytes, handles| {
297 match this.inner.channel().read_etc(cx, bytes, handles) {
298 std::task::Poll::Ready(Ok(())) => {}
299 std::task::Poll::Pending => return std::task::Poll::Pending,
300 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
301 this.is_terminated = true;
302 return std::task::Poll::Ready(None);
303 }
304 std::task::Poll::Ready(Err(e)) => {
305 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
306 e.into(),
307 ))))
308 }
309 }
310
311 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
313
314 std::task::Poll::Ready(Some(match header.ordinal {
315 0x69243da09135d131 => {
316 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
317 let mut req = fidl::new_empty!(
318 fidl::encoding::EmptyPayload,
319 fidl::encoding::DefaultFuchsiaResourceDialect
320 );
321 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
322 let control_handle =
323 EmergencyProviderControlHandle { inner: this.inner.clone() };
324 Ok(EmergencyProviderRequest::GetCurrent {
325 responder: EmergencyProviderGetCurrentResponder {
326 control_handle: std::mem::ManuallyDrop::new(control_handle),
327 tx_id: header.tx_id,
328 },
329 })
330 }
331 _ => Err(fidl::Error::UnknownOrdinal {
332 ordinal: header.ordinal,
333 protocol_name:
334 <EmergencyProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
335 }),
336 }))
337 },
338 )
339 }
340}
341
342#[derive(Debug)]
346pub enum EmergencyProviderRequest {
347 GetCurrent { responder: EmergencyProviderGetCurrentResponder },
349}
350
351impl EmergencyProviderRequest {
352 #[allow(irrefutable_let_patterns)]
353 pub fn into_get_current(self) -> Option<(EmergencyProviderGetCurrentResponder)> {
354 if let EmergencyProviderRequest::GetCurrent { responder } = self {
355 Some((responder))
356 } else {
357 None
358 }
359 }
360
361 pub fn method_name(&self) -> &'static str {
363 match *self {
364 EmergencyProviderRequest::GetCurrent { .. } => "get_current",
365 }
366 }
367}
368
369#[derive(Debug, Clone)]
370pub struct EmergencyProviderControlHandle {
371 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
372}
373
374impl fidl::endpoints::ControlHandle for EmergencyProviderControlHandle {
375 fn shutdown(&self) {
376 self.inner.shutdown()
377 }
378 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
379 self.inner.shutdown_with_epitaph(status)
380 }
381
382 fn is_closed(&self) -> bool {
383 self.inner.channel().is_closed()
384 }
385 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
386 self.inner.channel().on_closed()
387 }
388
389 #[cfg(target_os = "fuchsia")]
390 fn signal_peer(
391 &self,
392 clear_mask: zx::Signals,
393 set_mask: zx::Signals,
394 ) -> Result<(), zx_status::Status> {
395 use fidl::Peered;
396 self.inner.channel().signal_peer(clear_mask, set_mask)
397 }
398}
399
400impl EmergencyProviderControlHandle {}
401
402#[must_use = "FIDL methods require a response to be sent"]
403#[derive(Debug)]
404pub struct EmergencyProviderGetCurrentResponder {
405 control_handle: std::mem::ManuallyDrop<EmergencyProviderControlHandle>,
406 tx_id: u32,
407}
408
409impl std::ops::Drop for EmergencyProviderGetCurrentResponder {
413 fn drop(&mut self) {
414 self.control_handle.shutdown();
415 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
417 }
418}
419
420impl fidl::endpoints::Responder for EmergencyProviderGetCurrentResponder {
421 type ControlHandle = EmergencyProviderControlHandle;
422
423 fn control_handle(&self) -> &EmergencyProviderControlHandle {
424 &self.control_handle
425 }
426
427 fn drop_without_shutdown(mut self) {
428 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
430 std::mem::forget(self);
432 }
433}
434
435impl EmergencyProviderGetCurrentResponder {
436 pub fn send(
440 self,
441 mut result: Result<&Position, fidl_fuchsia_location::Error>,
442 ) -> Result<(), fidl::Error> {
443 let _result = self.send_raw(result);
444 if _result.is_err() {
445 self.control_handle.shutdown();
446 }
447 self.drop_without_shutdown();
448 _result
449 }
450
451 pub fn send_no_shutdown_on_err(
453 self,
454 mut result: Result<&Position, fidl_fuchsia_location::Error>,
455 ) -> Result<(), fidl::Error> {
456 let _result = self.send_raw(result);
457 self.drop_without_shutdown();
458 _result
459 }
460
461 fn send_raw(
462 &self,
463 mut result: Result<&Position, fidl_fuchsia_location::Error>,
464 ) -> Result<(), fidl::Error> {
465 self.control_handle.inner.send::<fidl::encoding::ResultType<
466 EmergencyProviderGetCurrentResponse,
467 fidl_fuchsia_location::Error,
468 >>(
469 result.map(|position| (position,)),
470 self.tx_id,
471 0x69243da09135d131,
472 fidl::encoding::DynamicFlags::empty(),
473 )
474 }
475}
476
477mod internal {
478 use super::*;
479}