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_debugdata__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct PublisherPublishRequest {
16 pub data_sink: String,
17 pub data: fidl::Vmo,
18 pub vmo_token: fidl::EventPair,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PublisherPublishRequest {}
22
23#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
24pub struct PublisherMarker;
25
26impl fidl::endpoints::ProtocolMarker for PublisherMarker {
27 type Proxy = PublisherProxy;
28 type RequestStream = PublisherRequestStream;
29 #[cfg(target_os = "fuchsia")]
30 type SynchronousProxy = PublisherSynchronousProxy;
31
32 const DEBUG_NAME: &'static str = "fuchsia.debugdata.Publisher";
33}
34impl fidl::endpoints::DiscoverableProtocolMarker for PublisherMarker {}
35
36pub trait PublisherProxyInterface: Send + Sync {
37 fn r#publish(
38 &self,
39 data_sink: &str,
40 data: fidl::Vmo,
41 vmo_token: fidl::EventPair,
42 ) -> Result<(), fidl::Error>;
43}
44#[derive(Debug)]
45#[cfg(target_os = "fuchsia")]
46pub struct PublisherSynchronousProxy {
47 client: fidl::client::sync::Client,
48}
49
50#[cfg(target_os = "fuchsia")]
51impl fidl::endpoints::SynchronousProxy for PublisherSynchronousProxy {
52 type Proxy = PublisherProxy;
53 type Protocol = PublisherMarker;
54
55 fn from_channel(inner: fidl::Channel) -> Self {
56 Self::new(inner)
57 }
58
59 fn into_channel(self) -> fidl::Channel {
60 self.client.into_channel()
61 }
62
63 fn as_channel(&self) -> &fidl::Channel {
64 self.client.as_channel()
65 }
66}
67
68#[cfg(target_os = "fuchsia")]
69impl PublisherSynchronousProxy {
70 pub fn new(channel: fidl::Channel) -> Self {
71 let protocol_name = <PublisherMarker 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<PublisherEvent, fidl::Error> {
85 PublisherEvent::decode(self.client.wait_for_event(deadline)?)
86 }
87
88 pub fn r#publish(
103 &self,
104 mut data_sink: &str,
105 mut data: fidl::Vmo,
106 mut vmo_token: fidl::EventPair,
107 ) -> Result<(), fidl::Error> {
108 self.client.send::<PublisherPublishRequest>(
109 (data_sink, data, vmo_token),
110 0xf52f8806121e066,
111 fidl::encoding::DynamicFlags::empty(),
112 )
113 }
114}
115
116#[cfg(target_os = "fuchsia")]
117impl From<PublisherSynchronousProxy> for zx::NullableHandle {
118 fn from(value: PublisherSynchronousProxy) -> Self {
119 value.into_channel().into()
120 }
121}
122
123#[cfg(target_os = "fuchsia")]
124impl From<fidl::Channel> for PublisherSynchronousProxy {
125 fn from(value: fidl::Channel) -> Self {
126 Self::new(value)
127 }
128}
129
130#[cfg(target_os = "fuchsia")]
131impl fidl::endpoints::FromClient for PublisherSynchronousProxy {
132 type Protocol = PublisherMarker;
133
134 fn from_client(value: fidl::endpoints::ClientEnd<PublisherMarker>) -> Self {
135 Self::new(value.into_channel())
136 }
137}
138
139#[derive(Debug, Clone)]
140pub struct PublisherProxy {
141 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
142}
143
144impl fidl::endpoints::Proxy for PublisherProxy {
145 type Protocol = PublisherMarker;
146
147 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
148 Self::new(inner)
149 }
150
151 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
152 self.client.into_channel().map_err(|client| Self { client })
153 }
154
155 fn as_channel(&self) -> &::fidl::AsyncChannel {
156 self.client.as_channel()
157 }
158}
159
160impl PublisherProxy {
161 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
163 let protocol_name = <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
164 Self { client: fidl::client::Client::new(channel, protocol_name) }
165 }
166
167 pub fn take_event_stream(&self) -> PublisherEventStream {
173 PublisherEventStream { event_receiver: self.client.take_event_receiver() }
174 }
175
176 pub fn r#publish(
191 &self,
192 mut data_sink: &str,
193 mut data: fidl::Vmo,
194 mut vmo_token: fidl::EventPair,
195 ) -> Result<(), fidl::Error> {
196 PublisherProxyInterface::r#publish(self, data_sink, data, vmo_token)
197 }
198}
199
200impl PublisherProxyInterface for PublisherProxy {
201 fn r#publish(
202 &self,
203 mut data_sink: &str,
204 mut data: fidl::Vmo,
205 mut vmo_token: fidl::EventPair,
206 ) -> Result<(), fidl::Error> {
207 self.client.send::<PublisherPublishRequest>(
208 (data_sink, data, vmo_token),
209 0xf52f8806121e066,
210 fidl::encoding::DynamicFlags::empty(),
211 )
212 }
213}
214
215pub struct PublisherEventStream {
216 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
217}
218
219impl std::marker::Unpin for PublisherEventStream {}
220
221impl futures::stream::FusedStream for PublisherEventStream {
222 fn is_terminated(&self) -> bool {
223 self.event_receiver.is_terminated()
224 }
225}
226
227impl futures::Stream for PublisherEventStream {
228 type Item = Result<PublisherEvent, fidl::Error>;
229
230 fn poll_next(
231 mut self: std::pin::Pin<&mut Self>,
232 cx: &mut std::task::Context<'_>,
233 ) -> std::task::Poll<Option<Self::Item>> {
234 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
235 &mut self.event_receiver,
236 cx
237 )?) {
238 Some(buf) => std::task::Poll::Ready(Some(PublisherEvent::decode(buf))),
239 None => std::task::Poll::Ready(None),
240 }
241 }
242}
243
244#[derive(Debug)]
245pub enum PublisherEvent {}
246
247impl PublisherEvent {
248 fn decode(
250 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
251 ) -> Result<PublisherEvent, fidl::Error> {
252 let (bytes, _handles) = buf.split_mut();
253 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
254 debug_assert_eq!(tx_header.tx_id, 0);
255 match tx_header.ordinal {
256 _ => Err(fidl::Error::UnknownOrdinal {
257 ordinal: tx_header.ordinal,
258 protocol_name: <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
259 }),
260 }
261 }
262}
263
264pub struct PublisherRequestStream {
266 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
267 is_terminated: bool,
268}
269
270impl std::marker::Unpin for PublisherRequestStream {}
271
272impl futures::stream::FusedStream for PublisherRequestStream {
273 fn is_terminated(&self) -> bool {
274 self.is_terminated
275 }
276}
277
278impl fidl::endpoints::RequestStream for PublisherRequestStream {
279 type Protocol = PublisherMarker;
280 type ControlHandle = PublisherControlHandle;
281
282 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
283 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
284 }
285
286 fn control_handle(&self) -> Self::ControlHandle {
287 PublisherControlHandle { inner: self.inner.clone() }
288 }
289
290 fn into_inner(
291 self,
292 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
293 {
294 (self.inner, self.is_terminated)
295 }
296
297 fn from_inner(
298 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
299 is_terminated: bool,
300 ) -> Self {
301 Self { inner, is_terminated }
302 }
303}
304
305impl futures::Stream for PublisherRequestStream {
306 type Item = Result<PublisherRequest, fidl::Error>;
307
308 fn poll_next(
309 mut self: std::pin::Pin<&mut Self>,
310 cx: &mut std::task::Context<'_>,
311 ) -> std::task::Poll<Option<Self::Item>> {
312 let this = &mut *self;
313 if this.inner.check_shutdown(cx) {
314 this.is_terminated = true;
315 return std::task::Poll::Ready(None);
316 }
317 if this.is_terminated {
318 panic!("polled PublisherRequestStream after completion");
319 }
320 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
321 |bytes, handles| {
322 match this.inner.channel().read_etc(cx, bytes, handles) {
323 std::task::Poll::Ready(Ok(())) => {}
324 std::task::Poll::Pending => return std::task::Poll::Pending,
325 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
326 this.is_terminated = true;
327 return std::task::Poll::Ready(None);
328 }
329 std::task::Poll::Ready(Err(e)) => {
330 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
331 e.into(),
332 ))));
333 }
334 }
335
336 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
338
339 std::task::Poll::Ready(Some(match header.ordinal {
340 0xf52f8806121e066 => {
341 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
342 let mut req = fidl::new_empty!(
343 PublisherPublishRequest,
344 fidl::encoding::DefaultFuchsiaResourceDialect
345 );
346 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PublisherPublishRequest>(&header, _body_bytes, handles, &mut req)?;
347 let control_handle = PublisherControlHandle { inner: this.inner.clone() };
348 Ok(PublisherRequest::Publish {
349 data_sink: req.data_sink,
350 data: req.data,
351 vmo_token: req.vmo_token,
352
353 control_handle,
354 })
355 }
356 _ => Err(fidl::Error::UnknownOrdinal {
357 ordinal: header.ordinal,
358 protocol_name:
359 <PublisherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
360 }),
361 }))
362 },
363 )
364 }
365}
366
367#[derive(Debug)]
369pub enum PublisherRequest {
370 Publish {
385 data_sink: String,
386 data: fidl::Vmo,
387 vmo_token: fidl::EventPair,
388 control_handle: PublisherControlHandle,
389 },
390}
391
392impl PublisherRequest {
393 #[allow(irrefutable_let_patterns)]
394 pub fn into_publish(
395 self,
396 ) -> Option<(String, fidl::Vmo, fidl::EventPair, PublisherControlHandle)> {
397 if let PublisherRequest::Publish { data_sink, data, vmo_token, control_handle } = self {
398 Some((data_sink, data, vmo_token, control_handle))
399 } else {
400 None
401 }
402 }
403
404 pub fn method_name(&self) -> &'static str {
406 match *self {
407 PublisherRequest::Publish { .. } => "publish",
408 }
409 }
410}
411
412#[derive(Debug, Clone)]
413pub struct PublisherControlHandle {
414 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
415}
416
417impl fidl::endpoints::ControlHandle for PublisherControlHandle {
418 fn shutdown(&self) {
419 self.inner.shutdown()
420 }
421
422 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
423 self.inner.shutdown_with_epitaph(status)
424 }
425
426 fn is_closed(&self) -> bool {
427 self.inner.channel().is_closed()
428 }
429 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
430 self.inner.channel().on_closed()
431 }
432
433 #[cfg(target_os = "fuchsia")]
434 fn signal_peer(
435 &self,
436 clear_mask: zx::Signals,
437 set_mask: zx::Signals,
438 ) -> Result<(), zx_status::Status> {
439 use fidl::Peered;
440 self.inner.channel().signal_peer(clear_mask, set_mask)
441 }
442}
443
444impl PublisherControlHandle {}
445
446mod internal {
447 use super::*;
448
449 impl fidl::encoding::ResourceTypeMarker for PublisherPublishRequest {
450 type Borrowed<'a> = &'a mut Self;
451 fn take_or_borrow<'a>(
452 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
453 ) -> Self::Borrowed<'a> {
454 value
455 }
456 }
457
458 unsafe impl fidl::encoding::TypeMarker for PublisherPublishRequest {
459 type Owned = Self;
460
461 #[inline(always)]
462 fn inline_align(_context: fidl::encoding::Context) -> usize {
463 8
464 }
465
466 #[inline(always)]
467 fn inline_size(_context: fidl::encoding::Context) -> usize {
468 24
469 }
470 }
471
472 unsafe impl
473 fidl::encoding::Encode<
474 PublisherPublishRequest,
475 fidl::encoding::DefaultFuchsiaResourceDialect,
476 > for &mut PublisherPublishRequest
477 {
478 #[inline]
479 unsafe fn encode(
480 self,
481 encoder: &mut fidl::encoding::Encoder<
482 '_,
483 fidl::encoding::DefaultFuchsiaResourceDialect,
484 >,
485 offset: usize,
486 _depth: fidl::encoding::Depth,
487 ) -> fidl::Result<()> {
488 encoder.debug_check_bounds::<PublisherPublishRequest>(offset);
489 fidl::encoding::Encode::<
491 PublisherPublishRequest,
492 fidl::encoding::DefaultFuchsiaResourceDialect,
493 >::encode(
494 (
495 <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
496 &self.data_sink,
497 ),
498 <fidl::encoding::HandleType<
499 fidl::Vmo,
500 { fidl::ObjectType::VMO.into_raw() },
501 2147483648,
502 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
503 &mut self.data
504 ),
505 <fidl::encoding::HandleType<
506 fidl::EventPair,
507 { fidl::ObjectType::EVENTPAIR.into_raw() },
508 2147483648,
509 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
510 &mut self.vmo_token
511 ),
512 ),
513 encoder,
514 offset,
515 _depth,
516 )
517 }
518 }
519 unsafe impl<
520 T0: fidl::encoding::Encode<
521 fidl::encoding::BoundedString<255>,
522 fidl::encoding::DefaultFuchsiaResourceDialect,
523 >,
524 T1: fidl::encoding::Encode<
525 fidl::encoding::HandleType<
526 fidl::Vmo,
527 { fidl::ObjectType::VMO.into_raw() },
528 2147483648,
529 >,
530 fidl::encoding::DefaultFuchsiaResourceDialect,
531 >,
532 T2: fidl::encoding::Encode<
533 fidl::encoding::HandleType<
534 fidl::EventPair,
535 { fidl::ObjectType::EVENTPAIR.into_raw() },
536 2147483648,
537 >,
538 fidl::encoding::DefaultFuchsiaResourceDialect,
539 >,
540 >
541 fidl::encoding::Encode<
542 PublisherPublishRequest,
543 fidl::encoding::DefaultFuchsiaResourceDialect,
544 > for (T0, T1, T2)
545 {
546 #[inline]
547 unsafe fn encode(
548 self,
549 encoder: &mut fidl::encoding::Encoder<
550 '_,
551 fidl::encoding::DefaultFuchsiaResourceDialect,
552 >,
553 offset: usize,
554 depth: fidl::encoding::Depth,
555 ) -> fidl::Result<()> {
556 encoder.debug_check_bounds::<PublisherPublishRequest>(offset);
557 self.0.encode(encoder, offset + 0, depth)?;
561 self.1.encode(encoder, offset + 16, depth)?;
562 self.2.encode(encoder, offset + 20, depth)?;
563 Ok(())
564 }
565 }
566
567 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
568 for PublisherPublishRequest
569 {
570 #[inline(always)]
571 fn new_empty() -> Self {
572 Self {
573 data_sink: fidl::new_empty!(
574 fidl::encoding::BoundedString<255>,
575 fidl::encoding::DefaultFuchsiaResourceDialect
576 ),
577 data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
578 vmo_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
579 }
580 }
581
582 #[inline]
583 unsafe fn decode(
584 &mut self,
585 decoder: &mut fidl::encoding::Decoder<
586 '_,
587 fidl::encoding::DefaultFuchsiaResourceDialect,
588 >,
589 offset: usize,
590 _depth: fidl::encoding::Depth,
591 ) -> fidl::Result<()> {
592 decoder.debug_check_bounds::<Self>(offset);
593 fidl::decode!(
595 fidl::encoding::BoundedString<255>,
596 fidl::encoding::DefaultFuchsiaResourceDialect,
597 &mut self.data_sink,
598 decoder,
599 offset + 0,
600 _depth
601 )?;
602 fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 16, _depth)?;
603 fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo_token, decoder, offset + 20, _depth)?;
604 Ok(())
605 }
606 }
607}