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#[cfg(target_os = "fuchsia")]
102impl From<TimeSourceControlSynchronousProxy> for zx::Handle {
103 fn from(value: TimeSourceControlSynchronousProxy) -> Self {
104 value.into_channel().into()
105 }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl From<fidl::Channel> for TimeSourceControlSynchronousProxy {
110 fn from(value: fidl::Channel) -> Self {
111 Self::new(value)
112 }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl fidl::endpoints::FromClient for TimeSourceControlSynchronousProxy {
117 type Protocol = TimeSourceControlMarker;
118
119 fn from_client(value: fidl::endpoints::ClientEnd<TimeSourceControlMarker>) -> Self {
120 Self::new(value.into_channel())
121 }
122}
123
124#[derive(Debug, Clone)]
125pub struct TimeSourceControlProxy {
126 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
127}
128
129impl fidl::endpoints::Proxy for TimeSourceControlProxy {
130 type Protocol = TimeSourceControlMarker;
131
132 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
133 Self::new(inner)
134 }
135
136 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
137 self.client.into_channel().map_err(|client| Self { client })
138 }
139
140 fn as_channel(&self) -> &::fidl::AsyncChannel {
141 self.client.as_channel()
142 }
143}
144
145impl TimeSourceControlProxy {
146 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
148 let protocol_name =
149 <TimeSourceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
150 Self { client: fidl::client::Client::new(channel, protocol_name) }
151 }
152
153 pub fn take_event_stream(&self) -> TimeSourceControlEventStream {
159 TimeSourceControlEventStream { event_receiver: self.client.take_event_receiver() }
160 }
161
162 pub fn r#connect_push_source(
164 &self,
165 mut push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
166 ) -> Result<(), fidl::Error> {
167 TimeSourceControlProxyInterface::r#connect_push_source(self, push_source)
168 }
169}
170
171impl TimeSourceControlProxyInterface for TimeSourceControlProxy {
172 fn r#connect_push_source(
173 &self,
174 mut push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
175 ) -> Result<(), fidl::Error> {
176 self.client.send::<TimeSourceControlConnectPushSourceRequest>(
177 (push_source,),
178 0x6da5e3723a74f6e4,
179 fidl::encoding::DynamicFlags::empty(),
180 )
181 }
182}
183
184pub struct TimeSourceControlEventStream {
185 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
186}
187
188impl std::marker::Unpin for TimeSourceControlEventStream {}
189
190impl futures::stream::FusedStream for TimeSourceControlEventStream {
191 fn is_terminated(&self) -> bool {
192 self.event_receiver.is_terminated()
193 }
194}
195
196impl futures::Stream for TimeSourceControlEventStream {
197 type Item = Result<TimeSourceControlEvent, fidl::Error>;
198
199 fn poll_next(
200 mut self: std::pin::Pin<&mut Self>,
201 cx: &mut std::task::Context<'_>,
202 ) -> std::task::Poll<Option<Self::Item>> {
203 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
204 &mut self.event_receiver,
205 cx
206 )?) {
207 Some(buf) => std::task::Poll::Ready(Some(TimeSourceControlEvent::decode(buf))),
208 None => std::task::Poll::Ready(None),
209 }
210 }
211}
212
213#[derive(Debug)]
214pub enum TimeSourceControlEvent {}
215
216impl TimeSourceControlEvent {
217 fn decode(
219 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
220 ) -> Result<TimeSourceControlEvent, fidl::Error> {
221 let (bytes, _handles) = buf.split_mut();
222 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
223 debug_assert_eq!(tx_header.tx_id, 0);
224 match tx_header.ordinal {
225 _ => Err(fidl::Error::UnknownOrdinal {
226 ordinal: tx_header.ordinal,
227 protocol_name:
228 <TimeSourceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
229 }),
230 }
231 }
232}
233
234pub struct TimeSourceControlRequestStream {
236 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
237 is_terminated: bool,
238}
239
240impl std::marker::Unpin for TimeSourceControlRequestStream {}
241
242impl futures::stream::FusedStream for TimeSourceControlRequestStream {
243 fn is_terminated(&self) -> bool {
244 self.is_terminated
245 }
246}
247
248impl fidl::endpoints::RequestStream for TimeSourceControlRequestStream {
249 type Protocol = TimeSourceControlMarker;
250 type ControlHandle = TimeSourceControlControlHandle;
251
252 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
253 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
254 }
255
256 fn control_handle(&self) -> Self::ControlHandle {
257 TimeSourceControlControlHandle { inner: self.inner.clone() }
258 }
259
260 fn into_inner(
261 self,
262 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
263 {
264 (self.inner, self.is_terminated)
265 }
266
267 fn from_inner(
268 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
269 is_terminated: bool,
270 ) -> Self {
271 Self { inner, is_terminated }
272 }
273}
274
275impl futures::Stream for TimeSourceControlRequestStream {
276 type Item = Result<TimeSourceControlRequest, fidl::Error>;
277
278 fn poll_next(
279 mut self: std::pin::Pin<&mut Self>,
280 cx: &mut std::task::Context<'_>,
281 ) -> std::task::Poll<Option<Self::Item>> {
282 let this = &mut *self;
283 if this.inner.check_shutdown(cx) {
284 this.is_terminated = true;
285 return std::task::Poll::Ready(None);
286 }
287 if this.is_terminated {
288 panic!("polled TimeSourceControlRequestStream after completion");
289 }
290 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
291 |bytes, handles| {
292 match this.inner.channel().read_etc(cx, bytes, handles) {
293 std::task::Poll::Ready(Ok(())) => {}
294 std::task::Poll::Pending => return std::task::Poll::Pending,
295 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
296 this.is_terminated = true;
297 return std::task::Poll::Ready(None);
298 }
299 std::task::Poll::Ready(Err(e)) => {
300 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
301 e.into(),
302 ))))
303 }
304 }
305
306 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
308
309 std::task::Poll::Ready(Some(match header.ordinal {
310 0x6da5e3723a74f6e4 => {
311 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
312 let mut req = fidl::new_empty!(
313 TimeSourceControlConnectPushSourceRequest,
314 fidl::encoding::DefaultFuchsiaResourceDialect
315 );
316 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TimeSourceControlConnectPushSourceRequest>(&header, _body_bytes, handles, &mut req)?;
317 let control_handle =
318 TimeSourceControlControlHandle { inner: this.inner.clone() };
319 Ok(TimeSourceControlRequest::ConnectPushSource {
320 push_source: req.push_source,
321
322 control_handle,
323 })
324 }
325 _ => Err(fidl::Error::UnknownOrdinal {
326 ordinal: header.ordinal,
327 protocol_name:
328 <TimeSourceControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
329 }),
330 }))
331 },
332 )
333 }
334}
335
336#[derive(Debug)]
341pub enum TimeSourceControlRequest {
342 ConnectPushSource {
344 push_source: fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
345 control_handle: TimeSourceControlControlHandle,
346 },
347}
348
349impl TimeSourceControlRequest {
350 #[allow(irrefutable_let_patterns)]
351 pub fn into_connect_push_source(
352 self,
353 ) -> Option<(
354 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
355 TimeSourceControlControlHandle,
356 )> {
357 if let TimeSourceControlRequest::ConnectPushSource { push_source, control_handle } = self {
358 Some((push_source, control_handle))
359 } else {
360 None
361 }
362 }
363
364 pub fn method_name(&self) -> &'static str {
366 match *self {
367 TimeSourceControlRequest::ConnectPushSource { .. } => "connect_push_source",
368 }
369 }
370}
371
372#[derive(Debug, Clone)]
373pub struct TimeSourceControlControlHandle {
374 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
375}
376
377impl fidl::endpoints::ControlHandle for TimeSourceControlControlHandle {
378 fn shutdown(&self) {
379 self.inner.shutdown()
380 }
381 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
382 self.inner.shutdown_with_epitaph(status)
383 }
384
385 fn is_closed(&self) -> bool {
386 self.inner.channel().is_closed()
387 }
388 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
389 self.inner.channel().on_closed()
390 }
391
392 #[cfg(target_os = "fuchsia")]
393 fn signal_peer(
394 &self,
395 clear_mask: zx::Signals,
396 set_mask: zx::Signals,
397 ) -> Result<(), zx_status::Status> {
398 use fidl::Peered;
399 self.inner.channel().signal_peer(clear_mask, set_mask)
400 }
401}
402
403impl TimeSourceControlControlHandle {}
404
405mod internal {
406 use super::*;
407
408 impl fidl::encoding::ResourceTypeMarker for TimeSourceControlConnectPushSourceRequest {
409 type Borrowed<'a> = &'a mut Self;
410 fn take_or_borrow<'a>(
411 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
412 ) -> Self::Borrowed<'a> {
413 value
414 }
415 }
416
417 unsafe impl fidl::encoding::TypeMarker for TimeSourceControlConnectPushSourceRequest {
418 type Owned = Self;
419
420 #[inline(always)]
421 fn inline_align(_context: fidl::encoding::Context) -> usize {
422 4
423 }
424
425 #[inline(always)]
426 fn inline_size(_context: fidl::encoding::Context) -> usize {
427 4
428 }
429 }
430
431 unsafe impl
432 fidl::encoding::Encode<
433 TimeSourceControlConnectPushSourceRequest,
434 fidl::encoding::DefaultFuchsiaResourceDialect,
435 > for &mut TimeSourceControlConnectPushSourceRequest
436 {
437 #[inline]
438 unsafe fn encode(
439 self,
440 encoder: &mut fidl::encoding::Encoder<
441 '_,
442 fidl::encoding::DefaultFuchsiaResourceDialect,
443 >,
444 offset: usize,
445 _depth: fidl::encoding::Depth,
446 ) -> fidl::Result<()> {
447 encoder.debug_check_bounds::<TimeSourceControlConnectPushSourceRequest>(offset);
448 fidl::encoding::Encode::<
450 TimeSourceControlConnectPushSourceRequest,
451 fidl::encoding::DefaultFuchsiaResourceDialect,
452 >::encode(
453 (<fidl::encoding::Endpoint<
454 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
455 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
456 &mut self.push_source
457 ),),
458 encoder,
459 offset,
460 _depth,
461 )
462 }
463 }
464 unsafe impl<
465 T0: fidl::encoding::Encode<
466 fidl::encoding::Endpoint<
467 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
468 >,
469 fidl::encoding::DefaultFuchsiaResourceDialect,
470 >,
471 >
472 fidl::encoding::Encode<
473 TimeSourceControlConnectPushSourceRequest,
474 fidl::encoding::DefaultFuchsiaResourceDialect,
475 > for (T0,)
476 {
477 #[inline]
478 unsafe fn encode(
479 self,
480 encoder: &mut fidl::encoding::Encoder<
481 '_,
482 fidl::encoding::DefaultFuchsiaResourceDialect,
483 >,
484 offset: usize,
485 depth: fidl::encoding::Depth,
486 ) -> fidl::Result<()> {
487 encoder.debug_check_bounds::<TimeSourceControlConnectPushSourceRequest>(offset);
488 self.0.encode(encoder, offset + 0, depth)?;
492 Ok(())
493 }
494 }
495
496 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
497 for TimeSourceControlConnectPushSourceRequest
498 {
499 #[inline(always)]
500 fn new_empty() -> Self {
501 Self {
502 push_source: fidl::new_empty!(
503 fidl::encoding::Endpoint<
504 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
505 >,
506 fidl::encoding::DefaultFuchsiaResourceDialect
507 ),
508 }
509 }
510
511 #[inline]
512 unsafe fn decode(
513 &mut self,
514 decoder: &mut fidl::encoding::Decoder<
515 '_,
516 fidl::encoding::DefaultFuchsiaResourceDialect,
517 >,
518 offset: usize,
519 _depth: fidl::encoding::Depth,
520 ) -> fidl::Result<()> {
521 decoder.debug_check_bounds::<Self>(offset);
522 fidl::decode!(
524 fidl::encoding::Endpoint<
525 fidl::endpoints::ServerEnd<fidl_fuchsia_time_external::PushSourceMarker>,
526 >,
527 fidl::encoding::DefaultFuchsiaResourceDialect,
528 &mut self.push_source,
529 decoder,
530 offset + 0,
531 _depth
532 )?;
533 Ok(())
534 }
535 }
536}