fidl_fuchsia_update_channel/
fidl_fuchsia_update_channel.rs
1#![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_channel_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ProviderMarker;
16
17impl fidl::endpoints::ProtocolMarker for ProviderMarker {
18 type Proxy = ProviderProxy;
19 type RequestStream = ProviderRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ProviderSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.update.channel.Provider";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ProviderMarker {}
26
27pub trait ProviderProxyInterface: Send + Sync {
28 type GetCurrentResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
29 fn r#get_current(&self) -> Self::GetCurrentResponseFut;
30}
31#[derive(Debug)]
32#[cfg(target_os = "fuchsia")]
33pub struct ProviderSynchronousProxy {
34 client: fidl::client::sync::Client,
35}
36
37#[cfg(target_os = "fuchsia")]
38impl fidl::endpoints::SynchronousProxy for ProviderSynchronousProxy {
39 type Proxy = ProviderProxy;
40 type Protocol = ProviderMarker;
41
42 fn from_channel(inner: fidl::Channel) -> Self {
43 Self::new(inner)
44 }
45
46 fn into_channel(self) -> fidl::Channel {
47 self.client.into_channel()
48 }
49
50 fn as_channel(&self) -> &fidl::Channel {
51 self.client.as_channel()
52 }
53}
54
55#[cfg(target_os = "fuchsia")]
56impl ProviderSynchronousProxy {
57 pub fn new(channel: fidl::Channel) -> Self {
58 let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
59 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
60 }
61
62 pub fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 pub fn wait_for_event(
69 &self,
70 deadline: zx::MonotonicInstant,
71 ) -> Result<ProviderEvent, fidl::Error> {
72 ProviderEvent::decode(self.client.wait_for_event(deadline)?)
73 }
74
75 pub fn r#get_current(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
79 let _response =
80 self.client.send_query::<fidl::encoding::EmptyPayload, ProviderGetCurrentResponse>(
81 (),
82 0x15af055da76e5016,
83 fidl::encoding::DynamicFlags::empty(),
84 ___deadline,
85 )?;
86 Ok(_response.channel)
87 }
88}
89
90#[cfg(target_os = "fuchsia")]
91impl From<ProviderSynchronousProxy> for zx::Handle {
92 fn from(value: ProviderSynchronousProxy) -> Self {
93 value.into_channel().into()
94 }
95}
96
97#[cfg(target_os = "fuchsia")]
98impl From<fidl::Channel> for ProviderSynchronousProxy {
99 fn from(value: fidl::Channel) -> Self {
100 Self::new(value)
101 }
102}
103
104#[derive(Debug, Clone)]
105pub struct ProviderProxy {
106 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
107}
108
109impl fidl::endpoints::Proxy for ProviderProxy {
110 type Protocol = ProviderMarker;
111
112 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
113 Self::new(inner)
114 }
115
116 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
117 self.client.into_channel().map_err(|client| Self { client })
118 }
119
120 fn as_channel(&self) -> &::fidl::AsyncChannel {
121 self.client.as_channel()
122 }
123}
124
125impl ProviderProxy {
126 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
128 let protocol_name = <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
129 Self { client: fidl::client::Client::new(channel, protocol_name) }
130 }
131
132 pub fn take_event_stream(&self) -> ProviderEventStream {
138 ProviderEventStream { event_receiver: self.client.take_event_receiver() }
139 }
140
141 pub fn r#get_current(
145 &self,
146 ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
147 ProviderProxyInterface::r#get_current(self)
148 }
149}
150
151impl ProviderProxyInterface for ProviderProxy {
152 type GetCurrentResponseFut =
153 fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
154 fn r#get_current(&self) -> Self::GetCurrentResponseFut {
155 fn _decode(
156 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
157 ) -> Result<String, fidl::Error> {
158 let _response = fidl::client::decode_transaction_body::<
159 ProviderGetCurrentResponse,
160 fidl::encoding::DefaultFuchsiaResourceDialect,
161 0x15af055da76e5016,
162 >(_buf?)?;
163 Ok(_response.channel)
164 }
165 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
166 (),
167 0x15af055da76e5016,
168 fidl::encoding::DynamicFlags::empty(),
169 _decode,
170 )
171 }
172}
173
174pub struct ProviderEventStream {
175 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
176}
177
178impl std::marker::Unpin for ProviderEventStream {}
179
180impl futures::stream::FusedStream for ProviderEventStream {
181 fn is_terminated(&self) -> bool {
182 self.event_receiver.is_terminated()
183 }
184}
185
186impl futures::Stream for ProviderEventStream {
187 type Item = Result<ProviderEvent, fidl::Error>;
188
189 fn poll_next(
190 mut self: std::pin::Pin<&mut Self>,
191 cx: &mut std::task::Context<'_>,
192 ) -> std::task::Poll<Option<Self::Item>> {
193 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
194 &mut self.event_receiver,
195 cx
196 )?) {
197 Some(buf) => std::task::Poll::Ready(Some(ProviderEvent::decode(buf))),
198 None => std::task::Poll::Ready(None),
199 }
200 }
201}
202
203#[derive(Debug)]
204pub enum ProviderEvent {}
205
206impl ProviderEvent {
207 fn decode(
209 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
210 ) -> Result<ProviderEvent, fidl::Error> {
211 let (bytes, _handles) = buf.split_mut();
212 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
213 debug_assert_eq!(tx_header.tx_id, 0);
214 match tx_header.ordinal {
215 _ => Err(fidl::Error::UnknownOrdinal {
216 ordinal: tx_header.ordinal,
217 protocol_name: <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
218 }),
219 }
220 }
221}
222
223pub struct ProviderRequestStream {
225 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
226 is_terminated: bool,
227}
228
229impl std::marker::Unpin for ProviderRequestStream {}
230
231impl futures::stream::FusedStream for ProviderRequestStream {
232 fn is_terminated(&self) -> bool {
233 self.is_terminated
234 }
235}
236
237impl fidl::endpoints::RequestStream for ProviderRequestStream {
238 type Protocol = ProviderMarker;
239 type ControlHandle = ProviderControlHandle;
240
241 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
242 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
243 }
244
245 fn control_handle(&self) -> Self::ControlHandle {
246 ProviderControlHandle { inner: self.inner.clone() }
247 }
248
249 fn into_inner(
250 self,
251 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
252 {
253 (self.inner, self.is_terminated)
254 }
255
256 fn from_inner(
257 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
258 is_terminated: bool,
259 ) -> Self {
260 Self { inner, is_terminated }
261 }
262}
263
264impl futures::Stream for ProviderRequestStream {
265 type Item = Result<ProviderRequest, fidl::Error>;
266
267 fn poll_next(
268 mut self: std::pin::Pin<&mut Self>,
269 cx: &mut std::task::Context<'_>,
270 ) -> std::task::Poll<Option<Self::Item>> {
271 let this = &mut *self;
272 if this.inner.check_shutdown(cx) {
273 this.is_terminated = true;
274 return std::task::Poll::Ready(None);
275 }
276 if this.is_terminated {
277 panic!("polled ProviderRequestStream after completion");
278 }
279 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
280 |bytes, handles| {
281 match this.inner.channel().read_etc(cx, bytes, handles) {
282 std::task::Poll::Ready(Ok(())) => {}
283 std::task::Poll::Pending => return std::task::Poll::Pending,
284 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
285 this.is_terminated = true;
286 return std::task::Poll::Ready(None);
287 }
288 std::task::Poll::Ready(Err(e)) => {
289 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
290 e.into(),
291 ))))
292 }
293 }
294
295 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
297
298 std::task::Poll::Ready(Some(match header.ordinal {
299 0x15af055da76e5016 => {
300 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
301 let mut req = fidl::new_empty!(
302 fidl::encoding::EmptyPayload,
303 fidl::encoding::DefaultFuchsiaResourceDialect
304 );
305 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
306 let control_handle = ProviderControlHandle { inner: this.inner.clone() };
307 Ok(ProviderRequest::GetCurrent {
308 responder: ProviderGetCurrentResponder {
309 control_handle: std::mem::ManuallyDrop::new(control_handle),
310 tx_id: header.tx_id,
311 },
312 })
313 }
314 _ => Err(fidl::Error::UnknownOrdinal {
315 ordinal: header.ordinal,
316 protocol_name:
317 <ProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
318 }),
319 }))
320 },
321 )
322 }
323}
324
325#[derive(Debug)]
327pub enum ProviderRequest {
328 GetCurrent { responder: ProviderGetCurrentResponder },
332}
333
334impl ProviderRequest {
335 #[allow(irrefutable_let_patterns)]
336 pub fn into_get_current(self) -> Option<(ProviderGetCurrentResponder)> {
337 if let ProviderRequest::GetCurrent { responder } = self {
338 Some((responder))
339 } else {
340 None
341 }
342 }
343
344 pub fn method_name(&self) -> &'static str {
346 match *self {
347 ProviderRequest::GetCurrent { .. } => "get_current",
348 }
349 }
350}
351
352#[derive(Debug, Clone)]
353pub struct ProviderControlHandle {
354 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
355}
356
357impl fidl::endpoints::ControlHandle for ProviderControlHandle {
358 fn shutdown(&self) {
359 self.inner.shutdown()
360 }
361 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
362 self.inner.shutdown_with_epitaph(status)
363 }
364
365 fn is_closed(&self) -> bool {
366 self.inner.channel().is_closed()
367 }
368 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
369 self.inner.channel().on_closed()
370 }
371
372 #[cfg(target_os = "fuchsia")]
373 fn signal_peer(
374 &self,
375 clear_mask: zx::Signals,
376 set_mask: zx::Signals,
377 ) -> Result<(), zx_status::Status> {
378 use fidl::Peered;
379 self.inner.channel().signal_peer(clear_mask, set_mask)
380 }
381}
382
383impl ProviderControlHandle {}
384
385#[must_use = "FIDL methods require a response to be sent"]
386#[derive(Debug)]
387pub struct ProviderGetCurrentResponder {
388 control_handle: std::mem::ManuallyDrop<ProviderControlHandle>,
389 tx_id: u32,
390}
391
392impl std::ops::Drop for ProviderGetCurrentResponder {
396 fn drop(&mut self) {
397 self.control_handle.shutdown();
398 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
400 }
401}
402
403impl fidl::endpoints::Responder for ProviderGetCurrentResponder {
404 type ControlHandle = ProviderControlHandle;
405
406 fn control_handle(&self) -> &ProviderControlHandle {
407 &self.control_handle
408 }
409
410 fn drop_without_shutdown(mut self) {
411 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
413 std::mem::forget(self);
415 }
416}
417
418impl ProviderGetCurrentResponder {
419 pub fn send(self, mut channel: &str) -> Result<(), fidl::Error> {
423 let _result = self.send_raw(channel);
424 if _result.is_err() {
425 self.control_handle.shutdown();
426 }
427 self.drop_without_shutdown();
428 _result
429 }
430
431 pub fn send_no_shutdown_on_err(self, mut channel: &str) -> Result<(), fidl::Error> {
433 let _result = self.send_raw(channel);
434 self.drop_without_shutdown();
435 _result
436 }
437
438 fn send_raw(&self, mut channel: &str) -> Result<(), fidl::Error> {
439 self.control_handle.inner.send::<ProviderGetCurrentResponse>(
440 (channel,),
441 self.tx_id,
442 0x15af055da76e5016,
443 fidl::encoding::DynamicFlags::empty(),
444 )
445 }
446}
447
448mod internal {
449 use super::*;
450}