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