Skip to main content

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