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