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