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