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