fidl_fuchsia_cobalt/
fidl_fuchsia_cobalt.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_cobalt__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct AggregateAndUploadMarker;
16
17impl fidl::endpoints::ProtocolMarker for AggregateAndUploadMarker {
18    type Proxy = AggregateAndUploadProxy;
19    type RequestStream = AggregateAndUploadRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = AggregateAndUploadSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.cobalt.AggregateAndUpload";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for AggregateAndUploadMarker {}
26
27pub trait AggregateAndUploadProxyInterface: Send + Sync {
28    type AggregateAndUploadMetricEventsResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
29        + Send;
30    fn r#aggregate_and_upload_metric_events(
31        &self,
32    ) -> Self::AggregateAndUploadMetricEventsResponseFut;
33}
34#[derive(Debug)]
35#[cfg(target_os = "fuchsia")]
36pub struct AggregateAndUploadSynchronousProxy {
37    client: fidl::client::sync::Client,
38}
39
40#[cfg(target_os = "fuchsia")]
41impl fidl::endpoints::SynchronousProxy for AggregateAndUploadSynchronousProxy {
42    type Proxy = AggregateAndUploadProxy;
43    type Protocol = AggregateAndUploadMarker;
44
45    fn from_channel(inner: fidl::Channel) -> Self {
46        Self::new(inner)
47    }
48
49    fn into_channel(self) -> fidl::Channel {
50        self.client.into_channel()
51    }
52
53    fn as_channel(&self) -> &fidl::Channel {
54        self.client.as_channel()
55    }
56}
57
58#[cfg(target_os = "fuchsia")]
59impl AggregateAndUploadSynchronousProxy {
60    pub fn new(channel: fidl::Channel) -> Self {
61        let protocol_name =
62            <AggregateAndUploadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
63        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
64    }
65
66    pub fn into_channel(self) -> fidl::Channel {
67        self.client.into_channel()
68    }
69
70    /// Waits until an event arrives and returns it. It is safe for other
71    /// threads to make concurrent requests while waiting for an event.
72    pub fn wait_for_event(
73        &self,
74        deadline: zx::MonotonicInstant,
75    ) -> Result<AggregateAndUploadEvent, fidl::Error> {
76        AggregateAndUploadEvent::decode(self.client.wait_for_event(deadline)?)
77    }
78
79    pub fn r#aggregate_and_upload_metric_events(
80        &self,
81        ___deadline: zx::MonotonicInstant,
82    ) -> Result<(), fidl::Error> {
83        let _response =
84            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
85                (),
86                0x48db82fb20a16550,
87                fidl::encoding::DynamicFlags::empty(),
88                ___deadline,
89            )?;
90        Ok(_response)
91    }
92}
93
94#[cfg(target_os = "fuchsia")]
95impl From<AggregateAndUploadSynchronousProxy> for zx::Handle {
96    fn from(value: AggregateAndUploadSynchronousProxy) -> Self {
97        value.into_channel().into()
98    }
99}
100
101#[cfg(target_os = "fuchsia")]
102impl From<fidl::Channel> for AggregateAndUploadSynchronousProxy {
103    fn from(value: fidl::Channel) -> Self {
104        Self::new(value)
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl fidl::endpoints::FromClient for AggregateAndUploadSynchronousProxy {
110    type Protocol = AggregateAndUploadMarker;
111
112    fn from_client(value: fidl::endpoints::ClientEnd<AggregateAndUploadMarker>) -> Self {
113        Self::new(value.into_channel())
114    }
115}
116
117#[derive(Debug, Clone)]
118pub struct AggregateAndUploadProxy {
119    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
120}
121
122impl fidl::endpoints::Proxy for AggregateAndUploadProxy {
123    type Protocol = AggregateAndUploadMarker;
124
125    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
126        Self::new(inner)
127    }
128
129    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
130        self.client.into_channel().map_err(|client| Self { client })
131    }
132
133    fn as_channel(&self) -> &::fidl::AsyncChannel {
134        self.client.as_channel()
135    }
136}
137
138impl AggregateAndUploadProxy {
139    /// Create a new Proxy for fuchsia.cobalt/AggregateAndUpload.
140    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
141        let protocol_name =
142            <AggregateAndUploadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
143        Self { client: fidl::client::Client::new(channel, protocol_name) }
144    }
145
146    /// Get a Stream of events from the remote end of the protocol.
147    ///
148    /// # Panics
149    ///
150    /// Panics if the event stream was already taken.
151    pub fn take_event_stream(&self) -> AggregateAndUploadEventStream {
152        AggregateAndUploadEventStream { event_receiver: self.client.take_event_receiver() }
153    }
154
155    pub fn r#aggregate_and_upload_metric_events(
156        &self,
157    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
158        AggregateAndUploadProxyInterface::r#aggregate_and_upload_metric_events(self)
159    }
160}
161
162impl AggregateAndUploadProxyInterface for AggregateAndUploadProxy {
163    type AggregateAndUploadMetricEventsResponseFut =
164        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
165    fn r#aggregate_and_upload_metric_events(
166        &self,
167    ) -> Self::AggregateAndUploadMetricEventsResponseFut {
168        fn _decode(
169            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
170        ) -> Result<(), fidl::Error> {
171            let _response = fidl::client::decode_transaction_body::<
172                fidl::encoding::EmptyPayload,
173                fidl::encoding::DefaultFuchsiaResourceDialect,
174                0x48db82fb20a16550,
175            >(_buf?)?;
176            Ok(_response)
177        }
178        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
179            (),
180            0x48db82fb20a16550,
181            fidl::encoding::DynamicFlags::empty(),
182            _decode,
183        )
184    }
185}
186
187pub struct AggregateAndUploadEventStream {
188    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
189}
190
191impl std::marker::Unpin for AggregateAndUploadEventStream {}
192
193impl futures::stream::FusedStream for AggregateAndUploadEventStream {
194    fn is_terminated(&self) -> bool {
195        self.event_receiver.is_terminated()
196    }
197}
198
199impl futures::Stream for AggregateAndUploadEventStream {
200    type Item = Result<AggregateAndUploadEvent, fidl::Error>;
201
202    fn poll_next(
203        mut self: std::pin::Pin<&mut Self>,
204        cx: &mut std::task::Context<'_>,
205    ) -> std::task::Poll<Option<Self::Item>> {
206        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
207            &mut self.event_receiver,
208            cx
209        )?) {
210            Some(buf) => std::task::Poll::Ready(Some(AggregateAndUploadEvent::decode(buf))),
211            None => std::task::Poll::Ready(None),
212        }
213    }
214}
215
216#[derive(Debug)]
217pub enum AggregateAndUploadEvent {}
218
219impl AggregateAndUploadEvent {
220    /// Decodes a message buffer as a [`AggregateAndUploadEvent`].
221    fn decode(
222        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
223    ) -> Result<AggregateAndUploadEvent, fidl::Error> {
224        let (bytes, _handles) = buf.split_mut();
225        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
226        debug_assert_eq!(tx_header.tx_id, 0);
227        match tx_header.ordinal {
228            _ => Err(fidl::Error::UnknownOrdinal {
229                ordinal: tx_header.ordinal,
230                protocol_name:
231                    <AggregateAndUploadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
232            }),
233        }
234    }
235}
236
237/// A Stream of incoming requests for fuchsia.cobalt/AggregateAndUpload.
238pub struct AggregateAndUploadRequestStream {
239    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
240    is_terminated: bool,
241}
242
243impl std::marker::Unpin for AggregateAndUploadRequestStream {}
244
245impl futures::stream::FusedStream for AggregateAndUploadRequestStream {
246    fn is_terminated(&self) -> bool {
247        self.is_terminated
248    }
249}
250
251impl fidl::endpoints::RequestStream for AggregateAndUploadRequestStream {
252    type Protocol = AggregateAndUploadMarker;
253    type ControlHandle = AggregateAndUploadControlHandle;
254
255    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
256        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
257    }
258
259    fn control_handle(&self) -> Self::ControlHandle {
260        AggregateAndUploadControlHandle { inner: self.inner.clone() }
261    }
262
263    fn into_inner(
264        self,
265    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
266    {
267        (self.inner, self.is_terminated)
268    }
269
270    fn from_inner(
271        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
272        is_terminated: bool,
273    ) -> Self {
274        Self { inner, is_terminated }
275    }
276}
277
278impl futures::Stream for AggregateAndUploadRequestStream {
279    type Item = Result<AggregateAndUploadRequest, fidl::Error>;
280
281    fn poll_next(
282        mut self: std::pin::Pin<&mut Self>,
283        cx: &mut std::task::Context<'_>,
284    ) -> std::task::Poll<Option<Self::Item>> {
285        let this = &mut *self;
286        if this.inner.check_shutdown(cx) {
287            this.is_terminated = true;
288            return std::task::Poll::Ready(None);
289        }
290        if this.is_terminated {
291            panic!("polled AggregateAndUploadRequestStream after completion");
292        }
293        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
294            |bytes, handles| {
295                match this.inner.channel().read_etc(cx, bytes, handles) {
296                    std::task::Poll::Ready(Ok(())) => {}
297                    std::task::Poll::Pending => return std::task::Poll::Pending,
298                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
299                        this.is_terminated = true;
300                        return std::task::Poll::Ready(None);
301                    }
302                    std::task::Poll::Ready(Err(e)) => {
303                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
304                            e.into(),
305                        ))))
306                    }
307                }
308
309                // A message has been received from the channel
310                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
311
312                std::task::Poll::Ready(Some(match header.ordinal {
313                0x48db82fb20a16550 => {
314                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
315                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
316                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
317                    let control_handle = AggregateAndUploadControlHandle {
318                        inner: this.inner.clone(),
319                    };
320                    Ok(AggregateAndUploadRequest::AggregateAndUploadMetricEvents {
321                        responder: AggregateAndUploadAggregateAndUploadMetricEventsResponder {
322                            control_handle: std::mem::ManuallyDrop::new(control_handle),
323                            tx_id: header.tx_id,
324                        },
325                    })
326                }
327                _ => Err(fidl::Error::UnknownOrdinal {
328                    ordinal: header.ordinal,
329                    protocol_name: <AggregateAndUploadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
330                }),
331            }))
332            },
333        )
334    }
335}
336
337/// Locally aggregates all collected metrics and uploads generated
338/// observations immediately. This is only to be used for Recovery, and
339/// should only be called once per Recovery attempt.
340///
341/// If AggregateAndUpload completes, then the collected metrics were uploaded
342/// to Cobalt successfully. Otherwise, AggregateAndUpload may continue to run
343/// until the calling service cancels the process when long running operation
344/// exceeds the specified timeout. The reason this may occur, is that
345/// AggregateAndUpload has a retry policy, and will retry any failures until
346/// the operation succeeds or is cancelled due to exceeding a specified
347/// timeout.
348#[derive(Debug)]
349pub enum AggregateAndUploadRequest {
350    AggregateAndUploadMetricEvents {
351        responder: AggregateAndUploadAggregateAndUploadMetricEventsResponder,
352    },
353}
354
355impl AggregateAndUploadRequest {
356    #[allow(irrefutable_let_patterns)]
357    pub fn into_aggregate_and_upload_metric_events(
358        self,
359    ) -> Option<(AggregateAndUploadAggregateAndUploadMetricEventsResponder)> {
360        if let AggregateAndUploadRequest::AggregateAndUploadMetricEvents { responder } = self {
361            Some((responder))
362        } else {
363            None
364        }
365    }
366
367    /// Name of the method defined in FIDL
368    pub fn method_name(&self) -> &'static str {
369        match *self {
370            AggregateAndUploadRequest::AggregateAndUploadMetricEvents { .. } => {
371                "aggregate_and_upload_metric_events"
372            }
373        }
374    }
375}
376
377#[derive(Debug, Clone)]
378pub struct AggregateAndUploadControlHandle {
379    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
380}
381
382impl fidl::endpoints::ControlHandle for AggregateAndUploadControlHandle {
383    fn shutdown(&self) {
384        self.inner.shutdown()
385    }
386    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
387        self.inner.shutdown_with_epitaph(status)
388    }
389
390    fn is_closed(&self) -> bool {
391        self.inner.channel().is_closed()
392    }
393    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
394        self.inner.channel().on_closed()
395    }
396
397    #[cfg(target_os = "fuchsia")]
398    fn signal_peer(
399        &self,
400        clear_mask: zx::Signals,
401        set_mask: zx::Signals,
402    ) -> Result<(), zx_status::Status> {
403        use fidl::Peered;
404        self.inner.channel().signal_peer(clear_mask, set_mask)
405    }
406}
407
408impl AggregateAndUploadControlHandle {}
409
410#[must_use = "FIDL methods require a response to be sent"]
411#[derive(Debug)]
412pub struct AggregateAndUploadAggregateAndUploadMetricEventsResponder {
413    control_handle: std::mem::ManuallyDrop<AggregateAndUploadControlHandle>,
414    tx_id: u32,
415}
416
417/// Set the the channel to be shutdown (see [`AggregateAndUploadControlHandle::shutdown`])
418/// if the responder is dropped without sending a response, so that the client
419/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
420impl std::ops::Drop for AggregateAndUploadAggregateAndUploadMetricEventsResponder {
421    fn drop(&mut self) {
422        self.control_handle.shutdown();
423        // Safety: drops once, never accessed again
424        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
425    }
426}
427
428impl fidl::endpoints::Responder for AggregateAndUploadAggregateAndUploadMetricEventsResponder {
429    type ControlHandle = AggregateAndUploadControlHandle;
430
431    fn control_handle(&self) -> &AggregateAndUploadControlHandle {
432        &self.control_handle
433    }
434
435    fn drop_without_shutdown(mut self) {
436        // Safety: drops once, never accessed again due to mem::forget
437        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
438        // Prevent Drop from running (which would shut down the channel)
439        std::mem::forget(self);
440    }
441}
442
443impl AggregateAndUploadAggregateAndUploadMetricEventsResponder {
444    /// Sends a response to the FIDL transaction.
445    ///
446    /// Sets the channel to shutdown if an error occurs.
447    pub fn send(self) -> Result<(), fidl::Error> {
448        let _result = self.send_raw();
449        if _result.is_err() {
450            self.control_handle.shutdown();
451        }
452        self.drop_without_shutdown();
453        _result
454    }
455
456    /// Similar to "send" but does not shutdown the channel if an error occurs.
457    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
458        let _result = self.send_raw();
459        self.drop_without_shutdown();
460        _result
461    }
462
463    fn send_raw(&self) -> Result<(), fidl::Error> {
464        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
465            (),
466            self.tx_id,
467            0x48db82fb20a16550,
468            fidl::encoding::DynamicFlags::empty(),
469        )
470    }
471}
472
473#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
474pub struct ControllerMarker;
475
476impl fidl::endpoints::ProtocolMarker for ControllerMarker {
477    type Proxy = ControllerProxy;
478    type RequestStream = ControllerRequestStream;
479    #[cfg(target_os = "fuchsia")]
480    type SynchronousProxy = ControllerSynchronousProxy;
481
482    const DEBUG_NAME: &'static str = "fuchsia.cobalt.Controller";
483}
484impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
485
486pub trait ControllerProxyInterface: Send + Sync {
487    type RequestSendSoonResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
488    fn r#request_send_soon(&self) -> Self::RequestSendSoonResponseFut;
489    type GenerateAggregatedObservationsResponseFut: std::future::Future<Output = Result<Vec<u64>, fidl::Error>>
490        + Send;
491    fn r#generate_aggregated_observations(
492        &self,
493        day_index: u32,
494        report_specs: &[ReportSpec],
495    ) -> Self::GenerateAggregatedObservationsResponseFut;
496    type ListenForInitializedResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
497        + Send;
498    fn r#listen_for_initialized(&self) -> Self::ListenForInitializedResponseFut;
499}
500#[derive(Debug)]
501#[cfg(target_os = "fuchsia")]
502pub struct ControllerSynchronousProxy {
503    client: fidl::client::sync::Client,
504}
505
506#[cfg(target_os = "fuchsia")]
507impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
508    type Proxy = ControllerProxy;
509    type Protocol = ControllerMarker;
510
511    fn from_channel(inner: fidl::Channel) -> Self {
512        Self::new(inner)
513    }
514
515    fn into_channel(self) -> fidl::Channel {
516        self.client.into_channel()
517    }
518
519    fn as_channel(&self) -> &fidl::Channel {
520        self.client.as_channel()
521    }
522}
523
524#[cfg(target_os = "fuchsia")]
525impl ControllerSynchronousProxy {
526    pub fn new(channel: fidl::Channel) -> Self {
527        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
528        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
529    }
530
531    pub fn into_channel(self) -> fidl::Channel {
532        self.client.into_channel()
533    }
534
535    /// Waits until an event arrives and returns it. It is safe for other
536    /// threads to make concurrent requests while waiting for an event.
537    pub fn wait_for_event(
538        &self,
539        deadline: zx::MonotonicInstant,
540    ) -> Result<ControllerEvent, fidl::Error> {
541        ControllerEvent::decode(self.client.wait_for_event(deadline)?)
542    }
543
544    /// Requests that the collection of Observations that are currently cached
545    /// locally be sent to the Cobalt server soon. Cobalt will send the
546    /// Observations in one or more batches and will retry several times upon
547    /// failure. The response occurs only after that procedure is completed. A
548    /// return value of true indicates that all Observations were successfully
549    /// sent. A return value of false indicates otherwise.
550    pub fn r#request_send_soon(
551        &self,
552        ___deadline: zx::MonotonicInstant,
553    ) -> Result<bool, fidl::Error> {
554        let _response = self
555            .client
556            .send_query::<fidl::encoding::EmptyPayload, ControllerRequestSendSoonResponse>(
557                (),
558                0x554e66bab8f72e3d,
559                fidl::encoding::DynamicFlags::empty(),
560                ___deadline,
561            )?;
562        Ok(_response.success)
563    }
564
565    /// Triggers Cobalt to generate Observations based on locally aggregated
566    /// event data and write them to the local ObservationStore. In a non-test
567    /// environment this would normally be done periodically by a background
568    /// thread. In a test environment this method should be invoked against an
569    /// instance of the Cobalt FIDL service that was passed the flag
570    /// --start_event_aggregator_worker=false.
571    ///
572    /// `day_index` The index of the day for which locally aggregated
573    ///             Observations should be generated.
574    ///
575    /// `report_specs` A vector of specifications identifying the reports to
576    ///                return the number of observations for.
577    ///
578    /// Returns a vector whose k-th element is the number of observations
579    /// generated for the k-th element of `report_specs`. If `report_specs`
580    /// is the empty vector, then an empty vector is returned.
581    pub fn r#generate_aggregated_observations(
582        &self,
583        mut day_index: u32,
584        mut report_specs: &[ReportSpec],
585        ___deadline: zx::MonotonicInstant,
586    ) -> Result<Vec<u64>, fidl::Error> {
587        let _response = self.client.send_query::<
588            ControllerGenerateAggregatedObservationsRequest,
589            ControllerGenerateAggregatedObservationsResponse,
590        >(
591            (day_index, report_specs,),
592            0x79e058c9497f1ab1,
593            fidl::encoding::DynamicFlags::empty(),
594            ___deadline,
595        )?;
596        Ok(_response.num_obs)
597    }
598
599    /// Requests that the caller be notified after the Cobalt FIDL service
600    /// is in the fully-initialized state.
601    ///
602    /// Cobalt starts serving requests before it is fully initialized. In this
603    /// pre-initialized state it will buffer incoming log events in memory
604    /// but not complete their processing. After Cobalt becomes fully
605    /// initialized the events in the bufer are fully processed.
606    ///
607    /// A partial list of things that must happen before Cobalt enters the
608    /// fully-initialized state are:
609    ///
610    /// - Cobalt must by notified by the timekeeper service that the system
611    ///   clock has become accurate--usually because the time has been
612    ///   fetched from a trusted network resource.
613    ///
614    /// The callback to this method will be invoked after Cobalt transistions
615    pub fn r#listen_for_initialized(
616        &self,
617        ___deadline: zx::MonotonicInstant,
618    ) -> Result<(), fidl::Error> {
619        let _response =
620            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
621                (),
622                0x3454fbf05fcf10ef,
623                fidl::encoding::DynamicFlags::empty(),
624                ___deadline,
625            )?;
626        Ok(_response)
627    }
628}
629
630#[cfg(target_os = "fuchsia")]
631impl From<ControllerSynchronousProxy> for zx::Handle {
632    fn from(value: ControllerSynchronousProxy) -> Self {
633        value.into_channel().into()
634    }
635}
636
637#[cfg(target_os = "fuchsia")]
638impl From<fidl::Channel> for ControllerSynchronousProxy {
639    fn from(value: fidl::Channel) -> Self {
640        Self::new(value)
641    }
642}
643
644#[cfg(target_os = "fuchsia")]
645impl fidl::endpoints::FromClient for ControllerSynchronousProxy {
646    type Protocol = ControllerMarker;
647
648    fn from_client(value: fidl::endpoints::ClientEnd<ControllerMarker>) -> Self {
649        Self::new(value.into_channel())
650    }
651}
652
653#[derive(Debug, Clone)]
654pub struct ControllerProxy {
655    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
656}
657
658impl fidl::endpoints::Proxy for ControllerProxy {
659    type Protocol = ControllerMarker;
660
661    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
662        Self::new(inner)
663    }
664
665    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
666        self.client.into_channel().map_err(|client| Self { client })
667    }
668
669    fn as_channel(&self) -> &::fidl::AsyncChannel {
670        self.client.as_channel()
671    }
672}
673
674impl ControllerProxy {
675    /// Create a new Proxy for fuchsia.cobalt/Controller.
676    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
677        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
678        Self { client: fidl::client::Client::new(channel, protocol_name) }
679    }
680
681    /// Get a Stream of events from the remote end of the protocol.
682    ///
683    /// # Panics
684    ///
685    /// Panics if the event stream was already taken.
686    pub fn take_event_stream(&self) -> ControllerEventStream {
687        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
688    }
689
690    /// Requests that the collection of Observations that are currently cached
691    /// locally be sent to the Cobalt server soon. Cobalt will send the
692    /// Observations in one or more batches and will retry several times upon
693    /// failure. The response occurs only after that procedure is completed. A
694    /// return value of true indicates that all Observations were successfully
695    /// sent. A return value of false indicates otherwise.
696    pub fn r#request_send_soon(
697        &self,
698    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
699        ControllerProxyInterface::r#request_send_soon(self)
700    }
701
702    /// Triggers Cobalt to generate Observations based on locally aggregated
703    /// event data and write them to the local ObservationStore. In a non-test
704    /// environment this would normally be done periodically by a background
705    /// thread. In a test environment this method should be invoked against an
706    /// instance of the Cobalt FIDL service that was passed the flag
707    /// --start_event_aggregator_worker=false.
708    ///
709    /// `day_index` The index of the day for which locally aggregated
710    ///             Observations should be generated.
711    ///
712    /// `report_specs` A vector of specifications identifying the reports to
713    ///                return the number of observations for.
714    ///
715    /// Returns a vector whose k-th element is the number of observations
716    /// generated for the k-th element of `report_specs`. If `report_specs`
717    /// is the empty vector, then an empty vector is returned.
718    pub fn r#generate_aggregated_observations(
719        &self,
720        mut day_index: u32,
721        mut report_specs: &[ReportSpec],
722    ) -> fidl::client::QueryResponseFut<Vec<u64>, fidl::encoding::DefaultFuchsiaResourceDialect>
723    {
724        ControllerProxyInterface::r#generate_aggregated_observations(self, day_index, report_specs)
725    }
726
727    /// Requests that the caller be notified after the Cobalt FIDL service
728    /// is in the fully-initialized state.
729    ///
730    /// Cobalt starts serving requests before it is fully initialized. In this
731    /// pre-initialized state it will buffer incoming log events in memory
732    /// but not complete their processing. After Cobalt becomes fully
733    /// initialized the events in the bufer are fully processed.
734    ///
735    /// A partial list of things that must happen before Cobalt enters the
736    /// fully-initialized state are:
737    ///
738    /// - Cobalt must by notified by the timekeeper service that the system
739    ///   clock has become accurate--usually because the time has been
740    ///   fetched from a trusted network resource.
741    ///
742    /// The callback to this method will be invoked after Cobalt transistions
743    pub fn r#listen_for_initialized(
744        &self,
745    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
746        ControllerProxyInterface::r#listen_for_initialized(self)
747    }
748}
749
750impl ControllerProxyInterface for ControllerProxy {
751    type RequestSendSoonResponseFut =
752        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
753    fn r#request_send_soon(&self) -> Self::RequestSendSoonResponseFut {
754        fn _decode(
755            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
756        ) -> Result<bool, fidl::Error> {
757            let _response = fidl::client::decode_transaction_body::<
758                ControllerRequestSendSoonResponse,
759                fidl::encoding::DefaultFuchsiaResourceDialect,
760                0x554e66bab8f72e3d,
761            >(_buf?)?;
762            Ok(_response.success)
763        }
764        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
765            (),
766            0x554e66bab8f72e3d,
767            fidl::encoding::DynamicFlags::empty(),
768            _decode,
769        )
770    }
771
772    type GenerateAggregatedObservationsResponseFut =
773        fidl::client::QueryResponseFut<Vec<u64>, fidl::encoding::DefaultFuchsiaResourceDialect>;
774    fn r#generate_aggregated_observations(
775        &self,
776        mut day_index: u32,
777        mut report_specs: &[ReportSpec],
778    ) -> Self::GenerateAggregatedObservationsResponseFut {
779        fn _decode(
780            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
781        ) -> Result<Vec<u64>, fidl::Error> {
782            let _response = fidl::client::decode_transaction_body::<
783                ControllerGenerateAggregatedObservationsResponse,
784                fidl::encoding::DefaultFuchsiaResourceDialect,
785                0x79e058c9497f1ab1,
786            >(_buf?)?;
787            Ok(_response.num_obs)
788        }
789        self.client
790            .send_query_and_decode::<ControllerGenerateAggregatedObservationsRequest, Vec<u64>>(
791                (day_index, report_specs),
792                0x79e058c9497f1ab1,
793                fidl::encoding::DynamicFlags::empty(),
794                _decode,
795            )
796    }
797
798    type ListenForInitializedResponseFut =
799        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
800    fn r#listen_for_initialized(&self) -> Self::ListenForInitializedResponseFut {
801        fn _decode(
802            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
803        ) -> Result<(), fidl::Error> {
804            let _response = fidl::client::decode_transaction_body::<
805                fidl::encoding::EmptyPayload,
806                fidl::encoding::DefaultFuchsiaResourceDialect,
807                0x3454fbf05fcf10ef,
808            >(_buf?)?;
809            Ok(_response)
810        }
811        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
812            (),
813            0x3454fbf05fcf10ef,
814            fidl::encoding::DynamicFlags::empty(),
815            _decode,
816        )
817    }
818}
819
820pub struct ControllerEventStream {
821    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
822}
823
824impl std::marker::Unpin for ControllerEventStream {}
825
826impl futures::stream::FusedStream for ControllerEventStream {
827    fn is_terminated(&self) -> bool {
828        self.event_receiver.is_terminated()
829    }
830}
831
832impl futures::Stream for ControllerEventStream {
833    type Item = Result<ControllerEvent, fidl::Error>;
834
835    fn poll_next(
836        mut self: std::pin::Pin<&mut Self>,
837        cx: &mut std::task::Context<'_>,
838    ) -> std::task::Poll<Option<Self::Item>> {
839        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
840            &mut self.event_receiver,
841            cx
842        )?) {
843            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
844            None => std::task::Poll::Ready(None),
845        }
846    }
847}
848
849#[derive(Debug)]
850pub enum ControllerEvent {}
851
852impl ControllerEvent {
853    /// Decodes a message buffer as a [`ControllerEvent`].
854    fn decode(
855        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
856    ) -> Result<ControllerEvent, fidl::Error> {
857        let (bytes, _handles) = buf.split_mut();
858        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
859        debug_assert_eq!(tx_header.tx_id, 0);
860        match tx_header.ordinal {
861            _ => Err(fidl::Error::UnknownOrdinal {
862                ordinal: tx_header.ordinal,
863                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
864            }),
865        }
866    }
867}
868
869/// A Stream of incoming requests for fuchsia.cobalt/Controller.
870pub struct ControllerRequestStream {
871    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
872    is_terminated: bool,
873}
874
875impl std::marker::Unpin for ControllerRequestStream {}
876
877impl futures::stream::FusedStream for ControllerRequestStream {
878    fn is_terminated(&self) -> bool {
879        self.is_terminated
880    }
881}
882
883impl fidl::endpoints::RequestStream for ControllerRequestStream {
884    type Protocol = ControllerMarker;
885    type ControlHandle = ControllerControlHandle;
886
887    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
888        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
889    }
890
891    fn control_handle(&self) -> Self::ControlHandle {
892        ControllerControlHandle { inner: self.inner.clone() }
893    }
894
895    fn into_inner(
896        self,
897    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
898    {
899        (self.inner, self.is_terminated)
900    }
901
902    fn from_inner(
903        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
904        is_terminated: bool,
905    ) -> Self {
906        Self { inner, is_terminated }
907    }
908}
909
910impl futures::Stream for ControllerRequestStream {
911    type Item = Result<ControllerRequest, fidl::Error>;
912
913    fn poll_next(
914        mut self: std::pin::Pin<&mut Self>,
915        cx: &mut std::task::Context<'_>,
916    ) -> std::task::Poll<Option<Self::Item>> {
917        let this = &mut *self;
918        if this.inner.check_shutdown(cx) {
919            this.is_terminated = true;
920            return std::task::Poll::Ready(None);
921        }
922        if this.is_terminated {
923            panic!("polled ControllerRequestStream after completion");
924        }
925        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
926            |bytes, handles| {
927                match this.inner.channel().read_etc(cx, bytes, handles) {
928                    std::task::Poll::Ready(Ok(())) => {}
929                    std::task::Poll::Pending => return std::task::Poll::Pending,
930                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
931                        this.is_terminated = true;
932                        return std::task::Poll::Ready(None);
933                    }
934                    std::task::Poll::Ready(Err(e)) => {
935                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
936                            e.into(),
937                        ))))
938                    }
939                }
940
941                // A message has been received from the channel
942                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
943
944                std::task::Poll::Ready(Some(match header.ordinal {
945                    0x554e66bab8f72e3d => {
946                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
947                        let mut req = fidl::new_empty!(
948                            fidl::encoding::EmptyPayload,
949                            fidl::encoding::DefaultFuchsiaResourceDialect
950                        );
951                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
952                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
953                        Ok(ControllerRequest::RequestSendSoon {
954                            responder: ControllerRequestSendSoonResponder {
955                                control_handle: std::mem::ManuallyDrop::new(control_handle),
956                                tx_id: header.tx_id,
957                            },
958                        })
959                    }
960                    0x79e058c9497f1ab1 => {
961                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
962                        let mut req = fidl::new_empty!(
963                            ControllerGenerateAggregatedObservationsRequest,
964                            fidl::encoding::DefaultFuchsiaResourceDialect
965                        );
966                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerGenerateAggregatedObservationsRequest>(&header, _body_bytes, handles, &mut req)?;
967                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
968                        Ok(ControllerRequest::GenerateAggregatedObservations {
969                            day_index: req.day_index,
970                            report_specs: req.report_specs,
971
972                            responder: ControllerGenerateAggregatedObservationsResponder {
973                                control_handle: std::mem::ManuallyDrop::new(control_handle),
974                                tx_id: header.tx_id,
975                            },
976                        })
977                    }
978                    0x3454fbf05fcf10ef => {
979                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
980                        let mut req = fidl::new_empty!(
981                            fidl::encoding::EmptyPayload,
982                            fidl::encoding::DefaultFuchsiaResourceDialect
983                        );
984                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
985                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
986                        Ok(ControllerRequest::ListenForInitialized {
987                            responder: ControllerListenForInitializedResponder {
988                                control_handle: std::mem::ManuallyDrop::new(control_handle),
989                                tx_id: header.tx_id,
990                            },
991                        })
992                    }
993                    _ => Err(fidl::Error::UnknownOrdinal {
994                        ordinal: header.ordinal,
995                        protocol_name:
996                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
997                    }),
998                }))
999            },
1000        )
1001    }
1002}
1003
1004/// The Controller is primarily useful for testing the Cobalt service.
1005/// Cobalt clients should use the Logger.
1006#[derive(Debug)]
1007pub enum ControllerRequest {
1008    /// Requests that the collection of Observations that are currently cached
1009    /// locally be sent to the Cobalt server soon. Cobalt will send the
1010    /// Observations in one or more batches and will retry several times upon
1011    /// failure. The response occurs only after that procedure is completed. A
1012    /// return value of true indicates that all Observations were successfully
1013    /// sent. A return value of false indicates otherwise.
1014    RequestSendSoon { responder: ControllerRequestSendSoonResponder },
1015    /// Triggers Cobalt to generate Observations based on locally aggregated
1016    /// event data and write them to the local ObservationStore. In a non-test
1017    /// environment this would normally be done periodically by a background
1018    /// thread. In a test environment this method should be invoked against an
1019    /// instance of the Cobalt FIDL service that was passed the flag
1020    /// --start_event_aggregator_worker=false.
1021    ///
1022    /// `day_index` The index of the day for which locally aggregated
1023    ///             Observations should be generated.
1024    ///
1025    /// `report_specs` A vector of specifications identifying the reports to
1026    ///                return the number of observations for.
1027    ///
1028    /// Returns a vector whose k-th element is the number of observations
1029    /// generated for the k-th element of `report_specs`. If `report_specs`
1030    /// is the empty vector, then an empty vector is returned.
1031    GenerateAggregatedObservations {
1032        day_index: u32,
1033        report_specs: Vec<ReportSpec>,
1034        responder: ControllerGenerateAggregatedObservationsResponder,
1035    },
1036    /// Requests that the caller be notified after the Cobalt FIDL service
1037    /// is in the fully-initialized state.
1038    ///
1039    /// Cobalt starts serving requests before it is fully initialized. In this
1040    /// pre-initialized state it will buffer incoming log events in memory
1041    /// but not complete their processing. After Cobalt becomes fully
1042    /// initialized the events in the bufer are fully processed.
1043    ///
1044    /// A partial list of things that must happen before Cobalt enters the
1045    /// fully-initialized state are:
1046    ///
1047    /// - Cobalt must by notified by the timekeeper service that the system
1048    ///   clock has become accurate--usually because the time has been
1049    ///   fetched from a trusted network resource.
1050    ///
1051    /// The callback to this method will be invoked after Cobalt transistions
1052    ListenForInitialized { responder: ControllerListenForInitializedResponder },
1053}
1054
1055impl ControllerRequest {
1056    #[allow(irrefutable_let_patterns)]
1057    pub fn into_request_send_soon(self) -> Option<(ControllerRequestSendSoonResponder)> {
1058        if let ControllerRequest::RequestSendSoon { responder } = self {
1059            Some((responder))
1060        } else {
1061            None
1062        }
1063    }
1064
1065    #[allow(irrefutable_let_patterns)]
1066    pub fn into_generate_aggregated_observations(
1067        self,
1068    ) -> Option<(u32, Vec<ReportSpec>, ControllerGenerateAggregatedObservationsResponder)> {
1069        if let ControllerRequest::GenerateAggregatedObservations {
1070            day_index,
1071            report_specs,
1072            responder,
1073        } = self
1074        {
1075            Some((day_index, report_specs, responder))
1076        } else {
1077            None
1078        }
1079    }
1080
1081    #[allow(irrefutable_let_patterns)]
1082    pub fn into_listen_for_initialized(self) -> Option<(ControllerListenForInitializedResponder)> {
1083        if let ControllerRequest::ListenForInitialized { responder } = self {
1084            Some((responder))
1085        } else {
1086            None
1087        }
1088    }
1089
1090    /// Name of the method defined in FIDL
1091    pub fn method_name(&self) -> &'static str {
1092        match *self {
1093            ControllerRequest::RequestSendSoon { .. } => "request_send_soon",
1094            ControllerRequest::GenerateAggregatedObservations { .. } => {
1095                "generate_aggregated_observations"
1096            }
1097            ControllerRequest::ListenForInitialized { .. } => "listen_for_initialized",
1098        }
1099    }
1100}
1101
1102#[derive(Debug, Clone)]
1103pub struct ControllerControlHandle {
1104    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1105}
1106
1107impl fidl::endpoints::ControlHandle for ControllerControlHandle {
1108    fn shutdown(&self) {
1109        self.inner.shutdown()
1110    }
1111    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1112        self.inner.shutdown_with_epitaph(status)
1113    }
1114
1115    fn is_closed(&self) -> bool {
1116        self.inner.channel().is_closed()
1117    }
1118    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1119        self.inner.channel().on_closed()
1120    }
1121
1122    #[cfg(target_os = "fuchsia")]
1123    fn signal_peer(
1124        &self,
1125        clear_mask: zx::Signals,
1126        set_mask: zx::Signals,
1127    ) -> Result<(), zx_status::Status> {
1128        use fidl::Peered;
1129        self.inner.channel().signal_peer(clear_mask, set_mask)
1130    }
1131}
1132
1133impl ControllerControlHandle {}
1134
1135#[must_use = "FIDL methods require a response to be sent"]
1136#[derive(Debug)]
1137pub struct ControllerRequestSendSoonResponder {
1138    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1139    tx_id: u32,
1140}
1141
1142/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1143/// if the responder is dropped without sending a response, so that the client
1144/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1145impl std::ops::Drop for ControllerRequestSendSoonResponder {
1146    fn drop(&mut self) {
1147        self.control_handle.shutdown();
1148        // Safety: drops once, never accessed again
1149        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1150    }
1151}
1152
1153impl fidl::endpoints::Responder for ControllerRequestSendSoonResponder {
1154    type ControlHandle = ControllerControlHandle;
1155
1156    fn control_handle(&self) -> &ControllerControlHandle {
1157        &self.control_handle
1158    }
1159
1160    fn drop_without_shutdown(mut self) {
1161        // Safety: drops once, never accessed again due to mem::forget
1162        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1163        // Prevent Drop from running (which would shut down the channel)
1164        std::mem::forget(self);
1165    }
1166}
1167
1168impl ControllerRequestSendSoonResponder {
1169    /// Sends a response to the FIDL transaction.
1170    ///
1171    /// Sets the channel to shutdown if an error occurs.
1172    pub fn send(self, mut success: bool) -> Result<(), fidl::Error> {
1173        let _result = self.send_raw(success);
1174        if _result.is_err() {
1175            self.control_handle.shutdown();
1176        }
1177        self.drop_without_shutdown();
1178        _result
1179    }
1180
1181    /// Similar to "send" but does not shutdown the channel if an error occurs.
1182    pub fn send_no_shutdown_on_err(self, mut success: bool) -> Result<(), fidl::Error> {
1183        let _result = self.send_raw(success);
1184        self.drop_without_shutdown();
1185        _result
1186    }
1187
1188    fn send_raw(&self, mut success: bool) -> Result<(), fidl::Error> {
1189        self.control_handle.inner.send::<ControllerRequestSendSoonResponse>(
1190            (success,),
1191            self.tx_id,
1192            0x554e66bab8f72e3d,
1193            fidl::encoding::DynamicFlags::empty(),
1194        )
1195    }
1196}
1197
1198#[must_use = "FIDL methods require a response to be sent"]
1199#[derive(Debug)]
1200pub struct ControllerGenerateAggregatedObservationsResponder {
1201    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1202    tx_id: u32,
1203}
1204
1205/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1206/// if the responder is dropped without sending a response, so that the client
1207/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1208impl std::ops::Drop for ControllerGenerateAggregatedObservationsResponder {
1209    fn drop(&mut self) {
1210        self.control_handle.shutdown();
1211        // Safety: drops once, never accessed again
1212        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1213    }
1214}
1215
1216impl fidl::endpoints::Responder for ControllerGenerateAggregatedObservationsResponder {
1217    type ControlHandle = ControllerControlHandle;
1218
1219    fn control_handle(&self) -> &ControllerControlHandle {
1220        &self.control_handle
1221    }
1222
1223    fn drop_without_shutdown(mut self) {
1224        // Safety: drops once, never accessed again due to mem::forget
1225        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1226        // Prevent Drop from running (which would shut down the channel)
1227        std::mem::forget(self);
1228    }
1229}
1230
1231impl ControllerGenerateAggregatedObservationsResponder {
1232    /// Sends a response to the FIDL transaction.
1233    ///
1234    /// Sets the channel to shutdown if an error occurs.
1235    pub fn send(self, mut num_obs: &[u64]) -> Result<(), fidl::Error> {
1236        let _result = self.send_raw(num_obs);
1237        if _result.is_err() {
1238            self.control_handle.shutdown();
1239        }
1240        self.drop_without_shutdown();
1241        _result
1242    }
1243
1244    /// Similar to "send" but does not shutdown the channel if an error occurs.
1245    pub fn send_no_shutdown_on_err(self, mut num_obs: &[u64]) -> Result<(), fidl::Error> {
1246        let _result = self.send_raw(num_obs);
1247        self.drop_without_shutdown();
1248        _result
1249    }
1250
1251    fn send_raw(&self, mut num_obs: &[u64]) -> Result<(), fidl::Error> {
1252        self.control_handle.inner.send::<ControllerGenerateAggregatedObservationsResponse>(
1253            (num_obs,),
1254            self.tx_id,
1255            0x79e058c9497f1ab1,
1256            fidl::encoding::DynamicFlags::empty(),
1257        )
1258    }
1259}
1260
1261#[must_use = "FIDL methods require a response to be sent"]
1262#[derive(Debug)]
1263pub struct ControllerListenForInitializedResponder {
1264    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
1265    tx_id: u32,
1266}
1267
1268/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
1269/// if the responder is dropped without sending a response, so that the client
1270/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1271impl std::ops::Drop for ControllerListenForInitializedResponder {
1272    fn drop(&mut self) {
1273        self.control_handle.shutdown();
1274        // Safety: drops once, never accessed again
1275        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1276    }
1277}
1278
1279impl fidl::endpoints::Responder for ControllerListenForInitializedResponder {
1280    type ControlHandle = ControllerControlHandle;
1281
1282    fn control_handle(&self) -> &ControllerControlHandle {
1283        &self.control_handle
1284    }
1285
1286    fn drop_without_shutdown(mut self) {
1287        // Safety: drops once, never accessed again due to mem::forget
1288        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1289        // Prevent Drop from running (which would shut down the channel)
1290        std::mem::forget(self);
1291    }
1292}
1293
1294impl ControllerListenForInitializedResponder {
1295    /// Sends a response to the FIDL transaction.
1296    ///
1297    /// Sets the channel to shutdown if an error occurs.
1298    pub fn send(self) -> Result<(), fidl::Error> {
1299        let _result = self.send_raw();
1300        if _result.is_err() {
1301            self.control_handle.shutdown();
1302        }
1303        self.drop_without_shutdown();
1304        _result
1305    }
1306
1307    /// Similar to "send" but does not shutdown the channel if an error occurs.
1308    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1309        let _result = self.send_raw();
1310        self.drop_without_shutdown();
1311        _result
1312    }
1313
1314    fn send_raw(&self) -> Result<(), fidl::Error> {
1315        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1316            (),
1317            self.tx_id,
1318            0x3454fbf05fcf10ef,
1319            fidl::encoding::DynamicFlags::empty(),
1320        )
1321    }
1322}
1323
1324mod internal {
1325    use super::*;
1326}