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_test_time_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct TimeSourceControlConnectPushSourceRequest {
16 pub push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for TimeSourceControlConnectPushSourceRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct TimeSourceControlMarker;
26
27impl fidl::endpoints::ProtocolMarker for TimeSourceControlMarker {
28 type Proxy = TimeSourceControlProxy;
29 type RequestStream = TimeSourceControlRequestStream;
30 #[cfg(target_os = "fuchsia")]
31 type SynchronousProxy = TimeSourceControlSynchronousProxy;
32
33 const DEBUG_NAME: &'static str = "test.time.TimeSourceControl";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for TimeSourceControlMarker {}
36
37pub trait TimeSourceControlProxyInterface: Send + Sync {
38 fn r#connect_push_source(
39 &self,
40 push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
41 ) -> Result<(), fidl::Error>;
42}
43#[derive(Debug)]
44#[cfg(target_os = "fuchsia")]
45pub struct TimeSourceControlSynchronousProxy {
46 client: fidl::client::sync::Client,
47}
48
49#[cfg(target_os = "fuchsia")]
50impl fidl::endpoints::SynchronousProxy for TimeSourceControlSynchronousProxy {
51 type Proxy = TimeSourceControlProxy;
52 type Protocol = TimeSourceControlMarker;
53
54 fn from_channel(inner: fidl::Channel) -> Self {
55 Self::new(inner)
56 }
57
58 fn into_channel(self) -> fidl::Channel {
59 self.client.into_channel()
60 }
61
62 fn as_channel(&self) -> &fidl::Channel {
63 self.client.as_channel()
64 }
65}
66
67#[cfg(target_os = "fuchsia")]
68impl TimeSourceControlSynchronousProxy {
69 pub fn new(channel: fidl::Channel) -> Self {
70 let protocol_name =
71 <TimeSourceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
72 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
73 }
74
75 pub fn into_channel(self) -> fidl::Channel {
76 self.client.into_channel()
77 }
78
79 pub fn wait_for_event(
82 &self,
83 deadline: zx::MonotonicInstant,
84 ) -> Result<TimeSourceControlEvent, fidl::Error> {
85 TimeSourceControlEvent::decode(self.client.wait_for_event(deadline)?)
86 }
87
88 pub fn r#connect_push_source(
90 &self,
91 mut push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
92 ) -> Result<(), fidl::Error> {
93 self.client.send::<TimeSourceControlConnectPushSourceRequest>(
94 (push_source,),
95 0x6da5e3723a74f6e4,
96 fidl::encoding::DynamicFlags::empty(),
97 )
98 }
99}
100
101#[derive(Debug, Clone)]
102pub struct TimeSourceControlProxy {
103 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
104}
105
106impl fidl::endpoints::Proxy for TimeSourceControlProxy {
107 type Protocol = TimeSourceControlMarker;
108
109 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
110 Self::new(inner)
111 }
112
113 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
114 self.client.into_channel().map_err(|client| Self { client })
115 }
116
117 fn as_channel(&self) -> &::fidl::AsyncChannel {
118 self.client.as_channel()
119 }
120}
121
122impl TimeSourceControlProxy {
123 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
125 let protocol_name =
126 <TimeSourceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
127 Self { client: fidl::client::Client::new(channel, protocol_name) }
128 }
129
130 pub fn take_event_stream(&self) -> TimeSourceControlEventStream {
136 TimeSourceControlEventStream { event_receiver: self.client.take_event_receiver() }
137 }
138
139 pub fn r#connect_push_source(
141 &self,
142 mut push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
143 ) -> Result<(), fidl::Error> {
144 TimeSourceControlProxyInterface::r#connect_push_source(self, push_source)
145 }
146}
147
148impl TimeSourceControlProxyInterface for TimeSourceControlProxy {
149 fn r#connect_push_source(
150 &self,
151 mut push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
152 ) -> Result<(), fidl::Error> {
153 self.client.send::<TimeSourceControlConnectPushSourceRequest>(
154 (push_source,),
155 0x6da5e3723a74f6e4,
156 fidl::encoding::DynamicFlags::empty(),
157 )
158 }
159}
160
161pub struct TimeSourceControlEventStream {
162 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
163}
164
165impl std::marker::Unpin for TimeSourceControlEventStream {}
166
167impl futures::stream::FusedStream for TimeSourceControlEventStream {
168 fn is_terminated(&self) -> bool {
169 self.event_receiver.is_terminated()
170 }
171}
172
173impl futures::Stream for TimeSourceControlEventStream {
174 type Item = Result<TimeSourceControlEvent, fidl::Error>;
175
176 fn poll_next(
177 mut self: std::pin::Pin<&mut Self>,
178 cx: &mut std::task::Context<'_>,
179 ) -> std::task::Poll<Option<Self::Item>> {
180 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
181 &mut self.event_receiver,
182 cx
183 )?) {
184 Some(buf) => std::task::Poll::Ready(Some(TimeSourceControlEvent::decode(buf))),
185 None => std::task::Poll::Ready(None),
186 }
187 }
188}
189
190#[derive(Debug)]
191pub enum TimeSourceControlEvent {}
192
193impl TimeSourceControlEvent {
194 fn decode(
196 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
197 ) -> Result<TimeSourceControlEvent, fidl::Error> {
198 let (bytes, _handles) = buf.split_mut();
199 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
200 debug_assert_eq!(tx_header.tx_id, 0);
201 match tx_header.ordinal {
202 _ => Err(fidl::Error::UnknownOrdinal {
203 ordinal: tx_header.ordinal,
204 protocol_name:
205 <TimeSourceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
206 }),
207 }
208 }
209}
210
211pub struct TimeSourceControlRequestStream {
213 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
214 is_terminated: bool,
215}
216
217impl std::marker::Unpin for TimeSourceControlRequestStream {}
218
219impl futures::stream::FusedStream for TimeSourceControlRequestStream {
220 fn is_terminated(&self) -> bool {
221 self.is_terminated
222 }
223}
224
225impl fidl::endpoints::RequestStream for TimeSourceControlRequestStream {
226 type Protocol = TimeSourceControlMarker;
227 type ControlHandle = TimeSourceControlControlHandle;
228
229 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
230 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
231 }
232
233 fn control_handle(&self) -> Self::ControlHandle {
234 TimeSourceControlControlHandle { inner: self.inner.clone() }
235 }
236
237 fn into_inner(
238 self,
239 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
240 {
241 (self.inner, self.is_terminated)
242 }
243
244 fn from_inner(
245 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
246 is_terminated: bool,
247 ) -> Self {
248 Self { inner, is_terminated }
249 }
250}
251
252impl futures::Stream for TimeSourceControlRequestStream {
253 type Item = Result<TimeSourceControlRequest, fidl::Error>;
254
255 fn poll_next(
256 mut self: std::pin::Pin<&mut Self>,
257 cx: &mut std::task::Context<'_>,
258 ) -> std::task::Poll<Option<Self::Item>> {
259 let this = &mut *self;
260 if this.inner.check_shutdown(cx) {
261 this.is_terminated = true;
262 return std::task::Poll::Ready(None);
263 }
264 if this.is_terminated {
265 panic!("polled TimeSourceControlRequestStream after completion");
266 }
267 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
268 |bytes, handles| {
269 match this.inner.channel().read_etc(cx, bytes, handles) {
270 std::task::Poll::Ready(Ok(())) => {}
271 std::task::Poll::Pending => return std::task::Poll::Pending,
272 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
273 this.is_terminated = true;
274 return std::task::Poll::Ready(None);
275 }
276 std::task::Poll::Ready(Err(e)) => {
277 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
278 e.into(),
279 ))))
280 }
281 }
282
283 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
285
286 std::task::Poll::Ready(Some(match header.ordinal {
287 0x6da5e3723a74f6e4 => {
288 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
289 let mut req = fidl::new_empty!(
290 TimeSourceControlConnectPushSourceRequest,
291 fidl::encoding::DefaultFuchsiaResourceDialect
292 );
293 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeSourceControlConnectPushSourceRequest>(&header, _body_bytes, handles, &mut req)?;
294 let control_handle =
295 TimeSourceControlControlHandle { inner: this.inner.clone() };
296 Ok(TimeSourceControlRequest::ConnectPushSource {
297 push_source: req.push_source,
298
299 control_handle,
300 })
301 }
302 _ => Err(fidl::Error::UnknownOrdinal {
303 ordinal: header.ordinal,
304 protocol_name:
305 <TimeSourceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
306 }),
307 }))
308 },
309 )
310 }
311}
312
313#[derive(Debug)]
318pub enum TimeSourceControlRequest {
319 ConnectPushSource {
321 push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
322 control_handle: TimeSourceControlControlHandle,
323 },
324}
325
326impl TimeSourceControlRequest {
327 #[allow(irrefutable_let_patterns)]
328 pub fn into_connect_push_source(
329 self,
330 ) -> Option<(
331 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
332 TimeSourceControlControlHandle,
333 )> {
334 if let TimeSourceControlRequest::ConnectPushSource { push_source, control_handle } = self {
335 Some((push_source, control_handle))
336 } else {
337 None
338 }
339 }
340
341 pub fn method_name(&self) -> &'static str {
343 match *self {
344 TimeSourceControlRequest::ConnectPushSource { .. } => "connect_push_source",
345 }
346 }
347}
348
349#[derive(Debug, Clone)]
350pub struct TimeSourceControlControlHandle {
351 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
352}
353
354impl fidl::endpoints::ControlHandle for TimeSourceControlControlHandle {
355 fn shutdown(&self) {
356 self.inner.shutdown()
357 }
358 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
359 self.inner.shutdown_with_epitaph(status)
360 }
361
362 fn is_closed(&self) -> bool {
363 self.inner.channel().is_closed()
364 }
365 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
366 self.inner.channel().on_closed()
367 }
368
369 #[cfg(target_os = "fuchsia")]
370 fn signal_peer(
371 &self,
372 clear_mask: zx::Signals,
373 set_mask: zx::Signals,
374 ) -> Result<(), zx_status::Status> {
375 use fidl::Peered;
376 self.inner.channel().signal_peer(clear_mask, set_mask)
377 }
378}
379
380impl TimeSourceControlControlHandle {}
381
382mod internal {
383 use super::*;
384
385 impl fidl::encoding::ResourceTypeMarker for TimeSourceControlConnectPushSourceRequest {
386 type Borrowed<'a> = &'a mut Self;
387 fn take_or_borrow<'a>(
388 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
389 ) -> Self::Borrowed<'a> {
390 value
391 }
392 }
393
394 unsafe impl fidl::encoding::TypeMarker for TimeSourceControlConnectPushSourceRequest {
395 type Owned = Self;
396
397 #[inline(always)]
398 fn inline_align(_context: fidl::encoding::Context) -> usize {
399 4
400 }
401
402 #[inline(always)]
403 fn inline_size(_context: fidl::encoding::Context) -> usize {
404 4
405 }
406 }
407
408 unsafe impl
409 fidl::encoding::Encode<
410 TimeSourceControlConnectPushSourceRequest,
411 fidl::encoding::DefaultFuchsiaResourceDialect,
412 > for &mut TimeSourceControlConnectPushSourceRequest
413 {
414 #[inline]
415 unsafe fn encode(
416 self,
417 encoder: &mut fidl::encoding::Encoder<
418 '_,
419 fidl::encoding::DefaultFuchsiaResourceDialect,
420 >,
421 offset: usize,
422 _depth: fidl::encoding::Depth,
423 ) -> fidl::Result<()> {
424 encoder.debug_check_bounds::<TimeSourceControlConnectPushSourceRequest>(offset);
425 fidl::encoding::Encode::<
427 TimeSourceControlConnectPushSourceRequest,
428 fidl::encoding::DefaultFuchsiaResourceDialect,
429 >::encode(
430 (<fidl::encoding::Endpoint<
431 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
432 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
433 &mut self.push_source
434 ),),
435 encoder,
436 offset,
437 _depth,
438 )
439 }
440 }
441 unsafe impl<
442 T0: fidl::encoding::Encode<
443 fidl::encoding::Endpoint<
444 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
445 >,
446 fidl::encoding::DefaultFuchsiaResourceDialect,
447 >,
448 >
449 fidl::encoding::Encode<
450 TimeSourceControlConnectPushSourceRequest,
451 fidl::encoding::DefaultFuchsiaResourceDialect,
452 > for (T0,)
453 {
454 #[inline]
455 unsafe fn encode(
456 self,
457 encoder: &mut fidl::encoding::Encoder<
458 '_,
459 fidl::encoding::DefaultFuchsiaResourceDialect,
460 >,
461 offset: usize,
462 depth: fidl::encoding::Depth,
463 ) -> fidl::Result<()> {
464 encoder.debug_check_bounds::<TimeSourceControlConnectPushSourceRequest>(offset);
465 self.0.encode(encoder, offset + 0, depth)?;
469 Ok(())
470 }
471 }
472
473 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
474 for TimeSourceControlConnectPushSourceRequest
475 {
476 #[inline(always)]
477 fn new_empty() -> Self {
478 Self {
479 push_source: fidl::new_empty!(
480 fidl::encoding::Endpoint<
481 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
482 >,
483 fidl::encoding::DefaultFuchsiaResourceDialect
484 ),
485 }
486 }
487
488 #[inline]
489 unsafe fn decode(
490 &mut self,
491 decoder: &mut fidl::encoding::Decoder<
492 '_,
493 fidl::encoding::DefaultFuchsiaResourceDialect,
494 >,
495 offset: usize,
496 _depth: fidl::encoding::Depth,
497 ) -> fidl::Result<()> {
498 decoder.debug_check_bounds::<Self>(offset);
499 fidl::decode!(
501 fidl::encoding::Endpoint<
502 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
503 >,
504 fidl::encoding::DefaultFuchsiaResourceDialect,
505 &mut self.push_source,
506 decoder,
507 offset + 0,
508 _depth
509 )?;
510 Ok(())
511 }
512 }
513}