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 { Some((responder)) } else { None }
354    }
355
356    /// Name of the method defined in FIDL
357    pub fn method_name(&self) -> &'static str {
358        match *self {
359            OptOutRequest::Get { .. } => "get",
360        }
361    }
362}
363
364#[derive(Debug, Clone)]
365pub struct OptOutControlHandle {
366    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
367}
368
369impl fidl::endpoints::ControlHandle for OptOutControlHandle {
370    fn shutdown(&self) {
371        self.inner.shutdown()
372    }
373    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
374        self.inner.shutdown_with_epitaph(status)
375    }
376
377    fn is_closed(&self) -> bool {
378        self.inner.channel().is_closed()
379    }
380    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
381        self.inner.channel().on_closed()
382    }
383
384    #[cfg(target_os = "fuchsia")]
385    fn signal_peer(
386        &self,
387        clear_mask: zx::Signals,
388        set_mask: zx::Signals,
389    ) -> Result<(), zx_status::Status> {
390        use fidl::Peered;
391        self.inner.channel().signal_peer(clear_mask, set_mask)
392    }
393}
394
395impl OptOutControlHandle {}
396
397#[must_use = "FIDL methods require a response to be sent"]
398#[derive(Debug)]
399pub struct OptOutGetResponder {
400    control_handle: std::mem::ManuallyDrop<OptOutControlHandle>,
401    tx_id: u32,
402}
403
404/// Set the the channel to be shutdown (see [`OptOutControlHandle::shutdown`])
405/// if the responder is dropped without sending a response, so that the client
406/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
407impl std::ops::Drop for OptOutGetResponder {
408    fn drop(&mut self) {
409        self.control_handle.shutdown();
410        // Safety: drops once, never accessed again
411        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
412    }
413}
414
415impl fidl::endpoints::Responder for OptOutGetResponder {
416    type ControlHandle = OptOutControlHandle;
417
418    fn control_handle(&self) -> &OptOutControlHandle {
419        &self.control_handle
420    }
421
422    fn drop_without_shutdown(mut self) {
423        // Safety: drops once, never accessed again due to mem::forget
424        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
425        // Prevent Drop from running (which would shut down the channel)
426        std::mem::forget(self);
427    }
428}
429
430impl OptOutGetResponder {
431    /// Sends a response to the FIDL transaction.
432    ///
433    /// Sets the channel to shutdown if an error occurs.
434    pub fn send(self, mut value: OptOutPreference) -> Result<(), fidl::Error> {
435        let _result = self.send_raw(value);
436        if _result.is_err() {
437            self.control_handle.shutdown();
438        }
439        self.drop_without_shutdown();
440        _result
441    }
442
443    /// Similar to "send" but does not shutdown the channel if an error occurs.
444    pub fn send_no_shutdown_on_err(self, mut value: OptOutPreference) -> Result<(), fidl::Error> {
445        let _result = self.send_raw(value);
446        self.drop_without_shutdown();
447        _result
448    }
449
450    fn send_raw(&self, mut value: OptOutPreference) -> Result<(), fidl::Error> {
451        self.control_handle.inner.send::<OptOutGetResponse>(
452            (value,),
453            self.tx_id,
454            0x7d905c32077a3cd8,
455            fidl::encoding::DynamicFlags::empty(),
456        )
457    }
458}
459
460#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
461pub struct OptOutAdminMarker;
462
463impl fidl::endpoints::ProtocolMarker for OptOutAdminMarker {
464    type Proxy = OptOutAdminProxy;
465    type RequestStream = OptOutAdminRequestStream;
466    #[cfg(target_os = "fuchsia")]
467    type SynchronousProxy = OptOutAdminSynchronousProxy;
468
469    const DEBUG_NAME: &'static str = "fuchsia.update.config.OptOutAdmin";
470}
471impl fidl::endpoints::DiscoverableProtocolMarker for OptOutAdminMarker {}
472pub type OptOutAdminSetResult = Result<(), OptOutAdminError>;
473
474pub trait OptOutAdminProxyInterface: Send + Sync {
475    type SetResponseFut: std::future::Future<Output = Result<OptOutAdminSetResult, fidl::Error>>
476        + Send;
477    fn r#set(&self, value: OptOutPreference) -> Self::SetResponseFut;
478}
479#[derive(Debug)]
480#[cfg(target_os = "fuchsia")]
481pub struct OptOutAdminSynchronousProxy {
482    client: fidl::client::sync::Client,
483}
484
485#[cfg(target_os = "fuchsia")]
486impl fidl::endpoints::SynchronousProxy for OptOutAdminSynchronousProxy {
487    type Proxy = OptOutAdminProxy;
488    type Protocol = OptOutAdminMarker;
489
490    fn from_channel(inner: fidl::Channel) -> Self {
491        Self::new(inner)
492    }
493
494    fn into_channel(self) -> fidl::Channel {
495        self.client.into_channel()
496    }
497
498    fn as_channel(&self) -> &fidl::Channel {
499        self.client.as_channel()
500    }
501}
502
503#[cfg(target_os = "fuchsia")]
504impl OptOutAdminSynchronousProxy {
505    pub fn new(channel: fidl::Channel) -> Self {
506        let protocol_name = <OptOutAdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
507        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
508    }
509
510    pub fn into_channel(self) -> fidl::Channel {
511        self.client.into_channel()
512    }
513
514    /// Waits until an event arrives and returns it. It is safe for other
515    /// threads to make concurrent requests while waiting for an event.
516    pub fn wait_for_event(
517        &self,
518        deadline: zx::MonotonicInstant,
519    ) -> Result<OptOutAdminEvent, fidl::Error> {
520        OptOutAdminEvent::decode(self.client.wait_for_event(deadline)?)
521    }
522
523    /// Sets the update opt-out preference to `value`.
524    ///
525    /// + request `value` The user's new opt-out preference.
526    ///
527    /// * error Any error encountered while persisting the new setting.
528    pub fn r#set(
529        &self,
530        mut value: OptOutPreference,
531        ___deadline: zx::MonotonicInstant,
532    ) -> Result<OptOutAdminSetResult, fidl::Error> {
533        let _response = self.client.send_query::<
534            OptOutAdminSetRequest,
535            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OptOutAdminError>,
536        >(
537            (value,),
538            0x7c990c7f64cfff27,
539            fidl::encoding::DynamicFlags::empty(),
540            ___deadline,
541        )?;
542        Ok(_response.map(|x| x))
543    }
544}
545
546#[cfg(target_os = "fuchsia")]
547impl From<OptOutAdminSynchronousProxy> for zx::Handle {
548    fn from(value: OptOutAdminSynchronousProxy) -> Self {
549        value.into_channel().into()
550    }
551}
552
553#[cfg(target_os = "fuchsia")]
554impl From<fidl::Channel> for OptOutAdminSynchronousProxy {
555    fn from(value: fidl::Channel) -> Self {
556        Self::new(value)
557    }
558}
559
560#[cfg(target_os = "fuchsia")]
561impl fidl::endpoints::FromClient for OptOutAdminSynchronousProxy {
562    type Protocol = OptOutAdminMarker;
563
564    fn from_client(value: fidl::endpoints::ClientEnd<OptOutAdminMarker>) -> Self {
565        Self::new(value.into_channel())
566    }
567}
568
569#[derive(Debug, Clone)]
570pub struct OptOutAdminProxy {
571    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
572}
573
574impl fidl::endpoints::Proxy for OptOutAdminProxy {
575    type Protocol = OptOutAdminMarker;
576
577    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
578        Self::new(inner)
579    }
580
581    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
582        self.client.into_channel().map_err(|client| Self { client })
583    }
584
585    fn as_channel(&self) -> &::fidl::AsyncChannel {
586        self.client.as_channel()
587    }
588}
589
590impl OptOutAdminProxy {
591    /// Create a new Proxy for fuchsia.update.config/OptOutAdmin.
592    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
593        let protocol_name = <OptOutAdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
594        Self { client: fidl::client::Client::new(channel, protocol_name) }
595    }
596
597    /// Get a Stream of events from the remote end of the protocol.
598    ///
599    /// # Panics
600    ///
601    /// Panics if the event stream was already taken.
602    pub fn take_event_stream(&self) -> OptOutAdminEventStream {
603        OptOutAdminEventStream { event_receiver: self.client.take_event_receiver() }
604    }
605
606    /// Sets the update opt-out preference to `value`.
607    ///
608    /// + request `value` The user's new opt-out preference.
609    ///
610    /// * error Any error encountered while persisting the new setting.
611    pub fn r#set(
612        &self,
613        mut value: OptOutPreference,
614    ) -> fidl::client::QueryResponseFut<
615        OptOutAdminSetResult,
616        fidl::encoding::DefaultFuchsiaResourceDialect,
617    > {
618        OptOutAdminProxyInterface::r#set(self, value)
619    }
620}
621
622impl OptOutAdminProxyInterface for OptOutAdminProxy {
623    type SetResponseFut = fidl::client::QueryResponseFut<
624        OptOutAdminSetResult,
625        fidl::encoding::DefaultFuchsiaResourceDialect,
626    >;
627    fn r#set(&self, mut value: OptOutPreference) -> Self::SetResponseFut {
628        fn _decode(
629            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
630        ) -> Result<OptOutAdminSetResult, fidl::Error> {
631            let _response = fidl::client::decode_transaction_body::<
632                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OptOutAdminError>,
633                fidl::encoding::DefaultFuchsiaResourceDialect,
634                0x7c990c7f64cfff27,
635            >(_buf?)?;
636            Ok(_response.map(|x| x))
637        }
638        self.client.send_query_and_decode::<OptOutAdminSetRequest, OptOutAdminSetResult>(
639            (value,),
640            0x7c990c7f64cfff27,
641            fidl::encoding::DynamicFlags::empty(),
642            _decode,
643        )
644    }
645}
646
647pub struct OptOutAdminEventStream {
648    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
649}
650
651impl std::marker::Unpin for OptOutAdminEventStream {}
652
653impl futures::stream::FusedStream for OptOutAdminEventStream {
654    fn is_terminated(&self) -> bool {
655        self.event_receiver.is_terminated()
656    }
657}
658
659impl futures::Stream for OptOutAdminEventStream {
660    type Item = Result<OptOutAdminEvent, fidl::Error>;
661
662    fn poll_next(
663        mut self: std::pin::Pin<&mut Self>,
664        cx: &mut std::task::Context<'_>,
665    ) -> std::task::Poll<Option<Self::Item>> {
666        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
667            &mut self.event_receiver,
668            cx
669        )?) {
670            Some(buf) => std::task::Poll::Ready(Some(OptOutAdminEvent::decode(buf))),
671            None => std::task::Poll::Ready(None),
672        }
673    }
674}
675
676#[derive(Debug)]
677pub enum OptOutAdminEvent {}
678
679impl OptOutAdminEvent {
680    /// Decodes a message buffer as a [`OptOutAdminEvent`].
681    fn decode(
682        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
683    ) -> Result<OptOutAdminEvent, fidl::Error> {
684        let (bytes, _handles) = buf.split_mut();
685        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
686        debug_assert_eq!(tx_header.tx_id, 0);
687        match tx_header.ordinal {
688            _ => Err(fidl::Error::UnknownOrdinal {
689                ordinal: tx_header.ordinal,
690                protocol_name: <OptOutAdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
691            }),
692        }
693    }
694}
695
696/// A Stream of incoming requests for fuchsia.update.config/OptOutAdmin.
697pub struct OptOutAdminRequestStream {
698    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
699    is_terminated: bool,
700}
701
702impl std::marker::Unpin for OptOutAdminRequestStream {}
703
704impl futures::stream::FusedStream for OptOutAdminRequestStream {
705    fn is_terminated(&self) -> bool {
706        self.is_terminated
707    }
708}
709
710impl fidl::endpoints::RequestStream for OptOutAdminRequestStream {
711    type Protocol = OptOutAdminMarker;
712    type ControlHandle = OptOutAdminControlHandle;
713
714    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
715        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
716    }
717
718    fn control_handle(&self) -> Self::ControlHandle {
719        OptOutAdminControlHandle { inner: self.inner.clone() }
720    }
721
722    fn into_inner(
723        self,
724    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
725    {
726        (self.inner, self.is_terminated)
727    }
728
729    fn from_inner(
730        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
731        is_terminated: bool,
732    ) -> Self {
733        Self { inner, is_terminated }
734    }
735}
736
737impl futures::Stream for OptOutAdminRequestStream {
738    type Item = Result<OptOutAdminRequest, fidl::Error>;
739
740    fn poll_next(
741        mut self: std::pin::Pin<&mut Self>,
742        cx: &mut std::task::Context<'_>,
743    ) -> std::task::Poll<Option<Self::Item>> {
744        let this = &mut *self;
745        if this.inner.check_shutdown(cx) {
746            this.is_terminated = true;
747            return std::task::Poll::Ready(None);
748        }
749        if this.is_terminated {
750            panic!("polled OptOutAdminRequestStream after completion");
751        }
752        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
753            |bytes, handles| {
754                match this.inner.channel().read_etc(cx, bytes, handles) {
755                    std::task::Poll::Ready(Ok(())) => {}
756                    std::task::Poll::Pending => return std::task::Poll::Pending,
757                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
758                        this.is_terminated = true;
759                        return std::task::Poll::Ready(None);
760                    }
761                    std::task::Poll::Ready(Err(e)) => {
762                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
763                            e.into(),
764                        ))));
765                    }
766                }
767
768                // A message has been received from the channel
769                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
770
771                std::task::Poll::Ready(Some(match header.ordinal {
772                    0x7c990c7f64cfff27 => {
773                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
774                        let mut req = fidl::new_empty!(
775                            OptOutAdminSetRequest,
776                            fidl::encoding::DefaultFuchsiaResourceDialect
777                        );
778                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<OptOutAdminSetRequest>(&header, _body_bytes, handles, &mut req)?;
779                        let control_handle = OptOutAdminControlHandle { inner: this.inner.clone() };
780                        Ok(OptOutAdminRequest::Set {
781                            value: req.value,
782
783                            responder: OptOutAdminSetResponder {
784                                control_handle: std::mem::ManuallyDrop::new(control_handle),
785                                tx_id: header.tx_id,
786                            },
787                        })
788                    }
789                    _ => Err(fidl::Error::UnknownOrdinal {
790                        ordinal: header.ordinal,
791                        protocol_name:
792                            <OptOutAdminMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
793                    }),
794                }))
795            },
796        )
797    }
798}
799
800/// Management for the state of the update system's opt-out functionality.
801#[derive(Debug)]
802pub enum OptOutAdminRequest {
803    /// Sets the update opt-out preference to `value`.
804    ///
805    /// + request `value` The user's new opt-out preference.
806    ///
807    /// * error Any error encountered while persisting the new setting.
808    Set { value: OptOutPreference, responder: OptOutAdminSetResponder },
809}
810
811impl OptOutAdminRequest {
812    #[allow(irrefutable_let_patterns)]
813    pub fn into_set(self) -> Option<(OptOutPreference, OptOutAdminSetResponder)> {
814        if let OptOutAdminRequest::Set { value, responder } = self {
815            Some((value, responder))
816        } else {
817            None
818        }
819    }
820
821    /// Name of the method defined in FIDL
822    pub fn method_name(&self) -> &'static str {
823        match *self {
824            OptOutAdminRequest::Set { .. } => "set",
825        }
826    }
827}
828
829#[derive(Debug, Clone)]
830pub struct OptOutAdminControlHandle {
831    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
832}
833
834impl fidl::endpoints::ControlHandle for OptOutAdminControlHandle {
835    fn shutdown(&self) {
836        self.inner.shutdown()
837    }
838    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
839        self.inner.shutdown_with_epitaph(status)
840    }
841
842    fn is_closed(&self) -> bool {
843        self.inner.channel().is_closed()
844    }
845    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
846        self.inner.channel().on_closed()
847    }
848
849    #[cfg(target_os = "fuchsia")]
850    fn signal_peer(
851        &self,
852        clear_mask: zx::Signals,
853        set_mask: zx::Signals,
854    ) -> Result<(), zx_status::Status> {
855        use fidl::Peered;
856        self.inner.channel().signal_peer(clear_mask, set_mask)
857    }
858}
859
860impl OptOutAdminControlHandle {}
861
862#[must_use = "FIDL methods require a response to be sent"]
863#[derive(Debug)]
864pub struct OptOutAdminSetResponder {
865    control_handle: std::mem::ManuallyDrop<OptOutAdminControlHandle>,
866    tx_id: u32,
867}
868
869/// Set the the channel to be shutdown (see [`OptOutAdminControlHandle::shutdown`])
870/// if the responder is dropped without sending a response, so that the client
871/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
872impl std::ops::Drop for OptOutAdminSetResponder {
873    fn drop(&mut self) {
874        self.control_handle.shutdown();
875        // Safety: drops once, never accessed again
876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
877    }
878}
879
880impl fidl::endpoints::Responder for OptOutAdminSetResponder {
881    type ControlHandle = OptOutAdminControlHandle;
882
883    fn control_handle(&self) -> &OptOutAdminControlHandle {
884        &self.control_handle
885    }
886
887    fn drop_without_shutdown(mut self) {
888        // Safety: drops once, never accessed again due to mem::forget
889        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
890        // Prevent Drop from running (which would shut down the channel)
891        std::mem::forget(self);
892    }
893}
894
895impl OptOutAdminSetResponder {
896    /// Sends a response to the FIDL transaction.
897    ///
898    /// Sets the channel to shutdown if an error occurs.
899    pub fn send(self, mut result: Result<(), OptOutAdminError>) -> Result<(), fidl::Error> {
900        let _result = self.send_raw(result);
901        if _result.is_err() {
902            self.control_handle.shutdown();
903        }
904        self.drop_without_shutdown();
905        _result
906    }
907
908    /// Similar to "send" but does not shutdown the channel if an error occurs.
909    pub fn send_no_shutdown_on_err(
910        self,
911        mut result: Result<(), OptOutAdminError>,
912    ) -> Result<(), fidl::Error> {
913        let _result = self.send_raw(result);
914        self.drop_without_shutdown();
915        _result
916    }
917
918    fn send_raw(&self, mut result: Result<(), OptOutAdminError>) -> Result<(), fidl::Error> {
919        self.control_handle.inner.send::<fidl::encoding::ResultType<
920            fidl::encoding::EmptyStruct,
921            OptOutAdminError,
922        >>(
923            result,
924            self.tx_id,
925            0x7c990c7f64cfff27,
926            fidl::encoding::DynamicFlags::empty(),
927        )
928    }
929}
930
931mod internal {
932    use super::*;
933}