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