Skip to main content

fidl_fuchsia_update_verify/
fidl_fuchsia_update_verify.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_update_verify__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ComponentOtaHealthCheckMarker;
16
17impl fidl::endpoints::ProtocolMarker for ComponentOtaHealthCheckMarker {
18    type Proxy = ComponentOtaHealthCheckProxy;
19    type RequestStream = ComponentOtaHealthCheckRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ComponentOtaHealthCheckSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.update.verify.ComponentOtaHealthCheck";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ComponentOtaHealthCheckMarker {}
26
27pub trait ComponentOtaHealthCheckProxyInterface: Send + Sync {
28    type GetHealthStatusResponseFut: std::future::Future<Output = Result<HealthStatus, fidl::Error>>
29        + Send;
30    fn r#get_health_status(&self) -> Self::GetHealthStatusResponseFut;
31}
32#[derive(Debug)]
33#[cfg(target_os = "fuchsia")]
34pub struct ComponentOtaHealthCheckSynchronousProxy {
35    client: fidl::client::sync::Client,
36}
37
38#[cfg(target_os = "fuchsia")]
39impl fidl::endpoints::SynchronousProxy for ComponentOtaHealthCheckSynchronousProxy {
40    type Proxy = ComponentOtaHealthCheckProxy;
41    type Protocol = ComponentOtaHealthCheckMarker;
42
43    fn from_channel(inner: fidl::Channel) -> Self {
44        Self::new(inner)
45    }
46
47    fn into_channel(self) -> fidl::Channel {
48        self.client.into_channel()
49    }
50
51    fn as_channel(&self) -> &fidl::Channel {
52        self.client.as_channel()
53    }
54}
55
56#[cfg(target_os = "fuchsia")]
57impl ComponentOtaHealthCheckSynchronousProxy {
58    pub fn new(channel: fidl::Channel) -> Self {
59        Self { client: fidl::client::sync::Client::new(channel) }
60    }
61
62    pub fn into_channel(self) -> fidl::Channel {
63        self.client.into_channel()
64    }
65
66    /// Waits until an event arrives and returns it. It is safe for other
67    /// threads to make concurrent requests while waiting for an event.
68    pub fn wait_for_event(
69        &self,
70        deadline: zx::MonotonicInstant,
71    ) -> Result<ComponentOtaHealthCheckEvent, fidl::Error> {
72        ComponentOtaHealthCheckEvent::decode(
73            self.client.wait_for_event::<ComponentOtaHealthCheckMarker>(deadline)?,
74        )
75    }
76
77    pub fn r#get_health_status(
78        &self,
79        ___deadline: zx::MonotonicInstant,
80    ) -> Result<HealthStatus, fidl::Error> {
81        let _response = self.client.send_query::<
82            fidl::encoding::EmptyPayload,
83            ComponentOtaHealthCheckGetHealthStatusResponse,
84            ComponentOtaHealthCheckMarker,
85        >(
86            (),
87            0x4a0bab1f2132f9ee,
88            fidl::encoding::DynamicFlags::empty(),
89            ___deadline,
90        )?;
91        Ok(_response.health_status)
92    }
93}
94
95#[cfg(target_os = "fuchsia")]
96impl From<ComponentOtaHealthCheckSynchronousProxy> for zx::NullableHandle {
97    fn from(value: ComponentOtaHealthCheckSynchronousProxy) -> Self {
98        value.into_channel().into()
99    }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl From<fidl::Channel> for ComponentOtaHealthCheckSynchronousProxy {
104    fn from(value: fidl::Channel) -> Self {
105        Self::new(value)
106    }
107}
108
109#[cfg(target_os = "fuchsia")]
110impl fidl::endpoints::FromClient for ComponentOtaHealthCheckSynchronousProxy {
111    type Protocol = ComponentOtaHealthCheckMarker;
112
113    fn from_client(value: fidl::endpoints::ClientEnd<ComponentOtaHealthCheckMarker>) -> Self {
114        Self::new(value.into_channel())
115    }
116}
117
118#[derive(Debug, Clone)]
119pub struct ComponentOtaHealthCheckProxy {
120    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
121}
122
123impl fidl::endpoints::Proxy for ComponentOtaHealthCheckProxy {
124    type Protocol = ComponentOtaHealthCheckMarker;
125
126    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
127        Self::new(inner)
128    }
129
130    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
131        self.client.into_channel().map_err(|client| Self { client })
132    }
133
134    fn as_channel(&self) -> &::fidl::AsyncChannel {
135        self.client.as_channel()
136    }
137}
138
139impl ComponentOtaHealthCheckProxy {
140    /// Create a new Proxy for fuchsia.update.verify/ComponentOtaHealthCheck.
141    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
142        let protocol_name =
143            <ComponentOtaHealthCheckMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
144        Self { client: fidl::client::Client::new(channel, protocol_name) }
145    }
146
147    /// Get a Stream of events from the remote end of the protocol.
148    ///
149    /// # Panics
150    ///
151    /// Panics if the event stream was already taken.
152    pub fn take_event_stream(&self) -> ComponentOtaHealthCheckEventStream {
153        ComponentOtaHealthCheckEventStream { event_receiver: self.client.take_event_receiver() }
154    }
155
156    pub fn r#get_health_status(
157        &self,
158    ) -> fidl::client::QueryResponseFut<HealthStatus, fidl::encoding::DefaultFuchsiaResourceDialect>
159    {
160        ComponentOtaHealthCheckProxyInterface::r#get_health_status(self)
161    }
162}
163
164impl ComponentOtaHealthCheckProxyInterface for ComponentOtaHealthCheckProxy {
165    type GetHealthStatusResponseFut =
166        fidl::client::QueryResponseFut<HealthStatus, fidl::encoding::DefaultFuchsiaResourceDialect>;
167    fn r#get_health_status(&self) -> Self::GetHealthStatusResponseFut {
168        fn _decode(
169            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
170        ) -> Result<HealthStatus, fidl::Error> {
171            let _response = fidl::client::decode_transaction_body::<
172                ComponentOtaHealthCheckGetHealthStatusResponse,
173                fidl::encoding::DefaultFuchsiaResourceDialect,
174                0x4a0bab1f2132f9ee,
175            >(_buf?)?;
176            Ok(_response.health_status)
177        }
178        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, HealthStatus>(
179            (),
180            0x4a0bab1f2132f9ee,
181            fidl::encoding::DynamicFlags::empty(),
182            _decode,
183        )
184    }
185}
186
187pub struct ComponentOtaHealthCheckEventStream {
188    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
189}
190
191impl std::marker::Unpin for ComponentOtaHealthCheckEventStream {}
192
193impl futures::stream::FusedStream for ComponentOtaHealthCheckEventStream {
194    fn is_terminated(&self) -> bool {
195        self.event_receiver.is_terminated()
196    }
197}
198
199impl futures::Stream for ComponentOtaHealthCheckEventStream {
200    type Item = Result<ComponentOtaHealthCheckEvent, 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(ComponentOtaHealthCheckEvent::decode(buf))),
211            None => std::task::Poll::Ready(None),
212        }
213    }
214}
215
216#[derive(Debug)]
217pub enum ComponentOtaHealthCheckEvent {}
218
219impl ComponentOtaHealthCheckEvent {
220    /// Decodes a message buffer as a [`ComponentOtaHealthCheckEvent`].
221    fn decode(
222        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
223    ) -> Result<ComponentOtaHealthCheckEvent, 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                    <ComponentOtaHealthCheckMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
232            }),
233        }
234    }
235}
236
237/// A Stream of incoming requests for fuchsia.update.verify/ComponentOtaHealthCheck.
238pub struct ComponentOtaHealthCheckRequestStream {
239    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
240    is_terminated: bool,
241}
242
243impl std::marker::Unpin for ComponentOtaHealthCheckRequestStream {}
244
245impl futures::stream::FusedStream for ComponentOtaHealthCheckRequestStream {
246    fn is_terminated(&self) -> bool {
247        self.is_terminated
248    }
249}
250
251impl fidl::endpoints::RequestStream for ComponentOtaHealthCheckRequestStream {
252    type Protocol = ComponentOtaHealthCheckMarker;
253    type ControlHandle = ComponentOtaHealthCheckControlHandle;
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        ComponentOtaHealthCheckControlHandle { 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 ComponentOtaHealthCheckRequestStream {
279    type Item = Result<ComponentOtaHealthCheckRequest, 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 ComponentOtaHealthCheckRequestStream 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                0x4a0bab1f2132f9ee => {
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 = ComponentOtaHealthCheckControlHandle {
318                        inner: this.inner.clone(),
319                    };
320                    Ok(ComponentOtaHealthCheckRequest::GetHealthStatus {
321                        responder: ComponentOtaHealthCheckGetHealthStatusResponder {
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: <ComponentOtaHealthCheckMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
330                }),
331            }))
332            },
333        )
334    }
335}
336
337/// Protocol for getting the health status of a component.
338/// It is up to the component authors to decide what a component should do after marking
339/// the partition as unhealthy.
340#[derive(Debug)]
341pub enum ComponentOtaHealthCheckRequest {
342    GetHealthStatus { responder: ComponentOtaHealthCheckGetHealthStatusResponder },
343}
344
345impl ComponentOtaHealthCheckRequest {
346    #[allow(irrefutable_let_patterns)]
347    pub fn into_get_health_status(
348        self,
349    ) -> Option<(ComponentOtaHealthCheckGetHealthStatusResponder)> {
350        if let ComponentOtaHealthCheckRequest::GetHealthStatus { responder } = self {
351            Some((responder))
352        } else {
353            None
354        }
355    }
356
357    /// Name of the method defined in FIDL
358    pub fn method_name(&self) -> &'static str {
359        match *self {
360            ComponentOtaHealthCheckRequest::GetHealthStatus { .. } => "get_health_status",
361        }
362    }
363}
364
365#[derive(Debug, Clone)]
366pub struct ComponentOtaHealthCheckControlHandle {
367    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
368}
369
370impl fidl::endpoints::ControlHandle for ComponentOtaHealthCheckControlHandle {
371    fn shutdown(&self) {
372        self.inner.shutdown()
373    }
374
375    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
376        self.inner.shutdown_with_epitaph(status)
377    }
378
379    fn is_closed(&self) -> bool {
380        self.inner.channel().is_closed()
381    }
382    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
383        self.inner.channel().on_closed()
384    }
385
386    #[cfg(target_os = "fuchsia")]
387    fn signal_peer(
388        &self,
389        clear_mask: zx::Signals,
390        set_mask: zx::Signals,
391    ) -> Result<(), zx_status::Status> {
392        use fidl::Peered;
393        self.inner.channel().signal_peer(clear_mask, set_mask)
394    }
395}
396
397impl ComponentOtaHealthCheckControlHandle {}
398
399#[must_use = "FIDL methods require a response to be sent"]
400#[derive(Debug)]
401pub struct ComponentOtaHealthCheckGetHealthStatusResponder {
402    control_handle: std::mem::ManuallyDrop<ComponentOtaHealthCheckControlHandle>,
403    tx_id: u32,
404}
405
406/// Set the the channel to be shutdown (see [`ComponentOtaHealthCheckControlHandle::shutdown`])
407/// if the responder is dropped without sending a response, so that the client
408/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
409impl std::ops::Drop for ComponentOtaHealthCheckGetHealthStatusResponder {
410    fn drop(&mut self) {
411        self.control_handle.shutdown();
412        // Safety: drops once, never accessed again
413        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
414    }
415}
416
417impl fidl::endpoints::Responder for ComponentOtaHealthCheckGetHealthStatusResponder {
418    type ControlHandle = ComponentOtaHealthCheckControlHandle;
419
420    fn control_handle(&self) -> &ComponentOtaHealthCheckControlHandle {
421        &self.control_handle
422    }
423
424    fn drop_without_shutdown(mut self) {
425        // Safety: drops once, never accessed again due to mem::forget
426        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
427        // Prevent Drop from running (which would shut down the channel)
428        std::mem::forget(self);
429    }
430}
431
432impl ComponentOtaHealthCheckGetHealthStatusResponder {
433    /// Sends a response to the FIDL transaction.
434    ///
435    /// Sets the channel to shutdown if an error occurs.
436    pub fn send(self, mut health_status: HealthStatus) -> Result<(), fidl::Error> {
437        let _result = self.send_raw(health_status);
438        if _result.is_err() {
439            self.control_handle.shutdown();
440        }
441        self.drop_without_shutdown();
442        _result
443    }
444
445    /// Similar to "send" but does not shutdown the channel if an error occurs.
446    pub fn send_no_shutdown_on_err(
447        self,
448        mut health_status: HealthStatus,
449    ) -> Result<(), fidl::Error> {
450        let _result = self.send_raw(health_status);
451        self.drop_without_shutdown();
452        _result
453    }
454
455    fn send_raw(&self, mut health_status: HealthStatus) -> Result<(), fidl::Error> {
456        self.control_handle.inner.send::<ComponentOtaHealthCheckGetHealthStatusResponse>(
457            (health_status,),
458            self.tx_id,
459            0x4a0bab1f2132f9ee,
460            fidl::encoding::DynamicFlags::empty(),
461        )
462    }
463}
464
465#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
466pub struct HealthVerificationMarker;
467
468impl fidl::endpoints::ProtocolMarker for HealthVerificationMarker {
469    type Proxy = HealthVerificationProxy;
470    type RequestStream = HealthVerificationRequestStream;
471    #[cfg(target_os = "fuchsia")]
472    type SynchronousProxy = HealthVerificationSynchronousProxy;
473
474    const DEBUG_NAME: &'static str = "fuchsia.update.verify.HealthVerification";
475}
476impl fidl::endpoints::DiscoverableProtocolMarker for HealthVerificationMarker {}
477
478pub trait HealthVerificationProxyInterface: Send + Sync {
479    type QueryHealthChecksResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
480    fn r#query_health_checks(&self) -> Self::QueryHealthChecksResponseFut;
481}
482#[derive(Debug)]
483#[cfg(target_os = "fuchsia")]
484pub struct HealthVerificationSynchronousProxy {
485    client: fidl::client::sync::Client,
486}
487
488#[cfg(target_os = "fuchsia")]
489impl fidl::endpoints::SynchronousProxy for HealthVerificationSynchronousProxy {
490    type Proxy = HealthVerificationProxy;
491    type Protocol = HealthVerificationMarker;
492
493    fn from_channel(inner: fidl::Channel) -> Self {
494        Self::new(inner)
495    }
496
497    fn into_channel(self) -> fidl::Channel {
498        self.client.into_channel()
499    }
500
501    fn as_channel(&self) -> &fidl::Channel {
502        self.client.as_channel()
503    }
504}
505
506#[cfg(target_os = "fuchsia")]
507impl HealthVerificationSynchronousProxy {
508    pub fn new(channel: fidl::Channel) -> Self {
509        Self { client: fidl::client::sync::Client::new(channel) }
510    }
511
512    pub fn into_channel(self) -> fidl::Channel {
513        self.client.into_channel()
514    }
515
516    /// Waits until an event arrives and returns it. It is safe for other
517    /// threads to make concurrent requests while waiting for an event.
518    pub fn wait_for_event(
519        &self,
520        deadline: zx::MonotonicInstant,
521    ) -> Result<HealthVerificationEvent, fidl::Error> {
522        HealthVerificationEvent::decode(
523            self.client.wait_for_event::<HealthVerificationMarker>(deadline)?,
524        )
525    }
526
527    /// Queries the suite of health checks.
528    ///
529    /// Returns `ZX_OK` if every required check is healthy.
530    pub fn r#query_health_checks(
531        &self,
532        ___deadline: zx::MonotonicInstant,
533    ) -> Result<i32, fidl::Error> {
534        let _response = self.client.send_query::<
535            fidl::encoding::EmptyPayload,
536            HealthVerificationQueryHealthChecksResponse,
537            HealthVerificationMarker,
538        >(
539            (),
540            0x372e04d635be9532,
541            fidl::encoding::DynamicFlags::empty(),
542            ___deadline,
543        )?;
544        Ok(_response.status)
545    }
546}
547
548#[cfg(target_os = "fuchsia")]
549impl From<HealthVerificationSynchronousProxy> for zx::NullableHandle {
550    fn from(value: HealthVerificationSynchronousProxy) -> Self {
551        value.into_channel().into()
552    }
553}
554
555#[cfg(target_os = "fuchsia")]
556impl From<fidl::Channel> for HealthVerificationSynchronousProxy {
557    fn from(value: fidl::Channel) -> Self {
558        Self::new(value)
559    }
560}
561
562#[cfg(target_os = "fuchsia")]
563impl fidl::endpoints::FromClient for HealthVerificationSynchronousProxy {
564    type Protocol = HealthVerificationMarker;
565
566    fn from_client(value: fidl::endpoints::ClientEnd<HealthVerificationMarker>) -> Self {
567        Self::new(value.into_channel())
568    }
569}
570
571#[derive(Debug, Clone)]
572pub struct HealthVerificationProxy {
573    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
574}
575
576impl fidl::endpoints::Proxy for HealthVerificationProxy {
577    type Protocol = HealthVerificationMarker;
578
579    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
580        Self::new(inner)
581    }
582
583    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
584        self.client.into_channel().map_err(|client| Self { client })
585    }
586
587    fn as_channel(&self) -> &::fidl::AsyncChannel {
588        self.client.as_channel()
589    }
590}
591
592impl HealthVerificationProxy {
593    /// Create a new Proxy for fuchsia.update.verify/HealthVerification.
594    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
595        let protocol_name =
596            <HealthVerificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
597        Self { client: fidl::client::Client::new(channel, protocol_name) }
598    }
599
600    /// Get a Stream of events from the remote end of the protocol.
601    ///
602    /// # Panics
603    ///
604    /// Panics if the event stream was already taken.
605    pub fn take_event_stream(&self) -> HealthVerificationEventStream {
606        HealthVerificationEventStream { event_receiver: self.client.take_event_receiver() }
607    }
608
609    /// Queries the suite of health checks.
610    ///
611    /// Returns `ZX_OK` if every required check is healthy.
612    pub fn r#query_health_checks(
613        &self,
614    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
615        HealthVerificationProxyInterface::r#query_health_checks(self)
616    }
617}
618
619impl HealthVerificationProxyInterface for HealthVerificationProxy {
620    type QueryHealthChecksResponseFut =
621        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
622    fn r#query_health_checks(&self) -> Self::QueryHealthChecksResponseFut {
623        fn _decode(
624            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
625        ) -> Result<i32, fidl::Error> {
626            let _response = fidl::client::decode_transaction_body::<
627                HealthVerificationQueryHealthChecksResponse,
628                fidl::encoding::DefaultFuchsiaResourceDialect,
629                0x372e04d635be9532,
630            >(_buf?)?;
631            Ok(_response.status)
632        }
633        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
634            (),
635            0x372e04d635be9532,
636            fidl::encoding::DynamicFlags::empty(),
637            _decode,
638        )
639    }
640}
641
642pub struct HealthVerificationEventStream {
643    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
644}
645
646impl std::marker::Unpin for HealthVerificationEventStream {}
647
648impl futures::stream::FusedStream for HealthVerificationEventStream {
649    fn is_terminated(&self) -> bool {
650        self.event_receiver.is_terminated()
651    }
652}
653
654impl futures::Stream for HealthVerificationEventStream {
655    type Item = Result<HealthVerificationEvent, fidl::Error>;
656
657    fn poll_next(
658        mut self: std::pin::Pin<&mut Self>,
659        cx: &mut std::task::Context<'_>,
660    ) -> std::task::Poll<Option<Self::Item>> {
661        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
662            &mut self.event_receiver,
663            cx
664        )?) {
665            Some(buf) => std::task::Poll::Ready(Some(HealthVerificationEvent::decode(buf))),
666            None => std::task::Poll::Ready(None),
667        }
668    }
669}
670
671#[derive(Debug)]
672pub enum HealthVerificationEvent {}
673
674impl HealthVerificationEvent {
675    /// Decodes a message buffer as a [`HealthVerificationEvent`].
676    fn decode(
677        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
678    ) -> Result<HealthVerificationEvent, fidl::Error> {
679        let (bytes, _handles) = buf.split_mut();
680        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
681        debug_assert_eq!(tx_header.tx_id, 0);
682        match tx_header.ordinal {
683            _ => Err(fidl::Error::UnknownOrdinal {
684                ordinal: tx_header.ordinal,
685                protocol_name:
686                    <HealthVerificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
687            }),
688        }
689    }
690}
691
692/// A Stream of incoming requests for fuchsia.update.verify/HealthVerification.
693pub struct HealthVerificationRequestStream {
694    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
695    is_terminated: bool,
696}
697
698impl std::marker::Unpin for HealthVerificationRequestStream {}
699
700impl futures::stream::FusedStream for HealthVerificationRequestStream {
701    fn is_terminated(&self) -> bool {
702        self.is_terminated
703    }
704}
705
706impl fidl::endpoints::RequestStream for HealthVerificationRequestStream {
707    type Protocol = HealthVerificationMarker;
708    type ControlHandle = HealthVerificationControlHandle;
709
710    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
711        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
712    }
713
714    fn control_handle(&self) -> Self::ControlHandle {
715        HealthVerificationControlHandle { inner: self.inner.clone() }
716    }
717
718    fn into_inner(
719        self,
720    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
721    {
722        (self.inner, self.is_terminated)
723    }
724
725    fn from_inner(
726        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
727        is_terminated: bool,
728    ) -> Self {
729        Self { inner, is_terminated }
730    }
731}
732
733impl futures::Stream for HealthVerificationRequestStream {
734    type Item = Result<HealthVerificationRequest, fidl::Error>;
735
736    fn poll_next(
737        mut self: std::pin::Pin<&mut Self>,
738        cx: &mut std::task::Context<'_>,
739    ) -> std::task::Poll<Option<Self::Item>> {
740        let this = &mut *self;
741        if this.inner.check_shutdown(cx) {
742            this.is_terminated = true;
743            return std::task::Poll::Ready(None);
744        }
745        if this.is_terminated {
746            panic!("polled HealthVerificationRequestStream after completion");
747        }
748        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
749            |bytes, handles| {
750                match this.inner.channel().read_etc(cx, bytes, handles) {
751                    std::task::Poll::Ready(Ok(())) => {}
752                    std::task::Poll::Pending => return std::task::Poll::Pending,
753                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
754                        this.is_terminated = true;
755                        return std::task::Poll::Ready(None);
756                    }
757                    std::task::Poll::Ready(Err(e)) => {
758                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
759                            e.into(),
760                        ))));
761                    }
762                }
763
764                // A message has been received from the channel
765                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
766
767                std::task::Poll::Ready(Some(match header.ordinal {
768                0x372e04d635be9532 => {
769                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
770                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
771                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
772                    let control_handle = HealthVerificationControlHandle {
773                        inner: this.inner.clone(),
774                    };
775                    Ok(HealthVerificationRequest::QueryHealthChecks {
776                        responder: HealthVerificationQueryHealthChecksResponder {
777                            control_handle: std::mem::ManuallyDrop::new(control_handle),
778                            tx_id: header.tx_id,
779                        },
780                    })
781                }
782                _ => Err(fidl::Error::UnknownOrdinal {
783                    ordinal: header.ordinal,
784                    protocol_name: <HealthVerificationMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
785                }),
786            }))
787            },
788        )
789    }
790}
791
792/// Protocol for reading health check statuses.
793#[derive(Debug)]
794pub enum HealthVerificationRequest {
795    /// Queries the suite of health checks.
796    ///
797    /// Returns `ZX_OK` if every required check is healthy.
798    QueryHealthChecks { responder: HealthVerificationQueryHealthChecksResponder },
799}
800
801impl HealthVerificationRequest {
802    #[allow(irrefutable_let_patterns)]
803    pub fn into_query_health_checks(
804        self,
805    ) -> Option<(HealthVerificationQueryHealthChecksResponder)> {
806        if let HealthVerificationRequest::QueryHealthChecks { responder } = self {
807            Some((responder))
808        } else {
809            None
810        }
811    }
812
813    /// Name of the method defined in FIDL
814    pub fn method_name(&self) -> &'static str {
815        match *self {
816            HealthVerificationRequest::QueryHealthChecks { .. } => "query_health_checks",
817        }
818    }
819}
820
821#[derive(Debug, Clone)]
822pub struct HealthVerificationControlHandle {
823    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
824}
825
826impl fidl::endpoints::ControlHandle for HealthVerificationControlHandle {
827    fn shutdown(&self) {
828        self.inner.shutdown()
829    }
830
831    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
832        self.inner.shutdown_with_epitaph(status)
833    }
834
835    fn is_closed(&self) -> bool {
836        self.inner.channel().is_closed()
837    }
838    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
839        self.inner.channel().on_closed()
840    }
841
842    #[cfg(target_os = "fuchsia")]
843    fn signal_peer(
844        &self,
845        clear_mask: zx::Signals,
846        set_mask: zx::Signals,
847    ) -> Result<(), zx_status::Status> {
848        use fidl::Peered;
849        self.inner.channel().signal_peer(clear_mask, set_mask)
850    }
851}
852
853impl HealthVerificationControlHandle {}
854
855#[must_use = "FIDL methods require a response to be sent"]
856#[derive(Debug)]
857pub struct HealthVerificationQueryHealthChecksResponder {
858    control_handle: std::mem::ManuallyDrop<HealthVerificationControlHandle>,
859    tx_id: u32,
860}
861
862/// Set the the channel to be shutdown (see [`HealthVerificationControlHandle::shutdown`])
863/// if the responder is dropped without sending a response, so that the client
864/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
865impl std::ops::Drop for HealthVerificationQueryHealthChecksResponder {
866    fn drop(&mut self) {
867        self.control_handle.shutdown();
868        // Safety: drops once, never accessed again
869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
870    }
871}
872
873impl fidl::endpoints::Responder for HealthVerificationQueryHealthChecksResponder {
874    type ControlHandle = HealthVerificationControlHandle;
875
876    fn control_handle(&self) -> &HealthVerificationControlHandle {
877        &self.control_handle
878    }
879
880    fn drop_without_shutdown(mut self) {
881        // Safety: drops once, never accessed again due to mem::forget
882        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
883        // Prevent Drop from running (which would shut down the channel)
884        std::mem::forget(self);
885    }
886}
887
888impl HealthVerificationQueryHealthChecksResponder {
889    /// Sends a response to the FIDL transaction.
890    ///
891    /// Sets the channel to shutdown if an error occurs.
892    pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
893        let _result = self.send_raw(status);
894        if _result.is_err() {
895            self.control_handle.shutdown();
896        }
897        self.drop_without_shutdown();
898        _result
899    }
900
901    /// Similar to "send" but does not shutdown the channel if an error occurs.
902    pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
903        let _result = self.send_raw(status);
904        self.drop_without_shutdown();
905        _result
906    }
907
908    fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
909        self.control_handle.inner.send::<HealthVerificationQueryHealthChecksResponse>(
910            (status,),
911            self.tx_id,
912            0x372e04d635be9532,
913            fidl::encoding::DynamicFlags::empty(),
914        )
915    }
916}
917
918mod internal {
919    use super::*;
920}