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