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