Skip to main content

fidl_fuchsia_tracing_provider/
fidl_fuchsia_tracing_provider.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_tracing_provider__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14/// Trace provider configuration.
15#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
16pub struct ProviderConfig {
17    /// `buffering_mode` specifies what happens when the buffer fills.
18    pub buffering_mode: fidl_fuchsia_tracing::BufferingMode,
19    /// The buffer to write trace records into.
20    pub buffer: fidl::Vmo,
21    /// When the trace provider observes `ZX_FIFO_PEER_CLOSED` on `fifo`, it
22    /// must assume the trace manager has terminated abnormally (since `Stop`
23    /// was not received as usual) and stop tracing automatically, discarding
24    /// any in-flight trace data.
25    pub fifo: fidl::Fifo,
26    /// What trace categories to collect data for.
27    pub categories: Vec<String>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderConfig {}
31
32#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33pub struct ProviderInitializeRequest {
34    pub config: ProviderConfig,
35}
36
37impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderInitializeRequest {}
38
39#[derive(Debug, PartialEq)]
40pub struct ProviderV2InitializeRequest {
41    pub config: ProviderConfigV2,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
45    for ProviderV2InitializeRequest
46{
47}
48
49#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct RegistryRegisterProviderRequest {
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 RegistryRegisterProviderRequest
58{
59}
60
61#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
62pub struct RegistryRegisterProviderSynchronouslyRequest {
63    pub provider: fidl::endpoints::ClientEnd<ProviderMarker>,
64    pub pid: u64,
65    pub name: String,
66}
67
68impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
69    for RegistryRegisterProviderSynchronouslyRequest
70{
71}
72
73#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
74pub struct RegistryRegisterV2Request {
75    pub provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
76    /// The process id of the provider used for logging and diagnostics
77    pub pid: u64,
78    /// The name of the provider used for logging and diagnostics
79    pub name: String,
80}
81
82impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RegistryRegisterV2Request {}
83
84#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
85pub struct RegistryRegisterV2SynchronouslyRequest {
86    pub provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
87    /// The process id of the provider used for logging and diagnostics
88    pub pid: u64,
89    /// The name of the provider used for logging and diagnostics
90    pub name: String,
91}
92
93impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
94    for RegistryRegisterV2SynchronouslyRequest
95{
96}
97
98/// Trace provider configuration.
99#[derive(Debug, Default, PartialEq)]
100pub struct ProviderConfigV2 {
101    /// `buffering_mode` specifies what happens when the buffer fills.
102    pub buffering_mode: Option<fidl_fuchsia_tracing::BufferingMode>,
103    /// The buffer to write trace records into.
104    pub buffer: Option<fidl::Vmo>,
105    /// What trace categories to collect data for.
106    pub categories: Option<Vec<String>>,
107    #[doc(hidden)]
108    pub __source_breaking: fidl::marker::SourceBreaking,
109}
110
111impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ProviderConfigV2 {}
112
113#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
114pub struct ProviderMarker;
115
116impl fidl::endpoints::ProtocolMarker for ProviderMarker {
117    type Proxy = ProviderProxy;
118    type RequestStream = ProviderRequestStream;
119    #[cfg(target_os = "fuchsia")]
120    type SynchronousProxy = ProviderSynchronousProxy;
121
122    const DEBUG_NAME: &'static str = "(anonymous) Provider";
123}
124
125pub trait ProviderProxyInterface: Send + Sync {
126    fn r#initialize(&self, config: ProviderConfig) -> Result<(), fidl::Error>;
127    fn r#start(&self, options: &StartOptions) -> Result<(), fidl::Error>;
128    fn r#stop(&self) -> Result<(), fidl::Error>;
129    fn r#terminate(&self) -> Result<(), fidl::Error>;
130    type GetKnownCategoriesResponseFut: std::future::Future<Output = Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error>>
131        + Send;
132    fn r#get_known_categories(&self) -> Self::GetKnownCategoriesResponseFut;
133}
134#[derive(Debug)]
135#[cfg(target_os = "fuchsia")]
136pub struct ProviderSynchronousProxy {
137    client: fidl::client::sync::Client,
138}
139
140#[cfg(target_os = "fuchsia")]
141impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
142    type Proxy = ProviderProxy;
143    type Protocol = ProviderMarker;
144
145    fn from_channel(inner: fidl::Channel) -> Self {
146        Self::new(inner)
147    }
148
149    fn into_channel(self) -> fidl::Channel {
150        self.client.into_channel()
151    }
152
153    fn as_channel(&self) -> &fidl::Channel {
154        self.client.as_channel()
155    }
156}
157
158#[cfg(target_os = "fuchsia")]
159impl ProviderSynchronousProxy {
160    pub fn new(channel: fidl::Channel) -> Self {
161        Self { client: fidl::client::sync::Client::new(channel) }
162    }
163
164    pub fn into_channel(self) -> fidl::Channel {
165        self.client.into_channel()
166    }
167
168    /// Waits until an event arrives and returns it. It is safe for other
169    /// threads to make concurrent requests while waiting for an event.
170    pub fn wait_for_event(
171        &self,
172        deadline: zx::MonotonicInstant,
173    ) -> Result<ProviderEvent, fidl::Error> {
174        ProviderEvent::decode(self.client.wait_for_event::<ProviderMarker>(deadline)?)
175    }
176
177    /// Initialize tracing and prepare for writing trace records for events in
178    /// the specified `categories` into `buffer` using `fifo` for signaling.
179    /// Tracing hasn't started yet, a `Start()` call is still required.
180    ///
181    ///
182    /// At most one trace can be active at a time. Subsequent `Initialize()`
183    /// requests received prior to a `Terminate()` call must be ignored.
184    pub fn r#initialize(&self, mut config: ProviderConfig) -> Result<(), fidl::Error> {
185        self.client.send::<ProviderInitializeRequest>(
186            (&mut config,),
187            0x9e31667d7b180f7,
188            fidl::encoding::DynamicFlags::empty(),
189        )
190    }
191
192    /// Begin tracing.
193    ///
194    /// If tracing has already started the provider must ignore the request.
195    ///
196    /// There is no result. The provider must send a `TRACE_PROVIDER_STARTED`
197    /// packet on `fifo` to indicate success/failure of starting.
198    pub fn r#start(&self, mut options: &StartOptions) -> Result<(), fidl::Error> {
199        self.client.send::<ProviderStartRequest>(
200            (options,),
201            0x5bae2b60be66a815,
202            fidl::encoding::DynamicFlags::empty(),
203        )
204    }
205
206    /// Stop tracing.
207    ///
208    /// If tracing has already stopped the provider must ignore the request.
209    ///
210    /// Once the provider has finished writing any final events to the trace
211    /// buffer, it must send a `TRACE_PROVIDER_STOPPED` packet on `fifo`.
212    /// Note that multiple `Start,Stop` requests can be received between
213    /// `Initialize,Terminate`.
214    pub fn r#stop(&self) -> Result<(), fidl::Error> {
215        self.client.send::<fidl::encoding::EmptyPayload>(
216            (),
217            0x133df8ebb1897df0,
218            fidl::encoding::DynamicFlags::empty(),
219        )
220    }
221
222    /// Terminate tracing.
223    ///
224    /// Tracing is stopped first if not already stopped.
225    /// After tracing has fully terminated the provider must close both
226    /// `buffer` and `fifo` to indicate to the trace manager that tracing is
227    /// finished.
228    pub fn r#terminate(&self) -> Result<(), fidl::Error> {
229        self.client.send::<fidl::encoding::EmptyPayload>(
230            (),
231            0x6b5564032f2726b1,
232            fidl::encoding::DynamicFlags::empty(),
233        )
234    }
235
236    /// Gets the trace categories that might be produced by this provider.
237    pub fn r#get_known_categories(
238        &self,
239        ___deadline: zx::MonotonicInstant,
240    ) -> Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error> {
241        let _response = self.client.send_query::<
242            fidl::encoding::EmptyPayload,
243            ProviderGetKnownCategoriesResponse,
244            ProviderMarker,
245        >(
246            (),
247            0x5f5b0ad77af3f886,
248            fidl::encoding::DynamicFlags::empty(),
249            ___deadline,
250        )?;
251        Ok(_response.categories)
252    }
253}
254
255#[cfg(target_os = "fuchsia")]
256impl From<ProviderSynchronousProxy> for zx::NullableHandle {
257    fn from(value: ProviderSynchronousProxy) -> Self {
258        value.into_channel().into()
259    }
260}
261
262#[cfg(target_os = "fuchsia")]
263impl From<fidl::Channel> for ProviderSynchronousProxy {
264    fn from(value: fidl::Channel) -> Self {
265        Self::new(value)
266    }
267}
268
269#[cfg(target_os = "fuchsia")]
270impl fidl::endpoints::FromClient for ProviderSynchronousProxy {
271    type Protocol = ProviderMarker;
272
273    fn from_client(value: fidl::endpoints::ClientEnd<ProviderMarker>) -> Self {
274        Self::new(value.into_channel())
275    }
276}
277
278#[derive(Debug, Clone)]
279pub struct ProviderProxy {
280    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
281}
282
283impl fidl::endpoints::Proxy for ProviderProxy {
284    type Protocol = ProviderMarker;
285
286    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
287        Self::new(inner)
288    }
289
290    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
291        self.client.into_channel().map_err(|client| Self { client })
292    }
293
294    fn as_channel(&self) -> &::fidl::AsyncChannel {
295        self.client.as_channel()
296    }
297}
298
299impl ProviderProxy {
300    /// Create a new Proxy for fuchsia.tracing.provider/Provider.
301    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
302        let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
303        Self { client: fidl::client::Client::new(channel, protocol_name) }
304    }
305
306    /// Get a Stream of events from the remote end of the protocol.
307    ///
308    /// # Panics
309    ///
310    /// Panics if the event stream was already taken.
311    pub fn take_event_stream(&self) -> ProviderEventStream {
312        ProviderEventStream { event_receiver: self.client.take_event_receiver() }
313    }
314
315    /// Initialize tracing and prepare for writing trace records for events in
316    /// the specified `categories` into `buffer` using `fifo` for signaling.
317    /// Tracing hasn't started yet, a `Start()` call is still required.
318    ///
319    ///
320    /// At most one trace can be active at a time. Subsequent `Initialize()`
321    /// requests received prior to a `Terminate()` call must be ignored.
322    pub fn r#initialize(&self, mut config: ProviderConfig) -> Result<(), fidl::Error> {
323        ProviderProxyInterface::r#initialize(self, config)
324    }
325
326    /// Begin tracing.
327    ///
328    /// If tracing has already started the provider must ignore the request.
329    ///
330    /// There is no result. The provider must send a `TRACE_PROVIDER_STARTED`
331    /// packet on `fifo` to indicate success/failure of starting.
332    pub fn r#start(&self, mut options: &StartOptions) -> Result<(), fidl::Error> {
333        ProviderProxyInterface::r#start(self, options)
334    }
335
336    /// Stop tracing.
337    ///
338    /// If tracing has already stopped the provider must ignore the request.
339    ///
340    /// Once the provider has finished writing any final events to the trace
341    /// buffer, it must send a `TRACE_PROVIDER_STOPPED` packet on `fifo`.
342    /// Note that multiple `Start,Stop` requests can be received between
343    /// `Initialize,Terminate`.
344    pub fn r#stop(&self) -> Result<(), fidl::Error> {
345        ProviderProxyInterface::r#stop(self)
346    }
347
348    /// Terminate tracing.
349    ///
350    /// Tracing is stopped first if not already stopped.
351    /// After tracing has fully terminated the provider must close both
352    /// `buffer` and `fifo` to indicate to the trace manager that tracing is
353    /// finished.
354    pub fn r#terminate(&self) -> Result<(), fidl::Error> {
355        ProviderProxyInterface::r#terminate(self)
356    }
357
358    /// Gets the trace categories that might be produced by this provider.
359    pub fn r#get_known_categories(
360        &self,
361    ) -> fidl::client::QueryResponseFut<
362        Vec<fidl_fuchsia_tracing::KnownCategory>,
363        fidl::encoding::DefaultFuchsiaResourceDialect,
364    > {
365        ProviderProxyInterface::r#get_known_categories(self)
366    }
367}
368
369impl ProviderProxyInterface for ProviderProxy {
370    fn r#initialize(&self, mut config: ProviderConfig) -> Result<(), fidl::Error> {
371        self.client.send::<ProviderInitializeRequest>(
372            (&mut config,),
373            0x9e31667d7b180f7,
374            fidl::encoding::DynamicFlags::empty(),
375        )
376    }
377
378    fn r#start(&self, mut options: &StartOptions) -> Result<(), fidl::Error> {
379        self.client.send::<ProviderStartRequest>(
380            (options,),
381            0x5bae2b60be66a815,
382            fidl::encoding::DynamicFlags::empty(),
383        )
384    }
385
386    fn r#stop(&self) -> Result<(), fidl::Error> {
387        self.client.send::<fidl::encoding::EmptyPayload>(
388            (),
389            0x133df8ebb1897df0,
390            fidl::encoding::DynamicFlags::empty(),
391        )
392    }
393
394    fn r#terminate(&self) -> Result<(), fidl::Error> {
395        self.client.send::<fidl::encoding::EmptyPayload>(
396            (),
397            0x6b5564032f2726b1,
398            fidl::encoding::DynamicFlags::empty(),
399        )
400    }
401
402    type GetKnownCategoriesResponseFut = fidl::client::QueryResponseFut<
403        Vec<fidl_fuchsia_tracing::KnownCategory>,
404        fidl::encoding::DefaultFuchsiaResourceDialect,
405    >;
406    fn r#get_known_categories(&self) -> Self::GetKnownCategoriesResponseFut {
407        fn _decode(
408            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
409        ) -> Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error> {
410            let _response = fidl::client::decode_transaction_body::<
411                ProviderGetKnownCategoriesResponse,
412                fidl::encoding::DefaultFuchsiaResourceDialect,
413                0x5f5b0ad77af3f886,
414            >(_buf?)?;
415            Ok(_response.categories)
416        }
417        self.client.send_query_and_decode::<
418            fidl::encoding::EmptyPayload,
419            Vec<fidl_fuchsia_tracing::KnownCategory>,
420        >(
421            (),
422            0x5f5b0ad77af3f886,
423            fidl::encoding::DynamicFlags::empty(),
424            _decode,
425        )
426    }
427}
428
429pub struct ProviderEventStream {
430    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
431}
432
433impl std::marker::Unpin for ProviderEventStream {}
434
435impl futures::stream::FusedStream for ProviderEventStream {
436    fn is_terminated(&self) -> bool {
437        self.event_receiver.is_terminated()
438    }
439}
440
441impl futures::Stream for ProviderEventStream {
442    type Item = Result<ProviderEvent, fidl::Error>;
443
444    fn poll_next(
445        mut self: std::pin::Pin<&mut Self>,
446        cx: &mut std::task::Context<'_>,
447    ) -> std::task::Poll<Option<Self::Item>> {
448        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
449            &mut self.event_receiver,
450            cx
451        )?) {
452            Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
453            None => std::task::Poll::Ready(None),
454        }
455    }
456}
457
458#[derive(Debug)]
459pub enum ProviderEvent {}
460
461impl ProviderEvent {
462    /// Decodes a message buffer as a [`ProviderEvent`].
463    fn decode(
464        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
465    ) -> Result<ProviderEvent, fidl::Error> {
466        let (bytes, _handles) = buf.split_mut();
467        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
468        debug_assert_eq!(tx_header.tx_id, 0);
469        match tx_header.ordinal {
470            _ => Err(fidl::Error::UnknownOrdinal {
471                ordinal: tx_header.ordinal,
472                protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
473            }),
474        }
475    }
476}
477
478/// A Stream of incoming requests for fuchsia.tracing.provider/Provider.
479pub struct ProviderRequestStream {
480    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
481    is_terminated: bool,
482}
483
484impl std::marker::Unpin for ProviderRequestStream {}
485
486impl futures::stream::FusedStream for ProviderRequestStream {
487    fn is_terminated(&self) -> bool {
488        self.is_terminated
489    }
490}
491
492impl fidl::endpoints::RequestStream for ProviderRequestStream {
493    type Protocol = ProviderMarker;
494    type ControlHandle = ProviderControlHandle;
495
496    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
497        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
498    }
499
500    fn control_handle(&self) -> Self::ControlHandle {
501        ProviderControlHandle { inner: self.inner.clone() }
502    }
503
504    fn into_inner(
505        self,
506    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
507    {
508        (self.inner, self.is_terminated)
509    }
510
511    fn from_inner(
512        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
513        is_terminated: bool,
514    ) -> Self {
515        Self { inner, is_terminated }
516    }
517}
518
519impl futures::Stream for ProviderRequestStream {
520    type Item = Result<ProviderRequest, fidl::Error>;
521
522    fn poll_next(
523        mut self: std::pin::Pin<&mut Self>,
524        cx: &mut std::task::Context<'_>,
525    ) -> std::task::Poll<Option<Self::Item>> {
526        let this = &mut *self;
527        if this.inner.check_shutdown(cx) {
528            this.is_terminated = true;
529            return std::task::Poll::Ready(None);
530        }
531        if this.is_terminated {
532            panic!("polled ProviderRequestStream after completion");
533        }
534        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
535            |bytes, handles| {
536                match this.inner.channel().read_etc(cx, bytes, handles) {
537                    std::task::Poll::Ready(Ok(())) => {}
538                    std::task::Poll::Pending => return std::task::Poll::Pending,
539                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
540                        this.is_terminated = true;
541                        return std::task::Poll::Ready(None);
542                    }
543                    std::task::Poll::Ready(Err(e)) => {
544                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
545                            e.into(),
546                        ))));
547                    }
548                }
549
550                // A message has been received from the channel
551                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
552
553                std::task::Poll::Ready(Some(match header.ordinal {
554                    0x9e31667d7b180f7 => {
555                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
556                        let mut req = fidl::new_empty!(
557                            ProviderInitializeRequest,
558                            fidl::encoding::DefaultFuchsiaResourceDialect
559                        );
560                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderInitializeRequest>(&header, _body_bytes, handles, &mut req)?;
561                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
562                        Ok(ProviderRequest::Initialize { config: req.config, control_handle })
563                    }
564                    0x5bae2b60be66a815 => {
565                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
566                        let mut req = fidl::new_empty!(
567                            ProviderStartRequest,
568                            fidl::encoding::DefaultFuchsiaResourceDialect
569                        );
570                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderStartRequest>(&header, _body_bytes, handles, &mut req)?;
571                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
572                        Ok(ProviderRequest::Start { options: req.options, control_handle })
573                    }
574                    0x133df8ebb1897df0 => {
575                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
576                        let mut req = fidl::new_empty!(
577                            fidl::encoding::EmptyPayload,
578                            fidl::encoding::DefaultFuchsiaResourceDialect
579                        );
580                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
581                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
582                        Ok(ProviderRequest::Stop { control_handle })
583                    }
584                    0x6b5564032f2726b1 => {
585                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
586                        let mut req = fidl::new_empty!(
587                            fidl::encoding::EmptyPayload,
588                            fidl::encoding::DefaultFuchsiaResourceDialect
589                        );
590                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
591                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
592                        Ok(ProviderRequest::Terminate { control_handle })
593                    }
594                    0x5f5b0ad77af3f886 => {
595                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
596                        let mut req = fidl::new_empty!(
597                            fidl::encoding::EmptyPayload,
598                            fidl::encoding::DefaultFuchsiaResourceDialect
599                        );
600                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
601                        let control_handle = ProviderControlHandle { inner: this.inner.clone() };
602                        Ok(ProviderRequest::GetKnownCategories {
603                            responder: ProviderGetKnownCategoriesResponder {
604                                control_handle: std::mem::ManuallyDrop::new(control_handle),
605                                tx_id: header.tx_id,
606                            },
607                        })
608                    }
609                    _ => Err(fidl::Error::UnknownOrdinal {
610                        ordinal: header.ordinal,
611                        protocol_name:
612                            <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
613                    }),
614                }))
615            },
616        )
617    }
618}
619
620/// The provider interface which applications must implement and register
621/// with the `TraceRegistry` to participate in tracing.
622///
623/// See //zircon/system/ulib/trace-provider/ for a C++ implementation of
624/// this interface which can easily be configured by an application.
625#[derive(Debug)]
626pub enum ProviderRequest {
627    /// Initialize tracing and prepare for writing trace records for events in
628    /// the specified `categories` into `buffer` using `fifo` for signaling.
629    /// Tracing hasn't started yet, a `Start()` call is still required.
630    ///
631    ///
632    /// At most one trace can be active at a time. Subsequent `Initialize()`
633    /// requests received prior to a `Terminate()` call must be ignored.
634    Initialize { config: ProviderConfig, control_handle: ProviderControlHandle },
635    /// Begin tracing.
636    ///
637    /// If tracing has already started the provider must ignore the request.
638    ///
639    /// There is no result. The provider must send a `TRACE_PROVIDER_STARTED`
640    /// packet on `fifo` to indicate success/failure of starting.
641    Start { options: StartOptions, control_handle: ProviderControlHandle },
642    /// Stop tracing.
643    ///
644    /// If tracing has already stopped the provider must ignore the request.
645    ///
646    /// Once the provider has finished writing any final events to the trace
647    /// buffer, it must send a `TRACE_PROVIDER_STOPPED` packet on `fifo`.
648    /// Note that multiple `Start,Stop` requests can be received between
649    /// `Initialize,Terminate`.
650    Stop { control_handle: ProviderControlHandle },
651    /// Terminate tracing.
652    ///
653    /// Tracing is stopped first if not already stopped.
654    /// After tracing has fully terminated the provider must close both
655    /// `buffer` and `fifo` to indicate to the trace manager that tracing is
656    /// finished.
657    Terminate { control_handle: ProviderControlHandle },
658    /// Gets the trace categories that might be produced by this provider.
659    GetKnownCategories { responder: ProviderGetKnownCategoriesResponder },
660}
661
662impl ProviderRequest {
663    #[allow(irrefutable_let_patterns)]
664    pub fn into_initialize(self) -> Option<(ProviderConfig, ProviderControlHandle)> {
665        if let ProviderRequest::Initialize { config, control_handle } = self {
666            Some((config, control_handle))
667        } else {
668            None
669        }
670    }
671
672    #[allow(irrefutable_let_patterns)]
673    pub fn into_start(self) -> Option<(StartOptions, ProviderControlHandle)> {
674        if let ProviderRequest::Start { options, control_handle } = self {
675            Some((options, control_handle))
676        } else {
677            None
678        }
679    }
680
681    #[allow(irrefutable_let_patterns)]
682    pub fn into_stop(self) -> Option<(ProviderControlHandle)> {
683        if let ProviderRequest::Stop { control_handle } = self {
684            Some((control_handle))
685        } else {
686            None
687        }
688    }
689
690    #[allow(irrefutable_let_patterns)]
691    pub fn into_terminate(self) -> Option<(ProviderControlHandle)> {
692        if let ProviderRequest::Terminate { control_handle } = self {
693            Some((control_handle))
694        } else {
695            None
696        }
697    }
698
699    #[allow(irrefutable_let_patterns)]
700    pub fn into_get_known_categories(self) -> Option<(ProviderGetKnownCategoriesResponder)> {
701        if let ProviderRequest::GetKnownCategories { responder } = self {
702            Some((responder))
703        } else {
704            None
705        }
706    }
707
708    /// Name of the method defined in FIDL
709    pub fn method_name(&self) -> &'static str {
710        match *self {
711            ProviderRequest::Initialize { .. } => "initialize",
712            ProviderRequest::Start { .. } => "start",
713            ProviderRequest::Stop { .. } => "stop",
714            ProviderRequest::Terminate { .. } => "terminate",
715            ProviderRequest::GetKnownCategories { .. } => "get_known_categories",
716        }
717    }
718}
719
720#[derive(Debug, Clone)]
721pub struct ProviderControlHandle {
722    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
723}
724
725impl fidl::endpoints::ControlHandle for ProviderControlHandle {
726    fn shutdown(&self) {
727        self.inner.shutdown()
728    }
729
730    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
731        self.inner.shutdown_with_epitaph(status)
732    }
733
734    fn is_closed(&self) -> bool {
735        self.inner.channel().is_closed()
736    }
737    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
738        self.inner.channel().on_closed()
739    }
740
741    #[cfg(target_os = "fuchsia")]
742    fn signal_peer(
743        &self,
744        clear_mask: zx::Signals,
745        set_mask: zx::Signals,
746    ) -> Result<(), zx_status::Status> {
747        use fidl::Peered;
748        self.inner.channel().signal_peer(clear_mask, set_mask)
749    }
750}
751
752impl ProviderControlHandle {}
753
754#[must_use = "FIDL methods require a response to be sent"]
755#[derive(Debug)]
756pub struct ProviderGetKnownCategoriesResponder {
757    control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
758    tx_id: u32,
759}
760
761/// Set the the channel to be shutdown (see [`ProviderControlHandle::shutdown`])
762/// if the responder is dropped without sending a response, so that the client
763/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
764impl std::ops::Drop for ProviderGetKnownCategoriesResponder {
765    fn drop(&mut self) {
766        self.control_handle.shutdown();
767        // Safety: drops once, never accessed again
768        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
769    }
770}
771
772impl fidl::endpoints::Responder for ProviderGetKnownCategoriesResponder {
773    type ControlHandle = ProviderControlHandle;
774
775    fn control_handle(&self) -> &ProviderControlHandle {
776        &self.control_handle
777    }
778
779    fn drop_without_shutdown(mut self) {
780        // Safety: drops once, never accessed again due to mem::forget
781        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
782        // Prevent Drop from running (which would shut down the channel)
783        std::mem::forget(self);
784    }
785}
786
787impl ProviderGetKnownCategoriesResponder {
788    /// Sends a response to the FIDL transaction.
789    ///
790    /// Sets the channel to shutdown if an error occurs.
791    pub fn send(
792        self,
793        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
794    ) -> Result<(), fidl::Error> {
795        let _result = self.send_raw(categories);
796        if _result.is_err() {
797            self.control_handle.shutdown();
798        }
799        self.drop_without_shutdown();
800        _result
801    }
802
803    /// Similar to "send" but does not shutdown the channel if an error occurs.
804    pub fn send_no_shutdown_on_err(
805        self,
806        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
807    ) -> Result<(), fidl::Error> {
808        let _result = self.send_raw(categories);
809        self.drop_without_shutdown();
810        _result
811    }
812
813    fn send_raw(
814        &self,
815        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
816    ) -> Result<(), fidl::Error> {
817        self.control_handle.inner.send::<ProviderGetKnownCategoriesResponse>(
818            (categories,),
819            self.tx_id,
820            0x5f5b0ad77af3f886,
821            fidl::encoding::DynamicFlags::empty(),
822        )
823    }
824}
825
826#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
827pub struct ProviderV2Marker;
828
829impl fidl::endpoints::ProtocolMarker for ProviderV2Marker {
830    type Proxy = ProviderV2Proxy;
831    type RequestStream = ProviderV2RequestStream;
832    #[cfg(target_os = "fuchsia")]
833    type SynchronousProxy = ProviderV2SynchronousProxy;
834
835    const DEBUG_NAME: &'static str = "(anonymous) ProviderV2";
836}
837
838pub trait ProviderV2ProxyInterface: Send + Sync {
839    fn r#initialize(&self, config: ProviderConfigV2) -> Result<(), fidl::Error>;
840    type StartResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
841    fn r#start(&self, options: &StartOptions) -> Self::StartResponseFut;
842    type StopResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
843    fn r#stop(&self) -> Self::StopResponseFut;
844    type TerminateResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
845    fn r#terminate(&self) -> Self::TerminateResponseFut;
846    type GetKnownCategoriesResponseFut: std::future::Future<Output = Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error>>
847        + Send;
848    fn r#get_known_categories(&self) -> Self::GetKnownCategoriesResponseFut;
849    fn r#notify_buffer_saved(
850        &self,
851        wrapped_count: u32,
852        durable_data_end: u64,
853    ) -> Result<(), fidl::Error>;
854    fn r#flush(&self) -> Result<(), fidl::Error>;
855}
856#[derive(Debug)]
857#[cfg(target_os = "fuchsia")]
858pub struct ProviderV2SynchronousProxy {
859    client: fidl::client::sync::Client,
860}
861
862#[cfg(target_os = "fuchsia")]
863impl fidl::endpoints::SynchronousProxy for ProviderV2SynchronousProxy {
864    type Proxy = ProviderV2Proxy;
865    type Protocol = ProviderV2Marker;
866
867    fn from_channel(inner: fidl::Channel) -> Self {
868        Self::new(inner)
869    }
870
871    fn into_channel(self) -> fidl::Channel {
872        self.client.into_channel()
873    }
874
875    fn as_channel(&self) -> &fidl::Channel {
876        self.client.as_channel()
877    }
878}
879
880#[cfg(target_os = "fuchsia")]
881impl ProviderV2SynchronousProxy {
882    pub fn new(channel: fidl::Channel) -> Self {
883        Self { client: fidl::client::sync::Client::new(channel) }
884    }
885
886    pub fn into_channel(self) -> fidl::Channel {
887        self.client.into_channel()
888    }
889
890    /// Waits until an event arrives and returns it. It is safe for other
891    /// threads to make concurrent requests while waiting for an event.
892    pub fn wait_for_event(
893        &self,
894        deadline: zx::MonotonicInstant,
895    ) -> Result<ProviderV2Event, fidl::Error> {
896        ProviderV2Event::decode(self.client.wait_for_event::<ProviderV2Marker>(deadline)?)
897    }
898
899    /// Initialize tracing and prepare for writing trace records for events in
900    /// the specified `categories` into `buffer`.
901    /// Tracing hasn't started yet, a `Start()` call is still required.
902    ///
903    ///
904    /// At most one trace can be active at a time. Subsequent `Initialize()`
905    /// requests received prior to a `Terminate()` call must be ignored.
906    pub fn r#initialize(&self, mut config: ProviderConfigV2) -> Result<(), fidl::Error> {
907        self.client.send::<ProviderV2InitializeRequest>(
908            (&mut config,),
909            0x5402006f01edb9d1,
910            fidl::encoding::DynamicFlags::FLEXIBLE,
911        )
912    }
913
914    /// Begin tracing.
915    ///
916    /// If tracing has already started the provider must ignore the request.
917    pub fn r#start(
918        &self,
919        mut options: &StartOptions,
920        ___deadline: zx::MonotonicInstant,
921    ) -> Result<(), fidl::Error> {
922        let _response = self.client.send_query::<
923            ProviderV2StartRequest,
924            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
925            ProviderV2Marker,
926        >(
927            (options,),
928            0x71f85bc863e60f17,
929            fidl::encoding::DynamicFlags::FLEXIBLE,
930            ___deadline,
931        )?
932        .into_result::<ProviderV2Marker>("start")?;
933        Ok(_response)
934    }
935
936    /// Stop tracing.
937    ///
938    /// If tracing has already stopped the provider must ignore the request.
939    ///
940    /// Once the provider has finished writing any final events to the trace
941    /// buffer, it must send an `OnStopped()` event.
942    /// Note that multiple `Start,Stop` requests can be received between
943    /// `Initialize,Terminate`.
944    pub fn r#stop(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
945        let _response = self.client.send_query::<
946            fidl::encoding::EmptyPayload,
947            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
948            ProviderV2Marker,
949        >(
950            (),
951            0x16df330a02562aa2,
952            fidl::encoding::DynamicFlags::FLEXIBLE,
953            ___deadline,
954        )?
955        .into_result::<ProviderV2Marker>("stop")?;
956        Ok(_response)
957    }
958
959    /// Terminate tracing.
960    ///
961    /// Tracing is stopped first if not already stopped.
962    pub fn r#terminate(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
963        let _response = self.client.send_query::<
964            fidl::encoding::EmptyPayload,
965            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
966            ProviderV2Marker,
967        >(
968            (),
969            0x12a542af1614219f,
970            fidl::encoding::DynamicFlags::FLEXIBLE,
971            ___deadline,
972        )?
973        .into_result::<ProviderV2Marker>("terminate")?;
974        Ok(_response)
975    }
976
977    /// Gets the trace categories that might be produced by this provider.
978    pub fn r#get_known_categories(
979        &self,
980        ___deadline: zx::MonotonicInstant,
981    ) -> Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error> {
982        let _response = self.client.send_query::<
983            fidl::encoding::EmptyPayload,
984            fidl::encoding::FlexibleType<ProviderV2GetKnownCategoriesResponse>,
985            ProviderV2Marker,
986        >(
987            (),
988            0x24780beab3613747,
989            fidl::encoding::DynamicFlags::FLEXIBLE,
990            ___deadline,
991        )?
992        .into_result::<ProviderV2Marker>("get_known_categories")?;
993        Ok(_response.categories)
994    }
995
996    /// A buffer has been saved (streaming mode only).
997    pub fn r#notify_buffer_saved(
998        &self,
999        mut wrapped_count: u32,
1000        mut durable_data_end: u64,
1001    ) -> Result<(), fidl::Error> {
1002        self.client.send::<ProviderV2NotifyBufferSavedRequest>(
1003            (wrapped_count, durable_data_end),
1004            0x6a0a63b2e2d0dfe1,
1005            fidl::encoding::DynamicFlags::FLEXIBLE,
1006        )
1007    }
1008
1009    /// Requests the provider its buffer to be read out, regardless of it is
1010    /// full or not.
1011    ///
1012    /// Normally streaming mode only sends data once it has enough data to
1013    /// require a buffer swap and data flush. This produces fewer, but larger
1014    /// and bursty data transfers.
1015    ///
1016    /// Some clients may want more regular smaller data transfers. These clients
1017    /// may instead manually invoke Flush whenever they are ready for
1018    /// data.
1019    pub fn r#flush(&self) -> Result<(), fidl::Error> {
1020        self.client.send::<fidl::encoding::EmptyPayload>(
1021            (),
1022            0x635c3e76e1de8d29,
1023            fidl::encoding::DynamicFlags::FLEXIBLE,
1024        )
1025    }
1026}
1027
1028#[cfg(target_os = "fuchsia")]
1029impl From<ProviderV2SynchronousProxy> for zx::NullableHandle {
1030    fn from(value: ProviderV2SynchronousProxy) -> Self {
1031        value.into_channel().into()
1032    }
1033}
1034
1035#[cfg(target_os = "fuchsia")]
1036impl From<fidl::Channel> for ProviderV2SynchronousProxy {
1037    fn from(value: fidl::Channel) -> Self {
1038        Self::new(value)
1039    }
1040}
1041
1042#[cfg(target_os = "fuchsia")]
1043impl fidl::endpoints::FromClient for ProviderV2SynchronousProxy {
1044    type Protocol = ProviderV2Marker;
1045
1046    fn from_client(value: fidl::endpoints::ClientEnd<ProviderV2Marker>) -> Self {
1047        Self::new(value.into_channel())
1048    }
1049}
1050
1051#[derive(Debug, Clone)]
1052pub struct ProviderV2Proxy {
1053    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1054}
1055
1056impl fidl::endpoints::Proxy for ProviderV2Proxy {
1057    type Protocol = ProviderV2Marker;
1058
1059    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1060        Self::new(inner)
1061    }
1062
1063    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1064        self.client.into_channel().map_err(|client| Self { client })
1065    }
1066
1067    fn as_channel(&self) -> &::fidl::AsyncChannel {
1068        self.client.as_channel()
1069    }
1070}
1071
1072impl ProviderV2Proxy {
1073    /// Create a new Proxy for fuchsia.tracing.provider/ProviderV2.
1074    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1075        let protocol_name = <ProviderV2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1076        Self { client: fidl::client::Client::new(channel, protocol_name) }
1077    }
1078
1079    /// Get a Stream of events from the remote end of the protocol.
1080    ///
1081    /// # Panics
1082    ///
1083    /// Panics if the event stream was already taken.
1084    pub fn take_event_stream(&self) -> ProviderV2EventStream {
1085        ProviderV2EventStream { event_receiver: self.client.take_event_receiver() }
1086    }
1087
1088    /// Initialize tracing and prepare for writing trace records for events in
1089    /// the specified `categories` into `buffer`.
1090    /// Tracing hasn't started yet, a `Start()` call is still required.
1091    ///
1092    ///
1093    /// At most one trace can be active at a time. Subsequent `Initialize()`
1094    /// requests received prior to a `Terminate()` call must be ignored.
1095    pub fn r#initialize(&self, mut config: ProviderConfigV2) -> Result<(), fidl::Error> {
1096        ProviderV2ProxyInterface::r#initialize(self, config)
1097    }
1098
1099    /// Begin tracing.
1100    ///
1101    /// If tracing has already started the provider must ignore the request.
1102    pub fn r#start(
1103        &self,
1104        mut options: &StartOptions,
1105    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1106        ProviderV2ProxyInterface::r#start(self, options)
1107    }
1108
1109    /// Stop tracing.
1110    ///
1111    /// If tracing has already stopped the provider must ignore the request.
1112    ///
1113    /// Once the provider has finished writing any final events to the trace
1114    /// buffer, it must send an `OnStopped()` event.
1115    /// Note that multiple `Start,Stop` requests can be received between
1116    /// `Initialize,Terminate`.
1117    pub fn r#stop(
1118        &self,
1119    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1120        ProviderV2ProxyInterface::r#stop(self)
1121    }
1122
1123    /// Terminate tracing.
1124    ///
1125    /// Tracing is stopped first if not already stopped.
1126    pub fn r#terminate(
1127        &self,
1128    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1129        ProviderV2ProxyInterface::r#terminate(self)
1130    }
1131
1132    /// Gets the trace categories that might be produced by this provider.
1133    pub fn r#get_known_categories(
1134        &self,
1135    ) -> fidl::client::QueryResponseFut<
1136        Vec<fidl_fuchsia_tracing::KnownCategory>,
1137        fidl::encoding::DefaultFuchsiaResourceDialect,
1138    > {
1139        ProviderV2ProxyInterface::r#get_known_categories(self)
1140    }
1141
1142    /// A buffer has been saved (streaming mode only).
1143    pub fn r#notify_buffer_saved(
1144        &self,
1145        mut wrapped_count: u32,
1146        mut durable_data_end: u64,
1147    ) -> Result<(), fidl::Error> {
1148        ProviderV2ProxyInterface::r#notify_buffer_saved(self, wrapped_count, durable_data_end)
1149    }
1150
1151    /// Requests the provider its buffer to be read out, regardless of it is
1152    /// full or not.
1153    ///
1154    /// Normally streaming mode only sends data once it has enough data to
1155    /// require a buffer swap and data flush. This produces fewer, but larger
1156    /// and bursty data transfers.
1157    ///
1158    /// Some clients may want more regular smaller data transfers. These clients
1159    /// may instead manually invoke Flush whenever they are ready for
1160    /// data.
1161    pub fn r#flush(&self) -> Result<(), fidl::Error> {
1162        ProviderV2ProxyInterface::r#flush(self)
1163    }
1164}
1165
1166impl ProviderV2ProxyInterface for ProviderV2Proxy {
1167    fn r#initialize(&self, mut config: ProviderConfigV2) -> Result<(), fidl::Error> {
1168        self.client.send::<ProviderV2InitializeRequest>(
1169            (&mut config,),
1170            0x5402006f01edb9d1,
1171            fidl::encoding::DynamicFlags::FLEXIBLE,
1172        )
1173    }
1174
1175    type StartResponseFut =
1176        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1177    fn r#start(&self, mut options: &StartOptions) -> Self::StartResponseFut {
1178        fn _decode(
1179            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1180        ) -> Result<(), fidl::Error> {
1181            let _response = fidl::client::decode_transaction_body::<
1182                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1183                fidl::encoding::DefaultFuchsiaResourceDialect,
1184                0x71f85bc863e60f17,
1185            >(_buf?)?
1186            .into_result::<ProviderV2Marker>("start")?;
1187            Ok(_response)
1188        }
1189        self.client.send_query_and_decode::<ProviderV2StartRequest, ()>(
1190            (options,),
1191            0x71f85bc863e60f17,
1192            fidl::encoding::DynamicFlags::FLEXIBLE,
1193            _decode,
1194        )
1195    }
1196
1197    type StopResponseFut =
1198        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1199    fn r#stop(&self) -> Self::StopResponseFut {
1200        fn _decode(
1201            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1202        ) -> Result<(), fidl::Error> {
1203            let _response = fidl::client::decode_transaction_body::<
1204                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1205                fidl::encoding::DefaultFuchsiaResourceDialect,
1206                0x16df330a02562aa2,
1207            >(_buf?)?
1208            .into_result::<ProviderV2Marker>("stop")?;
1209            Ok(_response)
1210        }
1211        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1212            (),
1213            0x16df330a02562aa2,
1214            fidl::encoding::DynamicFlags::FLEXIBLE,
1215            _decode,
1216        )
1217    }
1218
1219    type TerminateResponseFut =
1220        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1221    fn r#terminate(&self) -> Self::TerminateResponseFut {
1222        fn _decode(
1223            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1224        ) -> Result<(), fidl::Error> {
1225            let _response = fidl::client::decode_transaction_body::<
1226                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1227                fidl::encoding::DefaultFuchsiaResourceDialect,
1228                0x12a542af1614219f,
1229            >(_buf?)?
1230            .into_result::<ProviderV2Marker>("terminate")?;
1231            Ok(_response)
1232        }
1233        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1234            (),
1235            0x12a542af1614219f,
1236            fidl::encoding::DynamicFlags::FLEXIBLE,
1237            _decode,
1238        )
1239    }
1240
1241    type GetKnownCategoriesResponseFut = fidl::client::QueryResponseFut<
1242        Vec<fidl_fuchsia_tracing::KnownCategory>,
1243        fidl::encoding::DefaultFuchsiaResourceDialect,
1244    >;
1245    fn r#get_known_categories(&self) -> Self::GetKnownCategoriesResponseFut {
1246        fn _decode(
1247            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1248        ) -> Result<Vec<fidl_fuchsia_tracing::KnownCategory>, fidl::Error> {
1249            let _response = fidl::client::decode_transaction_body::<
1250                fidl::encoding::FlexibleType<ProviderV2GetKnownCategoriesResponse>,
1251                fidl::encoding::DefaultFuchsiaResourceDialect,
1252                0x24780beab3613747,
1253            >(_buf?)?
1254            .into_result::<ProviderV2Marker>("get_known_categories")?;
1255            Ok(_response.categories)
1256        }
1257        self.client.send_query_and_decode::<
1258            fidl::encoding::EmptyPayload,
1259            Vec<fidl_fuchsia_tracing::KnownCategory>,
1260        >(
1261            (),
1262            0x24780beab3613747,
1263            fidl::encoding::DynamicFlags::FLEXIBLE,
1264            _decode,
1265        )
1266    }
1267
1268    fn r#notify_buffer_saved(
1269        &self,
1270        mut wrapped_count: u32,
1271        mut durable_data_end: u64,
1272    ) -> Result<(), fidl::Error> {
1273        self.client.send::<ProviderV2NotifyBufferSavedRequest>(
1274            (wrapped_count, durable_data_end),
1275            0x6a0a63b2e2d0dfe1,
1276            fidl::encoding::DynamicFlags::FLEXIBLE,
1277        )
1278    }
1279
1280    fn r#flush(&self) -> Result<(), fidl::Error> {
1281        self.client.send::<fidl::encoding::EmptyPayload>(
1282            (),
1283            0x635c3e76e1de8d29,
1284            fidl::encoding::DynamicFlags::FLEXIBLE,
1285        )
1286    }
1287}
1288
1289pub struct ProviderV2EventStream {
1290    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1291}
1292
1293impl std::marker::Unpin for ProviderV2EventStream {}
1294
1295impl futures::stream::FusedStream for ProviderV2EventStream {
1296    fn is_terminated(&self) -> bool {
1297        self.event_receiver.is_terminated()
1298    }
1299}
1300
1301impl futures::Stream for ProviderV2EventStream {
1302    type Item = Result<ProviderV2Event, fidl::Error>;
1303
1304    fn poll_next(
1305        mut self: std::pin::Pin<&mut Self>,
1306        cx: &mut std::task::Context<'_>,
1307    ) -> std::task::Poll<Option<Self::Item>> {
1308        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1309            &mut self.event_receiver,
1310            cx
1311        )?) {
1312            Some(buf) => std::task::Poll::Ready(Some(ProviderV2Event::decode(buf))),
1313            None => std::task::Poll::Ready(None),
1314        }
1315    }
1316}
1317
1318#[derive(Debug)]
1319pub enum ProviderV2Event {
1320    OnSaveBuffer {
1321        wrapped_count: u32,
1322        durable_data_end: u64,
1323    },
1324    OnAlert {
1325        name: String,
1326    },
1327    #[non_exhaustive]
1328    _UnknownEvent {
1329        /// Ordinal of the event that was sent.
1330        ordinal: u64,
1331    },
1332}
1333
1334impl ProviderV2Event {
1335    #[allow(irrefutable_let_patterns)]
1336    pub fn into_on_save_buffer(self) -> Option<(u32, u64)> {
1337        if let ProviderV2Event::OnSaveBuffer { wrapped_count, durable_data_end } = self {
1338            Some((wrapped_count, durable_data_end))
1339        } else {
1340            None
1341        }
1342    }
1343    #[allow(irrefutable_let_patterns)]
1344    pub fn into_on_alert(self) -> Option<String> {
1345        if let ProviderV2Event::OnAlert { name } = self { Some((name)) } else { None }
1346    }
1347
1348    /// Decodes a message buffer as a [`ProviderV2Event`].
1349    fn decode(
1350        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1351    ) -> Result<ProviderV2Event, fidl::Error> {
1352        let (bytes, _handles) = buf.split_mut();
1353        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1354        debug_assert_eq!(tx_header.tx_id, 0);
1355        match tx_header.ordinal {
1356            0x7d7c8f770a3c760d => {
1357                let mut out = fidl::new_empty!(
1358                    ProviderV2OnSaveBufferRequest,
1359                    fidl::encoding::DefaultFuchsiaResourceDialect
1360                );
1361                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderV2OnSaveBufferRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1362                Ok((ProviderV2Event::OnSaveBuffer {
1363                    wrapped_count: out.wrapped_count,
1364                    durable_data_end: out.durable_data_end,
1365                }))
1366            }
1367            0x23ecc93ef5106a2 => {
1368                let mut out = fidl::new_empty!(
1369                    ProviderV2OnAlertRequest,
1370                    fidl::encoding::DefaultFuchsiaResourceDialect
1371                );
1372                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderV2OnAlertRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1373                Ok((ProviderV2Event::OnAlert { name: out.name }))
1374            }
1375            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1376                Ok(ProviderV2Event::_UnknownEvent { ordinal: tx_header.ordinal })
1377            }
1378            _ => Err(fidl::Error::UnknownOrdinal {
1379                ordinal: tx_header.ordinal,
1380                protocol_name: <ProviderV2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1381            }),
1382        }
1383    }
1384}
1385
1386/// A Stream of incoming requests for fuchsia.tracing.provider/ProviderV2.
1387pub struct ProviderV2RequestStream {
1388    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1389    is_terminated: bool,
1390}
1391
1392impl std::marker::Unpin for ProviderV2RequestStream {}
1393
1394impl futures::stream::FusedStream for ProviderV2RequestStream {
1395    fn is_terminated(&self) -> bool {
1396        self.is_terminated
1397    }
1398}
1399
1400impl fidl::endpoints::RequestStream for ProviderV2RequestStream {
1401    type Protocol = ProviderV2Marker;
1402    type ControlHandle = ProviderV2ControlHandle;
1403
1404    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1405        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1406    }
1407
1408    fn control_handle(&self) -> Self::ControlHandle {
1409        ProviderV2ControlHandle { inner: self.inner.clone() }
1410    }
1411
1412    fn into_inner(
1413        self,
1414    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1415    {
1416        (self.inner, self.is_terminated)
1417    }
1418
1419    fn from_inner(
1420        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1421        is_terminated: bool,
1422    ) -> Self {
1423        Self { inner, is_terminated }
1424    }
1425}
1426
1427impl futures::Stream for ProviderV2RequestStream {
1428    type Item = Result<ProviderV2Request, fidl::Error>;
1429
1430    fn poll_next(
1431        mut self: std::pin::Pin<&mut Self>,
1432        cx: &mut std::task::Context<'_>,
1433    ) -> std::task::Poll<Option<Self::Item>> {
1434        let this = &mut *self;
1435        if this.inner.check_shutdown(cx) {
1436            this.is_terminated = true;
1437            return std::task::Poll::Ready(None);
1438        }
1439        if this.is_terminated {
1440            panic!("polled ProviderV2RequestStream after completion");
1441        }
1442        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1443            |bytes, handles| {
1444                match this.inner.channel().read_etc(cx, bytes, handles) {
1445                    std::task::Poll::Ready(Ok(())) => {}
1446                    std::task::Poll::Pending => return std::task::Poll::Pending,
1447                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1448                        this.is_terminated = true;
1449                        return std::task::Poll::Ready(None);
1450                    }
1451                    std::task::Poll::Ready(Err(e)) => {
1452                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1453                            e.into(),
1454                        ))));
1455                    }
1456                }
1457
1458                // A message has been received from the channel
1459                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1460
1461                std::task::Poll::Ready(Some(match header.ordinal {
1462                    0x5402006f01edb9d1 => {
1463                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1464                        let mut req = fidl::new_empty!(
1465                            ProviderV2InitializeRequest,
1466                            fidl::encoding::DefaultFuchsiaResourceDialect
1467                        );
1468                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderV2InitializeRequest>(&header, _body_bytes, handles, &mut req)?;
1469                        let control_handle = ProviderV2ControlHandle { inner: this.inner.clone() };
1470                        Ok(ProviderV2Request::Initialize { config: req.config, control_handle })
1471                    }
1472                    0x71f85bc863e60f17 => {
1473                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1474                        let mut req = fidl::new_empty!(
1475                            ProviderV2StartRequest,
1476                            fidl::encoding::DefaultFuchsiaResourceDialect
1477                        );
1478                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderV2StartRequest>(&header, _body_bytes, handles, &mut req)?;
1479                        let control_handle = ProviderV2ControlHandle { inner: this.inner.clone() };
1480                        Ok(ProviderV2Request::Start {
1481                            options: req.options,
1482
1483                            responder: ProviderV2StartResponder {
1484                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1485                                tx_id: header.tx_id,
1486                            },
1487                        })
1488                    }
1489                    0x16df330a02562aa2 => {
1490                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1491                        let mut req = fidl::new_empty!(
1492                            fidl::encoding::EmptyPayload,
1493                            fidl::encoding::DefaultFuchsiaResourceDialect
1494                        );
1495                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1496                        let control_handle = ProviderV2ControlHandle { inner: this.inner.clone() };
1497                        Ok(ProviderV2Request::Stop {
1498                            responder: ProviderV2StopResponder {
1499                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1500                                tx_id: header.tx_id,
1501                            },
1502                        })
1503                    }
1504                    0x12a542af1614219f => {
1505                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1506                        let mut req = fidl::new_empty!(
1507                            fidl::encoding::EmptyPayload,
1508                            fidl::encoding::DefaultFuchsiaResourceDialect
1509                        );
1510                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1511                        let control_handle = ProviderV2ControlHandle { inner: this.inner.clone() };
1512                        Ok(ProviderV2Request::Terminate {
1513                            responder: ProviderV2TerminateResponder {
1514                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1515                                tx_id: header.tx_id,
1516                            },
1517                        })
1518                    }
1519                    0x24780beab3613747 => {
1520                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1521                        let mut req = fidl::new_empty!(
1522                            fidl::encoding::EmptyPayload,
1523                            fidl::encoding::DefaultFuchsiaResourceDialect
1524                        );
1525                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1526                        let control_handle = ProviderV2ControlHandle { inner: this.inner.clone() };
1527                        Ok(ProviderV2Request::GetKnownCategories {
1528                            responder: ProviderV2GetKnownCategoriesResponder {
1529                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1530                                tx_id: header.tx_id,
1531                            },
1532                        })
1533                    }
1534                    0x6a0a63b2e2d0dfe1 => {
1535                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1536                        let mut req = fidl::new_empty!(
1537                            ProviderV2NotifyBufferSavedRequest,
1538                            fidl::encoding::DefaultFuchsiaResourceDialect
1539                        );
1540                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProviderV2NotifyBufferSavedRequest>(&header, _body_bytes, handles, &mut req)?;
1541                        let control_handle = ProviderV2ControlHandle { inner: this.inner.clone() };
1542                        Ok(ProviderV2Request::NotifyBufferSaved {
1543                            wrapped_count: req.wrapped_count,
1544                            durable_data_end: req.durable_data_end,
1545
1546                            control_handle,
1547                        })
1548                    }
1549                    0x635c3e76e1de8d29 => {
1550                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1551                        let mut req = fidl::new_empty!(
1552                            fidl::encoding::EmptyPayload,
1553                            fidl::encoding::DefaultFuchsiaResourceDialect
1554                        );
1555                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1556                        let control_handle = ProviderV2ControlHandle { inner: this.inner.clone() };
1557                        Ok(ProviderV2Request::Flush { control_handle })
1558                    }
1559                    _ if header.tx_id == 0
1560                        && header
1561                            .dynamic_flags()
1562                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1563                    {
1564                        Ok(ProviderV2Request::_UnknownMethod {
1565                            ordinal: header.ordinal,
1566                            control_handle: ProviderV2ControlHandle { inner: this.inner.clone() },
1567                            method_type: fidl::MethodType::OneWay,
1568                        })
1569                    }
1570                    _ if header
1571                        .dynamic_flags()
1572                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1573                    {
1574                        this.inner.send_framework_err(
1575                            fidl::encoding::FrameworkErr::UnknownMethod,
1576                            header.tx_id,
1577                            header.ordinal,
1578                            header.dynamic_flags(),
1579                            (bytes, handles),
1580                        )?;
1581                        Ok(ProviderV2Request::_UnknownMethod {
1582                            ordinal: header.ordinal,
1583                            control_handle: ProviderV2ControlHandle { inner: this.inner.clone() },
1584                            method_type: fidl::MethodType::TwoWay,
1585                        })
1586                    }
1587                    _ => Err(fidl::Error::UnknownOrdinal {
1588                        ordinal: header.ordinal,
1589                        protocol_name:
1590                            <ProviderV2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1591                    }),
1592                }))
1593            },
1594        )
1595    }
1596}
1597
1598/// The provider interface which applications must implement and register
1599/// with the `TraceRegistry` to participate in tracing.
1600#[derive(Debug)]
1601pub enum ProviderV2Request {
1602    /// Initialize tracing and prepare for writing trace records for events in
1603    /// the specified `categories` into `buffer`.
1604    /// Tracing hasn't started yet, a `Start()` call is still required.
1605    ///
1606    ///
1607    /// At most one trace can be active at a time. Subsequent `Initialize()`
1608    /// requests received prior to a `Terminate()` call must be ignored.
1609    Initialize { config: ProviderConfigV2, control_handle: ProviderV2ControlHandle },
1610    /// Begin tracing.
1611    ///
1612    /// If tracing has already started the provider must ignore the request.
1613    Start { options: StartOptions, responder: ProviderV2StartResponder },
1614    /// Stop tracing.
1615    ///
1616    /// If tracing has already stopped the provider must ignore the request.
1617    ///
1618    /// Once the provider has finished writing any final events to the trace
1619    /// buffer, it must send an `OnStopped()` event.
1620    /// Note that multiple `Start,Stop` requests can be received between
1621    /// `Initialize,Terminate`.
1622    Stop { responder: ProviderV2StopResponder },
1623    /// Terminate tracing.
1624    ///
1625    /// Tracing is stopped first if not already stopped.
1626    Terminate { responder: ProviderV2TerminateResponder },
1627    /// Gets the trace categories that might be produced by this provider.
1628    GetKnownCategories { responder: ProviderV2GetKnownCategoriesResponder },
1629    /// A buffer has been saved (streaming mode only).
1630    NotifyBufferSaved {
1631        wrapped_count: u32,
1632        durable_data_end: u64,
1633        control_handle: ProviderV2ControlHandle,
1634    },
1635    /// Requests the provider its buffer to be read out, regardless of it is
1636    /// full or not.
1637    ///
1638    /// Normally streaming mode only sends data once it has enough data to
1639    /// require a buffer swap and data flush. This produces fewer, but larger
1640    /// and bursty data transfers.
1641    ///
1642    /// Some clients may want more regular smaller data transfers. These clients
1643    /// may instead manually invoke Flush whenever they are ready for
1644    /// data.
1645    Flush { control_handle: ProviderV2ControlHandle },
1646    /// An interaction was received which does not match any known method.
1647    #[non_exhaustive]
1648    _UnknownMethod {
1649        /// Ordinal of the method that was called.
1650        ordinal: u64,
1651        control_handle: ProviderV2ControlHandle,
1652        method_type: fidl::MethodType,
1653    },
1654}
1655
1656impl ProviderV2Request {
1657    #[allow(irrefutable_let_patterns)]
1658    pub fn into_initialize(self) -> Option<(ProviderConfigV2, ProviderV2ControlHandle)> {
1659        if let ProviderV2Request::Initialize { config, control_handle } = self {
1660            Some((config, control_handle))
1661        } else {
1662            None
1663        }
1664    }
1665
1666    #[allow(irrefutable_let_patterns)]
1667    pub fn into_start(self) -> Option<(StartOptions, ProviderV2StartResponder)> {
1668        if let ProviderV2Request::Start { options, responder } = self {
1669            Some((options, responder))
1670        } else {
1671            None
1672        }
1673    }
1674
1675    #[allow(irrefutable_let_patterns)]
1676    pub fn into_stop(self) -> Option<(ProviderV2StopResponder)> {
1677        if let ProviderV2Request::Stop { responder } = self { Some((responder)) } else { None }
1678    }
1679
1680    #[allow(irrefutable_let_patterns)]
1681    pub fn into_terminate(self) -> Option<(ProviderV2TerminateResponder)> {
1682        if let ProviderV2Request::Terminate { responder } = self { Some((responder)) } else { None }
1683    }
1684
1685    #[allow(irrefutable_let_patterns)]
1686    pub fn into_get_known_categories(self) -> Option<(ProviderV2GetKnownCategoriesResponder)> {
1687        if let ProviderV2Request::GetKnownCategories { responder } = self {
1688            Some((responder))
1689        } else {
1690            None
1691        }
1692    }
1693
1694    #[allow(irrefutable_let_patterns)]
1695    pub fn into_notify_buffer_saved(self) -> Option<(u32, u64, ProviderV2ControlHandle)> {
1696        if let ProviderV2Request::NotifyBufferSaved {
1697            wrapped_count,
1698            durable_data_end,
1699            control_handle,
1700        } = self
1701        {
1702            Some((wrapped_count, durable_data_end, control_handle))
1703        } else {
1704            None
1705        }
1706    }
1707
1708    #[allow(irrefutable_let_patterns)]
1709    pub fn into_flush(self) -> Option<(ProviderV2ControlHandle)> {
1710        if let ProviderV2Request::Flush { control_handle } = self {
1711            Some((control_handle))
1712        } else {
1713            None
1714        }
1715    }
1716
1717    /// Name of the method defined in FIDL
1718    pub fn method_name(&self) -> &'static str {
1719        match *self {
1720            ProviderV2Request::Initialize { .. } => "initialize",
1721            ProviderV2Request::Start { .. } => "start",
1722            ProviderV2Request::Stop { .. } => "stop",
1723            ProviderV2Request::Terminate { .. } => "terminate",
1724            ProviderV2Request::GetKnownCategories { .. } => "get_known_categories",
1725            ProviderV2Request::NotifyBufferSaved { .. } => "notify_buffer_saved",
1726            ProviderV2Request::Flush { .. } => "flush",
1727            ProviderV2Request::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1728                "unknown one-way method"
1729            }
1730            ProviderV2Request::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1731                "unknown two-way method"
1732            }
1733        }
1734    }
1735}
1736
1737#[derive(Debug, Clone)]
1738pub struct ProviderV2ControlHandle {
1739    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1740}
1741
1742impl fidl::endpoints::ControlHandle for ProviderV2ControlHandle {
1743    fn shutdown(&self) {
1744        self.inner.shutdown()
1745    }
1746
1747    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1748        self.inner.shutdown_with_epitaph(status)
1749    }
1750
1751    fn is_closed(&self) -> bool {
1752        self.inner.channel().is_closed()
1753    }
1754    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1755        self.inner.channel().on_closed()
1756    }
1757
1758    #[cfg(target_os = "fuchsia")]
1759    fn signal_peer(
1760        &self,
1761        clear_mask: zx::Signals,
1762        set_mask: zx::Signals,
1763    ) -> Result<(), zx_status::Status> {
1764        use fidl::Peered;
1765        self.inner.channel().signal_peer(clear_mask, set_mask)
1766    }
1767}
1768
1769impl ProviderV2ControlHandle {
1770    pub fn send_on_save_buffer(
1771        &self,
1772        mut wrapped_count: u32,
1773        mut durable_data_end: u64,
1774    ) -> Result<(), fidl::Error> {
1775        self.inner.send::<ProviderV2OnSaveBufferRequest>(
1776            (wrapped_count, durable_data_end),
1777            0,
1778            0x7d7c8f770a3c760d,
1779            fidl::encoding::DynamicFlags::FLEXIBLE,
1780        )
1781    }
1782
1783    pub fn send_on_alert(&self, mut name: &str) -> Result<(), fidl::Error> {
1784        self.inner.send::<ProviderV2OnAlertRequest>(
1785            (name,),
1786            0,
1787            0x23ecc93ef5106a2,
1788            fidl::encoding::DynamicFlags::FLEXIBLE,
1789        )
1790    }
1791}
1792
1793#[must_use = "FIDL methods require a response to be sent"]
1794#[derive(Debug)]
1795pub struct ProviderV2StartResponder {
1796    control_handle: std::mem::ManuallyDrop<ProviderV2ControlHandle>,
1797    tx_id: u32,
1798}
1799
1800/// Set the the channel to be shutdown (see [`ProviderV2ControlHandle::shutdown`])
1801/// if the responder is dropped without sending a response, so that the client
1802/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1803impl std::ops::Drop for ProviderV2StartResponder {
1804    fn drop(&mut self) {
1805        self.control_handle.shutdown();
1806        // Safety: drops once, never accessed again
1807        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1808    }
1809}
1810
1811impl fidl::endpoints::Responder for ProviderV2StartResponder {
1812    type ControlHandle = ProviderV2ControlHandle;
1813
1814    fn control_handle(&self) -> &ProviderV2ControlHandle {
1815        &self.control_handle
1816    }
1817
1818    fn drop_without_shutdown(mut self) {
1819        // Safety: drops once, never accessed again due to mem::forget
1820        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1821        // Prevent Drop from running (which would shut down the channel)
1822        std::mem::forget(self);
1823    }
1824}
1825
1826impl ProviderV2StartResponder {
1827    /// Sends a response to the FIDL transaction.
1828    ///
1829    /// Sets the channel to shutdown if an error occurs.
1830    pub fn send(self) -> Result<(), fidl::Error> {
1831        let _result = self.send_raw();
1832        if _result.is_err() {
1833            self.control_handle.shutdown();
1834        }
1835        self.drop_without_shutdown();
1836        _result
1837    }
1838
1839    /// Similar to "send" but does not shutdown the channel if an error occurs.
1840    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1841        let _result = self.send_raw();
1842        self.drop_without_shutdown();
1843        _result
1844    }
1845
1846    fn send_raw(&self) -> Result<(), fidl::Error> {
1847        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1848            fidl::encoding::Flexible::new(()),
1849            self.tx_id,
1850            0x71f85bc863e60f17,
1851            fidl::encoding::DynamicFlags::FLEXIBLE,
1852        )
1853    }
1854}
1855
1856#[must_use = "FIDL methods require a response to be sent"]
1857#[derive(Debug)]
1858pub struct ProviderV2StopResponder {
1859    control_handle: std::mem::ManuallyDrop<ProviderV2ControlHandle>,
1860    tx_id: u32,
1861}
1862
1863/// Set the the channel to be shutdown (see [`ProviderV2ControlHandle::shutdown`])
1864/// if the responder is dropped without sending a response, so that the client
1865/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1866impl std::ops::Drop for ProviderV2StopResponder {
1867    fn drop(&mut self) {
1868        self.control_handle.shutdown();
1869        // Safety: drops once, never accessed again
1870        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1871    }
1872}
1873
1874impl fidl::endpoints::Responder for ProviderV2StopResponder {
1875    type ControlHandle = ProviderV2ControlHandle;
1876
1877    fn control_handle(&self) -> &ProviderV2ControlHandle {
1878        &self.control_handle
1879    }
1880
1881    fn drop_without_shutdown(mut self) {
1882        // Safety: drops once, never accessed again due to mem::forget
1883        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1884        // Prevent Drop from running (which would shut down the channel)
1885        std::mem::forget(self);
1886    }
1887}
1888
1889impl ProviderV2StopResponder {
1890    /// Sends a response to the FIDL transaction.
1891    ///
1892    /// Sets the channel to shutdown if an error occurs.
1893    pub fn send(self) -> Result<(), fidl::Error> {
1894        let _result = self.send_raw();
1895        if _result.is_err() {
1896            self.control_handle.shutdown();
1897        }
1898        self.drop_without_shutdown();
1899        _result
1900    }
1901
1902    /// Similar to "send" but does not shutdown the channel if an error occurs.
1903    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1904        let _result = self.send_raw();
1905        self.drop_without_shutdown();
1906        _result
1907    }
1908
1909    fn send_raw(&self) -> Result<(), fidl::Error> {
1910        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1911            fidl::encoding::Flexible::new(()),
1912            self.tx_id,
1913            0x16df330a02562aa2,
1914            fidl::encoding::DynamicFlags::FLEXIBLE,
1915        )
1916    }
1917}
1918
1919#[must_use = "FIDL methods require a response to be sent"]
1920#[derive(Debug)]
1921pub struct ProviderV2TerminateResponder {
1922    control_handle: std::mem::ManuallyDrop<ProviderV2ControlHandle>,
1923    tx_id: u32,
1924}
1925
1926/// Set the the channel to be shutdown (see [`ProviderV2ControlHandle::shutdown`])
1927/// if the responder is dropped without sending a response, so that the client
1928/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1929impl std::ops::Drop for ProviderV2TerminateResponder {
1930    fn drop(&mut self) {
1931        self.control_handle.shutdown();
1932        // Safety: drops once, never accessed again
1933        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1934    }
1935}
1936
1937impl fidl::endpoints::Responder for ProviderV2TerminateResponder {
1938    type ControlHandle = ProviderV2ControlHandle;
1939
1940    fn control_handle(&self) -> &ProviderV2ControlHandle {
1941        &self.control_handle
1942    }
1943
1944    fn drop_without_shutdown(mut self) {
1945        // Safety: drops once, never accessed again due to mem::forget
1946        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1947        // Prevent Drop from running (which would shut down the channel)
1948        std::mem::forget(self);
1949    }
1950}
1951
1952impl ProviderV2TerminateResponder {
1953    /// Sends a response to the FIDL transaction.
1954    ///
1955    /// Sets the channel to shutdown if an error occurs.
1956    pub fn send(self) -> Result<(), fidl::Error> {
1957        let _result = self.send_raw();
1958        if _result.is_err() {
1959            self.control_handle.shutdown();
1960        }
1961        self.drop_without_shutdown();
1962        _result
1963    }
1964
1965    /// Similar to "send" but does not shutdown the channel if an error occurs.
1966    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1967        let _result = self.send_raw();
1968        self.drop_without_shutdown();
1969        _result
1970    }
1971
1972    fn send_raw(&self) -> Result<(), fidl::Error> {
1973        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1974            fidl::encoding::Flexible::new(()),
1975            self.tx_id,
1976            0x12a542af1614219f,
1977            fidl::encoding::DynamicFlags::FLEXIBLE,
1978        )
1979    }
1980}
1981
1982#[must_use = "FIDL methods require a response to be sent"]
1983#[derive(Debug)]
1984pub struct ProviderV2GetKnownCategoriesResponder {
1985    control_handle: std::mem::ManuallyDrop<ProviderV2ControlHandle>,
1986    tx_id: u32,
1987}
1988
1989/// Set the the channel to be shutdown (see [`ProviderV2ControlHandle::shutdown`])
1990/// if the responder is dropped without sending a response, so that the client
1991/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1992impl std::ops::Drop for ProviderV2GetKnownCategoriesResponder {
1993    fn drop(&mut self) {
1994        self.control_handle.shutdown();
1995        // Safety: drops once, never accessed again
1996        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1997    }
1998}
1999
2000impl fidl::endpoints::Responder for ProviderV2GetKnownCategoriesResponder {
2001    type ControlHandle = ProviderV2ControlHandle;
2002
2003    fn control_handle(&self) -> &ProviderV2ControlHandle {
2004        &self.control_handle
2005    }
2006
2007    fn drop_without_shutdown(mut self) {
2008        // Safety: drops once, never accessed again due to mem::forget
2009        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2010        // Prevent Drop from running (which would shut down the channel)
2011        std::mem::forget(self);
2012    }
2013}
2014
2015impl ProviderV2GetKnownCategoriesResponder {
2016    /// Sends a response to the FIDL transaction.
2017    ///
2018    /// Sets the channel to shutdown if an error occurs.
2019    pub fn send(
2020        self,
2021        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
2022    ) -> Result<(), fidl::Error> {
2023        let _result = self.send_raw(categories);
2024        if _result.is_err() {
2025            self.control_handle.shutdown();
2026        }
2027        self.drop_without_shutdown();
2028        _result
2029    }
2030
2031    /// Similar to "send" but does not shutdown the channel if an error occurs.
2032    pub fn send_no_shutdown_on_err(
2033        self,
2034        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
2035    ) -> Result<(), fidl::Error> {
2036        let _result = self.send_raw(categories);
2037        self.drop_without_shutdown();
2038        _result
2039    }
2040
2041    fn send_raw(
2042        &self,
2043        mut categories: &[fidl_fuchsia_tracing::KnownCategory],
2044    ) -> Result<(), fidl::Error> {
2045        self.control_handle
2046            .inner
2047            .send::<fidl::encoding::FlexibleType<ProviderV2GetKnownCategoriesResponse>>(
2048                fidl::encoding::Flexible::new((categories,)),
2049                self.tx_id,
2050                0x24780beab3613747,
2051                fidl::encoding::DynamicFlags::FLEXIBLE,
2052            )
2053    }
2054}
2055
2056#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2057pub struct RegistryMarker;
2058
2059impl fidl::endpoints::ProtocolMarker for RegistryMarker {
2060    type Proxy = RegistryProxy;
2061    type RequestStream = RegistryRequestStream;
2062    #[cfg(target_os = "fuchsia")]
2063    type SynchronousProxy = RegistrySynchronousProxy;
2064
2065    const DEBUG_NAME: &'static str = "fuchsia.tracing.provider.Registry";
2066}
2067impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
2068pub type RegistryRegisterV2SynchronouslyResult = Result<bool, i32>;
2069
2070pub trait RegistryProxyInterface: Send + Sync {
2071    fn r#register_provider(
2072        &self,
2073        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2074        pid: u64,
2075        name: &str,
2076    ) -> Result<(), fidl::Error>;
2077    type RegisterProviderSynchronouslyResponseFut: std::future::Future<Output = Result<(i32, bool), fidl::Error>>
2078        + Send;
2079    fn r#register_provider_synchronously(
2080        &self,
2081        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2082        pid: u64,
2083        name: &str,
2084    ) -> Self::RegisterProviderSynchronouslyResponseFut;
2085    fn r#register_v2(
2086        &self,
2087        provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2088        pid: u64,
2089        name: &str,
2090    ) -> Result<(), fidl::Error>;
2091    type RegisterV2SynchronouslyResponseFut: std::future::Future<Output = Result<RegistryRegisterV2SynchronouslyResult, fidl::Error>>
2092        + Send;
2093    fn r#register_v2_synchronously(
2094        &self,
2095        provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2096        pid: u64,
2097        name: &str,
2098    ) -> Self::RegisterV2SynchronouslyResponseFut;
2099}
2100#[derive(Debug)]
2101#[cfg(target_os = "fuchsia")]
2102pub struct RegistrySynchronousProxy {
2103    client: fidl::client::sync::Client,
2104}
2105
2106#[cfg(target_os = "fuchsia")]
2107impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
2108    type Proxy = RegistryProxy;
2109    type Protocol = RegistryMarker;
2110
2111    fn from_channel(inner: fidl::Channel) -> Self {
2112        Self::new(inner)
2113    }
2114
2115    fn into_channel(self) -> fidl::Channel {
2116        self.client.into_channel()
2117    }
2118
2119    fn as_channel(&self) -> &fidl::Channel {
2120        self.client.as_channel()
2121    }
2122}
2123
2124#[cfg(target_os = "fuchsia")]
2125impl RegistrySynchronousProxy {
2126    pub fn new(channel: fidl::Channel) -> Self {
2127        Self { client: fidl::client::sync::Client::new(channel) }
2128    }
2129
2130    pub fn into_channel(self) -> fidl::Channel {
2131        self.client.into_channel()
2132    }
2133
2134    /// Waits until an event arrives and returns it. It is safe for other
2135    /// threads to make concurrent requests while waiting for an event.
2136    pub fn wait_for_event(
2137        &self,
2138        deadline: zx::MonotonicInstant,
2139    ) -> Result<RegistryEvent, fidl::Error> {
2140        RegistryEvent::decode(self.client.wait_for_event::<RegistryMarker>(deadline)?)
2141    }
2142
2143    /// Registers the trace provider.
2144    /// Note: Registration is asynchronous, it's only at some point after this
2145    /// returns that the provider is actually registered.
2146    /// To unregister, simply close the Provider pipe.
2147    /// `pid` is the process id of the provider, `name` is the name of the
2148    /// provider. Both of these are used in logging and diagnostic messages.
2149    ///
2150    /// # Deprecation
2151    ///
2152    /// Use "RegisterV2" instead to use the FIDL-based coordination protocol.
2153    pub fn r#register_provider(
2154        &self,
2155        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2156        mut pid: u64,
2157        mut name: &str,
2158    ) -> Result<(), fidl::Error> {
2159        self.client.send::<RegistryRegisterProviderRequest>(
2160            (provider, pid, name),
2161            0x75bcae3dfa08479c,
2162            fidl::encoding::DynamicFlags::empty(),
2163        )
2164    }
2165
2166    /// Registers the trace provider synchronously. The call doesn't return
2167    /// until the provider is registered.
2168    /// On return `s` is `ZX_OK` if registration was successful.
2169    /// `started` is true if tracing has already started, which is a hint to
2170    /// the provider to wait for the Start() message before continuing if it
2171    /// wishes to not drop trace records before Start() is received.
2172    /// To unregister, simply close the Provider pipe.
2173    /// `pid` is the process id of the provider, `name` is the name of the
2174    /// provider. Both of these are used in logging and diagnostic messages.
2175    ///
2176    /// # Deprecation
2177    ///
2178    /// Use "RegisterV2Synchronously" instead to use the FIDL-based coordination protocol.
2179    pub fn r#register_provider_synchronously(
2180        &self,
2181        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2182        mut pid: u64,
2183        mut name: &str,
2184        ___deadline: zx::MonotonicInstant,
2185    ) -> Result<(i32, bool), fidl::Error> {
2186        let _response = self.client.send_query::<
2187            RegistryRegisterProviderSynchronouslyRequest,
2188            RegistryRegisterProviderSynchronouslyResponse,
2189            RegistryMarker,
2190        >(
2191            (provider, pid, name,),
2192            0x4835ed419a808f16,
2193            fidl::encoding::DynamicFlags::empty(),
2194            ___deadline,
2195        )?;
2196        Ok((_response.s, _response.started))
2197    }
2198
2199    /// Registers the trace provider using the V2 protocol.
2200    ///
2201    /// Note: Registration is asynchronous, it's only at some point after this
2202    /// returns that the provider is actually registered.
2203    ///
2204    /// To unregister, close the `provider` connection.
2205    pub fn r#register_v2(
2206        &self,
2207        mut provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2208        mut pid: u64,
2209        mut name: &str,
2210    ) -> Result<(), fidl::Error> {
2211        self.client.send::<RegistryRegisterV2Request>(
2212            (provider, pid, name),
2213            0x2edaed92cc184b34,
2214            fidl::encoding::DynamicFlags::FLEXIBLE,
2215        )
2216    }
2217
2218    /// Registers the trace provider synchronously using the V2 protocol.
2219    ///
2220    /// The call doesn't return until the provider is registered. Most callers
2221    /// should use RegisterV2 unless they need to synchronize with they tracing
2222    /// system to ensure that specific events are captured.
2223    ///
2224    /// To unregister, close the `provider` connection.
2225    pub fn r#register_v2_synchronously(
2226        &self,
2227        mut provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2228        mut pid: u64,
2229        mut name: &str,
2230        ___deadline: zx::MonotonicInstant,
2231    ) -> Result<RegistryRegisterV2SynchronouslyResult, fidl::Error> {
2232        let _response = self.client.send_query::<
2233            RegistryRegisterV2SynchronouslyRequest,
2234            fidl::encoding::FlexibleResultType<RegistryRegisterV2SynchronouslyResponse, i32>,
2235            RegistryMarker,
2236        >(
2237            (provider, pid, name,),
2238            0x3da2ff760b018196,
2239            fidl::encoding::DynamicFlags::FLEXIBLE,
2240            ___deadline,
2241        )?
2242        .into_result::<RegistryMarker>("register_v2_synchronously")?;
2243        Ok(_response.map(|x| x.started))
2244    }
2245}
2246
2247#[cfg(target_os = "fuchsia")]
2248impl From<RegistrySynchronousProxy> for zx::NullableHandle {
2249    fn from(value: RegistrySynchronousProxy) -> Self {
2250        value.into_channel().into()
2251    }
2252}
2253
2254#[cfg(target_os = "fuchsia")]
2255impl From<fidl::Channel> for RegistrySynchronousProxy {
2256    fn from(value: fidl::Channel) -> Self {
2257        Self::new(value)
2258    }
2259}
2260
2261#[cfg(target_os = "fuchsia")]
2262impl fidl::endpoints::FromClient for RegistrySynchronousProxy {
2263    type Protocol = RegistryMarker;
2264
2265    fn from_client(value: fidl::endpoints::ClientEnd<RegistryMarker>) -> Self {
2266        Self::new(value.into_channel())
2267    }
2268}
2269
2270#[derive(Debug, Clone)]
2271pub struct RegistryProxy {
2272    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2273}
2274
2275impl fidl::endpoints::Proxy for RegistryProxy {
2276    type Protocol = RegistryMarker;
2277
2278    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2279        Self::new(inner)
2280    }
2281
2282    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2283        self.client.into_channel().map_err(|client| Self { client })
2284    }
2285
2286    fn as_channel(&self) -> &::fidl::AsyncChannel {
2287        self.client.as_channel()
2288    }
2289}
2290
2291impl RegistryProxy {
2292    /// Create a new Proxy for fuchsia.tracing.provider/Registry.
2293    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2294        let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2295        Self { client: fidl::client::Client::new(channel, protocol_name) }
2296    }
2297
2298    /// Get a Stream of events from the remote end of the protocol.
2299    ///
2300    /// # Panics
2301    ///
2302    /// Panics if the event stream was already taken.
2303    pub fn take_event_stream(&self) -> RegistryEventStream {
2304        RegistryEventStream { event_receiver: self.client.take_event_receiver() }
2305    }
2306
2307    /// Registers the trace provider.
2308    /// Note: Registration is asynchronous, it's only at some point after this
2309    /// returns that the provider is actually registered.
2310    /// To unregister, simply close the Provider pipe.
2311    /// `pid` is the process id of the provider, `name` is the name of the
2312    /// provider. Both of these are used in logging and diagnostic messages.
2313    ///
2314    /// # Deprecation
2315    ///
2316    /// Use "RegisterV2" instead to use the FIDL-based coordination protocol.
2317    pub fn r#register_provider(
2318        &self,
2319        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2320        mut pid: u64,
2321        mut name: &str,
2322    ) -> Result<(), fidl::Error> {
2323        RegistryProxyInterface::r#register_provider(self, provider, pid, name)
2324    }
2325
2326    /// Registers the trace provider synchronously. The call doesn't return
2327    /// until the provider is registered.
2328    /// On return `s` is `ZX_OK` if registration was successful.
2329    /// `started` is true if tracing has already started, which is a hint to
2330    /// the provider to wait for the Start() message before continuing if it
2331    /// wishes to not drop trace records before Start() is received.
2332    /// To unregister, simply close the Provider pipe.
2333    /// `pid` is the process id of the provider, `name` is the name of the
2334    /// provider. Both of these are used in logging and diagnostic messages.
2335    ///
2336    /// # Deprecation
2337    ///
2338    /// Use "RegisterV2Synchronously" instead to use the FIDL-based coordination protocol.
2339    pub fn r#register_provider_synchronously(
2340        &self,
2341        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2342        mut pid: u64,
2343        mut name: &str,
2344    ) -> fidl::client::QueryResponseFut<(i32, bool), fidl::encoding::DefaultFuchsiaResourceDialect>
2345    {
2346        RegistryProxyInterface::r#register_provider_synchronously(self, provider, pid, name)
2347    }
2348
2349    /// Registers the trace provider using the V2 protocol.
2350    ///
2351    /// Note: Registration is asynchronous, it's only at some point after this
2352    /// returns that the provider is actually registered.
2353    ///
2354    /// To unregister, close the `provider` connection.
2355    pub fn r#register_v2(
2356        &self,
2357        mut provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2358        mut pid: u64,
2359        mut name: &str,
2360    ) -> Result<(), fidl::Error> {
2361        RegistryProxyInterface::r#register_v2(self, provider, pid, name)
2362    }
2363
2364    /// Registers the trace provider synchronously using the V2 protocol.
2365    ///
2366    /// The call doesn't return until the provider is registered. Most callers
2367    /// should use RegisterV2 unless they need to synchronize with they tracing
2368    /// system to ensure that specific events are captured.
2369    ///
2370    /// To unregister, close the `provider` connection.
2371    pub fn r#register_v2_synchronously(
2372        &self,
2373        mut provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2374        mut pid: u64,
2375        mut name: &str,
2376    ) -> fidl::client::QueryResponseFut<
2377        RegistryRegisterV2SynchronouslyResult,
2378        fidl::encoding::DefaultFuchsiaResourceDialect,
2379    > {
2380        RegistryProxyInterface::r#register_v2_synchronously(self, provider, pid, name)
2381    }
2382}
2383
2384impl RegistryProxyInterface for RegistryProxy {
2385    fn r#register_provider(
2386        &self,
2387        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2388        mut pid: u64,
2389        mut name: &str,
2390    ) -> Result<(), fidl::Error> {
2391        self.client.send::<RegistryRegisterProviderRequest>(
2392            (provider, pid, name),
2393            0x75bcae3dfa08479c,
2394            fidl::encoding::DynamicFlags::empty(),
2395        )
2396    }
2397
2398    type RegisterProviderSynchronouslyResponseFut =
2399        fidl::client::QueryResponseFut<(i32, bool), fidl::encoding::DefaultFuchsiaResourceDialect>;
2400    fn r#register_provider_synchronously(
2401        &self,
2402        mut provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2403        mut pid: u64,
2404        mut name: &str,
2405    ) -> Self::RegisterProviderSynchronouslyResponseFut {
2406        fn _decode(
2407            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2408        ) -> Result<(i32, bool), fidl::Error> {
2409            let _response = fidl::client::decode_transaction_body::<
2410                RegistryRegisterProviderSynchronouslyResponse,
2411                fidl::encoding::DefaultFuchsiaResourceDialect,
2412                0x4835ed419a808f16,
2413            >(_buf?)?;
2414            Ok((_response.s, _response.started))
2415        }
2416        self.client
2417            .send_query_and_decode::<RegistryRegisterProviderSynchronouslyRequest, (i32, bool)>(
2418                (provider, pid, name),
2419                0x4835ed419a808f16,
2420                fidl::encoding::DynamicFlags::empty(),
2421                _decode,
2422            )
2423    }
2424
2425    fn r#register_v2(
2426        &self,
2427        mut provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2428        mut pid: u64,
2429        mut name: &str,
2430    ) -> Result<(), fidl::Error> {
2431        self.client.send::<RegistryRegisterV2Request>(
2432            (provider, pid, name),
2433            0x2edaed92cc184b34,
2434            fidl::encoding::DynamicFlags::FLEXIBLE,
2435        )
2436    }
2437
2438    type RegisterV2SynchronouslyResponseFut = fidl::client::QueryResponseFut<
2439        RegistryRegisterV2SynchronouslyResult,
2440        fidl::encoding::DefaultFuchsiaResourceDialect,
2441    >;
2442    fn r#register_v2_synchronously(
2443        &self,
2444        mut provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2445        mut pid: u64,
2446        mut name: &str,
2447    ) -> Self::RegisterV2SynchronouslyResponseFut {
2448        fn _decode(
2449            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2450        ) -> Result<RegistryRegisterV2SynchronouslyResult, fidl::Error> {
2451            let _response = fidl::client::decode_transaction_body::<
2452                fidl::encoding::FlexibleResultType<RegistryRegisterV2SynchronouslyResponse, i32>,
2453                fidl::encoding::DefaultFuchsiaResourceDialect,
2454                0x3da2ff760b018196,
2455            >(_buf?)?
2456            .into_result::<RegistryMarker>("register_v2_synchronously")?;
2457            Ok(_response.map(|x| x.started))
2458        }
2459        self.client.send_query_and_decode::<
2460            RegistryRegisterV2SynchronouslyRequest,
2461            RegistryRegisterV2SynchronouslyResult,
2462        >(
2463            (provider, pid, name,),
2464            0x3da2ff760b018196,
2465            fidl::encoding::DynamicFlags::FLEXIBLE,
2466            _decode,
2467        )
2468    }
2469}
2470
2471pub struct RegistryEventStream {
2472    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2473}
2474
2475impl std::marker::Unpin for RegistryEventStream {}
2476
2477impl futures::stream::FusedStream for RegistryEventStream {
2478    fn is_terminated(&self) -> bool {
2479        self.event_receiver.is_terminated()
2480    }
2481}
2482
2483impl futures::Stream for RegistryEventStream {
2484    type Item = Result<RegistryEvent, fidl::Error>;
2485
2486    fn poll_next(
2487        mut self: std::pin::Pin<&mut Self>,
2488        cx: &mut std::task::Context<'_>,
2489    ) -> std::task::Poll<Option<Self::Item>> {
2490        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2491            &mut self.event_receiver,
2492            cx
2493        )?) {
2494            Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
2495            None => std::task::Poll::Ready(None),
2496        }
2497    }
2498}
2499
2500#[derive(Debug)]
2501pub enum RegistryEvent {
2502    #[non_exhaustive]
2503    _UnknownEvent {
2504        /// Ordinal of the event that was sent.
2505        ordinal: u64,
2506    },
2507}
2508
2509impl RegistryEvent {
2510    /// Decodes a message buffer as a [`RegistryEvent`].
2511    fn decode(
2512        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2513    ) -> Result<RegistryEvent, fidl::Error> {
2514        let (bytes, _handles) = buf.split_mut();
2515        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2516        debug_assert_eq!(tx_header.tx_id, 0);
2517        match tx_header.ordinal {
2518            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2519                Ok(RegistryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2520            }
2521            _ => Err(fidl::Error::UnknownOrdinal {
2522                ordinal: tx_header.ordinal,
2523                protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2524            }),
2525        }
2526    }
2527}
2528
2529/// A Stream of incoming requests for fuchsia.tracing.provider/Registry.
2530pub struct RegistryRequestStream {
2531    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2532    is_terminated: bool,
2533}
2534
2535impl std::marker::Unpin for RegistryRequestStream {}
2536
2537impl futures::stream::FusedStream for RegistryRequestStream {
2538    fn is_terminated(&self) -> bool {
2539        self.is_terminated
2540    }
2541}
2542
2543impl fidl::endpoints::RequestStream for RegistryRequestStream {
2544    type Protocol = RegistryMarker;
2545    type ControlHandle = RegistryControlHandle;
2546
2547    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2548        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2549    }
2550
2551    fn control_handle(&self) -> Self::ControlHandle {
2552        RegistryControlHandle { inner: self.inner.clone() }
2553    }
2554
2555    fn into_inner(
2556        self,
2557    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2558    {
2559        (self.inner, self.is_terminated)
2560    }
2561
2562    fn from_inner(
2563        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2564        is_terminated: bool,
2565    ) -> Self {
2566        Self { inner, is_terminated }
2567    }
2568}
2569
2570impl futures::Stream for RegistryRequestStream {
2571    type Item = Result<RegistryRequest, fidl::Error>;
2572
2573    fn poll_next(
2574        mut self: std::pin::Pin<&mut Self>,
2575        cx: &mut std::task::Context<'_>,
2576    ) -> std::task::Poll<Option<Self::Item>> {
2577        let this = &mut *self;
2578        if this.inner.check_shutdown(cx) {
2579            this.is_terminated = true;
2580            return std::task::Poll::Ready(None);
2581        }
2582        if this.is_terminated {
2583            panic!("polled RegistryRequestStream after completion");
2584        }
2585        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2586            |bytes, handles| {
2587                match this.inner.channel().read_etc(cx, bytes, handles) {
2588                    std::task::Poll::Ready(Ok(())) => {}
2589                    std::task::Poll::Pending => return std::task::Poll::Pending,
2590                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2591                        this.is_terminated = true;
2592                        return std::task::Poll::Ready(None);
2593                    }
2594                    std::task::Poll::Ready(Err(e)) => {
2595                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2596                            e.into(),
2597                        ))));
2598                    }
2599                }
2600
2601                // A message has been received from the channel
2602                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2603
2604                std::task::Poll::Ready(Some(match header.ordinal {
2605                    0x75bcae3dfa08479c => {
2606                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2607                        let mut req = fidl::new_empty!(
2608                            RegistryRegisterProviderRequest,
2609                            fidl::encoding::DefaultFuchsiaResourceDialect
2610                        );
2611                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterProviderRequest>(&header, _body_bytes, handles, &mut req)?;
2612                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
2613                        Ok(RegistryRequest::RegisterProvider {
2614                            provider: req.provider,
2615                            pid: req.pid,
2616                            name: req.name,
2617
2618                            control_handle,
2619                        })
2620                    }
2621                    0x4835ed419a808f16 => {
2622                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2623                        let mut req = fidl::new_empty!(
2624                            RegistryRegisterProviderSynchronouslyRequest,
2625                            fidl::encoding::DefaultFuchsiaResourceDialect
2626                        );
2627                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterProviderSynchronouslyRequest>(&header, _body_bytes, handles, &mut req)?;
2628                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
2629                        Ok(RegistryRequest::RegisterProviderSynchronously {
2630                            provider: req.provider,
2631                            pid: req.pid,
2632                            name: req.name,
2633
2634                            responder: RegistryRegisterProviderSynchronouslyResponder {
2635                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2636                                tx_id: header.tx_id,
2637                            },
2638                        })
2639                    }
2640                    0x2edaed92cc184b34 => {
2641                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2642                        let mut req = fidl::new_empty!(
2643                            RegistryRegisterV2Request,
2644                            fidl::encoding::DefaultFuchsiaResourceDialect
2645                        );
2646                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterV2Request>(&header, _body_bytes, handles, &mut req)?;
2647                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
2648                        Ok(RegistryRequest::RegisterV2 {
2649                            provider: req.provider,
2650                            pid: req.pid,
2651                            name: req.name,
2652
2653                            control_handle,
2654                        })
2655                    }
2656                    0x3da2ff760b018196 => {
2657                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2658                        let mut req = fidl::new_empty!(
2659                            RegistryRegisterV2SynchronouslyRequest,
2660                            fidl::encoding::DefaultFuchsiaResourceDialect
2661                        );
2662                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterV2SynchronouslyRequest>(&header, _body_bytes, handles, &mut req)?;
2663                        let control_handle = RegistryControlHandle { inner: this.inner.clone() };
2664                        Ok(RegistryRequest::RegisterV2Synchronously {
2665                            provider: req.provider,
2666                            pid: req.pid,
2667                            name: req.name,
2668
2669                            responder: RegistryRegisterV2SynchronouslyResponder {
2670                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2671                                tx_id: header.tx_id,
2672                            },
2673                        })
2674                    }
2675                    _ if header.tx_id == 0
2676                        && header
2677                            .dynamic_flags()
2678                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2679                    {
2680                        Ok(RegistryRequest::_UnknownMethod {
2681                            ordinal: header.ordinal,
2682                            control_handle: RegistryControlHandle { inner: this.inner.clone() },
2683                            method_type: fidl::MethodType::OneWay,
2684                        })
2685                    }
2686                    _ if header
2687                        .dynamic_flags()
2688                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2689                    {
2690                        this.inner.send_framework_err(
2691                            fidl::encoding::FrameworkErr::UnknownMethod,
2692                            header.tx_id,
2693                            header.ordinal,
2694                            header.dynamic_flags(),
2695                            (bytes, handles),
2696                        )?;
2697                        Ok(RegistryRequest::_UnknownMethod {
2698                            ordinal: header.ordinal,
2699                            control_handle: RegistryControlHandle { inner: this.inner.clone() },
2700                            method_type: fidl::MethodType::TwoWay,
2701                        })
2702                    }
2703                    _ => Err(fidl::Error::UnknownOrdinal {
2704                        ordinal: header.ordinal,
2705                        protocol_name:
2706                            <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2707                    }),
2708                }))
2709            },
2710        )
2711    }
2712}
2713
2714/// The service which trace providers use to register themselves with
2715/// the tracing system.
2716/// Note that one property of this interface is that once registration is made
2717/// the provider can drop this connection.
2718#[derive(Debug)]
2719pub enum RegistryRequest {
2720    /// Registers the trace provider.
2721    /// Note: Registration is asynchronous, it's only at some point after this
2722    /// returns that the provider is actually registered.
2723    /// To unregister, simply close the Provider pipe.
2724    /// `pid` is the process id of the provider, `name` is the name of the
2725    /// provider. Both of these are used in logging and diagnostic messages.
2726    ///
2727    /// # Deprecation
2728    ///
2729    /// Use "RegisterV2" instead to use the FIDL-based coordination protocol.
2730    RegisterProvider {
2731        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2732        pid: u64,
2733        name: String,
2734        control_handle: RegistryControlHandle,
2735    },
2736    /// Registers the trace provider synchronously. The call doesn't return
2737    /// until the provider is registered.
2738    /// On return `s` is `ZX_OK` if registration was successful.
2739    /// `started` is true if tracing has already started, which is a hint to
2740    /// the provider to wait for the Start() message before continuing if it
2741    /// wishes to not drop trace records before Start() is received.
2742    /// To unregister, simply close the Provider pipe.
2743    /// `pid` is the process id of the provider, `name` is the name of the
2744    /// provider. Both of these are used in logging and diagnostic messages.
2745    ///
2746    /// # Deprecation
2747    ///
2748    /// Use "RegisterV2Synchronously" instead to use the FIDL-based coordination protocol.
2749    RegisterProviderSynchronously {
2750        provider: fidl::endpoints::ClientEnd<ProviderMarker>,
2751        pid: u64,
2752        name: String,
2753        responder: RegistryRegisterProviderSynchronouslyResponder,
2754    },
2755    /// Registers the trace provider using the V2 protocol.
2756    ///
2757    /// Note: Registration is asynchronous, it's only at some point after this
2758    /// returns that the provider is actually registered.
2759    ///
2760    /// To unregister, close the `provider` connection.
2761    RegisterV2 {
2762        provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2763        pid: u64,
2764        name: String,
2765        control_handle: RegistryControlHandle,
2766    },
2767    /// Registers the trace provider synchronously using the V2 protocol.
2768    ///
2769    /// The call doesn't return until the provider is registered. Most callers
2770    /// should use RegisterV2 unless they need to synchronize with they tracing
2771    /// system to ensure that specific events are captured.
2772    ///
2773    /// To unregister, close the `provider` connection.
2774    RegisterV2Synchronously {
2775        provider: fidl::endpoints::ClientEnd<ProviderV2Marker>,
2776        pid: u64,
2777        name: String,
2778        responder: RegistryRegisterV2SynchronouslyResponder,
2779    },
2780    /// An interaction was received which does not match any known method.
2781    #[non_exhaustive]
2782    _UnknownMethod {
2783        /// Ordinal of the method that was called.
2784        ordinal: u64,
2785        control_handle: RegistryControlHandle,
2786        method_type: fidl::MethodType,
2787    },
2788}
2789
2790impl RegistryRequest {
2791    #[allow(irrefutable_let_patterns)]
2792    pub fn into_register_provider(
2793        self,
2794    ) -> Option<(fidl::endpoints::ClientEnd<ProviderMarker>, u64, String, RegistryControlHandle)>
2795    {
2796        if let RegistryRequest::RegisterProvider { provider, pid, name, control_handle } = self {
2797            Some((provider, pid, name, control_handle))
2798        } else {
2799            None
2800        }
2801    }
2802
2803    #[allow(irrefutable_let_patterns)]
2804    pub fn into_register_provider_synchronously(
2805        self,
2806    ) -> Option<(
2807        fidl::endpoints::ClientEnd<ProviderMarker>,
2808        u64,
2809        String,
2810        RegistryRegisterProviderSynchronouslyResponder,
2811    )> {
2812        if let RegistryRequest::RegisterProviderSynchronously { provider, pid, name, responder } =
2813            self
2814        {
2815            Some((provider, pid, name, responder))
2816        } else {
2817            None
2818        }
2819    }
2820
2821    #[allow(irrefutable_let_patterns)]
2822    pub fn into_register_v2(
2823        self,
2824    ) -> Option<(fidl::endpoints::ClientEnd<ProviderV2Marker>, u64, String, RegistryControlHandle)>
2825    {
2826        if let RegistryRequest::RegisterV2 { provider, pid, name, control_handle } = self {
2827            Some((provider, pid, name, control_handle))
2828        } else {
2829            None
2830        }
2831    }
2832
2833    #[allow(irrefutable_let_patterns)]
2834    pub fn into_register_v2_synchronously(
2835        self,
2836    ) -> Option<(
2837        fidl::endpoints::ClientEnd<ProviderV2Marker>,
2838        u64,
2839        String,
2840        RegistryRegisterV2SynchronouslyResponder,
2841    )> {
2842        if let RegistryRequest::RegisterV2Synchronously { provider, pid, name, responder } = self {
2843            Some((provider, pid, name, responder))
2844        } else {
2845            None
2846        }
2847    }
2848
2849    /// Name of the method defined in FIDL
2850    pub fn method_name(&self) -> &'static str {
2851        match *self {
2852            RegistryRequest::RegisterProvider { .. } => "register_provider",
2853            RegistryRequest::RegisterProviderSynchronously { .. } => {
2854                "register_provider_synchronously"
2855            }
2856            RegistryRequest::RegisterV2 { .. } => "register_v2",
2857            RegistryRequest::RegisterV2Synchronously { .. } => "register_v2_synchronously",
2858            RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2859                "unknown one-way method"
2860            }
2861            RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2862                "unknown two-way method"
2863            }
2864        }
2865    }
2866}
2867
2868#[derive(Debug, Clone)]
2869pub struct RegistryControlHandle {
2870    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2871}
2872
2873impl fidl::endpoints::ControlHandle for RegistryControlHandle {
2874    fn shutdown(&self) {
2875        self.inner.shutdown()
2876    }
2877
2878    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2879        self.inner.shutdown_with_epitaph(status)
2880    }
2881
2882    fn is_closed(&self) -> bool {
2883        self.inner.channel().is_closed()
2884    }
2885    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2886        self.inner.channel().on_closed()
2887    }
2888
2889    #[cfg(target_os = "fuchsia")]
2890    fn signal_peer(
2891        &self,
2892        clear_mask: zx::Signals,
2893        set_mask: zx::Signals,
2894    ) -> Result<(), zx_status::Status> {
2895        use fidl::Peered;
2896        self.inner.channel().signal_peer(clear_mask, set_mask)
2897    }
2898}
2899
2900impl RegistryControlHandle {}
2901
2902#[must_use = "FIDL methods require a response to be sent"]
2903#[derive(Debug)]
2904pub struct RegistryRegisterProviderSynchronouslyResponder {
2905    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
2906    tx_id: u32,
2907}
2908
2909/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
2910/// if the responder is dropped without sending a response, so that the client
2911/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2912impl std::ops::Drop for RegistryRegisterProviderSynchronouslyResponder {
2913    fn drop(&mut self) {
2914        self.control_handle.shutdown();
2915        // Safety: drops once, never accessed again
2916        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2917    }
2918}
2919
2920impl fidl::endpoints::Responder for RegistryRegisterProviderSynchronouslyResponder {
2921    type ControlHandle = RegistryControlHandle;
2922
2923    fn control_handle(&self) -> &RegistryControlHandle {
2924        &self.control_handle
2925    }
2926
2927    fn drop_without_shutdown(mut self) {
2928        // Safety: drops once, never accessed again due to mem::forget
2929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2930        // Prevent Drop from running (which would shut down the channel)
2931        std::mem::forget(self);
2932    }
2933}
2934
2935impl RegistryRegisterProviderSynchronouslyResponder {
2936    /// Sends a response to the FIDL transaction.
2937    ///
2938    /// Sets the channel to shutdown if an error occurs.
2939    pub fn send(self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
2940        let _result = self.send_raw(s, started);
2941        if _result.is_err() {
2942            self.control_handle.shutdown();
2943        }
2944        self.drop_without_shutdown();
2945        _result
2946    }
2947
2948    /// Similar to "send" but does not shutdown the channel if an error occurs.
2949    pub fn send_no_shutdown_on_err(self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
2950        let _result = self.send_raw(s, started);
2951        self.drop_without_shutdown();
2952        _result
2953    }
2954
2955    fn send_raw(&self, mut s: i32, mut started: bool) -> Result<(), fidl::Error> {
2956        self.control_handle.inner.send::<RegistryRegisterProviderSynchronouslyResponse>(
2957            (s, started),
2958            self.tx_id,
2959            0x4835ed419a808f16,
2960            fidl::encoding::DynamicFlags::empty(),
2961        )
2962    }
2963}
2964
2965#[must_use = "FIDL methods require a response to be sent"]
2966#[derive(Debug)]
2967pub struct RegistryRegisterV2SynchronouslyResponder {
2968    control_handle: std::mem::ManuallyDrop<RegistryControlHandle>,
2969    tx_id: u32,
2970}
2971
2972/// Set the the channel to be shutdown (see [`RegistryControlHandle::shutdown`])
2973/// if the responder is dropped without sending a response, so that the client
2974/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2975impl std::ops::Drop for RegistryRegisterV2SynchronouslyResponder {
2976    fn drop(&mut self) {
2977        self.control_handle.shutdown();
2978        // Safety: drops once, never accessed again
2979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2980    }
2981}
2982
2983impl fidl::endpoints::Responder for RegistryRegisterV2SynchronouslyResponder {
2984    type ControlHandle = RegistryControlHandle;
2985
2986    fn control_handle(&self) -> &RegistryControlHandle {
2987        &self.control_handle
2988    }
2989
2990    fn drop_without_shutdown(mut self) {
2991        // Safety: drops once, never accessed again due to mem::forget
2992        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2993        // Prevent Drop from running (which would shut down the channel)
2994        std::mem::forget(self);
2995    }
2996}
2997
2998impl RegistryRegisterV2SynchronouslyResponder {
2999    /// Sends a response to the FIDL transaction.
3000    ///
3001    /// Sets the channel to shutdown if an error occurs.
3002    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3003        let _result = self.send_raw(result);
3004        if _result.is_err() {
3005            self.control_handle.shutdown();
3006        }
3007        self.drop_without_shutdown();
3008        _result
3009    }
3010
3011    /// Similar to "send" but does not shutdown the channel if an error occurs.
3012    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3013        let _result = self.send_raw(result);
3014        self.drop_without_shutdown();
3015        _result
3016    }
3017
3018    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3019        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3020            RegistryRegisterV2SynchronouslyResponse,
3021            i32,
3022        >>(
3023            fidl::encoding::FlexibleResult::new(result.map(|started| (started,))),
3024            self.tx_id,
3025            0x3da2ff760b018196,
3026            fidl::encoding::DynamicFlags::FLEXIBLE,
3027        )
3028    }
3029}
3030
3031mod internal {
3032    use super::*;
3033
3034    impl fidl::encoding::ResourceTypeMarker for ProviderConfig {
3035        type Borrowed<'a> = &'a mut Self;
3036        fn take_or_borrow<'a>(
3037            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3038        ) -> Self::Borrowed<'a> {
3039            value
3040        }
3041    }
3042
3043    unsafe impl fidl::encoding::TypeMarker for ProviderConfig {
3044        type Owned = Self;
3045
3046        #[inline(always)]
3047        fn inline_align(_context: fidl::encoding::Context) -> usize {
3048            8
3049        }
3050
3051        #[inline(always)]
3052        fn inline_size(_context: fidl::encoding::Context) -> usize {
3053            32
3054        }
3055    }
3056
3057    unsafe impl
3058        fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
3059        for &mut ProviderConfig
3060    {
3061        #[inline]
3062        unsafe fn encode(
3063            self,
3064            encoder: &mut fidl::encoding::Encoder<
3065                '_,
3066                fidl::encoding::DefaultFuchsiaResourceDialect,
3067            >,
3068            offset: usize,
3069            _depth: fidl::encoding::Depth,
3070        ) -> fidl::Result<()> {
3071            encoder.debug_check_bounds::<ProviderConfig>(offset);
3072            // Delegate to tuple encoding.
3073            fidl::encoding::Encode::<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3074                (
3075                    <fidl_fuchsia_tracing::BufferingMode as fidl::encoding::ValueTypeMarker>::borrow(&self.buffering_mode),
3076                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
3077                    <fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.fifo),
3078                    <fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000> as fidl::encoding::ValueTypeMarker>::borrow(&self.categories),
3079                ),
3080                encoder, offset, _depth
3081            )
3082        }
3083    }
3084    unsafe impl<
3085        T0: fidl::encoding::Encode<
3086                fidl_fuchsia_tracing::BufferingMode,
3087                fidl::encoding::DefaultFuchsiaResourceDialect,
3088            >,
3089        T1: fidl::encoding::Encode<
3090                fidl::encoding::HandleType<
3091                    fidl::Vmo,
3092                    { fidl::ObjectType::VMO.into_raw() },
3093                    2147483648,
3094                >,
3095                fidl::encoding::DefaultFuchsiaResourceDialect,
3096            >,
3097        T2: fidl::encoding::Encode<
3098                fidl::encoding::HandleType<
3099                    fidl::Fifo,
3100                    { fidl::ObjectType::FIFO.into_raw() },
3101                    2147483648,
3102                >,
3103                fidl::encoding::DefaultFuchsiaResourceDialect,
3104            >,
3105        T3: fidl::encoding::Encode<
3106                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
3107                fidl::encoding::DefaultFuchsiaResourceDialect,
3108            >,
3109    > fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
3110        for (T0, T1, T2, T3)
3111    {
3112        #[inline]
3113        unsafe fn encode(
3114            self,
3115            encoder: &mut fidl::encoding::Encoder<
3116                '_,
3117                fidl::encoding::DefaultFuchsiaResourceDialect,
3118            >,
3119            offset: usize,
3120            depth: fidl::encoding::Depth,
3121        ) -> fidl::Result<()> {
3122            encoder.debug_check_bounds::<ProviderConfig>(offset);
3123            // Zero out padding regions. There's no need to apply masks
3124            // because the unmasked parts will be overwritten by fields.
3125            unsafe {
3126                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3127                (ptr as *mut u64).write_unaligned(0);
3128            }
3129            unsafe {
3130                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
3131                (ptr as *mut u64).write_unaligned(0);
3132            }
3133            // Write the fields.
3134            self.0.encode(encoder, offset + 0, depth)?;
3135            self.1.encode(encoder, offset + 4, depth)?;
3136            self.2.encode(encoder, offset + 8, depth)?;
3137            self.3.encode(encoder, offset + 16, depth)?;
3138            Ok(())
3139        }
3140    }
3141
3142    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3143        for ProviderConfig
3144    {
3145        #[inline(always)]
3146        fn new_empty() -> Self {
3147            Self {
3148                buffering_mode: fidl::new_empty!(
3149                    fidl_fuchsia_tracing::BufferingMode,
3150                    fidl::encoding::DefaultFuchsiaResourceDialect
3151                ),
3152                buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3153                fifo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3154                categories: fidl::new_empty!(
3155                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
3156                    fidl::encoding::DefaultFuchsiaResourceDialect
3157                ),
3158            }
3159        }
3160
3161        #[inline]
3162        unsafe fn decode(
3163            &mut self,
3164            decoder: &mut fidl::encoding::Decoder<
3165                '_,
3166                fidl::encoding::DefaultFuchsiaResourceDialect,
3167            >,
3168            offset: usize,
3169            _depth: fidl::encoding::Depth,
3170        ) -> fidl::Result<()> {
3171            decoder.debug_check_bounds::<Self>(offset);
3172            // Verify that padding bytes are zero.
3173            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3174            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3175            let mask = 0xffffff00u64;
3176            let maskedval = padval & mask;
3177            if maskedval != 0 {
3178                return Err(fidl::Error::NonZeroPadding {
3179                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3180                });
3181            }
3182            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
3183            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3184            let mask = 0xffffffff00000000u64;
3185            let maskedval = padval & mask;
3186            if maskedval != 0 {
3187                return Err(fidl::Error::NonZeroPadding {
3188                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
3189                });
3190            }
3191            fidl::decode!(
3192                fidl_fuchsia_tracing::BufferingMode,
3193                fidl::encoding::DefaultFuchsiaResourceDialect,
3194                &mut self.buffering_mode,
3195                decoder,
3196                offset + 0,
3197                _depth
3198            )?;
3199            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.buffer, decoder, offset + 4, _depth)?;
3200            fidl::decode!(fidl::encoding::HandleType<fidl::Fifo, { fidl::ObjectType::FIFO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.fifo, decoder, offset + 8, _depth)?;
3201            fidl::decode!(
3202                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
3203                fidl::encoding::DefaultFuchsiaResourceDialect,
3204                &mut self.categories,
3205                decoder,
3206                offset + 16,
3207                _depth
3208            )?;
3209            Ok(())
3210        }
3211    }
3212
3213    impl fidl::encoding::ResourceTypeMarker for ProviderInitializeRequest {
3214        type Borrowed<'a> = &'a mut Self;
3215        fn take_or_borrow<'a>(
3216            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3217        ) -> Self::Borrowed<'a> {
3218            value
3219        }
3220    }
3221
3222    unsafe impl fidl::encoding::TypeMarker for ProviderInitializeRequest {
3223        type Owned = Self;
3224
3225        #[inline(always)]
3226        fn inline_align(_context: fidl::encoding::Context) -> usize {
3227            8
3228        }
3229
3230        #[inline(always)]
3231        fn inline_size(_context: fidl::encoding::Context) -> usize {
3232            32
3233        }
3234    }
3235
3236    unsafe impl
3237        fidl::encoding::Encode<
3238            ProviderInitializeRequest,
3239            fidl::encoding::DefaultFuchsiaResourceDialect,
3240        > for &mut ProviderInitializeRequest
3241    {
3242        #[inline]
3243        unsafe fn encode(
3244            self,
3245            encoder: &mut fidl::encoding::Encoder<
3246                '_,
3247                fidl::encoding::DefaultFuchsiaResourceDialect,
3248            >,
3249            offset: usize,
3250            _depth: fidl::encoding::Depth,
3251        ) -> fidl::Result<()> {
3252            encoder.debug_check_bounds::<ProviderInitializeRequest>(offset);
3253            // Delegate to tuple encoding.
3254            fidl::encoding::Encode::<
3255                ProviderInitializeRequest,
3256                fidl::encoding::DefaultFuchsiaResourceDialect,
3257            >::encode(
3258                (<ProviderConfig as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3259                    &mut self.config,
3260                ),),
3261                encoder,
3262                offset,
3263                _depth,
3264            )
3265        }
3266    }
3267    unsafe impl<
3268        T0: fidl::encoding::Encode<ProviderConfig, fidl::encoding::DefaultFuchsiaResourceDialect>,
3269    >
3270        fidl::encoding::Encode<
3271            ProviderInitializeRequest,
3272            fidl::encoding::DefaultFuchsiaResourceDialect,
3273        > for (T0,)
3274    {
3275        #[inline]
3276        unsafe fn encode(
3277            self,
3278            encoder: &mut fidl::encoding::Encoder<
3279                '_,
3280                fidl::encoding::DefaultFuchsiaResourceDialect,
3281            >,
3282            offset: usize,
3283            depth: fidl::encoding::Depth,
3284        ) -> fidl::Result<()> {
3285            encoder.debug_check_bounds::<ProviderInitializeRequest>(offset);
3286            // Zero out padding regions. There's no need to apply masks
3287            // because the unmasked parts will be overwritten by fields.
3288            // Write the fields.
3289            self.0.encode(encoder, offset + 0, depth)?;
3290            Ok(())
3291        }
3292    }
3293
3294    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3295        for ProviderInitializeRequest
3296    {
3297        #[inline(always)]
3298        fn new_empty() -> Self {
3299            Self {
3300                config: fidl::new_empty!(
3301                    ProviderConfig,
3302                    fidl::encoding::DefaultFuchsiaResourceDialect
3303                ),
3304            }
3305        }
3306
3307        #[inline]
3308        unsafe fn decode(
3309            &mut self,
3310            decoder: &mut fidl::encoding::Decoder<
3311                '_,
3312                fidl::encoding::DefaultFuchsiaResourceDialect,
3313            >,
3314            offset: usize,
3315            _depth: fidl::encoding::Depth,
3316        ) -> fidl::Result<()> {
3317            decoder.debug_check_bounds::<Self>(offset);
3318            // Verify that padding bytes are zero.
3319            fidl::decode!(
3320                ProviderConfig,
3321                fidl::encoding::DefaultFuchsiaResourceDialect,
3322                &mut self.config,
3323                decoder,
3324                offset + 0,
3325                _depth
3326            )?;
3327            Ok(())
3328        }
3329    }
3330
3331    impl fidl::encoding::ResourceTypeMarker for ProviderV2InitializeRequest {
3332        type Borrowed<'a> = &'a mut Self;
3333        fn take_or_borrow<'a>(
3334            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3335        ) -> Self::Borrowed<'a> {
3336            value
3337        }
3338    }
3339
3340    unsafe impl fidl::encoding::TypeMarker for ProviderV2InitializeRequest {
3341        type Owned = Self;
3342
3343        #[inline(always)]
3344        fn inline_align(_context: fidl::encoding::Context) -> usize {
3345            8
3346        }
3347
3348        #[inline(always)]
3349        fn inline_size(_context: fidl::encoding::Context) -> usize {
3350            16
3351        }
3352    }
3353
3354    unsafe impl
3355        fidl::encoding::Encode<
3356            ProviderV2InitializeRequest,
3357            fidl::encoding::DefaultFuchsiaResourceDialect,
3358        > for &mut ProviderV2InitializeRequest
3359    {
3360        #[inline]
3361        unsafe fn encode(
3362            self,
3363            encoder: &mut fidl::encoding::Encoder<
3364                '_,
3365                fidl::encoding::DefaultFuchsiaResourceDialect,
3366            >,
3367            offset: usize,
3368            _depth: fidl::encoding::Depth,
3369        ) -> fidl::Result<()> {
3370            encoder.debug_check_bounds::<ProviderV2InitializeRequest>(offset);
3371            // Delegate to tuple encoding.
3372            fidl::encoding::Encode::<
3373                ProviderV2InitializeRequest,
3374                fidl::encoding::DefaultFuchsiaResourceDialect,
3375            >::encode(
3376                (<ProviderConfigV2 as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3377                    &mut self.config,
3378                ),),
3379                encoder,
3380                offset,
3381                _depth,
3382            )
3383        }
3384    }
3385    unsafe impl<
3386        T0: fidl::encoding::Encode<ProviderConfigV2, fidl::encoding::DefaultFuchsiaResourceDialect>,
3387    >
3388        fidl::encoding::Encode<
3389            ProviderV2InitializeRequest,
3390            fidl::encoding::DefaultFuchsiaResourceDialect,
3391        > for (T0,)
3392    {
3393        #[inline]
3394        unsafe fn encode(
3395            self,
3396            encoder: &mut fidl::encoding::Encoder<
3397                '_,
3398                fidl::encoding::DefaultFuchsiaResourceDialect,
3399            >,
3400            offset: usize,
3401            depth: fidl::encoding::Depth,
3402        ) -> fidl::Result<()> {
3403            encoder.debug_check_bounds::<ProviderV2InitializeRequest>(offset);
3404            // Zero out padding regions. There's no need to apply masks
3405            // because the unmasked parts will be overwritten by fields.
3406            // Write the fields.
3407            self.0.encode(encoder, offset + 0, depth)?;
3408            Ok(())
3409        }
3410    }
3411
3412    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3413        for ProviderV2InitializeRequest
3414    {
3415        #[inline(always)]
3416        fn new_empty() -> Self {
3417            Self {
3418                config: fidl::new_empty!(
3419                    ProviderConfigV2,
3420                    fidl::encoding::DefaultFuchsiaResourceDialect
3421                ),
3422            }
3423        }
3424
3425        #[inline]
3426        unsafe fn decode(
3427            &mut self,
3428            decoder: &mut fidl::encoding::Decoder<
3429                '_,
3430                fidl::encoding::DefaultFuchsiaResourceDialect,
3431            >,
3432            offset: usize,
3433            _depth: fidl::encoding::Depth,
3434        ) -> fidl::Result<()> {
3435            decoder.debug_check_bounds::<Self>(offset);
3436            // Verify that padding bytes are zero.
3437            fidl::decode!(
3438                ProviderConfigV2,
3439                fidl::encoding::DefaultFuchsiaResourceDialect,
3440                &mut self.config,
3441                decoder,
3442                offset + 0,
3443                _depth
3444            )?;
3445            Ok(())
3446        }
3447    }
3448
3449    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterProviderRequest {
3450        type Borrowed<'a> = &'a mut Self;
3451        fn take_or_borrow<'a>(
3452            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3453        ) -> Self::Borrowed<'a> {
3454            value
3455        }
3456    }
3457
3458    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterProviderRequest {
3459        type Owned = Self;
3460
3461        #[inline(always)]
3462        fn inline_align(_context: fidl::encoding::Context) -> usize {
3463            8
3464        }
3465
3466        #[inline(always)]
3467        fn inline_size(_context: fidl::encoding::Context) -> usize {
3468            32
3469        }
3470    }
3471
3472    unsafe impl
3473        fidl::encoding::Encode<
3474            RegistryRegisterProviderRequest,
3475            fidl::encoding::DefaultFuchsiaResourceDialect,
3476        > for &mut RegistryRegisterProviderRequest
3477    {
3478        #[inline]
3479        unsafe fn encode(
3480            self,
3481            encoder: &mut fidl::encoding::Encoder<
3482                '_,
3483                fidl::encoding::DefaultFuchsiaResourceDialect,
3484            >,
3485            offset: usize,
3486            _depth: fidl::encoding::Depth,
3487        ) -> fidl::Result<()> {
3488            encoder.debug_check_bounds::<RegistryRegisterProviderRequest>(offset);
3489            // Delegate to tuple encoding.
3490            fidl::encoding::Encode::<RegistryRegisterProviderRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3491                (
3492                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.provider),
3493                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pid),
3494                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
3495                ),
3496                encoder, offset, _depth
3497            )
3498        }
3499    }
3500    unsafe impl<
3501        T0: fidl::encoding::Encode<
3502                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
3503                fidl::encoding::DefaultFuchsiaResourceDialect,
3504            >,
3505        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
3506        T2: fidl::encoding::Encode<
3507                fidl::encoding::BoundedString<100>,
3508                fidl::encoding::DefaultFuchsiaResourceDialect,
3509            >,
3510    >
3511        fidl::encoding::Encode<
3512            RegistryRegisterProviderRequest,
3513            fidl::encoding::DefaultFuchsiaResourceDialect,
3514        > for (T0, T1, T2)
3515    {
3516        #[inline]
3517        unsafe fn encode(
3518            self,
3519            encoder: &mut fidl::encoding::Encoder<
3520                '_,
3521                fidl::encoding::DefaultFuchsiaResourceDialect,
3522            >,
3523            offset: usize,
3524            depth: fidl::encoding::Depth,
3525        ) -> fidl::Result<()> {
3526            encoder.debug_check_bounds::<RegistryRegisterProviderRequest>(offset);
3527            // Zero out padding regions. There's no need to apply masks
3528            // because the unmasked parts will be overwritten by fields.
3529            unsafe {
3530                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3531                (ptr as *mut u64).write_unaligned(0);
3532            }
3533            // Write the fields.
3534            self.0.encode(encoder, offset + 0, depth)?;
3535            self.1.encode(encoder, offset + 8, depth)?;
3536            self.2.encode(encoder, offset + 16, depth)?;
3537            Ok(())
3538        }
3539    }
3540
3541    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3542        for RegistryRegisterProviderRequest
3543    {
3544        #[inline(always)]
3545        fn new_empty() -> Self {
3546            Self {
3547                provider: fidl::new_empty!(
3548                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
3549                    fidl::encoding::DefaultFuchsiaResourceDialect
3550                ),
3551                pid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
3552                name: fidl::new_empty!(
3553                    fidl::encoding::BoundedString<100>,
3554                    fidl::encoding::DefaultFuchsiaResourceDialect
3555                ),
3556            }
3557        }
3558
3559        #[inline]
3560        unsafe fn decode(
3561            &mut self,
3562            decoder: &mut fidl::encoding::Decoder<
3563                '_,
3564                fidl::encoding::DefaultFuchsiaResourceDialect,
3565            >,
3566            offset: usize,
3567            _depth: fidl::encoding::Depth,
3568        ) -> fidl::Result<()> {
3569            decoder.debug_check_bounds::<Self>(offset);
3570            // Verify that padding bytes are zero.
3571            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3572            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3573            let mask = 0xffffffff00000000u64;
3574            let maskedval = padval & mask;
3575            if maskedval != 0 {
3576                return Err(fidl::Error::NonZeroPadding {
3577                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3578                });
3579            }
3580            fidl::decode!(
3581                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
3582                fidl::encoding::DefaultFuchsiaResourceDialect,
3583                &mut self.provider,
3584                decoder,
3585                offset + 0,
3586                _depth
3587            )?;
3588            fidl::decode!(
3589                u64,
3590                fidl::encoding::DefaultFuchsiaResourceDialect,
3591                &mut self.pid,
3592                decoder,
3593                offset + 8,
3594                _depth
3595            )?;
3596            fidl::decode!(
3597                fidl::encoding::BoundedString<100>,
3598                fidl::encoding::DefaultFuchsiaResourceDialect,
3599                &mut self.name,
3600                decoder,
3601                offset + 16,
3602                _depth
3603            )?;
3604            Ok(())
3605        }
3606    }
3607
3608    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterProviderSynchronouslyRequest {
3609        type Borrowed<'a> = &'a mut Self;
3610        fn take_or_borrow<'a>(
3611            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3612        ) -> Self::Borrowed<'a> {
3613            value
3614        }
3615    }
3616
3617    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterProviderSynchronouslyRequest {
3618        type Owned = Self;
3619
3620        #[inline(always)]
3621        fn inline_align(_context: fidl::encoding::Context) -> usize {
3622            8
3623        }
3624
3625        #[inline(always)]
3626        fn inline_size(_context: fidl::encoding::Context) -> usize {
3627            32
3628        }
3629    }
3630
3631    unsafe impl
3632        fidl::encoding::Encode<
3633            RegistryRegisterProviderSynchronouslyRequest,
3634            fidl::encoding::DefaultFuchsiaResourceDialect,
3635        > for &mut RegistryRegisterProviderSynchronouslyRequest
3636    {
3637        #[inline]
3638        unsafe fn encode(
3639            self,
3640            encoder: &mut fidl::encoding::Encoder<
3641                '_,
3642                fidl::encoding::DefaultFuchsiaResourceDialect,
3643            >,
3644            offset: usize,
3645            _depth: fidl::encoding::Depth,
3646        ) -> fidl::Result<()> {
3647            encoder.debug_check_bounds::<RegistryRegisterProviderSynchronouslyRequest>(offset);
3648            // Delegate to tuple encoding.
3649            fidl::encoding::Encode::<RegistryRegisterProviderSynchronouslyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3650                (
3651                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.provider),
3652                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pid),
3653                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
3654                ),
3655                encoder, offset, _depth
3656            )
3657        }
3658    }
3659    unsafe impl<
3660        T0: fidl::encoding::Encode<
3661                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
3662                fidl::encoding::DefaultFuchsiaResourceDialect,
3663            >,
3664        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
3665        T2: fidl::encoding::Encode<
3666                fidl::encoding::BoundedString<100>,
3667                fidl::encoding::DefaultFuchsiaResourceDialect,
3668            >,
3669    >
3670        fidl::encoding::Encode<
3671            RegistryRegisterProviderSynchronouslyRequest,
3672            fidl::encoding::DefaultFuchsiaResourceDialect,
3673        > for (T0, T1, T2)
3674    {
3675        #[inline]
3676        unsafe fn encode(
3677            self,
3678            encoder: &mut fidl::encoding::Encoder<
3679                '_,
3680                fidl::encoding::DefaultFuchsiaResourceDialect,
3681            >,
3682            offset: usize,
3683            depth: fidl::encoding::Depth,
3684        ) -> fidl::Result<()> {
3685            encoder.debug_check_bounds::<RegistryRegisterProviderSynchronouslyRequest>(offset);
3686            // Zero out padding regions. There's no need to apply masks
3687            // because the unmasked parts will be overwritten by fields.
3688            unsafe {
3689                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3690                (ptr as *mut u64).write_unaligned(0);
3691            }
3692            // Write the fields.
3693            self.0.encode(encoder, offset + 0, depth)?;
3694            self.1.encode(encoder, offset + 8, depth)?;
3695            self.2.encode(encoder, offset + 16, depth)?;
3696            Ok(())
3697        }
3698    }
3699
3700    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3701        for RegistryRegisterProviderSynchronouslyRequest
3702    {
3703        #[inline(always)]
3704        fn new_empty() -> Self {
3705            Self {
3706                provider: fidl::new_empty!(
3707                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
3708                    fidl::encoding::DefaultFuchsiaResourceDialect
3709                ),
3710                pid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
3711                name: fidl::new_empty!(
3712                    fidl::encoding::BoundedString<100>,
3713                    fidl::encoding::DefaultFuchsiaResourceDialect
3714                ),
3715            }
3716        }
3717
3718        #[inline]
3719        unsafe fn decode(
3720            &mut self,
3721            decoder: &mut fidl::encoding::Decoder<
3722                '_,
3723                fidl::encoding::DefaultFuchsiaResourceDialect,
3724            >,
3725            offset: usize,
3726            _depth: fidl::encoding::Depth,
3727        ) -> fidl::Result<()> {
3728            decoder.debug_check_bounds::<Self>(offset);
3729            // Verify that padding bytes are zero.
3730            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3731            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3732            let mask = 0xffffffff00000000u64;
3733            let maskedval = padval & mask;
3734            if maskedval != 0 {
3735                return Err(fidl::Error::NonZeroPadding {
3736                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3737                });
3738            }
3739            fidl::decode!(
3740                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderMarker>>,
3741                fidl::encoding::DefaultFuchsiaResourceDialect,
3742                &mut self.provider,
3743                decoder,
3744                offset + 0,
3745                _depth
3746            )?;
3747            fidl::decode!(
3748                u64,
3749                fidl::encoding::DefaultFuchsiaResourceDialect,
3750                &mut self.pid,
3751                decoder,
3752                offset + 8,
3753                _depth
3754            )?;
3755            fidl::decode!(
3756                fidl::encoding::BoundedString<100>,
3757                fidl::encoding::DefaultFuchsiaResourceDialect,
3758                &mut self.name,
3759                decoder,
3760                offset + 16,
3761                _depth
3762            )?;
3763            Ok(())
3764        }
3765    }
3766
3767    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterV2Request {
3768        type Borrowed<'a> = &'a mut Self;
3769        fn take_or_borrow<'a>(
3770            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3771        ) -> Self::Borrowed<'a> {
3772            value
3773        }
3774    }
3775
3776    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterV2Request {
3777        type Owned = Self;
3778
3779        #[inline(always)]
3780        fn inline_align(_context: fidl::encoding::Context) -> usize {
3781            8
3782        }
3783
3784        #[inline(always)]
3785        fn inline_size(_context: fidl::encoding::Context) -> usize {
3786            32
3787        }
3788    }
3789
3790    unsafe impl
3791        fidl::encoding::Encode<
3792            RegistryRegisterV2Request,
3793            fidl::encoding::DefaultFuchsiaResourceDialect,
3794        > for &mut RegistryRegisterV2Request
3795    {
3796        #[inline]
3797        unsafe fn encode(
3798            self,
3799            encoder: &mut fidl::encoding::Encoder<
3800                '_,
3801                fidl::encoding::DefaultFuchsiaResourceDialect,
3802            >,
3803            offset: usize,
3804            _depth: fidl::encoding::Depth,
3805        ) -> fidl::Result<()> {
3806            encoder.debug_check_bounds::<RegistryRegisterV2Request>(offset);
3807            // Delegate to tuple encoding.
3808            fidl::encoding::Encode::<RegistryRegisterV2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3809                (
3810                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderV2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.provider),
3811                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pid),
3812                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
3813                ),
3814                encoder, offset, _depth
3815            )
3816        }
3817    }
3818    unsafe impl<
3819        T0: fidl::encoding::Encode<
3820                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderV2Marker>>,
3821                fidl::encoding::DefaultFuchsiaResourceDialect,
3822            >,
3823        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
3824        T2: fidl::encoding::Encode<
3825                fidl::encoding::BoundedString<100>,
3826                fidl::encoding::DefaultFuchsiaResourceDialect,
3827            >,
3828    >
3829        fidl::encoding::Encode<
3830            RegistryRegisterV2Request,
3831            fidl::encoding::DefaultFuchsiaResourceDialect,
3832        > for (T0, T1, T2)
3833    {
3834        #[inline]
3835        unsafe fn encode(
3836            self,
3837            encoder: &mut fidl::encoding::Encoder<
3838                '_,
3839                fidl::encoding::DefaultFuchsiaResourceDialect,
3840            >,
3841            offset: usize,
3842            depth: fidl::encoding::Depth,
3843        ) -> fidl::Result<()> {
3844            encoder.debug_check_bounds::<RegistryRegisterV2Request>(offset);
3845            // Zero out padding regions. There's no need to apply masks
3846            // because the unmasked parts will be overwritten by fields.
3847            unsafe {
3848                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3849                (ptr as *mut u64).write_unaligned(0);
3850            }
3851            // Write the fields.
3852            self.0.encode(encoder, offset + 0, depth)?;
3853            self.1.encode(encoder, offset + 8, depth)?;
3854            self.2.encode(encoder, offset + 16, depth)?;
3855            Ok(())
3856        }
3857    }
3858
3859    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3860        for RegistryRegisterV2Request
3861    {
3862        #[inline(always)]
3863        fn new_empty() -> Self {
3864            Self {
3865                provider: fidl::new_empty!(
3866                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderV2Marker>>,
3867                    fidl::encoding::DefaultFuchsiaResourceDialect
3868                ),
3869                pid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
3870                name: fidl::new_empty!(
3871                    fidl::encoding::BoundedString<100>,
3872                    fidl::encoding::DefaultFuchsiaResourceDialect
3873                ),
3874            }
3875        }
3876
3877        #[inline]
3878        unsafe fn decode(
3879            &mut self,
3880            decoder: &mut fidl::encoding::Decoder<
3881                '_,
3882                fidl::encoding::DefaultFuchsiaResourceDialect,
3883            >,
3884            offset: usize,
3885            _depth: fidl::encoding::Depth,
3886        ) -> fidl::Result<()> {
3887            decoder.debug_check_bounds::<Self>(offset);
3888            // Verify that padding bytes are zero.
3889            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3890            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3891            let mask = 0xffffffff00000000u64;
3892            let maskedval = padval & mask;
3893            if maskedval != 0 {
3894                return Err(fidl::Error::NonZeroPadding {
3895                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3896                });
3897            }
3898            fidl::decode!(
3899                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderV2Marker>>,
3900                fidl::encoding::DefaultFuchsiaResourceDialect,
3901                &mut self.provider,
3902                decoder,
3903                offset + 0,
3904                _depth
3905            )?;
3906            fidl::decode!(
3907                u64,
3908                fidl::encoding::DefaultFuchsiaResourceDialect,
3909                &mut self.pid,
3910                decoder,
3911                offset + 8,
3912                _depth
3913            )?;
3914            fidl::decode!(
3915                fidl::encoding::BoundedString<100>,
3916                fidl::encoding::DefaultFuchsiaResourceDialect,
3917                &mut self.name,
3918                decoder,
3919                offset + 16,
3920                _depth
3921            )?;
3922            Ok(())
3923        }
3924    }
3925
3926    impl fidl::encoding::ResourceTypeMarker for RegistryRegisterV2SynchronouslyRequest {
3927        type Borrowed<'a> = &'a mut Self;
3928        fn take_or_borrow<'a>(
3929            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3930        ) -> Self::Borrowed<'a> {
3931            value
3932        }
3933    }
3934
3935    unsafe impl fidl::encoding::TypeMarker for RegistryRegisterV2SynchronouslyRequest {
3936        type Owned = Self;
3937
3938        #[inline(always)]
3939        fn inline_align(_context: fidl::encoding::Context) -> usize {
3940            8
3941        }
3942
3943        #[inline(always)]
3944        fn inline_size(_context: fidl::encoding::Context) -> usize {
3945            32
3946        }
3947    }
3948
3949    unsafe impl
3950        fidl::encoding::Encode<
3951            RegistryRegisterV2SynchronouslyRequest,
3952            fidl::encoding::DefaultFuchsiaResourceDialect,
3953        > for &mut RegistryRegisterV2SynchronouslyRequest
3954    {
3955        #[inline]
3956        unsafe fn encode(
3957            self,
3958            encoder: &mut fidl::encoding::Encoder<
3959                '_,
3960                fidl::encoding::DefaultFuchsiaResourceDialect,
3961            >,
3962            offset: usize,
3963            _depth: fidl::encoding::Depth,
3964        ) -> fidl::Result<()> {
3965            encoder.debug_check_bounds::<RegistryRegisterV2SynchronouslyRequest>(offset);
3966            // Delegate to tuple encoding.
3967            fidl::encoding::Encode::<RegistryRegisterV2SynchronouslyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3968                (
3969                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderV2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.provider),
3970                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.pid),
3971                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
3972                ),
3973                encoder, offset, _depth
3974            )
3975        }
3976    }
3977    unsafe impl<
3978        T0: fidl::encoding::Encode<
3979                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderV2Marker>>,
3980                fidl::encoding::DefaultFuchsiaResourceDialect,
3981            >,
3982        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
3983        T2: fidl::encoding::Encode<
3984                fidl::encoding::BoundedString<100>,
3985                fidl::encoding::DefaultFuchsiaResourceDialect,
3986            >,
3987    >
3988        fidl::encoding::Encode<
3989            RegistryRegisterV2SynchronouslyRequest,
3990            fidl::encoding::DefaultFuchsiaResourceDialect,
3991        > for (T0, T1, T2)
3992    {
3993        #[inline]
3994        unsafe fn encode(
3995            self,
3996            encoder: &mut fidl::encoding::Encoder<
3997                '_,
3998                fidl::encoding::DefaultFuchsiaResourceDialect,
3999            >,
4000            offset: usize,
4001            depth: fidl::encoding::Depth,
4002        ) -> fidl::Result<()> {
4003            encoder.debug_check_bounds::<RegistryRegisterV2SynchronouslyRequest>(offset);
4004            // Zero out padding regions. There's no need to apply masks
4005            // because the unmasked parts will be overwritten by fields.
4006            unsafe {
4007                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
4008                (ptr as *mut u64).write_unaligned(0);
4009            }
4010            // Write the fields.
4011            self.0.encode(encoder, offset + 0, depth)?;
4012            self.1.encode(encoder, offset + 8, depth)?;
4013            self.2.encode(encoder, offset + 16, depth)?;
4014            Ok(())
4015        }
4016    }
4017
4018    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4019        for RegistryRegisterV2SynchronouslyRequest
4020    {
4021        #[inline(always)]
4022        fn new_empty() -> Self {
4023            Self {
4024                provider: fidl::new_empty!(
4025                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderV2Marker>>,
4026                    fidl::encoding::DefaultFuchsiaResourceDialect
4027                ),
4028                pid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
4029                name: fidl::new_empty!(
4030                    fidl::encoding::BoundedString<100>,
4031                    fidl::encoding::DefaultFuchsiaResourceDialect
4032                ),
4033            }
4034        }
4035
4036        #[inline]
4037        unsafe fn decode(
4038            &mut self,
4039            decoder: &mut fidl::encoding::Decoder<
4040                '_,
4041                fidl::encoding::DefaultFuchsiaResourceDialect,
4042            >,
4043            offset: usize,
4044            _depth: fidl::encoding::Depth,
4045        ) -> fidl::Result<()> {
4046            decoder.debug_check_bounds::<Self>(offset);
4047            // Verify that padding bytes are zero.
4048            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
4049            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4050            let mask = 0xffffffff00000000u64;
4051            let maskedval = padval & mask;
4052            if maskedval != 0 {
4053                return Err(fidl::Error::NonZeroPadding {
4054                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
4055                });
4056            }
4057            fidl::decode!(
4058                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProviderV2Marker>>,
4059                fidl::encoding::DefaultFuchsiaResourceDialect,
4060                &mut self.provider,
4061                decoder,
4062                offset + 0,
4063                _depth
4064            )?;
4065            fidl::decode!(
4066                u64,
4067                fidl::encoding::DefaultFuchsiaResourceDialect,
4068                &mut self.pid,
4069                decoder,
4070                offset + 8,
4071                _depth
4072            )?;
4073            fidl::decode!(
4074                fidl::encoding::BoundedString<100>,
4075                fidl::encoding::DefaultFuchsiaResourceDialect,
4076                &mut self.name,
4077                decoder,
4078                offset + 16,
4079                _depth
4080            )?;
4081            Ok(())
4082        }
4083    }
4084
4085    impl ProviderConfigV2 {
4086        #[inline(always)]
4087        fn max_ordinal_present(&self) -> u64 {
4088            if let Some(_) = self.categories {
4089                return 3;
4090            }
4091            if let Some(_) = self.buffer {
4092                return 2;
4093            }
4094            if let Some(_) = self.buffering_mode {
4095                return 1;
4096            }
4097            0
4098        }
4099    }
4100
4101    impl fidl::encoding::ResourceTypeMarker for ProviderConfigV2 {
4102        type Borrowed<'a> = &'a mut Self;
4103        fn take_or_borrow<'a>(
4104            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4105        ) -> Self::Borrowed<'a> {
4106            value
4107        }
4108    }
4109
4110    unsafe impl fidl::encoding::TypeMarker for ProviderConfigV2 {
4111        type Owned = Self;
4112
4113        #[inline(always)]
4114        fn inline_align(_context: fidl::encoding::Context) -> usize {
4115            8
4116        }
4117
4118        #[inline(always)]
4119        fn inline_size(_context: fidl::encoding::Context) -> usize {
4120            16
4121        }
4122    }
4123
4124    unsafe impl
4125        fidl::encoding::Encode<ProviderConfigV2, fidl::encoding::DefaultFuchsiaResourceDialect>
4126        for &mut ProviderConfigV2
4127    {
4128        unsafe fn encode(
4129            self,
4130            encoder: &mut fidl::encoding::Encoder<
4131                '_,
4132                fidl::encoding::DefaultFuchsiaResourceDialect,
4133            >,
4134            offset: usize,
4135            mut depth: fidl::encoding::Depth,
4136        ) -> fidl::Result<()> {
4137            encoder.debug_check_bounds::<ProviderConfigV2>(offset);
4138            // Vector header
4139            let max_ordinal: u64 = self.max_ordinal_present();
4140            encoder.write_num(max_ordinal, offset);
4141            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4142            // Calling encoder.out_of_line_offset(0) is not allowed.
4143            if max_ordinal == 0 {
4144                return Ok(());
4145            }
4146            depth.increment()?;
4147            let envelope_size = 8;
4148            let bytes_len = max_ordinal as usize * envelope_size;
4149            #[allow(unused_variables)]
4150            let offset = encoder.out_of_line_offset(bytes_len);
4151            let mut _prev_end_offset: usize = 0;
4152            if 1 > max_ordinal {
4153                return Ok(());
4154            }
4155
4156            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4157            // are envelope_size bytes.
4158            let cur_offset: usize = (1 - 1) * envelope_size;
4159
4160            // Zero reserved fields.
4161            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4162
4163            // Safety:
4164            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4165            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4166            //   envelope_size bytes, there is always sufficient room.
4167            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_tracing::BufferingMode, fidl::encoding::DefaultFuchsiaResourceDialect>(
4168            self.buffering_mode.as_ref().map(<fidl_fuchsia_tracing::BufferingMode as fidl::encoding::ValueTypeMarker>::borrow),
4169            encoder, offset + cur_offset, depth
4170        )?;
4171
4172            _prev_end_offset = cur_offset + envelope_size;
4173            if 2 > max_ordinal {
4174                return Ok(());
4175            }
4176
4177            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4178            // are envelope_size bytes.
4179            let cur_offset: usize = (2 - 1) * envelope_size;
4180
4181            // Zero reserved fields.
4182            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4183
4184            // Safety:
4185            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4186            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4187            //   envelope_size bytes, there is always sufficient room.
4188            fidl::encoding::encode_in_envelope_optional::<
4189                fidl::encoding::HandleType<
4190                    fidl::Vmo,
4191                    { fidl::ObjectType::VMO.into_raw() },
4192                    2147483648,
4193                >,
4194                fidl::encoding::DefaultFuchsiaResourceDialect,
4195            >(
4196                self.buffer.as_mut().map(
4197                    <fidl::encoding::HandleType<
4198                        fidl::Vmo,
4199                        { fidl::ObjectType::VMO.into_raw() },
4200                        2147483648,
4201                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4202                ),
4203                encoder,
4204                offset + cur_offset,
4205                depth,
4206            )?;
4207
4208            _prev_end_offset = cur_offset + envelope_size;
4209            if 3 > max_ordinal {
4210                return Ok(());
4211            }
4212
4213            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4214            // are envelope_size bytes.
4215            let cur_offset: usize = (3 - 1) * envelope_size;
4216
4217            // Zero reserved fields.
4218            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4219
4220            // Safety:
4221            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4222            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4223            //   envelope_size bytes, there is always sufficient room.
4224            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4225            self.categories.as_ref().map(<fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000> as fidl::encoding::ValueTypeMarker>::borrow),
4226            encoder, offset + cur_offset, depth
4227        )?;
4228
4229            _prev_end_offset = cur_offset + envelope_size;
4230
4231            Ok(())
4232        }
4233    }
4234
4235    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4236        for ProviderConfigV2
4237    {
4238        #[inline(always)]
4239        fn new_empty() -> Self {
4240            Self::default()
4241        }
4242
4243        unsafe fn decode(
4244            &mut self,
4245            decoder: &mut fidl::encoding::Decoder<
4246                '_,
4247                fidl::encoding::DefaultFuchsiaResourceDialect,
4248            >,
4249            offset: usize,
4250            mut depth: fidl::encoding::Depth,
4251        ) -> fidl::Result<()> {
4252            decoder.debug_check_bounds::<Self>(offset);
4253            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4254                None => return Err(fidl::Error::NotNullable),
4255                Some(len) => len,
4256            };
4257            // Calling decoder.out_of_line_offset(0) is not allowed.
4258            if len == 0 {
4259                return Ok(());
4260            };
4261            depth.increment()?;
4262            let envelope_size = 8;
4263            let bytes_len = len * envelope_size;
4264            let offset = decoder.out_of_line_offset(bytes_len)?;
4265            // Decode the envelope for each type.
4266            let mut _next_ordinal_to_read = 0;
4267            let mut next_offset = offset;
4268            let end_offset = offset + bytes_len;
4269            _next_ordinal_to_read += 1;
4270            if next_offset >= end_offset {
4271                return Ok(());
4272            }
4273
4274            // Decode unknown envelopes for gaps in ordinals.
4275            while _next_ordinal_to_read < 1 {
4276                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4277                _next_ordinal_to_read += 1;
4278                next_offset += envelope_size;
4279            }
4280
4281            let next_out_of_line = decoder.next_out_of_line();
4282            let handles_before = decoder.remaining_handles();
4283            if let Some((inlined, num_bytes, num_handles)) =
4284                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4285            {
4286                let member_inline_size = <fidl_fuchsia_tracing::BufferingMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4287                if inlined != (member_inline_size <= 4) {
4288                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4289                }
4290                let inner_offset;
4291                let mut inner_depth = depth.clone();
4292                if inlined {
4293                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4294                    inner_offset = next_offset;
4295                } else {
4296                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4297                    inner_depth.increment()?;
4298                }
4299                let val_ref = self.buffering_mode.get_or_insert_with(|| {
4300                    fidl::new_empty!(
4301                        fidl_fuchsia_tracing::BufferingMode,
4302                        fidl::encoding::DefaultFuchsiaResourceDialect
4303                    )
4304                });
4305                fidl::decode!(
4306                    fidl_fuchsia_tracing::BufferingMode,
4307                    fidl::encoding::DefaultFuchsiaResourceDialect,
4308                    val_ref,
4309                    decoder,
4310                    inner_offset,
4311                    inner_depth
4312                )?;
4313                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4314                {
4315                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4316                }
4317                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4318                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4319                }
4320            }
4321
4322            next_offset += envelope_size;
4323            _next_ordinal_to_read += 1;
4324            if next_offset >= end_offset {
4325                return Ok(());
4326            }
4327
4328            // Decode unknown envelopes for gaps in ordinals.
4329            while _next_ordinal_to_read < 2 {
4330                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4331                _next_ordinal_to_read += 1;
4332                next_offset += envelope_size;
4333            }
4334
4335            let next_out_of_line = decoder.next_out_of_line();
4336            let handles_before = decoder.remaining_handles();
4337            if let Some((inlined, num_bytes, num_handles)) =
4338                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4339            {
4340                let member_inline_size = <fidl::encoding::HandleType<
4341                    fidl::Vmo,
4342                    { fidl::ObjectType::VMO.into_raw() },
4343                    2147483648,
4344                > as fidl::encoding::TypeMarker>::inline_size(
4345                    decoder.context
4346                );
4347                if inlined != (member_inline_size <= 4) {
4348                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4349                }
4350                let inner_offset;
4351                let mut inner_depth = depth.clone();
4352                if inlined {
4353                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4354                    inner_offset = next_offset;
4355                } else {
4356                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4357                    inner_depth.increment()?;
4358                }
4359                let val_ref =
4360                self.buffer.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4361                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4362                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4363                {
4364                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4365                }
4366                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4367                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4368                }
4369            }
4370
4371            next_offset += envelope_size;
4372            _next_ordinal_to_read += 1;
4373            if next_offset >= end_offset {
4374                return Ok(());
4375            }
4376
4377            // Decode unknown envelopes for gaps in ordinals.
4378            while _next_ordinal_to_read < 3 {
4379                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4380                _next_ordinal_to_read += 1;
4381                next_offset += envelope_size;
4382            }
4383
4384            let next_out_of_line = decoder.next_out_of_line();
4385            let handles_before = decoder.remaining_handles();
4386            if let Some((inlined, num_bytes, num_handles)) =
4387                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4388            {
4389                let member_inline_size = <fidl::encoding::Vector<
4390                    fidl::encoding::BoundedString<100>,
4391                    5000,
4392                > as fidl::encoding::TypeMarker>::inline_size(
4393                    decoder.context
4394                );
4395                if inlined != (member_inline_size <= 4) {
4396                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4397                }
4398                let inner_offset;
4399                let mut inner_depth = depth.clone();
4400                if inlined {
4401                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4402                    inner_offset = next_offset;
4403                } else {
4404                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4405                    inner_depth.increment()?;
4406                }
4407                let val_ref = self.categories.get_or_insert_with(|| {
4408                    fidl::new_empty!(
4409                        fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
4410                        fidl::encoding::DefaultFuchsiaResourceDialect
4411                    )
4412                });
4413                fidl::decode!(
4414                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 5000>,
4415                    fidl::encoding::DefaultFuchsiaResourceDialect,
4416                    val_ref,
4417                    decoder,
4418                    inner_offset,
4419                    inner_depth
4420                )?;
4421                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4422                {
4423                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4424                }
4425                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4426                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4427                }
4428            }
4429
4430            next_offset += envelope_size;
4431
4432            // Decode the remaining unknown envelopes.
4433            while next_offset < end_offset {
4434                _next_ordinal_to_read += 1;
4435                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4436                next_offset += envelope_size;
4437            }
4438
4439            Ok(())
4440        }
4441    }
4442}