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