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