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::NullableHandle {
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
677    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
678        self.inner.shutdown_with_epitaph(status)
679    }
680
681    fn is_closed(&self) -> bool {
682        self.inner.channel().is_closed()
683    }
684    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
685        self.inner.channel().on_closed()
686    }
687
688    #[cfg(target_os = "fuchsia")]
689    fn signal_peer(
690        &self,
691        clear_mask: zx::Signals,
692        set_mask: zx::Signals,
693    ) -> Result<(), zx_status::Status> {
694        use fidl::Peered;
695        self.inner.channel().signal_peer(clear_mask, set_mask)
696    }
697}
698
699impl ProviderControlHandle {}
700
701#[must_use = "FIDL methods require a response to be sent"]
702#[derive(Debug)]
703pub struct ProviderGetKnownCategoriesResponder {
704    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
705    tx_id: u32,
706}
707
708/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
709/// if the responder is dropped without sending a response, so that the client
710/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
711impl std::ops::Drop for ProviderGetKnownCategoriesResponder {
712    fn drop(&mut self) {
713        self.control_handle.shutdown();
714        // Safety: drops once, never accessed again
715        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
716    }
717}
718
719impl fidl::endpoints::Responder for ProviderGetKnownCategoriesResponder {
720    type ControlHandle = ProviderControlHandle;
721
722    fn control_handle(&self) -> &ProviderControlHandle {
723        &self.control_handle
724    }
725
726    fn drop_without_shutdown(mut self) {
727        // Safety: drops once, never accessed again due to mem::forget
728        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
729        // Prevent Drop from running (which would shut down the channel)
730        std::mem::forget(self);
731    }
732}
733
734impl ProviderGetKnownCategoriesResponder {
735    /// Sends a response to the FIDL transaction.
736    ///
737    /// Sets the channel to shutdown if an error occurs.
738    pub fn send(
739        self,
740        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
741    ) -> Result<(), fidl::Error> {
742        let _result = self.send_raw(categories);
743        if _result.is_err() {
744            self.control_handle.shutdown();
745        }
746        self.drop_without_shutdown();
747        _result
748    }
749
750    /// Similar to "send" but does not shutdown the channel if an error occurs.
751    pub fn send_no_shutdown_on_err(
752        self,
753        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
754    ) -> Result<(), fidl::Error> {
755        let _result = self.send_raw(categories);
756        self.drop_without_shutdown();
757        _result
758    }
759
760    fn send_raw(
761        &self,
762        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
763    ) -> Result<(), fidl::Error> {
764        self.control_handle.inner.send::<ProviderGetKnownCategoriesResponse>(
765            (categories,),
766            self.tx_id,
767            0x5f5b0ad77af3f886,
768            fidl::encoding::DynamicFlags::empty(),
769        )
770    }
771}
772
773#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
774pub struct RegistryMarker;
775
776impl fidl::endpoints::ProtocolMarker for RegistryMarker {
777    type Proxy = RegistryProxy;
778    type RequestStream = RegistryRequestStream;
779    #[cfg(target_os = "fuchsia")]
780    type SynchronousProxy = RegistrySynchronousProxy;
781
782    const DEBUG_NAME: &'static str = "fuchsia.tracing.provider.Registry";
783}
784impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
785
786pub trait RegistryProxyInterface: Send + Sync {
787    fn r#register_provider(
788        &self,
789        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
790        pid: u64,
791        name: &str,
792    ) -> Result<(), fidl::Error>;
793    type RegisterProviderSynchronouslyResponseFut: std::future::Future<Output = Result<(i32, bool), fidl::Error>>
794        + Send;
795    fn r#register_provider_synchronously(
796        &self,
797        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
798        pid: u64,
799        name: &str,
800    ) -> Self::RegisterProviderSynchronouslyResponseFut;
801}
802#[derive(Debug)]
803#[cfg(target_os = "fuchsia")]
804pub struct RegistrySynchronousProxy {
805    client: fidl::client::sync::Client,
806}
807
808#[cfg(target_os = "fuchsia")]
809impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
810    type Proxy = RegistryProxy;
811    type Protocol = RegistryMarker;
812
813    fn from_channel(inner: fidl::Channel) -> Self {
814        Self::new(inner)
815    }
816
817    fn into_channel(self) -> fidl::Channel {
818        self.client.into_channel()
819    }
820
821    fn as_channel(&self) -> &fidl::Channel {
822        self.client.as_channel()
823    }
824}
825
826#[cfg(target_os = "fuchsia")]
827impl RegistrySynchronousProxy {
828    pub fn new(channel: fidl::Channel) -> Self {
829        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
830        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
831    }
832
833    pub fn into_channel(self) -> fidl::Channel {
834        self.client.into_channel()
835    }
836
837    /// Waits until an event arrives and returns it. It is safe for other
838    /// threads to make concurrent requests while waiting for an event.
839    pub fn wait_for_event(
840        &self,
841        deadline: zx::MonotonicInstant,
842    ) -> Result<RegistryEvent, fidl::Error> {
843        RegistryEvent::decode(self.client.wait_for_event(deadline)?)
844    }
845
846    /// Registers the trace provider.
847    /// Note: Registration is asynchronous, it's only at some point after this
848    /// returns that the provider is actually registered.
849    /// To unregister, simply close the Provider pipe.
850    /// `pid` is the process id of the provider, `name` is the name of the
851    /// provider. Both of these are used in logging and diagnostic messages.
852    pub fn r#register_provider(
853        &self,
854        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
855        mut pid: u64,
856        mut name: &str,
857    ) -> Result<(), fidl::Error> {
858        self.client.send::<RegistryRegisterProviderRequest>(
859            (provider, pid, name),
860            0x75bcae3dfa08479c,
861            fidl::encoding::DynamicFlags::empty(),
862        )
863    }
864
865    /// Registers the trace provider synchronously. The call doesn't return
866    /// until the provider is registered.
867    /// On return `s` is `ZX_OK` if registration was successful.
868    /// `started` is true if tracing has already started, which is a hint to
869    /// the provider to wait for the Start() message before continuing if it
870    /// wishes to not drop trace records before Start() is received.
871    /// To unregister, simply close the Provider pipe.
872    /// `pid` is the process id of the provider, `name` is the name of the
873    /// provider. Both of these are used in logging and diagnostic messages.
874    pub fn r#register_provider_synchronously(
875        &self,
876        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
877        mut pid: u64,
878        mut name: &str,
879        ___deadline: zx::MonotonicInstant,
880    ) -> Result<(i32, bool), fidl::Error> {
881        let _response = self.client.send_query::<
882            RegistryRegisterProviderSynchronouslyRequest,
883            RegistryRegisterProviderSynchronouslyResponse,
884        >(
885            (provider, pid, name,),
886            0x4835ed419a808f16,
887            fidl::encoding::DynamicFlags::empty(),
888            ___deadline,
889        )?;
890        Ok((_response.s, _response.started))
891    }
892}
893
894#[cfg(target_os = "fuchsia")]
895impl From<RegistrySynchronousProxy> for zx::NullableHandle {
896    fn from(value: RegistrySynchronousProxy) -> Self {
897        value.into_channel().into()
898    }
899}
900
901#[cfg(target_os = "fuchsia")]
902impl From<fidl::Channel> for RegistrySynchronousProxy {
903    fn from(value: fidl::Channel) -> Self {
904        Self::new(value)
905    }
906}
907
908#[cfg(target_os = "fuchsia")]
909impl fidl::endpoints::FromClient for RegistrySynchronousProxy {
910    type Protocol = RegistryMarker;
911
912    fn from_client(value: fidl::endpoints::ClientEnd<RegistryMarker>) -> Self {
913        Self::new(value.into_channel())
914    }
915}
916
917#[derive(Debug, Clone)]
918pub struct RegistryProxy {
919    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
920}
921
922impl fidl::endpoints::Proxy for RegistryProxy {
923    type Protocol = RegistryMarker;
924
925    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
926        Self::new(inner)
927    }
928
929    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
930        self.client.into_channel().map_err(|client| Self { client })
931    }
932
933    fn as_channel(&self) -> &::fidl::AsyncChannel {
934        self.client.as_channel()
935    }
936}
937
938impl RegistryProxy {
939    /// Create a new Proxy for fuchsia.tracing.provider/Registry.
940    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
941        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
942        Self { client: fidl::client::Client::new(channel, protocol_name) }
943    }
944
945    /// Get a Stream of events from the remote end of the protocol.
946    ///
947    /// # Panics
948    ///
949    /// Panics if the event stream was already taken.
950    pub fn take_event_stream(&self) -> RegistryEventStream {
951        RegistryEventStream { event_receiver: self.client.take_event_receiver() }
952    }
953
954    /// Registers the trace provider.
955    /// Note: Registration is asynchronous, it's only at some point after this
956    /// returns that the provider is actually registered.
957    /// To unregister, simply close the Provider pipe.
958    /// `pid` is the process id of the provider, `name` is the name of the
959    /// provider. Both of these are used in logging and diagnostic messages.
960    pub fn r#register_provider(
961        &self,
962        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
963        mut pid: u64,
964        mut name: &str,
965    ) -> Result<(), fidl::Error> {
966        RegistryProxyInterface::r#register_provider(self, provider, pid, name)
967    }
968
969    /// Registers the trace provider synchronously. The call doesn't return
970    /// until the provider is registered.
971    /// On return `s` is `ZX_OK` if registration was successful.
972    /// `started` is true if tracing has already started, which is a hint to
973    /// the provider to wait for the Start() message before continuing if it
974    /// wishes to not drop trace records before Start() is received.
975    /// To unregister, simply close the Provider pipe.
976    /// `pid` is the process id of the provider, `name` is the name of the
977    /// provider. Both of these are used in logging and diagnostic messages.
978    pub fn r#register_provider_synchronously(
979        &self,
980        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
981        mut pid: u64,
982        mut name: &str,
983    ) -> fidl::client::QueryResponseFut<(i32, bool), fidl::encoding::DefaultFuchsiaResourceDialect>
984    {
985        RegistryProxyInterface::r#register_provider_synchronously(self, provider, pid, name)
986    }
987}
988
989impl RegistryProxyInterface for RegistryProxy {
990    fn r#register_provider(
991        &self,
992        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
993        mut pid: u64,
994        mut name: &str,
995    ) -> Result<(), fidl::Error> {
996        self.client.send::<RegistryRegisterProviderRequest>(
997            (provider, pid, name),
998            0x75bcae3dfa08479c,
999            fidl::encoding::DynamicFlags::empty(),
1000        )
1001    }
1002
1003    type RegisterProviderSynchronouslyResponseFut =
1004        fidl::client::QueryResponseFut<(i32, bool), fidl::encoding::DefaultFuchsiaResourceDialect>;
1005    fn r#register_provider_synchronously(
1006        &self,
1007        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
1008        mut pid: u64,
1009        mut name: &str,
1010    ) -> Self::RegisterProviderSynchronouslyResponseFut {
1011        fn _decode(
1012            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1013        ) -> Result<(i32, bool), fidl::Error> {
1014            let _response = fidl::client::decode_transaction_body::<
1015                RegistryRegisterProviderSynchronouslyResponse,
1016                fidl::encoding::DefaultFuchsiaResourceDialect,
1017                0x4835ed419a808f16,
1018            >(_buf?)?;
1019            Ok((_response.s, _response.started))
1020        }
1021        self.client
1022            .send_query_and_decode::<RegistryRegisterProviderSynchronouslyRequest, (i32, bool)>(
1023                (provider, pid, name),
1024                0x4835ed419a808f16,
1025                fidl::encoding::DynamicFlags::empty(),
1026                _decode,
1027            )
1028    }
1029}
1030
1031pub struct RegistryEventStream {
1032    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1033}
1034
1035impl std::marker::Unpin for RegistryEventStream {}
1036
1037impl futures::stream::FusedStream for RegistryEventStream {
1038    fn is_terminated(&self) -> bool {
1039        self.event_receiver.is_terminated()
1040    }
1041}
1042
1043impl futures::Stream for RegistryEventStream {
1044    type Item = Result<RegistryEvent, fidl::Error>;
1045
1046    fn poll_next(
1047        mut self: std::pin::Pin<&mut Self>,
1048        cx: &mut std::task::Context<'_>,
1049    ) -> std::task::Poll<Option<Self::Item>> {
1050        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1051            &mut self.event_receiver,
1052            cx
1053        )?) {
1054            Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
1055            None => std::task::Poll::Ready(None),
1056        }
1057    }
1058}
1059
1060#[derive(Debug)]
1061pub enum RegistryEvent {}
1062
1063impl RegistryEvent {
1064    /// Decodes a message buffer as a [`RegistryEvent`].
1065    fn decode(
1066        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1067    ) -> Result<RegistryEvent, fidl::Error> {
1068        let (bytes, _handles) = buf.split_mut();
1069        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1070        debug_assert_eq!(tx_header.tx_id, 0);
1071        match tx_header.ordinal {
1072            _ => Err(fidl::Error::UnknownOrdinal {
1073                ordinal: tx_header.ordinal,
1074                protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1075            }),
1076        }
1077    }
1078}
1079
1080/// A Stream of incoming requests for fuchsia.tracing.provider/Registry.
1081pub struct RegistryRequestStream {
1082    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1083    is_terminated: bool,
1084}
1085
1086impl std::marker::Unpin for RegistryRequestStream {}
1087
1088impl futures::stream::FusedStream for RegistryRequestStream {
1089    fn is_terminated(&self) -> bool {
1090        self.is_terminated
1091    }
1092}
1093
1094impl fidl::endpoints::RequestStream for RegistryRequestStream {
1095    type Protocol = RegistryMarker;
1096    type ControlHandle = RegistryControlHandle;
1097
1098    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1099        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1100    }
1101
1102    fn control_handle(&self) -> Self::ControlHandle {
1103        RegistryControlHandle { inner: self.inner.clone() }
1104    }
1105
1106    fn into_inner(
1107        self,
1108    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1109    {
1110        (self.inner, self.is_terminated)
1111    }
1112
1113    fn from_inner(
1114        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1115        is_terminated: bool,
1116    ) -> Self {
1117        Self { inner, is_terminated }
1118    }
1119}
1120
1121impl futures::Stream for RegistryRequestStream {
1122    type Item = Result<RegistryRequest, fidl::Error>;
1123
1124    fn poll_next(
1125        mut self: std::pin::Pin<&mut Self>,
1126        cx: &mut std::task::Context<'_>,
1127    ) -> std::task::Poll<Option<Self::Item>> {
1128        let this = &mut *self;
1129        if this.inner.check_shutdown(cx) {
1130            this.is_terminated = true;
1131            return std::task::Poll::Ready(None);
1132        }
1133        if this.is_terminated {
1134            panic!("polled RegistryRequestStream after completion");
1135        }
1136        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1137            |bytes, handles| {
1138                match this.inner.channel().read_etc(cx, bytes, handles) {
1139                    std::task::Poll::Ready(Ok(())) => {}
1140                    std::task::Poll::Pending => return std::task::Poll::Pending,
1141                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1142                        this.is_terminated = true;
1143                        return std::task::Poll::Ready(None);
1144                    }
1145                    std::task::Poll::Ready(Err(e)) => {
1146                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1147                            e.into(),
1148                        ))));
1149                    }
1150                }
1151
1152                // A message has been received from the channel
1153                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1154
1155                std::task::Poll::Ready(Some(match header.ordinal {
1156                    0x75bcae3dfa08479c => {
1157                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1158                        let mut req = fidl::new_empty!(
1159                            RegistryRegisterProviderRequest,
1160                            fidl::encoding::DefaultFuchsiaResourceDialect
1161                        );
1162                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterProviderRequest>(&header, _body_bytes, handles, &mut req)?;
1163                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
1164                        Ok(RegistryRequest::RegisterProvider {
1165                            provider: req.provider,
1166                            pid: req.pid,
1167                            name: req.name,
1168
1169                            control_handle,
1170                        })
1171                    }
1172                    0x4835ed419a808f16 => {
1173                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1174                        let mut req = fidl::new_empty!(
1175                            RegistryRegisterProviderSynchronouslyRequest,
1176                            fidl::encoding::DefaultFuchsiaResourceDialect
1177                        );
1178                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterProviderSynchronouslyRequest>(&header, _body_bytes, handles, &mut req)?;
1179                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
1180                        Ok(RegistryRequest::RegisterProviderSynchronously {
1181                            provider: req.provider,
1182                            pid: req.pid,
1183                            name: req.name,
1184
1185                            responder: RegistryRegisterProviderSynchronouslyResponder {
1186                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1187                                tx_id: header.tx_id,
1188                            },
1189                        })
1190                    }
1191                    _ => Err(fidl::Error::UnknownOrdinal {
1192                        ordinal: header.ordinal,
1193                        protocol_name:
1194                            <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1195                    }),
1196                }))
1197            },
1198        )
1199    }
1200}
1201
1202/// The service which trace providers use to register themselves with
1203/// the tracing system.
1204/// Note that one property of this interface is that once registration is made
1205/// the provider can drop this connection.
1206#[derive(Debug)]
1207pub enum RegistryRequest {
1208    /// Registers the trace provider.
1209    /// Note: Registration is asynchronous, it's only at some point after this
1210    /// returns that the provider is actually registered.
1211    /// To unregister, simply close the Provider pipe.
1212    /// `pid` is the process id of the provider, `name` is the name of the
1213    /// provider. Both of these are used in logging and diagnostic messages.
1214    RegisterProvider {
1215        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
1216        pid: u64,
1217        name: String,
1218        control_handle: RegistryControlHandle,
1219    },
1220    /// Registers the trace provider synchronously. The call doesn't return
1221    /// until the provider is registered.
1222    /// On return `s` is `ZX_OK` if registration was successful.
1223    /// `started` is true if tracing has already started, which is a hint to
1224    /// the provider to wait for the Start() message before continuing if it
1225    /// wishes to not drop trace records before Start() is received.
1226    /// To unregister, simply close the Provider pipe.
1227    /// `pid` is the process id of the provider, `name` is the name of the
1228    /// provider. Both of these are used in logging and diagnostic messages.
1229    RegisterProviderSynchronously {
1230        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
1231        pid: u64,
1232        name: String,
1233        responder: RegistryRegisterProviderSynchronouslyResponder,
1234    },
1235}
1236
1237impl RegistryRequest {
1238    #[allow(irrefutable_let_patterns)]
1239    pub fn into_register_provider(
1240        self,
1241    ) -> Option<(fidl::endpoints::ClientEnd<ProviderMarker>, u64, String, RegistryControlHandle)>
1242    {
1243        if let RegistryRequest::RegisterProvider { provider, pid, name, control_handle } = self {
1244            Some((provider, pid, name, control_handle))
1245        } else {
1246            None
1247        }
1248    }
1249
1250    #[allow(irrefutable_let_patterns)]
1251    pub fn into_register_provider_synchronously(
1252        self,
1253    ) -> Option<(
1254        fidl::endpoints::ClientEnd<ProviderMarker>,
1255        u64,
1256        String,
1257        RegistryRegisterProviderSynchronouslyResponder,
1258    )> {
1259        if let RegistryRequest::RegisterProviderSynchronously { provider, pid, name, responder } =
1260            self
1261        {
1262            Some((provider, pid, name, responder))
1263        } else {
1264            None
1265        }
1266    }
1267
1268    /// Name of the method defined in FIDL
1269    pub fn method_name(&self) -> &'static str {
1270        match *self {
1271            RegistryRequest::RegisterProvider { .. } => "register_provider",
1272            RegistryRequest::RegisterProviderSynchronously { .. } => {
1273                "register_provider_synchronously"
1274            }
1275        }
1276    }
1277}
1278
1279#[derive(Debug, Clone)]
1280pub struct RegistryControlHandle {
1281    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1282}
1283
1284impl fidl::endpoints::ControlHandle for RegistryControlHandle {
1285    fn shutdown(&self) {
1286        self.inner.shutdown()
1287    }
1288
1289    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1290        self.inner.shutdown_with_epitaph(status)
1291    }
1292
1293    fn is_closed(&self) -> bool {
1294        self.inner.channel().is_closed()
1295    }
1296    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1297        self.inner.channel().on_closed()
1298    }
1299
1300    #[cfg(target_os = "fuchsia")]
1301    fn signal_peer(
1302        &self,
1303        clear_mask: zx::Signals,
1304        set_mask: zx::Signals,
1305    ) -> Result<(), zx_status::Status> {
1306        use fidl::Peered;
1307        self.inner.channel().signal_peer(clear_mask, set_mask)
1308    }
1309}
1310
1311impl RegistryControlHandle {}
1312
1313#[must_use = "FIDL methods require a response to be sent"]
1314#[derive(Debug)]
1315pub struct RegistryRegisterProviderSynchronouslyResponder {
1316    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
1317    tx_id: u32,
1318}
1319
1320/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
1321/// if the responder is dropped without sending a response, so that the client
1322/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1323impl std::ops::Drop for RegistryRegisterProviderSynchronouslyResponder {
1324    fn drop(&mut self) {
1325        self.control_handle.shutdown();
1326        // Safety: drops once, never accessed again
1327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1328    }
1329}
1330
1331impl fidl::endpoints::Responder for RegistryRegisterProviderSynchronouslyResponder {
1332    type ControlHandle = RegistryControlHandle;
1333
1334    fn control_handle(&self) -> &RegistryControlHandle {
1335        &self.control_handle
1336    }
1337
1338    fn drop_without_shutdown(mut self) {
1339        // Safety: drops once, never accessed again due to mem::forget
1340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1341        // Prevent Drop from running (which would shut down the channel)
1342        std::mem::forget(self);
1343    }
1344}
1345
1346impl RegistryRegisterProviderSynchronouslyResponder {
1347    /// Sends a response to the FIDL transaction.
1348    ///
1349    /// Sets the channel to shutdown if an error occurs.
1350    pub fn send(self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
1351        let _result = self.send_raw(s, started);
1352        if _result.is_err() {
1353            self.control_handle.shutdown();
1354        }
1355        self.drop_without_shutdown();
1356        _result
1357    }
1358
1359    /// Similar to "send" but does not shutdown the channel if an error occurs.
1360    pub fn send_no_shutdown_on_err(self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
1361        let _result = self.send_raw(s, started);
1362        self.drop_without_shutdown();
1363        _result
1364    }
1365
1366    fn send_raw(&self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
1367        self.control_handle.inner.send::<RegistryRegisterProviderSynchronouslyResponse>(
1368            (s, started),
1369            self.tx_id,
1370            0x4835ed419a808f16,
1371            fidl::encoding::DynamicFlags::empty(),
1372        )
1373    }
1374}
1375
1376mod internal {
1377    use super::*;
1378
1379    impl fidl::encoding::ResourceTypeMarker for ProviderConfig {
1380        type Borrowed<'a> = &'a mut Self;
1381        fn take_or_borrow<'a>(
1382            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1383        ) -> Self::Borrowed<'a> {
1384            value
1385        }
1386    }
1387
1388    unsafe impl fidl::encoding::TypeMarker for ProviderConfig {
1389        type Owned = Self;
1390
1391        #[inline(always)]
1392        fn inline_align(_context: fidl::encoding::Context) -> usize {
1393            8
1394        }
1395
1396        #[inline(always)]
1397        fn inline_size(_context: fidl::encoding::Context) -> usize {
1398            32
1399        }
1400    }
1401
1402    unsafe impl
1403        fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
1404        for &mut ProviderConfig
1405    {
1406        #[inline]
1407        unsafe fn encode(
1408            self,
1409            encoder: &mut fidl::encoding::Encoder<
1410                '_,
1411                fidl::encoding::DefaultFuchsiaResourceDialect,
1412            >,
1413            offset: usize,
1414            _depth: fidl::encoding::Depth,
1415        ) -> fidl::Result<()> {
1416            encoder.debug_check_bounds::<ProviderConfig>(offset);
1417            // Delegate to tuple encoding.
1418            fidl::encoding::Encode::<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1419                (
1420                    <fidl_fuchsia_tracing::BufferingMode as fidl::encoding::ValueTypeMarker>::borrow(&self.buffering_mode),
1421                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
1422                    <fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.fifo),
1423                    <fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000> as fidl::encoding::ValueTypeMarker>::borrow(&self.categories),
1424                ),
1425                encoder, offset, _depth
1426            )
1427        }
1428    }
1429    unsafe impl<
1430        T0: fidl::encoding::Encode<
1431                fidl_fuchsia_tracing::BufferingMode,
1432                fidl::encoding::DefaultFuchsiaResourceDialect,
1433            >,
1434        T1: fidl::encoding::Encode<
1435                fidl::encoding::HandleType<
1436                    fidl::Vmo,
1437                    { fidl::ObjectType::VMO.into_raw() },
1438                    2147483648,
1439                >,
1440                fidl::encoding::DefaultFuchsiaResourceDialect,
1441            >,
1442        T2: fidl::encoding::Encode<
1443                fidl::encoding::HandleType<
1444                    fidl::Fifo,
1445                    { fidl::ObjectType::FIFO.into_raw() },
1446                    2147483648,
1447                >,
1448                fidl::encoding::DefaultFuchsiaResourceDialect,
1449            >,
1450        T3: fidl::encoding::Encode<
1451                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
1452                fidl::encoding::DefaultFuchsiaResourceDialect,
1453            >,
1454    > fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
1455        for (T0, T1, T2, T3)
1456    {
1457        #[inline]
1458        unsafe fn encode(
1459            self,
1460            encoder: &mut fidl::encoding::Encoder<
1461                '_,
1462                fidl::encoding::DefaultFuchsiaResourceDialect,
1463            >,
1464            offset: usize,
1465            depth: fidl::encoding::Depth,
1466        ) -> fidl::Result<()> {
1467            encoder.debug_check_bounds::<ProviderConfig>(offset);
1468            // Zero out padding regions. There's no need to apply masks
1469            // because the unmasked parts will be overwritten by fields.
1470            unsafe {
1471                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1472                (ptr as *mut u64).write_unaligned(0);
1473            }
1474            unsafe {
1475                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
1476                (ptr as *mut u64).write_unaligned(0);
1477            }
1478            // Write the fields.
1479            self.0.encode(encoder, offset + 0, depth)?;
1480            self.1.encode(encoder, offset + 4, depth)?;
1481            self.2.encode(encoder, offset + 8, depth)?;
1482            self.3.encode(encoder, offset + 16, depth)?;
1483            Ok(())
1484        }
1485    }
1486
1487    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1488        for ProviderConfig
1489    {
1490        #[inline(always)]
1491        fn new_empty() -> Self {
1492            Self {
1493                buffering_mode: fidl::new_empty!(
1494                    fidl_fuchsia_tracing::BufferingMode,
1495                    fidl::encoding::DefaultFuchsiaResourceDialect
1496                ),
1497                buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1498                fifo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1499                categories: fidl::new_empty!(
1500                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
1501                    fidl::encoding::DefaultFuchsiaResourceDialect
1502                ),
1503            }
1504        }
1505
1506        #[inline]
1507        unsafe fn decode(
1508            &mut self,
1509            decoder: &mut fidl::encoding::Decoder<
1510                '_,
1511                fidl::encoding::DefaultFuchsiaResourceDialect,
1512            >,
1513            offset: usize,
1514            _depth: fidl::encoding::Depth,
1515        ) -> fidl::Result<()> {
1516            decoder.debug_check_bounds::<Self>(offset);
1517            // Verify that padding bytes are zero.
1518            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1519            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1520            let mask = 0xffffff00u64;
1521            let maskedval = padval & mask;
1522            if maskedval != 0 {
1523                return Err(fidl::Error::NonZeroPadding {
1524                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1525                });
1526            }
1527            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
1528            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1529            let mask = 0xffffffff00000000u64;
1530            let maskedval = padval & mask;
1531            if maskedval != 0 {
1532                return Err(fidl::Error::NonZeroPadding {
1533                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
1534                });
1535            }
1536            fidl::decode!(
1537                fidl_fuchsia_tracing::BufferingMode,
1538                fidl::encoding::DefaultFuchsiaResourceDialect,
1539                &mut self.buffering_mode,
1540                decoder,
1541                offset + 0,
1542                _depth
1543            )?;
1544            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.buffer, decoder, offset + 4, _depth)?;
1545            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.fifo, decoder, offset + 8, _depth)?;
1546            fidl::decode!(
1547                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
1548                fidl::encoding::DefaultFuchsiaResourceDialect,
1549                &mut self.categories,
1550                decoder,
1551                offset + 16,
1552                _depth
1553            )?;
1554            Ok(())
1555        }
1556    }
1557
1558    impl fidl::encoding::ResourceTypeMarker for ProviderInitializeRequest {
1559        type Borrowed<'a> = &'a mut Self;
1560        fn take_or_borrow<'a>(
1561            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1562        ) -> Self::Borrowed<'a> {
1563            value
1564        }
1565    }
1566
1567    unsafe impl fidl::encoding::TypeMarker for ProviderInitializeRequest {
1568        type Owned = Self;
1569
1570        #[inline(always)]
1571        fn inline_align(_context: fidl::encoding::Context) -> usize {
1572            8
1573        }
1574
1575        #[inline(always)]
1576        fn inline_size(_context: fidl::encoding::Context) -> usize {
1577            32
1578        }
1579    }
1580
1581    unsafe impl
1582        fidl::encoding::Encode<
1583            ProviderInitializeRequest,
1584            fidl::encoding::DefaultFuchsiaResourceDialect,
1585        > for &mut ProviderInitializeRequest
1586    {
1587        #[inline]
1588        unsafe fn encode(
1589            self,
1590            encoder: &mut fidl::encoding::Encoder<
1591                '_,
1592                fidl::encoding::DefaultFuchsiaResourceDialect,
1593            >,
1594            offset: usize,
1595            _depth: fidl::encoding::Depth,
1596        ) -> fidl::Result<()> {
1597            encoder.debug_check_bounds::<ProviderInitializeRequest>(offset);
1598            // Delegate to tuple encoding.
1599            fidl::encoding::Encode::<
1600                ProviderInitializeRequest,
1601                fidl::encoding::DefaultFuchsiaResourceDialect,
1602            >::encode(
1603                (<ProviderConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1604                    &mut self.config,
1605                ),),
1606                encoder,
1607                offset,
1608                _depth,
1609            )
1610        }
1611    }
1612    unsafe impl<
1613        T0: fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
1614    >
1615        fidl::encoding::Encode<
1616            ProviderInitializeRequest,
1617            fidl::encoding::DefaultFuchsiaResourceDialect,
1618        > for (T0,)
1619    {
1620        #[inline]
1621        unsafe fn encode(
1622            self,
1623            encoder: &mut fidl::encoding::Encoder<
1624                '_,
1625                fidl::encoding::DefaultFuchsiaResourceDialect,
1626            >,
1627            offset: usize,
1628            depth: fidl::encoding::Depth,
1629        ) -> fidl::Result<()> {
1630            encoder.debug_check_bounds::<ProviderInitializeRequest>(offset);
1631            // Zero out padding regions. There's no need to apply masks
1632            // because the unmasked parts will be overwritten by fields.
1633            // Write the fields.
1634            self.0.encode(encoder, offset + 0, depth)?;
1635            Ok(())
1636        }
1637    }
1638
1639    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1640        for ProviderInitializeRequest
1641    {
1642        #[inline(always)]
1643        fn new_empty() -> Self {
1644            Self {
1645                config: fidl::new_empty!(
1646                    ProviderConfig,
1647                    fidl::encoding::DefaultFuchsiaResourceDialect
1648                ),
1649            }
1650        }
1651
1652        #[inline]
1653        unsafe fn decode(
1654            &mut self,
1655            decoder: &mut fidl::encoding::Decoder<
1656                '_,
1657                fidl::encoding::DefaultFuchsiaResourceDialect,
1658            >,
1659            offset: usize,
1660            _depth: fidl::encoding::Depth,
1661        ) -> fidl::Result<()> {
1662            decoder.debug_check_bounds::<Self>(offset);
1663            // Verify that padding bytes are zero.
1664            fidl::decode!(
1665                ProviderConfig,
1666                fidl::encoding::DefaultFuchsiaResourceDialect,
1667                &mut self.config,
1668                decoder,
1669                offset + 0,
1670                _depth
1671            )?;
1672            Ok(())
1673        }
1674    }
1675
1676    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterProviderRequest {
1677        type Borrowed<'a> = &'a mut Self;
1678        fn take_or_borrow<'a>(
1679            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1680        ) -> Self::Borrowed<'a> {
1681            value
1682        }
1683    }
1684
1685    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterProviderRequest {
1686        type Owned = Self;
1687
1688        #[inline(always)]
1689        fn inline_align(_context: fidl::encoding::Context) -> usize {
1690            8
1691        }
1692
1693        #[inline(always)]
1694        fn inline_size(_context: fidl::encoding::Context) -> usize {
1695            32
1696        }
1697    }
1698
1699    unsafe impl
1700        fidl::encoding::Encode<
1701            RegistryRegisterProviderRequest,
1702            fidl::encoding::DefaultFuchsiaResourceDialect,
1703        > for &mut RegistryRegisterProviderRequest
1704    {
1705        #[inline]
1706        unsafe fn encode(
1707            self,
1708            encoder: &mut fidl::encoding::Encoder<
1709                '_,
1710                fidl::encoding::DefaultFuchsiaResourceDialect,
1711            >,
1712            offset: usize,
1713            _depth: fidl::encoding::Depth,
1714        ) -> fidl::Result<()> {
1715            encoder.debug_check_bounds::<RegistryRegisterProviderRequest>(offset);
1716            // Delegate to tuple encoding.
1717            fidl::encoding::Encode::<RegistryRegisterProviderRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1718                (
1719                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.provider),
1720                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pid),
1721                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
1722                ),
1723                encoder, offset, _depth
1724            )
1725        }
1726    }
1727    unsafe impl<
1728        T0: fidl::encoding::Encode<
1729                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1730                fidl::encoding::DefaultFuchsiaResourceDialect,
1731            >,
1732        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
1733        T2: fidl::encoding::Encode<
1734                fidl::encoding::BoundedString<100>,
1735                fidl::encoding::DefaultFuchsiaResourceDialect,
1736            >,
1737    >
1738        fidl::encoding::Encode<
1739            RegistryRegisterProviderRequest,
1740            fidl::encoding::DefaultFuchsiaResourceDialect,
1741        > for (T0, T1, T2)
1742    {
1743        #[inline]
1744        unsafe fn encode(
1745            self,
1746            encoder: &mut fidl::encoding::Encoder<
1747                '_,
1748                fidl::encoding::DefaultFuchsiaResourceDialect,
1749            >,
1750            offset: usize,
1751            depth: fidl::encoding::Depth,
1752        ) -> fidl::Result<()> {
1753            encoder.debug_check_bounds::<RegistryRegisterProviderRequest>(offset);
1754            // Zero out padding regions. There's no need to apply masks
1755            // because the unmasked parts will be overwritten by fields.
1756            unsafe {
1757                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1758                (ptr as *mut u64).write_unaligned(0);
1759            }
1760            // Write the fields.
1761            self.0.encode(encoder, offset + 0, depth)?;
1762            self.1.encode(encoder, offset + 8, depth)?;
1763            self.2.encode(encoder, offset + 16, depth)?;
1764            Ok(())
1765        }
1766    }
1767
1768    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1769        for RegistryRegisterProviderRequest
1770    {
1771        #[inline(always)]
1772        fn new_empty() -> Self {
1773            Self {
1774                provider: fidl::new_empty!(
1775                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1776                    fidl::encoding::DefaultFuchsiaResourceDialect
1777                ),
1778                pid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
1779                name: fidl::new_empty!(
1780                    fidl::encoding::BoundedString<100>,
1781                    fidl::encoding::DefaultFuchsiaResourceDialect
1782                ),
1783            }
1784        }
1785
1786        #[inline]
1787        unsafe fn decode(
1788            &mut self,
1789            decoder: &mut fidl::encoding::Decoder<
1790                '_,
1791                fidl::encoding::DefaultFuchsiaResourceDialect,
1792            >,
1793            offset: usize,
1794            _depth: fidl::encoding::Depth,
1795        ) -> fidl::Result<()> {
1796            decoder.debug_check_bounds::<Self>(offset);
1797            // Verify that padding bytes are zero.
1798            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1799            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1800            let mask = 0xffffffff00000000u64;
1801            let maskedval = padval & mask;
1802            if maskedval != 0 {
1803                return Err(fidl::Error::NonZeroPadding {
1804                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1805                });
1806            }
1807            fidl::decode!(
1808                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1809                fidl::encoding::DefaultFuchsiaResourceDialect,
1810                &mut self.provider,
1811                decoder,
1812                offset + 0,
1813                _depth
1814            )?;
1815            fidl::decode!(
1816                u64,
1817                fidl::encoding::DefaultFuchsiaResourceDialect,
1818                &mut self.pid,
1819                decoder,
1820                offset + 8,
1821                _depth
1822            )?;
1823            fidl::decode!(
1824                fidl::encoding::BoundedString<100>,
1825                fidl::encoding::DefaultFuchsiaResourceDialect,
1826                &mut self.name,
1827                decoder,
1828                offset + 16,
1829                _depth
1830            )?;
1831            Ok(())
1832        }
1833    }
1834
1835    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterProviderSynchronouslyRequest {
1836        type Borrowed<'a> = &'a mut Self;
1837        fn take_or_borrow<'a>(
1838            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1839        ) -> Self::Borrowed<'a> {
1840            value
1841        }
1842    }
1843
1844    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterProviderSynchronouslyRequest {
1845        type Owned = Self;
1846
1847        #[inline(always)]
1848        fn inline_align(_context: fidl::encoding::Context) -> usize {
1849            8
1850        }
1851
1852        #[inline(always)]
1853        fn inline_size(_context: fidl::encoding::Context) -> usize {
1854            32
1855        }
1856    }
1857
1858    unsafe impl
1859        fidl::encoding::Encode<
1860            RegistryRegisterProviderSynchronouslyRequest,
1861            fidl::encoding::DefaultFuchsiaResourceDialect,
1862        > for &mut RegistryRegisterProviderSynchronouslyRequest
1863    {
1864        #[inline]
1865        unsafe fn encode(
1866            self,
1867            encoder: &mut fidl::encoding::Encoder<
1868                '_,
1869                fidl::encoding::DefaultFuchsiaResourceDialect,
1870            >,
1871            offset: usize,
1872            _depth: fidl::encoding::Depth,
1873        ) -> fidl::Result<()> {
1874            encoder.debug_check_bounds::<RegistryRegisterProviderSynchronouslyRequest>(offset);
1875            // Delegate to tuple encoding.
1876            fidl::encoding::Encode::<RegistryRegisterProviderSynchronouslyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1877                (
1878                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.provider),
1879                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pid),
1880                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
1881                ),
1882                encoder, offset, _depth
1883            )
1884        }
1885    }
1886    unsafe impl<
1887        T0: fidl::encoding::Encode<
1888                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1889                fidl::encoding::DefaultFuchsiaResourceDialect,
1890            >,
1891        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
1892        T2: fidl::encoding::Encode<
1893                fidl::encoding::BoundedString<100>,
1894                fidl::encoding::DefaultFuchsiaResourceDialect,
1895            >,
1896    >
1897        fidl::encoding::Encode<
1898            RegistryRegisterProviderSynchronouslyRequest,
1899            fidl::encoding::DefaultFuchsiaResourceDialect,
1900        > for (T0, T1, T2)
1901    {
1902        #[inline]
1903        unsafe fn encode(
1904            self,
1905            encoder: &mut fidl::encoding::Encoder<
1906                '_,
1907                fidl::encoding::DefaultFuchsiaResourceDialect,
1908            >,
1909            offset: usize,
1910            depth: fidl::encoding::Depth,
1911        ) -> fidl::Result<()> {
1912            encoder.debug_check_bounds::<RegistryRegisterProviderSynchronouslyRequest>(offset);
1913            // Zero out padding regions. There's no need to apply masks
1914            // because the unmasked parts will be overwritten by fields.
1915            unsafe {
1916                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1917                (ptr as *mut u64).write_unaligned(0);
1918            }
1919            // Write the fields.
1920            self.0.encode(encoder, offset + 0, depth)?;
1921            self.1.encode(encoder, offset + 8, depth)?;
1922            self.2.encode(encoder, offset + 16, depth)?;
1923            Ok(())
1924        }
1925    }
1926
1927    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1928        for RegistryRegisterProviderSynchronouslyRequest
1929    {
1930        #[inline(always)]
1931        fn new_empty() -> Self {
1932            Self {
1933                provider: fidl::new_empty!(
1934                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1935                    fidl::encoding::DefaultFuchsiaResourceDialect
1936                ),
1937                pid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
1938                name: fidl::new_empty!(
1939                    fidl::encoding::BoundedString<100>,
1940                    fidl::encoding::DefaultFuchsiaResourceDialect
1941                ),
1942            }
1943        }
1944
1945        #[inline]
1946        unsafe fn decode(
1947            &mut self,
1948            decoder: &mut fidl::encoding::Decoder<
1949                '_,
1950                fidl::encoding::DefaultFuchsiaResourceDialect,
1951            >,
1952            offset: usize,
1953            _depth: fidl::encoding::Depth,
1954        ) -> fidl::Result<()> {
1955            decoder.debug_check_bounds::<Self>(offset);
1956            // Verify that padding bytes are zero.
1957            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1958            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1959            let mask = 0xffffffff00000000u64;
1960            let maskedval = padval & mask;
1961            if maskedval != 0 {
1962                return Err(fidl::Error::NonZeroPadding {
1963                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1964                });
1965            }
1966            fidl::decode!(
1967                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
1968                fidl::encoding::DefaultFuchsiaResourceDialect,
1969                &mut self.provider,
1970                decoder,
1971                offset + 0,
1972                _depth
1973            )?;
1974            fidl::decode!(
1975                u64,
1976                fidl::encoding::DefaultFuchsiaResourceDialect,
1977                &mut self.pid,
1978                decoder,
1979                offset + 8,
1980                _depth
1981            )?;
1982            fidl::decode!(
1983                fidl::encoding::BoundedString<100>,
1984                fidl::encoding::DefaultFuchsiaResourceDialect,
1985                &mut self.name,
1986                decoder,
1987                offset + 16,
1988                _depth
1989            )?;
1990            Ok(())
1991        }
1992    }
1993}