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_netemul_sync__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct SyncManagerBusSubscribeRequest {
16 pub bus_name: String,
17 pub client_name: String,
18 pub bus: fidl::endpoints::ServerEnd<BusMarker>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22 for SyncManagerBusSubscribeRequest
23{
24}
25
26#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
27pub struct BusMarker;
28
29impl fidl::endpoints::ProtocolMarker for BusMarker {
30 type Proxy = BusProxy;
31 type RequestStream = BusRequestStream;
32 #[cfg(target_os = "fuchsia")]
33 type SynchronousProxy = BusSynchronousProxy;
34
35 const DEBUG_NAME: &'static str = "(anonymous) Bus";
36}
37
38pub trait BusProxyInterface: Send + Sync {
39 fn r#publish(&self, data: &Event) -> Result<(), fidl::Error>;
40 type EnsurePublishResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
41 fn r#ensure_publish(&self, data: &Event) -> Self::EnsurePublishResponseFut;
42 type GetClientsResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>>
43 + Send;
44 fn r#get_clients(&self) -> Self::GetClientsResponseFut;
45 type WaitForClientsResponseFut: std::future::Future<Output = Result<(bool, Option<Vec<String>>), fidl::Error>>
46 + Send;
47 fn r#wait_for_clients(
48 &self,
49 clients: &[String],
50 timeout: i64,
51 ) -> Self::WaitForClientsResponseFut;
52 type WaitForEvent_ResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
53 fn r#wait_for_event_(&self, data: &Event, timeout: i64) -> Self::WaitForEvent_ResponseFut;
54}
55#[derive(Debug)]
56#[cfg(target_os = "fuchsia")]
57pub struct BusSynchronousProxy {
58 client: fidl::client::sync::Client,
59}
60
61#[cfg(target_os = "fuchsia")]
62impl fidl::endpoints::SynchronousProxy for BusSynchronousProxy {
63 type Proxy = BusProxy;
64 type Protocol = BusMarker;
65
66 fn from_channel(inner: fidl::Channel) -> Self {
67 Self::new(inner)
68 }
69
70 fn into_channel(self) -> fidl::Channel {
71 self.client.into_channel()
72 }
73
74 fn as_channel(&self) -> &fidl::Channel {
75 self.client.as_channel()
76 }
77}
78
79#[cfg(target_os = "fuchsia")]
80impl BusSynchronousProxy {
81 pub fn new(channel: fidl::Channel) -> Self {
82 let protocol_name = <BusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
83 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
84 }
85
86 pub fn into_channel(self) -> fidl::Channel {
87 self.client.into_channel()
88 }
89
90 pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<BusEvent, fidl::Error> {
93 BusEvent::decode(self.client.wait_for_event(deadline)?)
94 }
95
96 pub fn r#publish(&self, mut data: &Event) -> Result<(), fidl::Error> {
98 self.client.send::<BusPublishRequest>(
99 (data,),
100 0x331ceb644024c14b,
101 fidl::encoding::DynamicFlags::empty(),
102 )
103 }
104
105 pub fn r#ensure_publish(
110 &self,
111 mut data: &Event,
112 ___deadline: zx::MonotonicInstant,
113 ) -> Result<(), fidl::Error> {
114 let _response =
115 self.client.send_query::<BusEnsurePublishRequest, fidl::encoding::EmptyPayload>(
116 (data,),
117 0x2969c5f5de5bb64,
118 fidl::encoding::DynamicFlags::empty(),
119 ___deadline,
120 )?;
121 Ok(_response)
122 }
123
124 pub fn r#get_clients(
126 &self,
127 ___deadline: zx::MonotonicInstant,
128 ) -> Result<Vec<String>, fidl::Error> {
129 let _response =
130 self.client.send_query::<fidl::encoding::EmptyPayload, BusGetClientsResponse>(
131 (),
132 0x733c5e2d525a006b,
133 fidl::encoding::DynamicFlags::empty(),
134 ___deadline,
135 )?;
136 Ok(_response.clients)
137 }
138
139 pub fn r#wait_for_clients(
145 &self,
146 mut clients: &[String],
147 mut timeout: i64,
148 ___deadline: zx::MonotonicInstant,
149 ) -> Result<(bool, Option<Vec<String>>), fidl::Error> {
150 let _response =
151 self.client.send_query::<BusWaitForClientsRequest, BusWaitForClientsResponse>(
152 (clients, timeout),
153 0x21c89fc6be990b23,
154 fidl::encoding::DynamicFlags::empty(),
155 ___deadline,
156 )?;
157 Ok((_response.result, _response.absent))
158 }
159
160 pub fn r#wait_for_event_(
165 &self,
166 mut data: &Event,
167 mut timeout: i64,
168 ___deadline: zx::MonotonicInstant,
169 ) -> Result<bool, fidl::Error> {
170 let _response = self.client.send_query::<BusWaitForEventRequest, BusWaitForEventResponse>(
171 (data, timeout),
172 0x600ca084a42ee5bf,
173 fidl::encoding::DynamicFlags::empty(),
174 ___deadline,
175 )?;
176 Ok(_response.result)
177 }
178}
179
180#[cfg(target_os = "fuchsia")]
181impl From<BusSynchronousProxy> for zx::Handle {
182 fn from(value: BusSynchronousProxy) -> Self {
183 value.into_channel().into()
184 }
185}
186
187#[cfg(target_os = "fuchsia")]
188impl From<fidl::Channel> for BusSynchronousProxy {
189 fn from(value: fidl::Channel) -> Self {
190 Self::new(value)
191 }
192}
193
194#[cfg(target_os = "fuchsia")]
195impl fidl::endpoints::FromClient for BusSynchronousProxy {
196 type Protocol = BusMarker;
197
198 fn from_client(value: fidl::endpoints::ClientEnd<BusMarker>) -> Self {
199 Self::new(value.into_channel())
200 }
201}
202
203#[derive(Debug, Clone)]
204pub struct BusProxy {
205 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
206}
207
208impl fidl::endpoints::Proxy for BusProxy {
209 type Protocol = BusMarker;
210
211 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
212 Self::new(inner)
213 }
214
215 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
216 self.client.into_channel().map_err(|client| Self { client })
217 }
218
219 fn as_channel(&self) -> &::fidl::AsyncChannel {
220 self.client.as_channel()
221 }
222}
223
224impl BusProxy {
225 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
227 let protocol_name = <BusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
228 Self { client: fidl::client::Client::new(channel, protocol_name) }
229 }
230
231 pub fn take_event_stream(&self) -> BusEventStream {
237 BusEventStream { event_receiver: self.client.take_event_receiver() }
238 }
239
240 pub fn r#publish(&self, mut data: &Event) -> Result<(), fidl::Error> {
242 BusProxyInterface::r#publish(self, data)
243 }
244
245 pub fn r#ensure_publish(
250 &self,
251 mut data: &Event,
252 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
253 BusProxyInterface::r#ensure_publish(self, data)
254 }
255
256 pub fn r#get_clients(
258 &self,
259 ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
260 {
261 BusProxyInterface::r#get_clients(self)
262 }
263
264 pub fn r#wait_for_clients(
270 &self,
271 mut clients: &[String],
272 mut timeout: i64,
273 ) -> fidl::client::QueryResponseFut<
274 (bool, Option<Vec<String>>),
275 fidl::encoding::DefaultFuchsiaResourceDialect,
276 > {
277 BusProxyInterface::r#wait_for_clients(self, clients, timeout)
278 }
279
280 pub fn r#wait_for_event_(
285 &self,
286 mut data: &Event,
287 mut timeout: i64,
288 ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
289 BusProxyInterface::r#wait_for_event_(self, data, timeout)
290 }
291}
292
293impl BusProxyInterface for BusProxy {
294 fn r#publish(&self, mut data: &Event) -> Result<(), fidl::Error> {
295 self.client.send::<BusPublishRequest>(
296 (data,),
297 0x331ceb644024c14b,
298 fidl::encoding::DynamicFlags::empty(),
299 )
300 }
301
302 type EnsurePublishResponseFut =
303 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
304 fn r#ensure_publish(&self, mut data: &Event) -> Self::EnsurePublishResponseFut {
305 fn _decode(
306 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
307 ) -> Result<(), fidl::Error> {
308 let _response = fidl::client::decode_transaction_body::<
309 fidl::encoding::EmptyPayload,
310 fidl::encoding::DefaultFuchsiaResourceDialect,
311 0x2969c5f5de5bb64,
312 >(_buf?)?;
313 Ok(_response)
314 }
315 self.client.send_query_and_decode::<BusEnsurePublishRequest, ()>(
316 (data,),
317 0x2969c5f5de5bb64,
318 fidl::encoding::DynamicFlags::empty(),
319 _decode,
320 )
321 }
322
323 type GetClientsResponseFut =
324 fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
325 fn r#get_clients(&self) -> Self::GetClientsResponseFut {
326 fn _decode(
327 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
328 ) -> Result<Vec<String>, fidl::Error> {
329 let _response = fidl::client::decode_transaction_body::<
330 BusGetClientsResponse,
331 fidl::encoding::DefaultFuchsiaResourceDialect,
332 0x733c5e2d525a006b,
333 >(_buf?)?;
334 Ok(_response.clients)
335 }
336 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
337 (),
338 0x733c5e2d525a006b,
339 fidl::encoding::DynamicFlags::empty(),
340 _decode,
341 )
342 }
343
344 type WaitForClientsResponseFut = fidl::client::QueryResponseFut<
345 (bool, Option<Vec<String>>),
346 fidl::encoding::DefaultFuchsiaResourceDialect,
347 >;
348 fn r#wait_for_clients(
349 &self,
350 mut clients: &[String],
351 mut timeout: i64,
352 ) -> Self::WaitForClientsResponseFut {
353 fn _decode(
354 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
355 ) -> Result<(bool, Option<Vec<String>>), fidl::Error> {
356 let _response = fidl::client::decode_transaction_body::<
357 BusWaitForClientsResponse,
358 fidl::encoding::DefaultFuchsiaResourceDialect,
359 0x21c89fc6be990b23,
360 >(_buf?)?;
361 Ok((_response.result, _response.absent))
362 }
363 self.client.send_query_and_decode::<BusWaitForClientsRequest, (bool, Option<Vec<String>>)>(
364 (clients, timeout),
365 0x21c89fc6be990b23,
366 fidl::encoding::DynamicFlags::empty(),
367 _decode,
368 )
369 }
370
371 type WaitForEvent_ResponseFut =
372 fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
373 fn r#wait_for_event_(
374 &self,
375 mut data: &Event,
376 mut timeout: i64,
377 ) -> Self::WaitForEvent_ResponseFut {
378 fn _decode(
379 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
380 ) -> Result<bool, fidl::Error> {
381 let _response = fidl::client::decode_transaction_body::<
382 BusWaitForEventResponse,
383 fidl::encoding::DefaultFuchsiaResourceDialect,
384 0x600ca084a42ee5bf,
385 >(_buf?)?;
386 Ok(_response.result)
387 }
388 self.client.send_query_and_decode::<BusWaitForEventRequest, bool>(
389 (data, timeout),
390 0x600ca084a42ee5bf,
391 fidl::encoding::DynamicFlags::empty(),
392 _decode,
393 )
394 }
395}
396
397pub struct BusEventStream {
398 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
399}
400
401impl std::marker::Unpin for BusEventStream {}
402
403impl futures::stream::FusedStream for BusEventStream {
404 fn is_terminated(&self) -> bool {
405 self.event_receiver.is_terminated()
406 }
407}
408
409impl futures::Stream for BusEventStream {
410 type Item = Result<BusEvent, fidl::Error>;
411
412 fn poll_next(
413 mut self: std::pin::Pin<&mut Self>,
414 cx: &mut std::task::Context<'_>,
415 ) -> std::task::Poll<Option<Self::Item>> {
416 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
417 &mut self.event_receiver,
418 cx
419 )?) {
420 Some(buf) => std::task::Poll::Ready(Some(BusEvent::decode(buf))),
421 None => std::task::Poll::Ready(None),
422 }
423 }
424}
425
426#[derive(Debug)]
427pub enum BusEvent {
428 OnBusData { data: Event },
429 OnClientAttached { client: String },
430 OnClientDetached { client: String },
431}
432
433impl BusEvent {
434 #[allow(irrefutable_let_patterns)]
435 pub fn into_on_bus_data(self) -> Option<Event> {
436 if let BusEvent::OnBusData { data } = self { Some((data)) } else { None }
437 }
438 #[allow(irrefutable_let_patterns)]
439 pub fn into_on_client_attached(self) -> Option<String> {
440 if let BusEvent::OnClientAttached { client } = self { Some((client)) } else { None }
441 }
442 #[allow(irrefutable_let_patterns)]
443 pub fn into_on_client_detached(self) -> Option<String> {
444 if let BusEvent::OnClientDetached { client } = self { Some((client)) } else { None }
445 }
446
447 fn decode(
449 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
450 ) -> Result<BusEvent, fidl::Error> {
451 let (bytes, _handles) = buf.split_mut();
452 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
453 debug_assert_eq!(tx_header.tx_id, 0);
454 match tx_header.ordinal {
455 0x26e9b9ffb43f638f => {
456 let mut out = fidl::new_empty!(
457 BusOnBusDataRequest,
458 fidl::encoding::DefaultFuchsiaResourceDialect
459 );
460 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BusOnBusDataRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
461 Ok((BusEvent::OnBusData { data: out.data }))
462 }
463 0x41af94df60bf8ba7 => {
464 let mut out = fidl::new_empty!(
465 BusOnClientAttachedRequest,
466 fidl::encoding::DefaultFuchsiaResourceDialect
467 );
468 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BusOnClientAttachedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
469 Ok((BusEvent::OnClientAttached { client: out.client }))
470 }
471 0x31a36387f8ab00d8 => {
472 let mut out = fidl::new_empty!(
473 BusOnClientDetachedRequest,
474 fidl::encoding::DefaultFuchsiaResourceDialect
475 );
476 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BusOnClientDetachedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
477 Ok((BusEvent::OnClientDetached { client: out.client }))
478 }
479 _ => Err(fidl::Error::UnknownOrdinal {
480 ordinal: tx_header.ordinal,
481 protocol_name: <BusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
482 }),
483 }
484 }
485}
486
487pub struct BusRequestStream {
489 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
490 is_terminated: bool,
491}
492
493impl std::marker::Unpin for BusRequestStream {}
494
495impl futures::stream::FusedStream for BusRequestStream {
496 fn is_terminated(&self) -> bool {
497 self.is_terminated
498 }
499}
500
501impl fidl::endpoints::RequestStream for BusRequestStream {
502 type Protocol = BusMarker;
503 type ControlHandle = BusControlHandle;
504
505 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
506 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
507 }
508
509 fn control_handle(&self) -> Self::ControlHandle {
510 BusControlHandle { inner: self.inner.clone() }
511 }
512
513 fn into_inner(
514 self,
515 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
516 {
517 (self.inner, self.is_terminated)
518 }
519
520 fn from_inner(
521 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
522 is_terminated: bool,
523 ) -> Self {
524 Self { inner, is_terminated }
525 }
526}
527
528impl futures::Stream for BusRequestStream {
529 type Item = Result<BusRequest, fidl::Error>;
530
531 fn poll_next(
532 mut self: std::pin::Pin<&mut Self>,
533 cx: &mut std::task::Context<'_>,
534 ) -> std::task::Poll<Option<Self::Item>> {
535 let this = &mut *self;
536 if this.inner.check_shutdown(cx) {
537 this.is_terminated = true;
538 return std::task::Poll::Ready(None);
539 }
540 if this.is_terminated {
541 panic!("polled BusRequestStream after completion");
542 }
543 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
544 |bytes, handles| {
545 match this.inner.channel().read_etc(cx, bytes, handles) {
546 std::task::Poll::Ready(Ok(())) => {}
547 std::task::Poll::Pending => return std::task::Poll::Pending,
548 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
549 this.is_terminated = true;
550 return std::task::Poll::Ready(None);
551 }
552 std::task::Poll::Ready(Err(e)) => {
553 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
554 e.into(),
555 ))));
556 }
557 }
558
559 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
561
562 std::task::Poll::Ready(Some(match header.ordinal {
563 0x331ceb644024c14b => {
564 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
565 let mut req = fidl::new_empty!(
566 BusPublishRequest,
567 fidl::encoding::DefaultFuchsiaResourceDialect
568 );
569 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BusPublishRequest>(&header, _body_bytes, handles, &mut req)?;
570 let control_handle = BusControlHandle { inner: this.inner.clone() };
571 Ok(BusRequest::Publish { data: req.data, control_handle })
572 }
573 0x2969c5f5de5bb64 => {
574 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
575 let mut req = fidl::new_empty!(
576 BusEnsurePublishRequest,
577 fidl::encoding::DefaultFuchsiaResourceDialect
578 );
579 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BusEnsurePublishRequest>(&header, _body_bytes, handles, &mut req)?;
580 let control_handle = BusControlHandle { inner: this.inner.clone() };
581 Ok(BusRequest::EnsurePublish {
582 data: req.data,
583
584 responder: BusEnsurePublishResponder {
585 control_handle: std::mem::ManuallyDrop::new(control_handle),
586 tx_id: header.tx_id,
587 },
588 })
589 }
590 0x733c5e2d525a006b => {
591 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
592 let mut req = fidl::new_empty!(
593 fidl::encoding::EmptyPayload,
594 fidl::encoding::DefaultFuchsiaResourceDialect
595 );
596 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
597 let control_handle = BusControlHandle { inner: this.inner.clone() };
598 Ok(BusRequest::GetClients {
599 responder: BusGetClientsResponder {
600 control_handle: std::mem::ManuallyDrop::new(control_handle),
601 tx_id: header.tx_id,
602 },
603 })
604 }
605 0x21c89fc6be990b23 => {
606 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
607 let mut req = fidl::new_empty!(
608 BusWaitForClientsRequest,
609 fidl::encoding::DefaultFuchsiaResourceDialect
610 );
611 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BusWaitForClientsRequest>(&header, _body_bytes, handles, &mut req)?;
612 let control_handle = BusControlHandle { inner: this.inner.clone() };
613 Ok(BusRequest::WaitForClients {
614 clients: req.clients,
615 timeout: req.timeout,
616
617 responder: BusWaitForClientsResponder {
618 control_handle: std::mem::ManuallyDrop::new(control_handle),
619 tx_id: header.tx_id,
620 },
621 })
622 }
623 0x600ca084a42ee5bf => {
624 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
625 let mut req = fidl::new_empty!(
626 BusWaitForEventRequest,
627 fidl::encoding::DefaultFuchsiaResourceDialect
628 );
629 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BusWaitForEventRequest>(&header, _body_bytes, handles, &mut req)?;
630 let control_handle = BusControlHandle { inner: this.inner.clone() };
631 Ok(BusRequest::WaitForEvent_ {
632 data: req.data,
633 timeout: req.timeout,
634
635 responder: BusWaitForEvent_Responder {
636 control_handle: std::mem::ManuallyDrop::new(control_handle),
637 tx_id: header.tx_id,
638 },
639 })
640 }
641 _ => Err(fidl::Error::UnknownOrdinal {
642 ordinal: header.ordinal,
643 protocol_name: <BusMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
644 }),
645 }))
646 },
647 )
648 }
649}
650
651#[derive(Debug)]
655pub enum BusRequest {
656 Publish { data: Event, control_handle: BusControlHandle },
658 EnsurePublish { data: Event, responder: BusEnsurePublishResponder },
663 GetClients { responder: BusGetClientsResponder },
665 WaitForClients { clients: Vec<String>, timeout: i64, responder: BusWaitForClientsResponder },
671 WaitForEvent_ { data: Event, timeout: i64, responder: BusWaitForEvent_Responder },
676}
677
678impl BusRequest {
679 #[allow(irrefutable_let_patterns)]
680 pub fn into_publish(self) -> Option<(Event, BusControlHandle)> {
681 if let BusRequest::Publish { data, control_handle } = self {
682 Some((data, control_handle))
683 } else {
684 None
685 }
686 }
687
688 #[allow(irrefutable_let_patterns)]
689 pub fn into_ensure_publish(self) -> Option<(Event, BusEnsurePublishResponder)> {
690 if let BusRequest::EnsurePublish { data, responder } = self {
691 Some((data, responder))
692 } else {
693 None
694 }
695 }
696
697 #[allow(irrefutable_let_patterns)]
698 pub fn into_get_clients(self) -> Option<(BusGetClientsResponder)> {
699 if let BusRequest::GetClients { responder } = self { Some((responder)) } else { None }
700 }
701
702 #[allow(irrefutable_let_patterns)]
703 pub fn into_wait_for_clients(self) -> Option<(Vec<String>, i64, BusWaitForClientsResponder)> {
704 if let BusRequest::WaitForClients { clients, timeout, responder } = self {
705 Some((clients, timeout, responder))
706 } else {
707 None
708 }
709 }
710
711 #[allow(irrefutable_let_patterns)]
712 pub fn into_wait_for_event_(self) -> Option<(Event, i64, BusWaitForEvent_Responder)> {
713 if let BusRequest::WaitForEvent_ { data, timeout, responder } = self {
714 Some((data, timeout, responder))
715 } else {
716 None
717 }
718 }
719
720 pub fn method_name(&self) -> &'static str {
722 match *self {
723 BusRequest::Publish { .. } => "publish",
724 BusRequest::EnsurePublish { .. } => "ensure_publish",
725 BusRequest::GetClients { .. } => "get_clients",
726 BusRequest::WaitForClients { .. } => "wait_for_clients",
727 BusRequest::WaitForEvent_ { .. } => "wait_for_event_",
728 }
729 }
730}
731
732#[derive(Debug, Clone)]
733pub struct BusControlHandle {
734 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
735}
736
737impl fidl::endpoints::ControlHandle for BusControlHandle {
738 fn shutdown(&self) {
739 self.inner.shutdown()
740 }
741 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
742 self.inner.shutdown_with_epitaph(status)
743 }
744
745 fn is_closed(&self) -> bool {
746 self.inner.channel().is_closed()
747 }
748 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
749 self.inner.channel().on_closed()
750 }
751
752 #[cfg(target_os = "fuchsia")]
753 fn signal_peer(
754 &self,
755 clear_mask: zx::Signals,
756 set_mask: zx::Signals,
757 ) -> Result<(), zx_status::Status> {
758 use fidl::Peered;
759 self.inner.channel().signal_peer(clear_mask, set_mask)
760 }
761}
762
763impl BusControlHandle {
764 pub fn send_on_bus_data(&self, mut data: &Event) -> Result<(), fidl::Error> {
765 self.inner.send::<BusOnBusDataRequest>(
766 (data,),
767 0,
768 0x26e9b9ffb43f638f,
769 fidl::encoding::DynamicFlags::empty(),
770 )
771 }
772
773 pub fn send_on_client_attached(&self, mut client: &str) -> Result<(), fidl::Error> {
774 self.inner.send::<BusOnClientAttachedRequest>(
775 (client,),
776 0,
777 0x41af94df60bf8ba7,
778 fidl::encoding::DynamicFlags::empty(),
779 )
780 }
781
782 pub fn send_on_client_detached(&self, mut client: &str) -> Result<(), fidl::Error> {
783 self.inner.send::<BusOnClientDetachedRequest>(
784 (client,),
785 0,
786 0x31a36387f8ab00d8,
787 fidl::encoding::DynamicFlags::empty(),
788 )
789 }
790}
791
792#[must_use = "FIDL methods require a response to be sent"]
793#[derive(Debug)]
794pub struct BusEnsurePublishResponder {
795 control_handle: std::mem::ManuallyDrop<BusControlHandle>,
796 tx_id: u32,
797}
798
799impl std::ops::Drop for BusEnsurePublishResponder {
803 fn drop(&mut self) {
804 self.control_handle.shutdown();
805 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
807 }
808}
809
810impl fidl::endpoints::Responder for BusEnsurePublishResponder {
811 type ControlHandle = BusControlHandle;
812
813 fn control_handle(&self) -> &BusControlHandle {
814 &self.control_handle
815 }
816
817 fn drop_without_shutdown(mut self) {
818 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
820 std::mem::forget(self);
822 }
823}
824
825impl BusEnsurePublishResponder {
826 pub fn send(self) -> Result<(), fidl::Error> {
830 let _result = self.send_raw();
831 if _result.is_err() {
832 self.control_handle.shutdown();
833 }
834 self.drop_without_shutdown();
835 _result
836 }
837
838 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
840 let _result = self.send_raw();
841 self.drop_without_shutdown();
842 _result
843 }
844
845 fn send_raw(&self) -> Result<(), fidl::Error> {
846 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
847 (),
848 self.tx_id,
849 0x2969c5f5de5bb64,
850 fidl::encoding::DynamicFlags::empty(),
851 )
852 }
853}
854
855#[must_use = "FIDL methods require a response to be sent"]
856#[derive(Debug)]
857pub struct BusGetClientsResponder {
858 control_handle: std::mem::ManuallyDrop<BusControlHandle>,
859 tx_id: u32,
860}
861
862impl std::ops::Drop for BusGetClientsResponder {
866 fn drop(&mut self) {
867 self.control_handle.shutdown();
868 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
870 }
871}
872
873impl fidl::endpoints::Responder for BusGetClientsResponder {
874 type ControlHandle = BusControlHandle;
875
876 fn control_handle(&self) -> &BusControlHandle {
877 &self.control_handle
878 }
879
880 fn drop_without_shutdown(mut self) {
881 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
883 std::mem::forget(self);
885 }
886}
887
888impl BusGetClientsResponder {
889 pub fn send(self, mut clients: &[String]) -> Result<(), fidl::Error> {
893 let _result = self.send_raw(clients);
894 if _result.is_err() {
895 self.control_handle.shutdown();
896 }
897 self.drop_without_shutdown();
898 _result
899 }
900
901 pub fn send_no_shutdown_on_err(self, mut clients: &[String]) -> Result<(), fidl::Error> {
903 let _result = self.send_raw(clients);
904 self.drop_without_shutdown();
905 _result
906 }
907
908 fn send_raw(&self, mut clients: &[String]) -> Result<(), fidl::Error> {
909 self.control_handle.inner.send::<BusGetClientsResponse>(
910 (clients,),
911 self.tx_id,
912 0x733c5e2d525a006b,
913 fidl::encoding::DynamicFlags::empty(),
914 )
915 }
916}
917
918#[must_use = "FIDL methods require a response to be sent"]
919#[derive(Debug)]
920pub struct BusWaitForClientsResponder {
921 control_handle: std::mem::ManuallyDrop<BusControlHandle>,
922 tx_id: u32,
923}
924
925impl std::ops::Drop for BusWaitForClientsResponder {
929 fn drop(&mut self) {
930 self.control_handle.shutdown();
931 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
933 }
934}
935
936impl fidl::endpoints::Responder for BusWaitForClientsResponder {
937 type ControlHandle = BusControlHandle;
938
939 fn control_handle(&self) -> &BusControlHandle {
940 &self.control_handle
941 }
942
943 fn drop_without_shutdown(mut self) {
944 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
946 std::mem::forget(self);
948 }
949}
950
951impl BusWaitForClientsResponder {
952 pub fn send(self, mut result: bool, mut absent: Option<&[String]>) -> Result<(), fidl::Error> {
956 let _result = self.send_raw(result, absent);
957 if _result.is_err() {
958 self.control_handle.shutdown();
959 }
960 self.drop_without_shutdown();
961 _result
962 }
963
964 pub fn send_no_shutdown_on_err(
966 self,
967 mut result: bool,
968 mut absent: Option<&[String]>,
969 ) -> Result<(), fidl::Error> {
970 let _result = self.send_raw(result, absent);
971 self.drop_without_shutdown();
972 _result
973 }
974
975 fn send_raw(&self, mut result: bool, mut absent: Option<&[String]>) -> Result<(), fidl::Error> {
976 self.control_handle.inner.send::<BusWaitForClientsResponse>(
977 (result, absent),
978 self.tx_id,
979 0x21c89fc6be990b23,
980 fidl::encoding::DynamicFlags::empty(),
981 )
982 }
983}
984
985#[must_use = "FIDL methods require a response to be sent"]
986#[derive(Debug)]
987pub struct BusWaitForEvent_Responder {
988 control_handle: std::mem::ManuallyDrop<BusControlHandle>,
989 tx_id: u32,
990}
991
992impl std::ops::Drop for BusWaitForEvent_Responder {
996 fn drop(&mut self) {
997 self.control_handle.shutdown();
998 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1000 }
1001}
1002
1003impl fidl::endpoints::Responder for BusWaitForEvent_Responder {
1004 type ControlHandle = BusControlHandle;
1005
1006 fn control_handle(&self) -> &BusControlHandle {
1007 &self.control_handle
1008 }
1009
1010 fn drop_without_shutdown(mut self) {
1011 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1013 std::mem::forget(self);
1015 }
1016}
1017
1018impl BusWaitForEvent_Responder {
1019 pub fn send(self, mut result: bool) -> Result<(), fidl::Error> {
1023 let _result = self.send_raw(result);
1024 if _result.is_err() {
1025 self.control_handle.shutdown();
1026 }
1027 self.drop_without_shutdown();
1028 _result
1029 }
1030
1031 pub fn send_no_shutdown_on_err(self, mut result: bool) -> Result<(), fidl::Error> {
1033 let _result = self.send_raw(result);
1034 self.drop_without_shutdown();
1035 _result
1036 }
1037
1038 fn send_raw(&self, mut result: bool) -> Result<(), fidl::Error> {
1039 self.control_handle.inner.send::<BusWaitForEventResponse>(
1040 (result,),
1041 self.tx_id,
1042 0x600ca084a42ee5bf,
1043 fidl::encoding::DynamicFlags::empty(),
1044 )
1045 }
1046}
1047
1048#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1049pub struct SyncManagerMarker;
1050
1051impl fidl::endpoints::ProtocolMarker for SyncManagerMarker {
1052 type Proxy = SyncManagerProxy;
1053 type RequestStream = SyncManagerRequestStream;
1054 #[cfg(target_os = "fuchsia")]
1055 type SynchronousProxy = SyncManagerSynchronousProxy;
1056
1057 const DEBUG_NAME: &'static str = "fuchsia.netemul.sync.SyncManager";
1058}
1059impl fidl::endpoints::DiscoverableProtocolMarker for SyncManagerMarker {}
1060
1061pub trait SyncManagerProxyInterface: Send + Sync {
1062 fn r#bus_subscribe(
1063 &self,
1064 bus_name: &str,
1065 client_name: &str,
1066 bus: fidl::endpoints::ServerEnd<BusMarker>,
1067 ) -> Result<(), fidl::Error>;
1068 type WaitForBarrierThresholdResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
1069 + Send;
1070 fn r#wait_for_barrier_threshold(
1071 &self,
1072 barrier_name: &str,
1073 threshold: u32,
1074 timeout: i64,
1075 ) -> Self::WaitForBarrierThresholdResponseFut;
1076}
1077#[derive(Debug)]
1078#[cfg(target_os = "fuchsia")]
1079pub struct SyncManagerSynchronousProxy {
1080 client: fidl::client::sync::Client,
1081}
1082
1083#[cfg(target_os = "fuchsia")]
1084impl fidl::endpoints::SynchronousProxy for SyncManagerSynchronousProxy {
1085 type Proxy = SyncManagerProxy;
1086 type Protocol = SyncManagerMarker;
1087
1088 fn from_channel(inner: fidl::Channel) -> Self {
1089 Self::new(inner)
1090 }
1091
1092 fn into_channel(self) -> fidl::Channel {
1093 self.client.into_channel()
1094 }
1095
1096 fn as_channel(&self) -> &fidl::Channel {
1097 self.client.as_channel()
1098 }
1099}
1100
1101#[cfg(target_os = "fuchsia")]
1102impl SyncManagerSynchronousProxy {
1103 pub fn new(channel: fidl::Channel) -> Self {
1104 let protocol_name = <SyncManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1105 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1106 }
1107
1108 pub fn into_channel(self) -> fidl::Channel {
1109 self.client.into_channel()
1110 }
1111
1112 pub fn wait_for_event(
1115 &self,
1116 deadline: zx::MonotonicInstant,
1117 ) -> Result<SyncManagerEvent, fidl::Error> {
1118 SyncManagerEvent::decode(self.client.wait_for_event(deadline)?)
1119 }
1120
1121 pub fn r#bus_subscribe(
1124 &self,
1125 mut bus_name: &str,
1126 mut client_name: &str,
1127 mut bus: fidl::endpoints::ServerEnd<BusMarker>,
1128 ) -> Result<(), fidl::Error> {
1129 self.client.send::<SyncManagerBusSubscribeRequest>(
1130 (bus_name, client_name, bus),
1131 0x39c25d810b5e7407,
1132 fidl::encoding::DynamicFlags::empty(),
1133 )
1134 }
1135
1136 pub fn r#wait_for_barrier_threshold(
1141 &self,
1142 mut barrier_name: &str,
1143 mut threshold: u32,
1144 mut timeout: i64,
1145 ___deadline: zx::MonotonicInstant,
1146 ) -> Result<bool, fidl::Error> {
1147 let _response = self.client.send_query::<
1148 SyncManagerWaitForBarrierThresholdRequest,
1149 SyncManagerWaitForBarrierThresholdResponse,
1150 >(
1151 (barrier_name, threshold, timeout,),
1152 0x592056b5825f4292,
1153 fidl::encoding::DynamicFlags::empty(),
1154 ___deadline,
1155 )?;
1156 Ok(_response.result)
1157 }
1158}
1159
1160#[cfg(target_os = "fuchsia")]
1161impl From<SyncManagerSynchronousProxy> for zx::Handle {
1162 fn from(value: SyncManagerSynchronousProxy) -> Self {
1163 value.into_channel().into()
1164 }
1165}
1166
1167#[cfg(target_os = "fuchsia")]
1168impl From<fidl::Channel> for SyncManagerSynchronousProxy {
1169 fn from(value: fidl::Channel) -> Self {
1170 Self::new(value)
1171 }
1172}
1173
1174#[cfg(target_os = "fuchsia")]
1175impl fidl::endpoints::FromClient for SyncManagerSynchronousProxy {
1176 type Protocol = SyncManagerMarker;
1177
1178 fn from_client(value: fidl::endpoints::ClientEnd<SyncManagerMarker>) -> Self {
1179 Self::new(value.into_channel())
1180 }
1181}
1182
1183#[derive(Debug, Clone)]
1184pub struct SyncManagerProxy {
1185 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1186}
1187
1188impl fidl::endpoints::Proxy for SyncManagerProxy {
1189 type Protocol = SyncManagerMarker;
1190
1191 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1192 Self::new(inner)
1193 }
1194
1195 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1196 self.client.into_channel().map_err(|client| Self { client })
1197 }
1198
1199 fn as_channel(&self) -> &::fidl::AsyncChannel {
1200 self.client.as_channel()
1201 }
1202}
1203
1204impl SyncManagerProxy {
1205 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1207 let protocol_name = <SyncManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1208 Self { client: fidl::client::Client::new(channel, protocol_name) }
1209 }
1210
1211 pub fn take_event_stream(&self) -> SyncManagerEventStream {
1217 SyncManagerEventStream { event_receiver: self.client.take_event_receiver() }
1218 }
1219
1220 pub fn r#bus_subscribe(
1223 &self,
1224 mut bus_name: &str,
1225 mut client_name: &str,
1226 mut bus: fidl::endpoints::ServerEnd<BusMarker>,
1227 ) -> Result<(), fidl::Error> {
1228 SyncManagerProxyInterface::r#bus_subscribe(self, bus_name, client_name, bus)
1229 }
1230
1231 pub fn r#wait_for_barrier_threshold(
1236 &self,
1237 mut barrier_name: &str,
1238 mut threshold: u32,
1239 mut timeout: i64,
1240 ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
1241 SyncManagerProxyInterface::r#wait_for_barrier_threshold(
1242 self,
1243 barrier_name,
1244 threshold,
1245 timeout,
1246 )
1247 }
1248}
1249
1250impl SyncManagerProxyInterface for SyncManagerProxy {
1251 fn r#bus_subscribe(
1252 &self,
1253 mut bus_name: &str,
1254 mut client_name: &str,
1255 mut bus: fidl::endpoints::ServerEnd<BusMarker>,
1256 ) -> Result<(), fidl::Error> {
1257 self.client.send::<SyncManagerBusSubscribeRequest>(
1258 (bus_name, client_name, bus),
1259 0x39c25d810b5e7407,
1260 fidl::encoding::DynamicFlags::empty(),
1261 )
1262 }
1263
1264 type WaitForBarrierThresholdResponseFut =
1265 fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
1266 fn r#wait_for_barrier_threshold(
1267 &self,
1268 mut barrier_name: &str,
1269 mut threshold: u32,
1270 mut timeout: i64,
1271 ) -> Self::WaitForBarrierThresholdResponseFut {
1272 fn _decode(
1273 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1274 ) -> Result<bool, fidl::Error> {
1275 let _response = fidl::client::decode_transaction_body::<
1276 SyncManagerWaitForBarrierThresholdResponse,
1277 fidl::encoding::DefaultFuchsiaResourceDialect,
1278 0x592056b5825f4292,
1279 >(_buf?)?;
1280 Ok(_response.result)
1281 }
1282 self.client.send_query_and_decode::<SyncManagerWaitForBarrierThresholdRequest, bool>(
1283 (barrier_name, threshold, timeout),
1284 0x592056b5825f4292,
1285 fidl::encoding::DynamicFlags::empty(),
1286 _decode,
1287 )
1288 }
1289}
1290
1291pub struct SyncManagerEventStream {
1292 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1293}
1294
1295impl std::marker::Unpin for SyncManagerEventStream {}
1296
1297impl futures::stream::FusedStream for SyncManagerEventStream {
1298 fn is_terminated(&self) -> bool {
1299 self.event_receiver.is_terminated()
1300 }
1301}
1302
1303impl futures::Stream for SyncManagerEventStream {
1304 type Item = Result<SyncManagerEvent, fidl::Error>;
1305
1306 fn poll_next(
1307 mut self: std::pin::Pin<&mut Self>,
1308 cx: &mut std::task::Context<'_>,
1309 ) -> std::task::Poll<Option<Self::Item>> {
1310 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1311 &mut self.event_receiver,
1312 cx
1313 )?) {
1314 Some(buf) => std::task::Poll::Ready(Some(SyncManagerEvent::decode(buf))),
1315 None => std::task::Poll::Ready(None),
1316 }
1317 }
1318}
1319
1320#[derive(Debug)]
1321pub enum SyncManagerEvent {}
1322
1323impl SyncManagerEvent {
1324 fn decode(
1326 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1327 ) -> Result<SyncManagerEvent, fidl::Error> {
1328 let (bytes, _handles) = buf.split_mut();
1329 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1330 debug_assert_eq!(tx_header.tx_id, 0);
1331 match tx_header.ordinal {
1332 _ => Err(fidl::Error::UnknownOrdinal {
1333 ordinal: tx_header.ordinal,
1334 protocol_name: <SyncManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1335 }),
1336 }
1337 }
1338}
1339
1340pub struct SyncManagerRequestStream {
1342 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1343 is_terminated: bool,
1344}
1345
1346impl std::marker::Unpin for SyncManagerRequestStream {}
1347
1348impl futures::stream::FusedStream for SyncManagerRequestStream {
1349 fn is_terminated(&self) -> bool {
1350 self.is_terminated
1351 }
1352}
1353
1354impl fidl::endpoints::RequestStream for SyncManagerRequestStream {
1355 type Protocol = SyncManagerMarker;
1356 type ControlHandle = SyncManagerControlHandle;
1357
1358 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1359 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1360 }
1361
1362 fn control_handle(&self) -> Self::ControlHandle {
1363 SyncManagerControlHandle { inner: self.inner.clone() }
1364 }
1365
1366 fn into_inner(
1367 self,
1368 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1369 {
1370 (self.inner, self.is_terminated)
1371 }
1372
1373 fn from_inner(
1374 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1375 is_terminated: bool,
1376 ) -> Self {
1377 Self { inner, is_terminated }
1378 }
1379}
1380
1381impl futures::Stream for SyncManagerRequestStream {
1382 type Item = Result<SyncManagerRequest, fidl::Error>;
1383
1384 fn poll_next(
1385 mut self: std::pin::Pin<&mut Self>,
1386 cx: &mut std::task::Context<'_>,
1387 ) -> std::task::Poll<Option<Self::Item>> {
1388 let this = &mut *self;
1389 if this.inner.check_shutdown(cx) {
1390 this.is_terminated = true;
1391 return std::task::Poll::Ready(None);
1392 }
1393 if this.is_terminated {
1394 panic!("polled SyncManagerRequestStream after completion");
1395 }
1396 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1397 |bytes, handles| {
1398 match this.inner.channel().read_etc(cx, bytes, handles) {
1399 std::task::Poll::Ready(Ok(())) => {}
1400 std::task::Poll::Pending => return std::task::Poll::Pending,
1401 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1402 this.is_terminated = true;
1403 return std::task::Poll::Ready(None);
1404 }
1405 std::task::Poll::Ready(Err(e)) => {
1406 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1407 e.into(),
1408 ))));
1409 }
1410 }
1411
1412 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1414
1415 std::task::Poll::Ready(Some(match header.ordinal {
1416 0x39c25d810b5e7407 => {
1417 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1418 let mut req = fidl::new_empty!(
1419 SyncManagerBusSubscribeRequest,
1420 fidl::encoding::DefaultFuchsiaResourceDialect
1421 );
1422 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SyncManagerBusSubscribeRequest>(&header, _body_bytes, handles, &mut req)?;
1423 let control_handle = SyncManagerControlHandle { inner: this.inner.clone() };
1424 Ok(SyncManagerRequest::BusSubscribe {
1425 bus_name: req.bus_name,
1426 client_name: req.client_name,
1427 bus: req.bus,
1428
1429 control_handle,
1430 })
1431 }
1432 0x592056b5825f4292 => {
1433 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1434 let mut req = fidl::new_empty!(
1435 SyncManagerWaitForBarrierThresholdRequest,
1436 fidl::encoding::DefaultFuchsiaResourceDialect
1437 );
1438 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SyncManagerWaitForBarrierThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
1439 let control_handle = SyncManagerControlHandle { inner: this.inner.clone() };
1440 Ok(SyncManagerRequest::WaitForBarrierThreshold {
1441 barrier_name: req.barrier_name,
1442 threshold: req.threshold,
1443 timeout: req.timeout,
1444
1445 responder: SyncManagerWaitForBarrierThresholdResponder {
1446 control_handle: std::mem::ManuallyDrop::new(control_handle),
1447 tx_id: header.tx_id,
1448 },
1449 })
1450 }
1451 _ => Err(fidl::Error::UnknownOrdinal {
1452 ordinal: header.ordinal,
1453 protocol_name:
1454 <SyncManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1455 }),
1456 }))
1457 },
1458 )
1459 }
1460}
1461
1462#[derive(Debug)]
1466pub enum SyncManagerRequest {
1467 BusSubscribe {
1470 bus_name: String,
1471 client_name: String,
1472 bus: fidl::endpoints::ServerEnd<BusMarker>,
1473 control_handle: SyncManagerControlHandle,
1474 },
1475 WaitForBarrierThreshold {
1480 barrier_name: String,
1481 threshold: u32,
1482 timeout: i64,
1483 responder: SyncManagerWaitForBarrierThresholdResponder,
1484 },
1485}
1486
1487impl SyncManagerRequest {
1488 #[allow(irrefutable_let_patterns)]
1489 pub fn into_bus_subscribe(
1490 self,
1491 ) -> Option<(String, String, fidl::endpoints::ServerEnd<BusMarker>, SyncManagerControlHandle)>
1492 {
1493 if let SyncManagerRequest::BusSubscribe { bus_name, client_name, bus, control_handle } =
1494 self
1495 {
1496 Some((bus_name, client_name, bus, control_handle))
1497 } else {
1498 None
1499 }
1500 }
1501
1502 #[allow(irrefutable_let_patterns)]
1503 pub fn into_wait_for_barrier_threshold(
1504 self,
1505 ) -> Option<(String, u32, i64, SyncManagerWaitForBarrierThresholdResponder)> {
1506 if let SyncManagerRequest::WaitForBarrierThreshold {
1507 barrier_name,
1508 threshold,
1509 timeout,
1510 responder,
1511 } = self
1512 {
1513 Some((barrier_name, threshold, timeout, responder))
1514 } else {
1515 None
1516 }
1517 }
1518
1519 pub fn method_name(&self) -> &'static str {
1521 match *self {
1522 SyncManagerRequest::BusSubscribe { .. } => "bus_subscribe",
1523 SyncManagerRequest::WaitForBarrierThreshold { .. } => "wait_for_barrier_threshold",
1524 }
1525 }
1526}
1527
1528#[derive(Debug, Clone)]
1529pub struct SyncManagerControlHandle {
1530 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1531}
1532
1533impl fidl::endpoints::ControlHandle for SyncManagerControlHandle {
1534 fn shutdown(&self) {
1535 self.inner.shutdown()
1536 }
1537 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1538 self.inner.shutdown_with_epitaph(status)
1539 }
1540
1541 fn is_closed(&self) -> bool {
1542 self.inner.channel().is_closed()
1543 }
1544 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1545 self.inner.channel().on_closed()
1546 }
1547
1548 #[cfg(target_os = "fuchsia")]
1549 fn signal_peer(
1550 &self,
1551 clear_mask: zx::Signals,
1552 set_mask: zx::Signals,
1553 ) -> Result<(), zx_status::Status> {
1554 use fidl::Peered;
1555 self.inner.channel().signal_peer(clear_mask, set_mask)
1556 }
1557}
1558
1559impl SyncManagerControlHandle {}
1560
1561#[must_use = "FIDL methods require a response to be sent"]
1562#[derive(Debug)]
1563pub struct SyncManagerWaitForBarrierThresholdResponder {
1564 control_handle: std::mem::ManuallyDrop<SyncManagerControlHandle>,
1565 tx_id: u32,
1566}
1567
1568impl std::ops::Drop for SyncManagerWaitForBarrierThresholdResponder {
1572 fn drop(&mut self) {
1573 self.control_handle.shutdown();
1574 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1576 }
1577}
1578
1579impl fidl::endpoints::Responder for SyncManagerWaitForBarrierThresholdResponder {
1580 type ControlHandle = SyncManagerControlHandle;
1581
1582 fn control_handle(&self) -> &SyncManagerControlHandle {
1583 &self.control_handle
1584 }
1585
1586 fn drop_without_shutdown(mut self) {
1587 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1589 std::mem::forget(self);
1591 }
1592}
1593
1594impl SyncManagerWaitForBarrierThresholdResponder {
1595 pub fn send(self, mut result: bool) -> Result<(), fidl::Error> {
1599 let _result = self.send_raw(result);
1600 if _result.is_err() {
1601 self.control_handle.shutdown();
1602 }
1603 self.drop_without_shutdown();
1604 _result
1605 }
1606
1607 pub fn send_no_shutdown_on_err(self, mut result: bool) -> Result<(), fidl::Error> {
1609 let _result = self.send_raw(result);
1610 self.drop_without_shutdown();
1611 _result
1612 }
1613
1614 fn send_raw(&self, mut result: bool) -> Result<(), fidl::Error> {
1615 self.control_handle.inner.send::<SyncManagerWaitForBarrierThresholdResponse>(
1616 (result,),
1617 self.tx_id,
1618 0x592056b5825f4292,
1619 fidl::encoding::DynamicFlags::empty(),
1620 )
1621 }
1622}
1623
1624mod internal {
1625 use super::*;
1626
1627 impl fidl::encoding::ResourceTypeMarker for SyncManagerBusSubscribeRequest {
1628 type Borrowed<'a> = &'a mut Self;
1629 fn take_or_borrow<'a>(
1630 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1631 ) -> Self::Borrowed<'a> {
1632 value
1633 }
1634 }
1635
1636 unsafe impl fidl::encoding::TypeMarker for SyncManagerBusSubscribeRequest {
1637 type Owned = Self;
1638
1639 #[inline(always)]
1640 fn inline_align(_context: fidl::encoding::Context) -> usize {
1641 8
1642 }
1643
1644 #[inline(always)]
1645 fn inline_size(_context: fidl::encoding::Context) -> usize {
1646 40
1647 }
1648 }
1649
1650 unsafe impl
1651 fidl::encoding::Encode<
1652 SyncManagerBusSubscribeRequest,
1653 fidl::encoding::DefaultFuchsiaResourceDialect,
1654 > for &mut SyncManagerBusSubscribeRequest
1655 {
1656 #[inline]
1657 unsafe fn encode(
1658 self,
1659 encoder: &mut fidl::encoding::Encoder<
1660 '_,
1661 fidl::encoding::DefaultFuchsiaResourceDialect,
1662 >,
1663 offset: usize,
1664 _depth: fidl::encoding::Depth,
1665 ) -> fidl::Result<()> {
1666 encoder.debug_check_bounds::<SyncManagerBusSubscribeRequest>(offset);
1667 fidl::encoding::Encode::<SyncManagerBusSubscribeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1669 (
1670 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.bus_name),
1671 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.client_name),
1672 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BusMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.bus),
1673 ),
1674 encoder, offset, _depth
1675 )
1676 }
1677 }
1678 unsafe impl<
1679 T0: fidl::encoding::Encode<
1680 fidl::encoding::UnboundedString,
1681 fidl::encoding::DefaultFuchsiaResourceDialect,
1682 >,
1683 T1: fidl::encoding::Encode<
1684 fidl::encoding::UnboundedString,
1685 fidl::encoding::DefaultFuchsiaResourceDialect,
1686 >,
1687 T2: fidl::encoding::Encode<
1688 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BusMarker>>,
1689 fidl::encoding::DefaultFuchsiaResourceDialect,
1690 >,
1691 >
1692 fidl::encoding::Encode<
1693 SyncManagerBusSubscribeRequest,
1694 fidl::encoding::DefaultFuchsiaResourceDialect,
1695 > for (T0, T1, T2)
1696 {
1697 #[inline]
1698 unsafe fn encode(
1699 self,
1700 encoder: &mut fidl::encoding::Encoder<
1701 '_,
1702 fidl::encoding::DefaultFuchsiaResourceDialect,
1703 >,
1704 offset: usize,
1705 depth: fidl::encoding::Depth,
1706 ) -> fidl::Result<()> {
1707 encoder.debug_check_bounds::<SyncManagerBusSubscribeRequest>(offset);
1708 unsafe {
1711 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1712 (ptr as *mut u64).write_unaligned(0);
1713 }
1714 self.0.encode(encoder, offset + 0, depth)?;
1716 self.1.encode(encoder, offset + 16, depth)?;
1717 self.2.encode(encoder, offset + 32, depth)?;
1718 Ok(())
1719 }
1720 }
1721
1722 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1723 for SyncManagerBusSubscribeRequest
1724 {
1725 #[inline(always)]
1726 fn new_empty() -> Self {
1727 Self {
1728 bus_name: fidl::new_empty!(
1729 fidl::encoding::UnboundedString,
1730 fidl::encoding::DefaultFuchsiaResourceDialect
1731 ),
1732 client_name: fidl::new_empty!(
1733 fidl::encoding::UnboundedString,
1734 fidl::encoding::DefaultFuchsiaResourceDialect
1735 ),
1736 bus: fidl::new_empty!(
1737 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BusMarker>>,
1738 fidl::encoding::DefaultFuchsiaResourceDialect
1739 ),
1740 }
1741 }
1742
1743 #[inline]
1744 unsafe fn decode(
1745 &mut self,
1746 decoder: &mut fidl::encoding::Decoder<
1747 '_,
1748 fidl::encoding::DefaultFuchsiaResourceDialect,
1749 >,
1750 offset: usize,
1751 _depth: fidl::encoding::Depth,
1752 ) -> fidl::Result<()> {
1753 decoder.debug_check_bounds::<Self>(offset);
1754 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1756 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1757 let mask = 0xffffffff00000000u64;
1758 let maskedval = padval & mask;
1759 if maskedval != 0 {
1760 return Err(fidl::Error::NonZeroPadding {
1761 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1762 });
1763 }
1764 fidl::decode!(
1765 fidl::encoding::UnboundedString,
1766 fidl::encoding::DefaultFuchsiaResourceDialect,
1767 &mut self.bus_name,
1768 decoder,
1769 offset + 0,
1770 _depth
1771 )?;
1772 fidl::decode!(
1773 fidl::encoding::UnboundedString,
1774 fidl::encoding::DefaultFuchsiaResourceDialect,
1775 &mut self.client_name,
1776 decoder,
1777 offset + 16,
1778 _depth
1779 )?;
1780 fidl::decode!(
1781 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BusMarker>>,
1782 fidl::encoding::DefaultFuchsiaResourceDialect,
1783 &mut self.bus,
1784 decoder,
1785 offset + 32,
1786 _depth
1787 )?;
1788 Ok(())
1789 }
1790 }
1791}