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 PublisherControlHandle {
417 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
418 self.inner.shutdown_with_epitaph(status.into())
419 }
420}
421
422impl fidl::endpoints::ControlHandle for PublisherControlHandle {
423 fn shutdown(&self) {
424 self.inner.shutdown()
425 }
426
427 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
428 self.inner.shutdown_with_epitaph(status)
429 }
430
431 fn is_closed(&self) -> bool {
432 self.inner.channel().is_closed()
433 }
434 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
435 self.inner.channel().on_closed()
436 }
437
438 #[cfg(target_os = "fuchsia")]
439 fn signal_peer(
440 &self,
441 clear_mask: zx::Signals,
442 set_mask: zx::Signals,
443 ) -> Result<(), zx_status::Status> {
444 use fidl::Peered;
445 self.inner.channel().signal_peer(clear_mask, set_mask)
446 }
447}
448
449impl PublisherControlHandle {}
450
451mod internal {
452 use super::*;
453
454 impl fidl::encoding::ResourceTypeMarker for PublisherPublishRequest {
455 type Borrowed<'a> = &'a mut Self;
456 fn take_or_borrow<'a>(
457 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
458 ) -> Self::Borrowed<'a> {
459 value
460 }
461 }
462
463 unsafe impl fidl::encoding::TypeMarker for PublisherPublishRequest {
464 type Owned = Self;
465
466 #[inline(always)]
467 fn inline_align(_context: fidl::encoding::Context) -> usize {
468 8
469 }
470
471 #[inline(always)]
472 fn inline_size(_context: fidl::encoding::Context) -> usize {
473 24
474 }
475 }
476
477 unsafe impl
478 fidl::encoding::Encode<
479 PublisherPublishRequest,
480 fidl::encoding::DefaultFuchsiaResourceDialect,
481 > for &mut PublisherPublishRequest
482 {
483 #[inline]
484 unsafe fn encode(
485 self,
486 encoder: &mut fidl::encoding::Encoder<
487 '_,
488 fidl::encoding::DefaultFuchsiaResourceDialect,
489 >,
490 offset: usize,
491 _depth: fidl::encoding::Depth,
492 ) -> fidl::Result<()> {
493 encoder.debug_check_bounds::<PublisherPublishRequest>(offset);
494 fidl::encoding::Encode::<
496 PublisherPublishRequest,
497 fidl::encoding::DefaultFuchsiaResourceDialect,
498 >::encode(
499 (
500 <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
501 &self.data_sink,
502 ),
503 <fidl::encoding::HandleType<
504 fidl::Vmo,
505 { fidl::ObjectType::VMO.into_raw() },
506 2147483648,
507 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
508 &mut self.data
509 ),
510 <fidl::encoding::HandleType<
511 fidl::EventPair,
512 { fidl::ObjectType::EVENTPAIR.into_raw() },
513 2147483648,
514 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
515 &mut self.vmo_token
516 ),
517 ),
518 encoder,
519 offset,
520 _depth,
521 )
522 }
523 }
524 unsafe impl<
525 T0: fidl::encoding::Encode<
526 fidl::encoding::BoundedString<255>,
527 fidl::encoding::DefaultFuchsiaResourceDialect,
528 >,
529 T1: fidl::encoding::Encode<
530 fidl::encoding::HandleType<
531 fidl::Vmo,
532 { fidl::ObjectType::VMO.into_raw() },
533 2147483648,
534 >,
535 fidl::encoding::DefaultFuchsiaResourceDialect,
536 >,
537 T2: fidl::encoding::Encode<
538 fidl::encoding::HandleType<
539 fidl::EventPair,
540 { fidl::ObjectType::EVENTPAIR.into_raw() },
541 2147483648,
542 >,
543 fidl::encoding::DefaultFuchsiaResourceDialect,
544 >,
545 >
546 fidl::encoding::Encode<
547 PublisherPublishRequest,
548 fidl::encoding::DefaultFuchsiaResourceDialect,
549 > for (T0, T1, T2)
550 {
551 #[inline]
552 unsafe fn encode(
553 self,
554 encoder: &mut fidl::encoding::Encoder<
555 '_,
556 fidl::encoding::DefaultFuchsiaResourceDialect,
557 >,
558 offset: usize,
559 depth: fidl::encoding::Depth,
560 ) -> fidl::Result<()> {
561 encoder.debug_check_bounds::<PublisherPublishRequest>(offset);
562 self.0.encode(encoder, offset + 0, depth)?;
566 self.1.encode(encoder, offset + 16, depth)?;
567 self.2.encode(encoder, offset + 20, depth)?;
568 Ok(())
569 }
570 }
571
572 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
573 for PublisherPublishRequest
574 {
575 #[inline(always)]
576 fn new_empty() -> Self {
577 Self {
578 data_sink: fidl::new_empty!(
579 fidl::encoding::BoundedString<255>,
580 fidl::encoding::DefaultFuchsiaResourceDialect
581 ),
582 data: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
583 vmo_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
584 }
585 }
586
587 #[inline]
588 unsafe fn decode(
589 &mut self,
590 decoder: &mut fidl::encoding::Decoder<
591 '_,
592 fidl::encoding::DefaultFuchsiaResourceDialect,
593 >,
594 offset: usize,
595 _depth: fidl::encoding::Depth,
596 ) -> fidl::Result<()> {
597 decoder.debug_check_bounds::<Self>(offset);
598 fidl::decode!(
600 fidl::encoding::BoundedString<255>,
601 fidl::encoding::DefaultFuchsiaResourceDialect,
602 &mut self.data_sink,
603 decoder,
604 offset + 0,
605 _depth
606 )?;
607 fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.data, decoder, offset + 16, _depth)?;
608 fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo_token, decoder, offset + 20, _depth)?;
609 Ok(())
610 }
611 }
612}