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::NullableHandle {
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
645    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
646        self.inner.shutdown_with_epitaph(status)
647    }
648
649    fn is_closed(&self) -> bool {
650        self.inner.channel().is_closed()
651    }
652    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
653        self.inner.channel().on_closed()
654    }
655
656    #[cfg(target_os = "fuchsia")]
657    fn signal_peer(
658        &self,
659        clear_mask: zx::Signals,
660        set_mask: zx::Signals,
661    ) -> Result<(), zx_status::Status> {
662        use fidl::Peered;
663        self.inner.channel().signal_peer(clear_mask, set_mask)
664    }
665}
666
667impl ChannelControlControlHandle {}
668
669#[must_use = "FIDL methods require a response to be sent"]
670#[derive(Debug)]
671pub struct ChannelControlGetCurrentResponder {
672    control_handle: std::mem::ManuallyDrop<ChannelControlControlHandle>,
673    tx_id: u32,
674}
675
676/// Set the the channel to be shutdown (see [`ChannelControlControlHandle::shutdown`])
677/// if the responder is dropped without sending a response, so that the client
678/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
679impl std::ops::Drop for ChannelControlGetCurrentResponder {
680    fn drop(&mut self) {
681        self.control_handle.shutdown();
682        // Safety: drops once, never accessed again
683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
684    }
685}
686
687impl fidl::endpoints::Responder for ChannelControlGetCurrentResponder {
688    type ControlHandle = ChannelControlControlHandle;
689
690    fn control_handle(&self) -> &ChannelControlControlHandle {
691        &self.control_handle
692    }
693
694    fn drop_without_shutdown(mut self) {
695        // Safety: drops once, never accessed again due to mem::forget
696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
697        // Prevent Drop from running (which would shut down the channel)
698        std::mem::forget(self);
699    }
700}
701
702impl ChannelControlGetCurrentResponder {
703    /// Sends a response to the FIDL transaction.
704    ///
705    /// Sets the channel to shutdown if an error occurs.
706    pub fn send(self, mut channel: &str) -> Result<(), fidl::Error> {
707        let _result = self.send_raw(channel);
708        if _result.is_err() {
709            self.control_handle.shutdown();
710        }
711        self.drop_without_shutdown();
712        _result
713    }
714
715    /// Similar to "send" but does not shutdown the channel if an error occurs.
716    pub fn send_no_shutdown_on_err(self, mut channel: &str) -> Result<(), fidl::Error> {
717        let _result = self.send_raw(channel);
718        self.drop_without_shutdown();
719        _result
720    }
721
722    fn send_raw(&self, mut channel: &str) -> Result<(), fidl::Error> {
723        self.control_handle.inner.send::<fidl_fuchsia_update_channel::ProviderGetCurrentResponse>(
724            (channel,),
725            self.tx_id,
726            0x15af055da76e5016,
727            fidl::encoding::DynamicFlags::empty(),
728        )
729    }
730}
731
732#[must_use = "FIDL methods require a response to be sent"]
733#[derive(Debug)]
734pub struct ChannelControlSetTargetResponder {
735    control_handle: std::mem::ManuallyDrop<ChannelControlControlHandle>,
736    tx_id: u32,
737}
738
739/// Set the the channel to be shutdown (see [`ChannelControlControlHandle::shutdown`])
740/// if the responder is dropped without sending a response, so that the client
741/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
742impl std::ops::Drop for ChannelControlSetTargetResponder {
743    fn drop(&mut self) {
744        self.control_handle.shutdown();
745        // Safety: drops once, never accessed again
746        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
747    }
748}
749
750impl fidl::endpoints::Responder for ChannelControlSetTargetResponder {
751    type ControlHandle = ChannelControlControlHandle;
752
753    fn control_handle(&self) -> &ChannelControlControlHandle {
754        &self.control_handle
755    }
756
757    fn drop_without_shutdown(mut self) {
758        // Safety: drops once, never accessed again due to mem::forget
759        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
760        // Prevent Drop from running (which would shut down the channel)
761        std::mem::forget(self);
762    }
763}
764
765impl ChannelControlSetTargetResponder {
766    /// Sends a response to the FIDL transaction.
767    ///
768    /// Sets the channel to shutdown if an error occurs.
769    pub fn send(self) -> Result<(), fidl::Error> {
770        let _result = self.send_raw();
771        if _result.is_err() {
772            self.control_handle.shutdown();
773        }
774        self.drop_without_shutdown();
775        _result
776    }
777
778    /// Similar to "send" but does not shutdown the channel if an error occurs.
779    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
780        let _result = self.send_raw();
781        self.drop_without_shutdown();
782        _result
783    }
784
785    fn send_raw(&self) -> Result<(), fidl::Error> {
786        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
787            (),
788            self.tx_id,
789            0x45f0a54099a1752e,
790            fidl::encoding::DynamicFlags::empty(),
791        )
792    }
793}
794
795#[must_use = "FIDL methods require a response to be sent"]
796#[derive(Debug)]
797pub struct ChannelControlGetTargetResponder {
798    control_handle: std::mem::ManuallyDrop<ChannelControlControlHandle>,
799    tx_id: u32,
800}
801
802/// Set the the channel to be shutdown (see [`ChannelControlControlHandle::shutdown`])
803/// if the responder is dropped without sending a response, so that the client
804/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
805impl std::ops::Drop for ChannelControlGetTargetResponder {
806    fn drop(&mut self) {
807        self.control_handle.shutdown();
808        // Safety: drops once, never accessed again
809        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
810    }
811}
812
813impl fidl::endpoints::Responder for ChannelControlGetTargetResponder {
814    type ControlHandle = ChannelControlControlHandle;
815
816    fn control_handle(&self) -> &ChannelControlControlHandle {
817        &self.control_handle
818    }
819
820    fn drop_without_shutdown(mut self) {
821        // Safety: drops once, never accessed again due to mem::forget
822        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
823        // Prevent Drop from running (which would shut down the channel)
824        std::mem::forget(self);
825    }
826}
827
828impl ChannelControlGetTargetResponder {
829    /// Sends a response to the FIDL transaction.
830    ///
831    /// Sets the channel to shutdown if an error occurs.
832    pub fn send(self, mut channel: &str) -> Result<(), fidl::Error> {
833        let _result = self.send_raw(channel);
834        if _result.is_err() {
835            self.control_handle.shutdown();
836        }
837        self.drop_without_shutdown();
838        _result
839    }
840
841    /// Similar to "send" but does not shutdown the channel if an error occurs.
842    pub fn send_no_shutdown_on_err(self, mut channel: &str) -> Result<(), fidl::Error> {
843        let _result = self.send_raw(channel);
844        self.drop_without_shutdown();
845        _result
846    }
847
848    fn send_raw(&self, mut channel: &str) -> Result<(), fidl::Error> {
849        self.control_handle.inner.send::<ChannelControlGetTargetResponse>(
850            (channel,),
851            self.tx_id,
852            0x3602953dfbabe7a2,
853            fidl::encoding::DynamicFlags::empty(),
854        )
855    }
856}
857
858#[must_use = "FIDL methods require a response to be sent"]
859#[derive(Debug)]
860pub struct ChannelControlGetTargetListResponder {
861    control_handle: std::mem::ManuallyDrop<ChannelControlControlHandle>,
862    tx_id: u32,
863}
864
865/// Set the the channel to be shutdown (see [`ChannelControlControlHandle::shutdown`])
866/// if the responder is dropped without sending a response, so that the client
867/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
868impl std::ops::Drop for ChannelControlGetTargetListResponder {
869    fn drop(&mut self) {
870        self.control_handle.shutdown();
871        // Safety: drops once, never accessed again
872        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
873    }
874}
875
876impl fidl::endpoints::Responder for ChannelControlGetTargetListResponder {
877    type ControlHandle = ChannelControlControlHandle;
878
879    fn control_handle(&self) -> &ChannelControlControlHandle {
880        &self.control_handle
881    }
882
883    fn drop_without_shutdown(mut self) {
884        // Safety: drops once, never accessed again due to mem::forget
885        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
886        // Prevent Drop from running (which would shut down the channel)
887        std::mem::forget(self);
888    }
889}
890
891impl ChannelControlGetTargetListResponder {
892    /// Sends a response to the FIDL transaction.
893    ///
894    /// Sets the channel to shutdown if an error occurs.
895    pub fn send(self, mut channels: &[String]) -> Result<(), fidl::Error> {
896        let _result = self.send_raw(channels);
897        if _result.is_err() {
898            self.control_handle.shutdown();
899        }
900        self.drop_without_shutdown();
901        _result
902    }
903
904    /// Similar to "send" but does not shutdown the channel if an error occurs.
905    pub fn send_no_shutdown_on_err(self, mut channels: &[String]) -> Result<(), fidl::Error> {
906        let _result = self.send_raw(channels);
907        self.drop_without_shutdown();
908        _result
909    }
910
911    fn send_raw(&self, mut channels: &[String]) -> Result<(), fidl::Error> {
912        self.control_handle.inner.send::<ChannelControlGetTargetListResponse>(
913            (channels,),
914            self.tx_id,
915            0x727a95a911d8db11,
916            fidl::encoding::DynamicFlags::empty(),
917        )
918    }
919}
920
921mod internal {
922    use super::*;
923}