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