fidl_fuchsia_debugdata/
fidl_fuchsia_debugdata.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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    /// Waits until an event arrives and returns it. It is safe for other
79    /// threads to make concurrent requests while waiting for an event.
80    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    /// The program runtime sends a string naming a `data_sink` and transfers
88    /// the handle to a VMO containing the `data` it wants published
89    /// there.  The `data_sink` string identifies a type of data, and the
90    /// VMO's object name can specifically identify the data set in this VMO.
91    /// The ZX_PROP_VMO_CONTENT_SIZE property should be set on the VMO to
92    /// indicate the precise size of the data in case that is not whole pages;
93    /// however, leaving it unset (i.e. 0) is acceptable when the whole-page
94    /// size of the VMO is the intended size of dump. Code instrumentation
95    /// runtimes use this to deliver large binary trace results. In such cases,
96    /// the client can resize the VMO and should use the `vmo_token` handle to
97    /// signal when the VMO is ready for processing by the recipient.  The
98    /// receiver will not process the VMO until the peer of `vmo_token` handle
99    /// is closed. Therefore, the client should retain the peer handle until
100    /// it has completed all writes to the VMO.
101    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    /// Create a new Proxy for fuchsia.debugdata/Publisher.
138    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    /// Get a Stream of events from the remote end of the protocol.
144    ///
145    /// # Panics
146    ///
147    /// Panics if the event stream was already taken.
148    pub fn take_event_stream(&self) -> PublisherEventStream {
149        PublisherEventStream { event_receiver: self.client.take_event_receiver() }
150    }
151
152    /// The program runtime sends a string naming a `data_sink` and transfers
153    /// the handle to a VMO containing the `data` it wants published
154    /// there.  The `data_sink` string identifies a type of data, and the
155    /// VMO's object name can specifically identify the data set in this VMO.
156    /// The ZX_PROP_VMO_CONTENT_SIZE property should be set on the VMO to
157    /// indicate the precise size of the data in case that is not whole pages;
158    /// however, leaving it unset (i.e. 0) is acceptable when the whole-page
159    /// size of the VMO is the intended size of dump. Code instrumentation
160    /// runtimes use this to deliver large binary trace results. In such cases,
161    /// the client can resize the VMO and should use the `vmo_token` handle to
162    /// signal when the VMO is ready for processing by the recipient.  The
163    /// receiver will not process the VMO until the peer of `vmo_token` handle
164    /// is closed. Therefore, the client should retain the peer handle until
165    /// it has completed all writes to the VMO.
166    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    /// Decodes a message buffer as a [`PublisherEvent`].
225    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
240/// A Stream of incoming requests for fuchsia.debugdata/Publisher.
241pub 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                // A message has been received from the channel
313                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/// Publisher defines the interface for publishing instrumentation data.
344#[derive(Debug)]
345pub enum PublisherRequest {
346    /// The program runtime sends a string naming a `data_sink` and transfers
347    /// the handle to a VMO containing the `data` it wants published
348    /// there.  The `data_sink` string identifies a type of data, and the
349    /// VMO's object name can specifically identify the data set in this VMO.
350    /// The ZX_PROP_VMO_CONTENT_SIZE property should be set on the VMO to
351    /// indicate the precise size of the data in case that is not whole pages;
352    /// however, leaving it unset (i.e. 0) is acceptable when the whole-page
353    /// size of the VMO is the intended size of dump. Code instrumentation
354    /// runtimes use this to deliver large binary trace results. In such cases,
355    /// the client can resize the VMO and should use the `vmo_token` handle to
356    /// signal when the VMO is ready for processing by the recipient.  The
357    /// receiver will not process the VMO until the peer of `vmo_token` handle
358    /// is closed. Therefore, the client should retain the peer handle until
359    /// it has completed all writes to the VMO.
360    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    /// Name of the method defined in FIDL
381    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            // Delegate to tuple encoding.
465            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            // Zero out padding regions. There's no need to apply masks
533            // because the unmasked parts will be overwritten by fields.
534            // Write the fields.
535            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            // Verify that padding bytes are zero.
569            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}