fidl_fuchsia_tracing_provider/
fidl_fuchsia_tracing_provider.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 _};
10pub use fidl_fuchsia_tracing_provider__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// Trace provider configuration.
15#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16pub struct ProviderConfig {
17    /// `buffering_mode` specifies what happens when the buffer fills.
18    pub buffering_mode: fidl_fuchsia_tracing::BufferingMode,
19    /// The buffer to write trace records into.
20    pub buffer: fidl::Vmo,
21    /// When the trace provider observes `ZX_FIFO_PEER_CLOSED` on `fifo`, it
22    /// must assume the trace manager has terminated abnormally (since `Stop`
23    /// was not received as usual) and stop tracing automatically, discarding
24    /// any in-flight trace data.
25    pub fifo: fidl::Fifo,
26    /// What trace categories to collect data for.
27    pub categories: Vec<String>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderConfig {}
31
32#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33pub struct ProviderInitializeRequest {
34    pub config: ProviderConfig,
35}
36
37impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderInitializeRequest {}
38
39#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
40pub struct RegistryRegisterProviderRequest {
41    pub provider: fidl::endpoints::ClientEnd<ProviderMarker>,
42    pub pid: u64,
43    pub name: String,
44}
45
46impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
47    for RegistryRegisterProviderRequest
48{
49}
50
51#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
52pub struct RegistryRegisterProviderSynchronouslyRequest {
53    pub provider: fidl::endpoints::ClientEnd<ProviderMarker>,
54    pub pid: u64,
55    pub name: String,
56}
57
58impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
59    for RegistryRegisterProviderSynchronouslyRequest
60{
61}
62
63#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
64pub struct ProviderMarker;
65
66impl fidl::endpoints::ProtocolMarker for ProviderMarker {
67    type Proxy = ProviderProxy;
68    type RequestStream = ProviderRequestStream;
69    #[cfg(target_os = "fuchsia")]
70    type SynchronousProxy = ProviderSynchronousProxy;
71
72    const DEBUG_NAME: &'static str = "(anonymous) Provider";
73}
74
75pub trait ProviderProxyInterface: Send + Sync {
76    fn r#initialize(&self, config: ProviderConfig) -> Result<(), fidl::Error>;
77    fn r#start(&self, options: &StartOptions) -> Result<(), fidl::Error>;
78    fn r#stop(&self) -> Result<(), fidl::Error>;
79    fn r#terminate(&self) -> Result<(), fidl::Error>;
80    type GetKnownCategoriesResponseFut: std::future::Future<Output = Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error>>
81        + Send;
82    fn r#get_known_categories(&self) -> Self::GetKnownCategoriesResponseFut;
83}
84#[derive(Debug)]
85#[cfg(target_os = "fuchsia")]
86pub struct ProviderSynchronousProxy {
87    client: fidl::client::sync::Client,
88}
89
90#[cfg(target_os = "fuchsia")]
91impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
92    type Proxy = ProviderProxy;
93    type Protocol = ProviderMarker;
94
95    fn from_channel(inner: fidl::Channel) -> Self {
96        Self::new(inner)
97    }
98
99    fn into_channel(self) -> fidl::Channel {
100        self.client.into_channel()
101    }
102
103    fn as_channel(&self) -> &fidl::Channel {
104        self.client.as_channel()
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl ProviderSynchronousProxy {
110    pub fn new(channel: fidl::Channel) -> Self {
111        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
112        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
113    }
114
115    pub fn into_channel(self) -> fidl::Channel {
116        self.client.into_channel()
117    }
118
119    /// Waits until an event arrives and returns it. It is safe for other
120    /// threads to make concurrent requests while waiting for an event.
121    pub fn wait_for_event(
122        &self,
123        deadline: zx::MonotonicInstant,
124    ) -> Result<ProviderEvent, fidl::Error> {
125        ProviderEvent::decode(self.client.wait_for_event(deadline)?)
126    }
127
128    /// Initialize tracing and prepare for writing trace records for events in
129    /// the specified `categories` into `buffer` using `fifo` for signaling.
130    /// Tracing hasn't started yet, a `Start()` call is still required.
131    ///
132    ///
133    /// At most one trace can be active at a time. Subsequent `Initialize()`
134    /// requests received prior to a `Terminate()` call must be ignored.
135    pub fn r#initialize(&self, mut config: ProviderConfig) -> Result<(), fidl::Error> {
136        self.client.send::<ProviderInitializeRequest>(
137            (&mut config,),
138            0x9e31667d7b180f7,
139            fidl::encoding::DynamicFlags::empty(),
140        )
141    }
142
143    /// Begin tracing.
144    ///
145    /// If tracing has already started the provider must ignore the request.
146    ///
147    /// There is no result. The provider must send a `TRACE_PROVIDER_STARTED`
148    /// packet on `fifo` to indicate success/failure of starting.
149    pub fn r#start(&self, mut options: &StartOptions) -> Result<(), fidl::Error> {
150        self.client.send::<ProviderStartRequest>(
151            (options,),
152            0x5bae2b60be66a815,
153            fidl::encoding::DynamicFlags::empty(),
154        )
155    }
156
157    /// Stop tracing.
158    ///
159    /// If tracing has already stopped the provider must ignore the request.
160    ///
161    /// Once the provider has finished writing any final events to the trace
162    /// buffer, it must send a `TRACE_PROVIDER_STOPPED` packet on `fifo`.
163    /// Note that multiple `Start,Stop` requests can be received between
164    /// `Initialize,Terminate`.
165    pub fn r#stop(&self) -> Result<(), fidl::Error> {
166        self.client.send::<fidl::encoding::EmptyPayload>(
167            (),
168            0x133df8ebb1897df0,
169            fidl::encoding::DynamicFlags::empty(),
170        )
171    }
172
173    /// Terminate tracing.
174    ///
175    /// Tracing is stopped first if not already stopped.
176    /// After tracing has fully terminated the provider must close both
177    /// `buffer` and `fifo` to indicate to the trace manager that tracing is
178    /// finished.
179    pub fn r#terminate(&self) -> Result<(), fidl::Error> {
180        self.client.send::<fidl::encoding::EmptyPayload>(
181            (),
182            0x6b5564032f2726b1,
183            fidl::encoding::DynamicFlags::empty(),
184        )
185    }
186
187    /// Gets the trace categories that might be produced by this provider.
188    pub fn r#get_known_categories(
189        &self,
190        ___deadline: zx::MonotonicInstant,
191    ) -> Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error> {
192        let _response = self
193            .client
194            .send_query::<fidl::encoding::EmptyPayload, ProviderGetKnownCategoriesResponse>(
195                (),
196                0x5f5b0ad77af3f886,
197                fidl::encoding::DynamicFlags::empty(),
198                ___deadline,
199            )?;
200        Ok(_response.categories)
201    }
202}
203
204#[cfg(target_os = "fuchsia")]
205impl From<ProviderSynchronousProxy> for zx::NullableHandle {
206    fn from(value: ProviderSynchronousProxy) -> Self {
207        value.into_channel().into()
208    }
209}
210
211#[cfg(target_os = "fuchsia")]
212impl From<fidl::Channel> for ProviderSynchronousProxy {
213    fn from(value: fidl::Channel) -> Self {
214        Self::new(value)
215    }
216}
217
218#[cfg(target_os = "fuchsia")]
219impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
220    type Protocol = ProviderMarker;
221
222    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
223        Self::new(value.into_channel())
224    }
225}
226
227#[derive(Debug, Clone)]
228pub struct ProviderProxy {
229    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
230}
231
232impl fidl::endpoints::Proxy for ProviderProxy {
233    type Protocol = ProviderMarker;
234
235    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
236        Self::new(inner)
237    }
238
239    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
240        self.client.into_channel().map_err(|client| Self { client })
241    }
242
243    fn as_channel(&self) -> &::fidl::AsyncChannel {
244        self.client.as_channel()
245    }
246}
247
248impl ProviderProxy {
249    /// Create a new Proxy for fuchsia.tracing.provider/Provider.
250    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
251        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
252        Self { client: fidl::client::Client::new(channel, protocol_name) }
253    }
254
255    /// Get a Stream of events from the remote end of the protocol.
256    ///
257    /// # Panics
258    ///
259    /// Panics if the event stream was already taken.
260    pub fn take_event_stream(&self) -> ProviderEventStream {
261        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
262    }
263
264    /// Initialize tracing and prepare for writing trace records for events in
265    /// the specified `categories` into `buffer` using `fifo` for signaling.
266    /// Tracing hasn't started yet, a `Start()` call is still required.
267    ///
268    ///
269    /// At most one trace can be active at a time. Subsequent `Initialize()`
270    /// requests received prior to a `Terminate()` call must be ignored.
271    pub fn r#initialize(&self, mut config: ProviderConfig) -> Result<(), fidl::Error> {
272        ProviderProxyInterface::r#initialize(self, config)
273    }
274
275    /// Begin tracing.
276    ///
277    /// If tracing has already started the provider must ignore the request.
278    ///
279    /// There is no result. The provider must send a `TRACE_PROVIDER_STARTED`
280    /// packet on `fifo` to indicate success/failure of starting.
281    pub fn r#start(&self, mut options: &StartOptions) -> Result<(), fidl::Error> {
282        ProviderProxyInterface::r#start(self, options)
283    }
284
285    /// Stop tracing.
286    ///
287    /// If tracing has already stopped the provider must ignore the request.
288    ///
289    /// Once the provider has finished writing any final events to the trace
290    /// buffer, it must send a `TRACE_PROVIDER_STOPPED` packet on `fifo`.
291    /// Note that multiple `Start,Stop` requests can be received between
292    /// `Initialize,Terminate`.
293    pub fn r#stop(&self) -> Result<(), fidl::Error> {
294        ProviderProxyInterface::r#stop(self)
295    }
296
297    /// Terminate tracing.
298    ///
299    /// Tracing is stopped first if not already stopped.
300    /// After tracing has fully terminated the provider must close both
301    /// `buffer` and `fifo` to indicate to the trace manager that tracing is
302    /// finished.
303    pub fn r#terminate(&self) -> Result<(), fidl::Error> {
304        ProviderProxyInterface::r#terminate(self)
305    }
306
307    /// Gets the trace categories that might be produced by this provider.
308    pub fn r#get_known_categories(
309        &self,
310    ) -> fidl::client::QueryResponseFut<
311        Vec<fidl_fuchsia_tracing::KnownCategory>,
312        fidl::encoding::DefaultFuchsiaResourceDialect,
313    > {
314        ProviderProxyInterface::r#get_known_categories(self)
315    }
316}
317
318impl ProviderProxyInterface for ProviderProxy {
319    fn r#initialize(&self, mut config: ProviderConfig) -> Result<(), fidl::Error> {
320        self.client.send::<ProviderInitializeRequest>(
321            (&mut config,),
322            0x9e31667d7b180f7,
323            fidl::encoding::DynamicFlags::empty(),
324        )
325    }
326
327    fn r#start(&self, mut options: &StartOptions) -> Result<(), fidl::Error> {
328        self.client.send::<ProviderStartRequest>(
329            (options,),
330            0x5bae2b60be66a815,
331            fidl::encoding::DynamicFlags::empty(),
332        )
333    }
334
335    fn r#stop(&self) -> Result<(), fidl::Error> {
336        self.client.send::<fidl::encoding::EmptyPayload>(
337            (),
338            0x133df8ebb1897df0,
339            fidl::encoding::DynamicFlags::empty(),
340        )
341    }
342
343    fn r#terminate(&self) -> Result<(), fidl::Error> {
344        self.client.send::<fidl::encoding::EmptyPayload>(
345            (),
346            0x6b5564032f2726b1,
347            fidl::encoding::DynamicFlags::empty(),
348        )
349    }
350
351    type GetKnownCategoriesResponseFut = fidl::client::QueryResponseFut<
352        Vec<fidl_fuchsia_tracing::KnownCategory>,
353        fidl::encoding::DefaultFuchsiaResourceDialect,
354    >;
355    fn r#get_known_categories(&self) -> Self::GetKnownCategoriesResponseFut {
356        fn _decode(
357            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
358        ) -> Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error> {
359            let _response = fidl::client::decode_transaction_body::<
360                ProviderGetKnownCategoriesResponse,
361                fidl::encoding::DefaultFuchsiaResourceDialect,
362                0x5f5b0ad77af3f886,
363            >(_buf?)?;
364            Ok(_response.categories)
365        }
366        self.client.send_query_and_decode::<
367            fidl::encoding::EmptyPayload,
368            Vec<fidl_fuchsia_tracing::KnownCategory>,
369        >(
370            (),
371            0x5f5b0ad77af3f886,
372            fidl::encoding::DynamicFlags::empty(),
373            _decode,
374        )
375    }
376}
377
378pub struct ProviderEventStream {
379    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
380}
381
382impl std::marker::Unpin for ProviderEventStream {}
383
384impl futures::stream::FusedStream for ProviderEventStream {
385    fn is_terminated(&self) -> bool {
386        self.event_receiver.is_terminated()
387    }
388}
389
390impl futures::Stream for ProviderEventStream {
391    type Item = Result<ProviderEvent, fidl::Error>;
392
393    fn poll_next(
394        mut self: std::pin::Pin<&mut Self>,
395        cx: &mut std::task::Context<'_>,
396    ) -> std::task::Poll<Option<Self::Item>> {
397        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
398            &mut self.event_receiver,
399            cx
400        )?) {
401            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
402            None => std::task::Poll::Ready(None),
403        }
404    }
405}
406
407#[derive(Debug)]
408pub enum ProviderEvent {}
409
410impl ProviderEvent {
411    /// Decodes a message buffer as a [`ProviderEvent`].
412    fn decode(
413        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
414    ) -> Result<ProviderEvent, fidl::Error> {
415        let (bytes, _handles) = buf.split_mut();
416        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
417        debug_assert_eq!(tx_header.tx_id, 0);
418        match tx_header.ordinal {
419            _ => Err(fidl::Error::UnknownOrdinal {
420                ordinal: tx_header.ordinal,
421                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
422            }),
423        }
424    }
425}
426
427/// A Stream of incoming requests for fuchsia.tracing.provider/Provider.
428pub struct ProviderRequestStream {
429    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
430    is_terminated: bool,
431}
432
433impl std::marker::Unpin for ProviderRequestStream {}
434
435impl futures::stream::FusedStream for ProviderRequestStream {
436    fn is_terminated(&self) -> bool {
437        self.is_terminated
438    }
439}
440
441impl fidl::endpoints::RequestStream for ProviderRequestStream {
442    type Protocol = ProviderMarker;
443    type ControlHandle = ProviderControlHandle;
444
445    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
446        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
447    }
448
449    fn control_handle(&self) -> Self::ControlHandle {
450        ProviderControlHandle { inner: self.inner.clone() }
451    }
452
453    fn into_inner(
454        self,
455    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
456    {
457        (self.inner, self.is_terminated)
458    }
459
460    fn from_inner(
461        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
462        is_terminated: bool,
463    ) -> Self {
464        Self { inner, is_terminated }
465    }
466}
467
468impl futures::Stream for ProviderRequestStream {
469    type Item = Result<ProviderRequest, fidl::Error>;
470
471    fn poll_next(
472        mut self: std::pin::Pin<&mut Self>,
473        cx: &mut std::task::Context<'_>,
474    ) -> std::task::Poll<Option<Self::Item>> {
475        let this = &mut *self;
476        if this.inner.check_shutdown(cx) {
477            this.is_terminated = true;
478            return std::task::Poll::Ready(None);
479        }
480        if this.is_terminated {
481            panic!("polled ProviderRequestStream after completion");
482        }
483        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
484            |bytes, handles| {
485                match this.inner.channel().read_etc(cx, bytes, handles) {
486                    std::task::Poll::Ready(Ok(())) => {}
487                    std::task::Poll::Pending => return std::task::Poll::Pending,
488                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
489                        this.is_terminated = true;
490                        return std::task::Poll::Ready(None);
491                    }
492                    std::task::Poll::Ready(Err(e)) => {
493                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
494                            e.into(),
495                        ))));
496                    }
497                }
498
499                // A message has been received from the channel
500                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
501
502                std::task::Poll::Ready(Some(match header.ordinal {
503                    0x9e31667d7b180f7 => {
504                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
505                        let mut req = fidl::new_empty!(
506                            ProviderInitializeRequest,
507                            fidl::encoding::DefaultFuchsiaResourceDialect
508                        );
509                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderInitializeRequest>(&header, _body_bytes, handles, &mut req)?;
510                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
511                        Ok(ProviderRequest::Initialize { config: req.config, control_handle })
512                    }
513                    0x5bae2b60be66a815 => {
514                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
515                        let mut req = fidl::new_empty!(
516                            ProviderStartRequest,
517                            fidl::encoding::DefaultFuchsiaResourceDialect
518                        );
519                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderStartRequest>(&header, _body_bytes, handles, &mut req)?;
520                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
521                        Ok(ProviderRequest::Start { options: req.options, control_handle })
522                    }
523                    0x133df8ebb1897df0 => {
524                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
525                        let mut req = fidl::new_empty!(
526                            fidl::encoding::EmptyPayload,
527                            fidl::encoding::DefaultFuchsiaResourceDialect
528                        );
529                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
530                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
531                        Ok(ProviderRequest::Stop { control_handle })
532                    }
533                    0x6b5564032f2726b1 => {
534                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
535                        let mut req = fidl::new_empty!(
536                            fidl::encoding::EmptyPayload,
537                            fidl::encoding::DefaultFuchsiaResourceDialect
538                        );
539                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
540                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
541                        Ok(ProviderRequest::Terminate { control_handle })
542                    }
543                    0x5f5b0ad77af3f886 => {
544                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
545                        let mut req = fidl::new_empty!(
546                            fidl::encoding::EmptyPayload,
547                            fidl::encoding::DefaultFuchsiaResourceDialect
548                        );
549                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
550                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
551                        Ok(ProviderRequest::GetKnownCategories {
552                            responder: ProviderGetKnownCategoriesResponder {
553                                control_handle: std::mem::ManuallyDrop::new(control_handle),
554                                tx_id: header.tx_id,
555                            },
556                        })
557                    }
558                    _ => Err(fidl::Error::UnknownOrdinal {
559                        ordinal: header.ordinal,
560                        protocol_name:
561                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
562                    }),
563                }))
564            },
565        )
566    }
567}
568
569/// The provider interface which applications must implement and register
570/// with the `TraceRegistry` to participate in tracing.
571///
572/// See //zircon/system/ulib/trace-provider/ for a C++ implementation of
573/// this interface which can easily be configured by an application.
574#[derive(Debug)]
575pub enum ProviderRequest {
576    /// Initialize tracing and prepare for writing trace records for events in
577    /// the specified `categories` into `buffer` using `fifo` for signaling.
578    /// Tracing hasn't started yet, a `Start()` call is still required.
579    ///
580    ///
581    /// At most one trace can be active at a time. Subsequent `Initialize()`
582    /// requests received prior to a `Terminate()` call must be ignored.
583    Initialize { config: ProviderConfig, control_handle: ProviderControlHandle },
584    /// Begin tracing.
585    ///
586    /// If tracing has already started the provider must ignore the request.
587    ///
588    /// There is no result. The provider must send a `TRACE_PROVIDER_STARTED`
589    /// packet on `fifo` to indicate success/failure of starting.
590    Start { options: StartOptions, control_handle: ProviderControlHandle },
591    /// Stop tracing.
592    ///
593    /// If tracing has already stopped the provider must ignore the request.
594    ///
595    /// Once the provider has finished writing any final events to the trace
596    /// buffer, it must send a `TRACE_PROVIDER_STOPPED` packet on `fifo`.
597    /// Note that multiple `Start,Stop` requests can be received between
598    /// `Initialize,Terminate`.
599    Stop { control_handle: ProviderControlHandle },
600    /// Terminate tracing.
601    ///
602    /// Tracing is stopped first if not already stopped.
603    /// After tracing has fully terminated the provider must close both
604    /// `buffer` and `fifo` to indicate to the trace manager that tracing is
605    /// finished.
606    Terminate { control_handle: ProviderControlHandle },
607    /// Gets the trace categories that might be produced by this provider.
608    GetKnownCategories { responder: ProviderGetKnownCategoriesResponder },
609}
610
611impl ProviderRequest {
612    #[allow(irrefutable_let_patterns)]
613    pub fn into_initialize(self) -> Option<(ProviderConfig, ProviderControlHandle)> {
614        if let ProviderRequest::Initialize { config, control_handle } = self {
615            Some((config, control_handle))
616        } else {
617            None
618        }
619    }
620
621    #[allow(irrefutable_let_patterns)]
622    pub fn into_start(self) -> Option<(StartOptions, ProviderControlHandle)> {
623        if let ProviderRequest::Start { options, control_handle } = self {
624            Some((options, control_handle))
625        } else {
626            None
627        }
628    }
629
630    #[allow(irrefutable_let_patterns)]
631    pub fn into_stop(self) -> Option<(ProviderControlHandle)> {
632        if let ProviderRequest::Stop { control_handle } = self {
633            Some((control_handle))
634        } else {
635            None
636        }
637    }
638
639    #[allow(irrefutable_let_patterns)]
640    pub fn into_terminate(self) -> Option<(ProviderControlHandle)> {
641        if let ProviderRequest::Terminate { control_handle } = self {
642            Some((control_handle))
643        } else {
644            None
645        }
646    }
647
648    #[allow(irrefutable_let_patterns)]
649    pub fn into_get_known_categories(self) -> Option<(ProviderGetKnownCategoriesResponder)> {
650        if let ProviderRequest::GetKnownCategories { responder } = self {
651            Some((responder))
652        } else {
653            None
654        }
655    }
656
657    /// Name of the method defined in FIDL
658    pub fn method_name(&self) -> &'static str {
659        match *self {
660            ProviderRequest::Initialize { .. } => "initialize",
661            ProviderRequest::Start { .. } => "start",
662            ProviderRequest::Stop { .. } => "stop",
663            ProviderRequest::Terminate { .. } => "terminate",
664            ProviderRequest::GetKnownCategories { .. } => "get_known_categories",
665        }
666    }
667}
668
669#[derive(Debug, Clone)]
670pub struct ProviderControlHandle {
671    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
672}
673
674impl fidl::endpoints::ControlHandle for ProviderControlHandle {
675    fn shutdown(&self) {
676        self.inner.shutdown()
677    }
678
679    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
680        self.inner.shutdown_with_epitaph(status)
681    }
682
683    fn is_closed(&self) -> bool {
684        self.inner.channel().is_closed()
685    }
686    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
687        self.inner.channel().on_closed()
688    }
689
690    #[cfg(target_os = "fuchsia")]
691    fn signal_peer(
692        &self,
693        clear_mask: zx::Signals,
694        set_mask: zx::Signals,
695    ) -> Result<(), zx_status::Status> {
696        use fidl::Peered;
697        self.inner.channel().signal_peer(clear_mask, set_mask)
698    }
699}
700
701impl ProviderControlHandle {}
702
703#[must_use = "FIDL methods require a response to be sent"]
704#[derive(Debug)]
705pub struct ProviderGetKnownCategoriesResponder {
706    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
707    tx_id: u32,
708}
709
710/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
711/// if the responder is dropped without sending a response, so that the client
712/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
713impl std::ops::Drop for ProviderGetKnownCategoriesResponder {
714    fn drop(&mut self) {
715        self.control_handle.shutdown();
716        // Safety: drops once, never accessed again
717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
718    }
719}
720
721impl fidl::endpoints::Responder for ProviderGetKnownCategoriesResponder {
722    type ControlHandle = ProviderControlHandle;
723
724    fn control_handle(&self) -> &ProviderControlHandle {
725        &self.control_handle
726    }
727
728    fn drop_without_shutdown(mut self) {
729        // Safety: drops once, never accessed again due to mem::forget
730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
731        // Prevent Drop from running (which would shut down the channel)
732        std::mem::forget(self);
733    }
734}
735
736impl ProviderGetKnownCategoriesResponder {
737    /// Sends a response to the FIDL transaction.
738    ///
739    /// Sets the channel to shutdown if an error occurs.
740    pub fn send(
741        self,
742        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
743    ) -> Result<(), fidl::Error> {
744        let _result = self.send_raw(categories);
745        if _result.is_err() {
746            self.control_handle.shutdown();
747        }
748        self.drop_without_shutdown();
749        _result
750    }
751
752    /// Similar to "send" but does not shutdown the channel if an error occurs.
753    pub fn send_no_shutdown_on_err(
754        self,
755        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
756    ) -> Result<(), fidl::Error> {
757        let _result = self.send_raw(categories);
758        self.drop_without_shutdown();
759        _result
760    }
761
762    fn send_raw(
763        &self,
764        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
765    ) -> Result<(), fidl::Error> {
766        self.control_handle.inner.send::<ProviderGetKnownCategoriesResponse>(
767            (categories,),
768            self.tx_id,
769            0x5f5b0ad77af3f886,
770            fidl::encoding::DynamicFlags::empty(),
771        )
772    }
773}
774
775#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
776pub struct RegistryMarker;
777
778impl fidl::endpoints::ProtocolMarker for RegistryMarker {
779    type Proxy = RegistryProxy;
780    type RequestStream = RegistryRequestStream;
781    #[cfg(target_os = "fuchsia")]
782    type SynchronousProxy = RegistrySynchronousProxy;
783
784    const DEBUG_NAME: &'static str = "fuchsia.tracing.provider.Registry";
785}
786impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
787
788pub trait RegistryProxyInterface: Send + Sync {
789    fn r#register_provider(
790        &self,
791        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
792        pid: u64,
793        name: &str,
794    ) -> Result<(), fidl::Error>;
795    type RegisterProviderSynchronouslyResponseFut: std::future::Future<Output = Result<(i32, bool), fidl::Error>>
796        + Send;
797    fn r#register_provider_synchronously(
798        &self,
799        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
800        pid: u64,
801        name: &str,
802    ) -> Self::RegisterProviderSynchronouslyResponseFut;
803}
804#[derive(Debug)]
805#[cfg(target_os = "fuchsia")]
806pub struct RegistrySynchronousProxy {
807    client: fidl::client::sync::Client,
808}
809
810#[cfg(target_os = "fuchsia")]
811impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
812    type Proxy = RegistryProxy;
813    type Protocol = RegistryMarker;
814
815    fn from_channel(inner: fidl::Channel) -> Self {
816        Self::new(inner)
817    }
818
819    fn into_channel(self) -> fidl::Channel {
820        self.client.into_channel()
821    }
822
823    fn as_channel(&self) -> &fidl::Channel {
824        self.client.as_channel()
825    }
826}
827
828#[cfg(target_os = "fuchsia")]
829impl RegistrySynchronousProxy {
830    pub fn new(channel: fidl::Channel) -> Self {
831        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
832        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
833    }
834
835    pub fn into_channel(self) -> fidl::Channel {
836        self.client.into_channel()
837    }
838
839    /// Waits until an event arrives and returns it. It is safe for other
840    /// threads to make concurrent requests while waiting for an event.
841    pub fn wait_for_event(
842        &self,
843        deadline: zx::MonotonicInstant,
844    ) -> Result<RegistryEvent, fidl::Error> {
845        RegistryEvent::decode(self.client.wait_for_event(deadline)?)
846    }
847
848    /// Registers the trace provider.
849    /// Note: Registration is asynchronous, it's only at some point after this
850    /// returns that the provider is actually registered.
851    /// To unregister, simply close the Provider pipe.
852    /// `pid` is the process id of the provider, `name` is the name of the
853    /// provider. Both of these are used in logging and diagnostic messages.
854    pub fn r#register_provider(
855        &self,
856        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
857        mut pid: u64,
858        mut name: &str,
859    ) -> Result<(), fidl::Error> {
860        self.client.send::<RegistryRegisterProviderRequest>(
861            (provider, pid, name),
862            0x75bcae3dfa08479c,
863            fidl::encoding::DynamicFlags::empty(),
864        )
865    }
866
867    /// Registers the trace provider synchronously. The call doesn't return
868    /// until the provider is registered.
869    /// On return `s` is `ZX_OK` if registration was successful.
870    /// `started` is true if tracing has already started, which is a hint to
871    /// the provider to wait for the Start() message before continuing if it
872    /// wishes to not drop trace records before Start() is received.
873    /// To unregister, simply close the Provider pipe.
874    /// `pid` is the process id of the provider, `name` is the name of the
875    /// provider. Both of these are used in logging and diagnostic messages.
876    pub fn r#register_provider_synchronously(
877        &self,
878        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
879        mut pid: u64,
880        mut name: &str,
881        ___deadline: zx::MonotonicInstant,
882    ) -> Result<(i32, bool), fidl::Error> {
883        let _response = self.client.send_query::<
884            RegistryRegisterProviderSynchronouslyRequest,
885            RegistryRegisterProviderSynchronouslyResponse,
886        >(
887            (provider, pid, name,),
888            0x4835ed419a808f16,
889            fidl::encoding::DynamicFlags::empty(),
890            ___deadline,
891        )?;
892        Ok((_response.s, _response.started))
893    }
894}
895
896#[cfg(target_os = "fuchsia")]
897impl From<RegistrySynchronousProxy> for zx::NullableHandle {
898    fn from(value: RegistrySynchronousProxy) -> Self {
899        value.into_channel().into()
900    }
901}
902
903#[cfg(target_os = "fuchsia")]
904impl From<fidl::Channel> for RegistrySynchronousProxy {
905    fn from(value: fidl::Channel) -> Self {
906        Self::new(value)
907    }
908}
909
910#[cfg(target_os = "fuchsia")]
911impl fidl::endpoints::FromClient for RegistrySynchronousProxy {
912    type Protocol = RegistryMarker;
913
914    fn from_client(value: fidl::endpoints::ClientEnd<RegistryMarker>) -> Self {
915        Self::new(value.into_channel())
916    }
917}
918
919#[derive(Debug, Clone)]
920pub struct RegistryProxy {
921    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
922}
923
924impl fidl::endpoints::Proxy for RegistryProxy {
925    type Protocol = RegistryMarker;
926
927    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
928        Self::new(inner)
929    }
930
931    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
932        self.client.into_channel().map_err(|client| Self { client })
933    }
934
935    fn as_channel(&self) -> &::fidl::AsyncChannel {
936        self.client.as_channel()
937    }
938}
939
940impl RegistryProxy {
941    /// Create a new Proxy for fuchsia.tracing.provider/Registry.
942    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
943        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
944        Self { client: fidl::client::Client::new(channel, protocol_name) }
945    }
946
947    /// Get a Stream of events from the remote end of the protocol.
948    ///
949    /// # Panics
950    ///
951    /// Panics if the event stream was already taken.
952    pub fn take_event_stream(&self) -> RegistryEventStream {
953        RegistryEventStream { event_receiver: self.client.take_event_receiver() }
954    }
955
956    /// Registers the trace provider.
957    /// Note: Registration is asynchronous, it's only at some point after this
958    /// returns that the provider is actually registered.
959    /// To unregister, simply close the Provider pipe.
960    /// `pid` is the process id of the provider, `name` is the name of the
961    /// provider. Both of these are used in logging and diagnostic messages.
962    pub fn r#register_provider(
963        &self,
964        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
965        mut pid: u64,
966        mut name: &str,
967    ) -> Result<(), fidl::Error> {
968        RegistryProxyInterface::r#register_provider(self, provider, pid, name)
969    }
970
971    /// Registers the trace provider synchronously. The call doesn't return
972    /// until the provider is registered.
973    /// On return `s` is `ZX_OK` if registration was successful.
974    /// `started` is true if tracing has already started, which is a hint to
975    /// the provider to wait for the Start() message before continuing if it
976    /// wishes to not drop trace records before Start() is received.
977    /// To unregister, simply close the Provider pipe.
978    /// `pid` is the process id of the provider, `name` is the name of the
979    /// provider. Both of these are used in logging and diagnostic messages.
980    pub fn r#register_provider_synchronously(
981        &self,
982        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
983        mut pid: u64,
984        mut name: &str,
985    ) -> fidl::client::QueryResponseFut<(i32, bool), fidl::encoding::DefaultFuchsiaResourceDialect>
986    {
987        RegistryProxyInterface::r#register_provider_synchronously(self, provider, pid, name)
988    }
989}
990
991impl RegistryProxyInterface for RegistryProxy {
992    fn r#register_provider(
993        &self,
994        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
995        mut pid: u64,
996        mut name: &str,
997    ) -> Result<(), fidl::Error> {
998        self.client.send::<RegistryRegisterProviderRequest>(
999            (provider, pid, name),
1000            0x75bcae3dfa08479c,
1001            fidl::encoding::DynamicFlags::empty(),
1002        )
1003    }
1004
1005    type RegisterProviderSynchronouslyResponseFut =
1006        fidl::client::QueryResponseFut<(i32, bool), fidl::encoding::DefaultFuchsiaResourceDialect>;
1007    fn r#register_provider_synchronously(
1008        &self,
1009        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
1010        mut pid: u64,
1011        mut name: &str,
1012    ) -> Self::RegisterProviderSynchronouslyResponseFut {
1013        fn _decode(
1014            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1015        ) -> Result<(i32, bool), fidl::Error> {
1016            let _response = fidl::client::decode_transaction_body::<
1017                RegistryRegisterProviderSynchronouslyResponse,
1018                fidl::encoding::DefaultFuchsiaResourceDialect,
1019                0x4835ed419a808f16,
1020            >(_buf?)?;
1021            Ok((_response.s, _response.started))
1022        }
1023        self.client
1024            .send_query_and_decode::<RegistryRegisterProviderSynchronouslyRequest, (i32, bool)>(
1025                (provider, pid, name),
1026                0x4835ed419a808f16,
1027                fidl::encoding::DynamicFlags::empty(),
1028                _decode,
1029            )
1030    }
1031}
1032
1033pub struct RegistryEventStream {
1034    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1035}
1036
1037impl std::marker::Unpin for RegistryEventStream {}
1038
1039impl futures::stream::FusedStream for RegistryEventStream {
1040    fn is_terminated(&self) -> bool {
1041        self.event_receiver.is_terminated()
1042    }
1043}
1044
1045impl futures::Stream for RegistryEventStream {
1046    type Item = Result<RegistryEvent, fidl::Error>;
1047
1048    fn poll_next(
1049        mut self: std::pin::Pin<&mut Self>,
1050        cx: &mut std::task::Context<'_>,
1051    ) -> std::task::Poll<Option<Self::Item>> {
1052        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1053            &mut self.event_receiver,
1054            cx
1055        )?) {
1056            Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
1057            None => std::task::Poll::Ready(None),
1058        }
1059    }
1060}
1061
1062#[derive(Debug)]
1063pub enum RegistryEvent {}
1064
1065impl RegistryEvent {
1066    /// Decodes a message buffer as a [`RegistryEvent`].
1067    fn decode(
1068        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1069    ) -> Result<RegistryEvent, fidl::Error> {
1070        let (bytes, _handles) = buf.split_mut();
1071        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1072        debug_assert_eq!(tx_header.tx_id, 0);
1073        match tx_header.ordinal {
1074            _ => Err(fidl::Error::UnknownOrdinal {
1075                ordinal: tx_header.ordinal,
1076                protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1077            }),
1078        }
1079    }
1080}
1081
1082/// A Stream of incoming requests for fuchsia.tracing.provider/Registry.
1083pub struct RegistryRequestStream {
1084    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1085    is_terminated: bool,
1086}
1087
1088impl std::marker::Unpin for RegistryRequestStream {}
1089
1090impl futures::stream::FusedStream for RegistryRequestStream {
1091    fn is_terminated(&self) -> bool {
1092        self.is_terminated
1093    }
1094}
1095
1096impl fidl::endpoints::RequestStream for RegistryRequestStream {
1097    type Protocol = RegistryMarker;
1098    type ControlHandle = RegistryControlHandle;
1099
1100    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1101        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1102    }
1103
1104    fn control_handle(&self) -> Self::ControlHandle {
1105        RegistryControlHandle { inner: self.inner.clone() }
1106    }
1107
1108    fn into_inner(
1109        self,
1110    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1111    {
1112        (self.inner, self.is_terminated)
1113    }
1114
1115    fn from_inner(
1116        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1117        is_terminated: bool,
1118    ) -> Self {
1119        Self { inner, is_terminated }
1120    }
1121}
1122
1123impl futures::Stream for RegistryRequestStream {
1124    type Item = Result<RegistryRequest, fidl::Error>;
1125
1126    fn poll_next(
1127        mut self: std::pin::Pin<&mut Self>,
1128        cx: &mut std::task::Context<'_>,
1129    ) -> std::task::Poll<Option<Self::Item>> {
1130        let this = &mut *self;
1131        if this.inner.check_shutdown(cx) {
1132            this.is_terminated = true;
1133            return std::task::Poll::Ready(None);
1134        }
1135        if this.is_terminated {
1136            panic!("polled RegistryRequestStream after completion");
1137        }
1138        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1139            |bytes, handles| {
1140                match this.inner.channel().read_etc(cx, bytes, handles) {
1141                    std::task::Poll::Ready(Ok(())) => {}
1142                    std::task::Poll::Pending => return std::task::Poll::Pending,
1143                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1144                        this.is_terminated = true;
1145                        return std::task::Poll::Ready(None);
1146                    }
1147                    std::task::Poll::Ready(Err(e)) => {
1148                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1149                            e.into(),
1150                        ))));
1151                    }
1152                }
1153
1154                // A message has been received from the channel
1155                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1156
1157                std::task::Poll::Ready(Some(match header.ordinal {
1158                    0x75bcae3dfa08479c => {
1159                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1160                        let mut req = fidl::new_empty!(
1161                            RegistryRegisterProviderRequest,
1162                            fidl::encoding::DefaultFuchsiaResourceDialect
1163                        );
1164                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterProviderRequest>(&header, _body_bytes, handles, &mut req)?;
1165                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
1166                        Ok(RegistryRequest::RegisterProvider {
1167                            provider: req.provider,
1168                            pid: req.pid,
1169                            name: req.name,
1170
1171                            control_handle,
1172                        })
1173                    }
1174                    0x4835ed419a808f16 => {
1175                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1176                        let mut req = fidl::new_empty!(
1177                            RegistryRegisterProviderSynchronouslyRequest,
1178                            fidl::encoding::DefaultFuchsiaResourceDialect
1179                        );
1180                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterProviderSynchronouslyRequest>(&header, _body_bytes, handles, &mut req)?;
1181                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
1182                        Ok(RegistryRequest::RegisterProviderSynchronously {
1183                            provider: req.provider,
1184                            pid: req.pid,
1185                            name: req.name,
1186
1187                            responder: RegistryRegisterProviderSynchronouslyResponder {
1188                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1189                                tx_id: header.tx_id,
1190                            },
1191                        })
1192                    }
1193                    _ => Err(fidl::Error::UnknownOrdinal {
1194                        ordinal: header.ordinal,
1195                        protocol_name:
1196                            <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1197                    }),
1198                }))
1199            },
1200        )
1201    }
1202}
1203
1204/// The service which trace providers use to register themselves with
1205/// the tracing system.
1206/// Note that one property of this interface is that once registration is made
1207/// the provider can drop this connection.
1208#[derive(Debug)]
1209pub enum RegistryRequest {
1210    /// Registers the trace provider.
1211    /// Note: Registration is asynchronous, it's only at some point after this
1212    /// returns that the provider is actually registered.
1213    /// To unregister, simply close the Provider pipe.
1214    /// `pid` is the process id of the provider, `name` is the name of the
1215    /// provider. Both of these are used in logging and diagnostic messages.
1216    RegisterProvider {
1217        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
1218        pid: u64,
1219        name: String,
1220        control_handle: RegistryControlHandle,
1221    },
1222    /// Registers the trace provider synchronously. The call doesn't return
1223    /// until the provider is registered.
1224    /// On return `s` is `ZX_OK` if registration was successful.
1225    /// `started` is true if tracing has already started, which is a hint to
1226    /// the provider to wait for the Start() message before continuing if it
1227    /// wishes to not drop trace records before Start() is received.
1228    /// To unregister, simply close the Provider pipe.
1229    /// `pid` is the process id of the provider, `name` is the name of the
1230    /// provider. Both of these are used in logging and diagnostic messages.
1231    RegisterProviderSynchronously {
1232        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
1233        pid: u64,
1234        name: String,
1235        responder: RegistryRegisterProviderSynchronouslyResponder,
1236    },
1237}
1238
1239impl RegistryRequest {
1240    #[allow(irrefutable_let_patterns)]
1241    pub fn into_register_provider(
1242        self,
1243    ) -> Option<(fidl::endpoints::ClientEnd<ProviderMarker>, u64, String, RegistryControlHandle)>
1244    {
1245        if let RegistryRequest::RegisterProvider { provider, pid, name, control_handle } = self {
1246            Some((provider, pid, name, control_handle))
1247        } else {
1248            None
1249        }
1250    }
1251
1252    #[allow(irrefutable_let_patterns)]
1253    pub fn into_register_provider_synchronously(
1254        self,
1255    ) -> Option<(
1256        fidl::endpoints::ClientEnd<ProviderMarker>,
1257        u64,
1258        String,
1259        RegistryRegisterProviderSynchronouslyResponder,
1260    )> {
1261        if let RegistryRequest::RegisterProviderSynchronously { provider, pid, name, responder } =
1262            self
1263        {
1264            Some((provider, pid, name, responder))
1265        } else {
1266            None
1267        }
1268    }
1269
1270    /// Name of the method defined in FIDL
1271    pub fn method_name(&self) -> &'static str {
1272        match *self {
1273            RegistryRequest::RegisterProvider { .. } => "register_provider",
1274            RegistryRequest::RegisterProviderSynchronously { .. } => {
1275                "register_provider_synchronously"
1276            }
1277        }
1278    }
1279}
1280
1281#[derive(Debug, Clone)]
1282pub struct RegistryControlHandle {
1283    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1284}
1285
1286impl fidl::endpoints::ControlHandle for RegistryControlHandle {
1287    fn shutdown(&self) {
1288        self.inner.shutdown()
1289    }
1290
1291    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1292        self.inner.shutdown_with_epitaph(status)
1293    }
1294
1295    fn is_closed(&self) -> bool {
1296        self.inner.channel().is_closed()
1297    }
1298    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1299        self.inner.channel().on_closed()
1300    }
1301
1302    #[cfg(target_os = "fuchsia")]
1303    fn signal_peer(
1304        &self,
1305        clear_mask: zx::Signals,
1306        set_mask: zx::Signals,
1307    ) -> Result<(), zx_status::Status> {
1308        use fidl::Peered;
1309        self.inner.channel().signal_peer(clear_mask, set_mask)
1310    }
1311}
1312
1313impl RegistryControlHandle {}
1314
1315#[must_use = "FIDL methods require a response to be sent"]
1316#[derive(Debug)]
1317pub struct RegistryRegisterProviderSynchronouslyResponder {
1318    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
1319    tx_id: u32,
1320}
1321
1322/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
1323/// if the responder is dropped without sending a response, so that the client
1324/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1325impl std::ops::Drop for RegistryRegisterProviderSynchronouslyResponder {
1326    fn drop(&mut self) {
1327        self.control_handle.shutdown();
1328        // Safety: drops once, never accessed again
1329        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1330    }
1331}
1332
1333impl fidl::endpoints::Responder for RegistryRegisterProviderSynchronouslyResponder {
1334    type ControlHandle = RegistryControlHandle;
1335
1336    fn control_handle(&self) -> &RegistryControlHandle {
1337        &self.control_handle
1338    }
1339
1340    fn drop_without_shutdown(mut self) {
1341        // Safety: drops once, never accessed again due to mem::forget
1342        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1343        // Prevent Drop from running (which would shut down the channel)
1344        std::mem::forget(self);
1345    }
1346}
1347
1348impl RegistryRegisterProviderSynchronouslyResponder {
1349    /// Sends a response to the FIDL transaction.
1350    ///
1351    /// Sets the channel to shutdown if an error occurs.
1352    pub fn send(self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
1353        let _result = self.send_raw(s, started);
1354        if _result.is_err() {
1355            self.control_handle.shutdown();
1356        }
1357        self.drop_without_shutdown();
1358        _result
1359    }
1360
1361    /// Similar to "send" but does not shutdown the channel if an error occurs.
1362    pub fn send_no_shutdown_on_err(self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
1363        let _result = self.send_raw(s, started);
1364        self.drop_without_shutdown();
1365        _result
1366    }
1367
1368    fn send_raw(&self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
1369        self.control_handle.inner.send::<RegistryRegisterProviderSynchronouslyResponse>(
1370            (s, started),
1371            self.tx_id,
1372            0x4835ed419a808f16,
1373            fidl::encoding::DynamicFlags::empty(),
1374        )
1375    }
1376}
1377
1378mod internal {
1379    use super::*;
1380
1381    impl fidl::encoding::ResourceTypeMarker for ProviderConfig {
1382        type Borrowed<'a> = &'a mut Self;
1383        fn take_or_borrow<'a>(
1384            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1385        ) -> Self::Borrowed<'a> {
1386            value
1387        }
1388    }
1389
1390    unsafe impl fidl::encoding::TypeMarker for ProviderConfig {
1391        type Owned = Self;
1392
1393        #[inline(always)]
1394        fn inline_align(_context: fidl::encoding::Context) -> usize {
1395            8
1396        }
1397
1398        #[inline(always)]
1399        fn inline_size(_context: fidl::encoding::Context) -> usize {
1400            32
1401        }
1402    }
1403
1404    unsafe impl
1405        fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
1406        for &mut ProviderConfig
1407    {
1408        #[inline]
1409        unsafe fn encode(
1410            self,
1411            encoder: &mut fidl::encoding::Encoder<
1412                '_,
1413                fidl::encoding::DefaultFuchsiaResourceDialect,
1414            >,
1415            offset: usize,
1416            _depth: fidl::encoding::Depth,
1417        ) -> fidl::Result<()> {
1418            encoder.debug_check_bounds::<ProviderConfig>(offset);
1419            // Delegate to tuple encoding.
1420            fidl::encoding::Encode::<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1421                (
1422                    <fidl_fuchsia_tracing::BufferingMode as fidl::encoding::ValueTypeMarker>::borrow(&self.buffering_mode),
1423                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
1424                    <fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.fifo),
1425                    <fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000> as fidl::encoding::ValueTypeMarker>::borrow(&self.categories),
1426                ),
1427                encoder, offset, _depth
1428            )
1429        }
1430    }
1431    unsafe impl<
1432        T0: fidl::encoding::Encode<
1433                fidl_fuchsia_tracing::BufferingMode,
1434                fidl::encoding::DefaultFuchsiaResourceDialect,
1435            >,
1436        T1: fidl::encoding::Encode<
1437                fidl::encoding::HandleType<
1438                    fidl::Vmo,
1439                    { fidl::ObjectType::VMO.into_raw() },
1440                    2147483648,
1441                >,
1442                fidl::encoding::DefaultFuchsiaResourceDialect,
1443            >,
1444        T2: fidl::encoding::Encode<
1445                fidl::encoding::HandleType<
1446                    fidl::Fifo,
1447                    { fidl::ObjectType::FIFO.into_raw() },
1448                    2147483648,
1449                >,
1450                fidl::encoding::DefaultFuchsiaResourceDialect,
1451            >,
1452        T3: fidl::encoding::Encode<
1453                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
1454                fidl::encoding::DefaultFuchsiaResourceDialect,
1455            >,
1456    > fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
1457        for (T0, T1, T2, T3)
1458    {
1459        #[inline]
1460        unsafe fn encode(
1461            self,
1462            encoder: &mut fidl::encoding::Encoder<
1463                '_,
1464                fidl::encoding::DefaultFuchsiaResourceDialect,
1465            >,
1466            offset: usize,
1467            depth: fidl::encoding::Depth,
1468        ) -> fidl::Result<()> {
1469            encoder.debug_check_bounds::<ProviderConfig>(offset);
1470            // Zero out padding regions. There's no need to apply masks
1471            // because the unmasked parts will be overwritten by fields.
1472            unsafe {
1473                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1474                (ptr as *mut u64).write_unaligned(0);
1475            }
1476            unsafe {
1477                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
1478                (ptr as *mut u64).write_unaligned(0);
1479            }
1480            // Write the fields.
1481            self.0.encode(encoder, offset + 0, depth)?;
1482            self.1.encode(encoder, offset + 4, depth)?;
1483            self.2.encode(encoder, offset + 8, depth)?;
1484            self.3.encode(encoder, offset + 16, depth)?;
1485            Ok(())
1486        }
1487    }
1488
1489    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1490        for ProviderConfig
1491    {
1492        #[inline(always)]
1493        fn new_empty() -> Self {
1494            Self {
1495                buffering_mode: fidl::new_empty!(
1496                    fidl_fuchsia_tracing::BufferingMode,
1497                    fidl::encoding::DefaultFuchsiaResourceDialect
1498                ),
1499                buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1500                fifo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1501                categories: fidl::new_empty!(
1502                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
1503                    fidl::encoding::DefaultFuchsiaResourceDialect
1504                ),
1505            }
1506        }
1507
1508        #[inline]
1509        unsafe fn decode(
1510            &mut self,
1511            decoder: &mut fidl::encoding::Decoder<
1512                '_,
1513                fidl::encoding::DefaultFuchsiaResourceDialect,
1514            >,
1515            offset: usize,
1516            _depth: fidl::encoding::Depth,
1517        ) -> fidl::Result<()> {
1518            decoder.debug_check_bounds::<Self>(offset);
1519            // Verify that padding bytes are zero.
1520            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1521            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1522            let mask = 0xffffff00u64;
1523            let maskedval = padval & mask;
1524            if maskedval != 0 {
1525                return Err(fidl::Error::NonZeroPadding {
1526                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1527                });
1528            }
1529            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
1530            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1531            let mask = 0xffffffff00000000u64;
1532            let maskedval = padval & mask;
1533            if maskedval != 0 {
1534                return Err(fidl::Error::NonZeroPadding {
1535                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
1536                });
1537            }
1538            fidl::decode!(
1539                fidl_fuchsia_tracing::BufferingMode,
1540                fidl::encoding::DefaultFuchsiaResourceDialect,
1541                &mut self.buffering_mode,
1542                decoder,
1543                offset + 0,
1544                _depth
1545            )?;
1546            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.buffer, decoder, offset + 4, _depth)?;
1547            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.fifo, decoder, offset + 8, _depth)?;
1548            fidl::decode!(
1549                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
1550                fidl::encoding::DefaultFuchsiaResourceDialect,
1551                &mut self.categories,
1552                decoder,
1553                offset + 16,
1554                _depth
1555            )?;
1556            Ok(())
1557        }
1558    }
1559
1560    impl fidl::encoding::ResourceTypeMarker for ProviderInitializeRequest {
1561        type Borrowed<'a> = &'a mut Self;
1562        fn take_or_borrow<'a>(
1563            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1564        ) -> Self::Borrowed<'a> {
1565            value
1566        }
1567    }
1568
1569    unsafe impl fidl::encoding::TypeMarker for ProviderInitializeRequest {
1570        type Owned = Self;
1571
1572        #[inline(always)]
1573        fn inline_align(_context: fidl::encoding::Context) -> usize {
1574            8
1575        }
1576
1577        #[inline(always)]
1578        fn inline_size(_context: fidl::encoding::Context) -> usize {
1579            32
1580        }
1581    }
1582
1583    unsafe impl
1584        fidl::encoding::Encode<
1585            ProviderInitializeRequest,
1586            fidl::encoding::DefaultFuchsiaResourceDialect,
1587        > for &mut ProviderInitializeRequest
1588    {
1589        #[inline]
1590        unsafe fn encode(
1591            self,
1592            encoder: &mut fidl::encoding::Encoder<
1593                '_,
1594                fidl::encoding::DefaultFuchsiaResourceDialect,
1595            >,
1596            offset: usize,
1597            _depth: fidl::encoding::Depth,
1598        ) -> fidl::Result<()> {
1599            encoder.debug_check_bounds::<ProviderInitializeRequest>(offset);
1600            // Delegate to tuple encoding.
1601            fidl::encoding::Encode::<
1602                ProviderInitializeRequest,
1603                fidl::encoding::DefaultFuchsiaResourceDialect,
1604            >::encode(
1605                (<ProviderConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1606                    &mut self.config,
1607                ),),
1608                encoder,
1609                offset,
1610                _depth,
1611            )
1612        }
1613    }
1614    unsafe impl<
1615        T0: fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
1616    >
1617        fidl::encoding::Encode<
1618            ProviderInitializeRequest,
1619            fidl::encoding::DefaultFuchsiaResourceDialect,
1620        > for (T0,)
1621    {
1622        #[inline]
1623        unsafe fn encode(
1624            self,
1625            encoder: &mut fidl::encoding::Encoder<
1626                '_,
1627                fidl::encoding::DefaultFuchsiaResourceDialect,
1628            >,
1629            offset: usize,
1630            depth: fidl::encoding::Depth,
1631        ) -> fidl::Result<()> {
1632            encoder.debug_check_bounds::<ProviderInitializeRequest>(offset);
1633            // Zero out padding regions. There's no need to apply masks
1634            // because the unmasked parts will be overwritten by fields.
1635            // Write the fields.
1636            self.0.encode(encoder, offset + 0, depth)?;
1637            Ok(())
1638        }
1639    }
1640
1641    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1642        for ProviderInitializeRequest
1643    {
1644        #[inline(always)]
1645        fn new_empty() -> Self {
1646            Self {
1647                config: fidl::new_empty!(
1648                    ProviderConfig,
1649                    fidl::encoding::DefaultFuchsiaResourceDialect
1650                ),
1651            }
1652        }
1653
1654        #[inline]
1655        unsafe fn decode(
1656            &mut self,
1657            decoder: &mut fidl::encoding::Decoder<
1658                '_,
1659                fidl::encoding::DefaultFuchsiaResourceDialect,
1660            >,
1661            offset: usize,
1662            _depth: fidl::encoding::Depth,
1663        ) -> fidl::Result<()> {
1664            decoder.debug_check_bounds::<Self>(offset);
1665            // Verify that padding bytes are zero.
1666            fidl::decode!(
1667                ProviderConfig,
1668                fidl::encoding::DefaultFuchsiaResourceDialect,
1669                &mut self.config,
1670                decoder,
1671                offset + 0,
1672                _depth
1673            )?;
1674            Ok(())
1675        }
1676    }
1677
1678    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterProviderRequest {
1679        type Borrowed<'a> = &'a mut Self;
1680        fn take_or_borrow<'a>(
1681            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1682        ) -> Self::Borrowed<'a> {
1683            value
1684        }
1685    }
1686
1687    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterProviderRequest {
1688        type Owned = Self;
1689
1690        #[inline(always)]
1691        fn inline_align(_context: fidl::encoding::Context) -> usize {
1692            8
1693        }
1694
1695        #[inline(always)]
1696        fn inline_size(_context: fidl::encoding::Context) -> usize {
1697            32
1698        }
1699    }
1700
1701    unsafe impl
1702        fidl::encoding::Encode<
1703            RegistryRegisterProviderRequest,
1704            fidl::encoding::DefaultFuchsiaResourceDialect,
1705        > for &mut RegistryRegisterProviderRequest
1706    {
1707        #[inline]
1708        unsafe fn encode(
1709            self,
1710            encoder: &mut fidl::encoding::Encoder<
1711                '_,
1712                fidl::encoding::DefaultFuchsiaResourceDialect,
1713            >,
1714            offset: usize,
1715            _depth: fidl::encoding::Depth,
1716        ) -> fidl::Result<()> {
1717            encoder.debug_check_bounds::<RegistryRegisterProviderRequest>(offset);
1718            // Delegate to tuple encoding.
1719            fidl::encoding::Encode::<RegistryRegisterProviderRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1720                (
1721                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.provider),
1722                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pid),
1723                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
1724                ),
1725                encoder, offset, _depth
1726            )
1727        }
1728    }
1729    unsafe impl<
1730        T0: fidl::encoding::Encode<
1731                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1732                fidl::encoding::DefaultFuchsiaResourceDialect,
1733            >,
1734        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
1735        T2: fidl::encoding::Encode<
1736                fidl::encoding::BoundedString<100>,
1737                fidl::encoding::DefaultFuchsiaResourceDialect,
1738            >,
1739    >
1740        fidl::encoding::Encode<
1741            RegistryRegisterProviderRequest,
1742            fidl::encoding::DefaultFuchsiaResourceDialect,
1743        > for (T0, T1, T2)
1744    {
1745        #[inline]
1746        unsafe fn encode(
1747            self,
1748            encoder: &mut fidl::encoding::Encoder<
1749                '_,
1750                fidl::encoding::DefaultFuchsiaResourceDialect,
1751            >,
1752            offset: usize,
1753            depth: fidl::encoding::Depth,
1754        ) -> fidl::Result<()> {
1755            encoder.debug_check_bounds::<RegistryRegisterProviderRequest>(offset);
1756            // Zero out padding regions. There's no need to apply masks
1757            // because the unmasked parts will be overwritten by fields.
1758            unsafe {
1759                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1760                (ptr as *mut u64).write_unaligned(0);
1761            }
1762            // Write the fields.
1763            self.0.encode(encoder, offset + 0, depth)?;
1764            self.1.encode(encoder, offset + 8, depth)?;
1765            self.2.encode(encoder, offset + 16, depth)?;
1766            Ok(())
1767        }
1768    }
1769
1770    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1771        for RegistryRegisterProviderRequest
1772    {
1773        #[inline(always)]
1774        fn new_empty() -> Self {
1775            Self {
1776                provider: fidl::new_empty!(
1777                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1778                    fidl::encoding::DefaultFuchsiaResourceDialect
1779                ),
1780                pid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
1781                name: fidl::new_empty!(
1782                    fidl::encoding::BoundedString<100>,
1783                    fidl::encoding::DefaultFuchsiaResourceDialect
1784                ),
1785            }
1786        }
1787
1788        #[inline]
1789        unsafe fn decode(
1790            &mut self,
1791            decoder: &mut fidl::encoding::Decoder<
1792                '_,
1793                fidl::encoding::DefaultFuchsiaResourceDialect,
1794            >,
1795            offset: usize,
1796            _depth: fidl::encoding::Depth,
1797        ) -> fidl::Result<()> {
1798            decoder.debug_check_bounds::<Self>(offset);
1799            // Verify that padding bytes are zero.
1800            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1801            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1802            let mask = 0xffffffff00000000u64;
1803            let maskedval = padval & mask;
1804            if maskedval != 0 {
1805                return Err(fidl::Error::NonZeroPadding {
1806                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1807                });
1808            }
1809            fidl::decode!(
1810                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1811                fidl::encoding::DefaultFuchsiaResourceDialect,
1812                &mut self.provider,
1813                decoder,
1814                offset + 0,
1815                _depth
1816            )?;
1817            fidl::decode!(
1818                u64,
1819                fidl::encoding::DefaultFuchsiaResourceDialect,
1820                &mut self.pid,
1821                decoder,
1822                offset + 8,
1823                _depth
1824            )?;
1825            fidl::decode!(
1826                fidl::encoding::BoundedString<100>,
1827                fidl::encoding::DefaultFuchsiaResourceDialect,
1828                &mut self.name,
1829                decoder,
1830                offset + 16,
1831                _depth
1832            )?;
1833            Ok(())
1834        }
1835    }
1836
1837    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterProviderSynchronouslyRequest {
1838        type Borrowed<'a> = &'a mut Self;
1839        fn take_or_borrow<'a>(
1840            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1841        ) -> Self::Borrowed<'a> {
1842            value
1843        }
1844    }
1845
1846    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterProviderSynchronouslyRequest {
1847        type Owned = Self;
1848
1849        #[inline(always)]
1850        fn inline_align(_context: fidl::encoding::Context) -> usize {
1851            8
1852        }
1853
1854        #[inline(always)]
1855        fn inline_size(_context: fidl::encoding::Context) -> usize {
1856            32
1857        }
1858    }
1859
1860    unsafe impl
1861        fidl::encoding::Encode<
1862            RegistryRegisterProviderSynchronouslyRequest,
1863            fidl::encoding::DefaultFuchsiaResourceDialect,
1864        > for &mut RegistryRegisterProviderSynchronouslyRequest
1865    {
1866        #[inline]
1867        unsafe fn encode(
1868            self,
1869            encoder: &mut fidl::encoding::Encoder<
1870                '_,
1871                fidl::encoding::DefaultFuchsiaResourceDialect,
1872            >,
1873            offset: usize,
1874            _depth: fidl::encoding::Depth,
1875        ) -> fidl::Result<()> {
1876            encoder.debug_check_bounds::<RegistryRegisterProviderSynchronouslyRequest>(offset);
1877            // Delegate to tuple encoding.
1878            fidl::encoding::Encode::<RegistryRegisterProviderSynchronouslyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1879                (
1880                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.provider),
1881                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pid),
1882                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
1883                ),
1884                encoder, offset, _depth
1885            )
1886        }
1887    }
1888    unsafe impl<
1889        T0: fidl::encoding::Encode<
1890                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1891                fidl::encoding::DefaultFuchsiaResourceDialect,
1892            >,
1893        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
1894        T2: fidl::encoding::Encode<
1895                fidl::encoding::BoundedString<100>,
1896                fidl::encoding::DefaultFuchsiaResourceDialect,
1897            >,
1898    >
1899        fidl::encoding::Encode<
1900            RegistryRegisterProviderSynchronouslyRequest,
1901            fidl::encoding::DefaultFuchsiaResourceDialect,
1902        > for (T0, T1, T2)
1903    {
1904        #[inline]
1905        unsafe fn encode(
1906            self,
1907            encoder: &mut fidl::encoding::Encoder<
1908                '_,
1909                fidl::encoding::DefaultFuchsiaResourceDialect,
1910            >,
1911            offset: usize,
1912            depth: fidl::encoding::Depth,
1913        ) -> fidl::Result<()> {
1914            encoder.debug_check_bounds::<RegistryRegisterProviderSynchronouslyRequest>(offset);
1915            // Zero out padding regions. There's no need to apply masks
1916            // because the unmasked parts will be overwritten by fields.
1917            unsafe {
1918                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1919                (ptr as *mut u64).write_unaligned(0);
1920            }
1921            // Write the fields.
1922            self.0.encode(encoder, offset + 0, depth)?;
1923            self.1.encode(encoder, offset + 8, depth)?;
1924            self.2.encode(encoder, offset + 16, depth)?;
1925            Ok(())
1926        }
1927    }
1928
1929    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1930        for RegistryRegisterProviderSynchronouslyRequest
1931    {
1932        #[inline(always)]
1933        fn new_empty() -> Self {
1934            Self {
1935                provider: fidl::new_empty!(
1936                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1937                    fidl::encoding::DefaultFuchsiaResourceDialect
1938                ),
1939                pid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
1940                name: fidl::new_empty!(
1941                    fidl::encoding::BoundedString<100>,
1942                    fidl::encoding::DefaultFuchsiaResourceDialect
1943                ),
1944            }
1945        }
1946
1947        #[inline]
1948        unsafe fn decode(
1949            &mut self,
1950            decoder: &mut fidl::encoding::Decoder<
1951                '_,
1952                fidl::encoding::DefaultFuchsiaResourceDialect,
1953            >,
1954            offset: usize,
1955            _depth: fidl::encoding::Depth,
1956        ) -> fidl::Result<()> {
1957            decoder.debug_check_bounds::<Self>(offset);
1958            // Verify that padding bytes are zero.
1959            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1960            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1961            let mask = 0xffffffff00000000u64;
1962            let maskedval = padval & mask;
1963            if maskedval != 0 {
1964                return Err(fidl::Error::NonZeroPadding {
1965                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1966                });
1967            }
1968            fidl::decode!(
1969                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1970                fidl::encoding::DefaultFuchsiaResourceDialect,
1971                &mut self.provider,
1972                decoder,
1973                offset + 0,
1974                _depth
1975            )?;
1976            fidl::decode!(
1977                u64,
1978                fidl::encoding::DefaultFuchsiaResourceDialect,
1979                &mut self.pid,
1980                decoder,
1981                offset + 8,
1982                _depth
1983            )?;
1984            fidl::decode!(
1985                fidl::encoding::BoundedString<100>,
1986                fidl::encoding::DefaultFuchsiaResourceDialect,
1987                &mut self.name,
1988                decoder,
1989                offset + 16,
1990                _depth
1991            )?;
1992            Ok(())
1993        }
1994    }
1995}