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