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_recovery_android__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct UpdaterUpdateRequest {
16 pub manifest_url: String,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for UpdaterUpdateRequest {}
21
22#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
23pub struct UpdaterMarker;
24
25impl fidl::endpoints::ProtocolMarker for UpdaterMarker {
26 type Proxy = UpdaterProxy;
27 type RequestStream = UpdaterRequestStream;
28 #[cfg(target_os = "fuchsia")]
29 type SynchronousProxy = UpdaterSynchronousProxy;
30
31 const DEBUG_NAME: &'static str = "fuchsia.recovery.android.Updater";
32}
33impl fidl::endpoints::DiscoverableProtocolMarker for UpdaterMarker {}
34
35pub trait UpdaterProxyInterface: Send + Sync {
36 type UpdateResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
37 fn r#update(&self, manifest_url: &str) -> Self::UpdateResponseFut;
38}
39#[derive(Debug)]
40#[cfg(target_os = "fuchsia")]
41pub struct UpdaterSynchronousProxy {
42 client: fidl::client::sync::Client,
43}
44
45#[cfg(target_os = "fuchsia")]
46impl fidl::endpoints::SynchronousProxy for UpdaterSynchronousProxy {
47 type Proxy = UpdaterProxy;
48 type Protocol = UpdaterMarker;
49
50 fn from_channel(inner: fidl::Channel) -> Self {
51 Self::new(inner)
52 }
53
54 fn into_channel(self) -> fidl::Channel {
55 self.client.into_channel()
56 }
57
58 fn as_channel(&self) -> &fidl::Channel {
59 self.client.as_channel()
60 }
61}
62
63#[cfg(target_os = "fuchsia")]
64impl UpdaterSynchronousProxy {
65 pub fn new(channel: fidl::Channel) -> Self {
66 let protocol_name = <UpdaterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
67 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
68 }
69
70 pub fn into_channel(self) -> fidl::Channel {
71 self.client.into_channel()
72 }
73
74 pub fn wait_for_event(
77 &self,
78 deadline: zx::MonotonicInstant,
79 ) -> Result<UpdaterEvent, fidl::Error> {
80 UpdaterEvent::decode(self.client.wait_for_event(deadline)?)
81 }
82
83 pub fn r#update(
88 &self,
89 mut manifest_url: &str,
90 ___deadline: zx::MonotonicInstant,
91 ) -> Result<(), fidl::Error> {
92 let _response =
93 self.client.send_query::<UpdaterUpdateRequest, fidl::encoding::EmptyPayload>(
94 (manifest_url,),
95 0x6e9c49ff8508aac7,
96 fidl::encoding::DynamicFlags::empty(),
97 ___deadline,
98 )?;
99 Ok(_response)
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<UpdaterSynchronousProxy> for zx::Handle {
105 fn from(value: UpdaterSynchronousProxy) -> Self {
106 value.into_channel().into()
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl From<fidl::Channel> for UpdaterSynchronousProxy {
112 fn from(value: fidl::Channel) -> Self {
113 Self::new(value)
114 }
115}
116
117#[cfg(target_os = "fuchsia")]
118impl fidl::endpoints::FromClient for UpdaterSynchronousProxy {
119 type Protocol = UpdaterMarker;
120
121 fn from_client(value: fidl::endpoints::ClientEnd<UpdaterMarker>) -> Self {
122 Self::new(value.into_channel())
123 }
124}
125
126#[derive(Debug, Clone)]
127pub struct UpdaterProxy {
128 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
129}
130
131impl fidl::endpoints::Proxy for UpdaterProxy {
132 type Protocol = UpdaterMarker;
133
134 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
135 Self::new(inner)
136 }
137
138 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
139 self.client.into_channel().map_err(|client| Self { client })
140 }
141
142 fn as_channel(&self) -> &::fidl::AsyncChannel {
143 self.client.as_channel()
144 }
145}
146
147impl UpdaterProxy {
148 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
150 let protocol_name = <UpdaterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
151 Self { client: fidl::client::Client::new(channel, protocol_name) }
152 }
153
154 pub fn take_event_stream(&self) -> UpdaterEventStream {
160 UpdaterEventStream { event_receiver: self.client.take_event_receiver() }
161 }
162
163 pub fn r#update(
168 &self,
169 mut manifest_url: &str,
170 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
171 UpdaterProxyInterface::r#update(self, manifest_url)
172 }
173}
174
175impl UpdaterProxyInterface for UpdaterProxy {
176 type UpdateResponseFut =
177 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
178 fn r#update(&self, mut manifest_url: &str) -> Self::UpdateResponseFut {
179 fn _decode(
180 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
181 ) -> Result<(), fidl::Error> {
182 let _response = fidl::client::decode_transaction_body::<
183 fidl::encoding::EmptyPayload,
184 fidl::encoding::DefaultFuchsiaResourceDialect,
185 0x6e9c49ff8508aac7,
186 >(_buf?)?;
187 Ok(_response)
188 }
189 self.client.send_query_and_decode::<UpdaterUpdateRequest, ()>(
190 (manifest_url,),
191 0x6e9c49ff8508aac7,
192 fidl::encoding::DynamicFlags::empty(),
193 _decode,
194 )
195 }
196}
197
198pub struct UpdaterEventStream {
199 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
200}
201
202impl std::marker::Unpin for UpdaterEventStream {}
203
204impl futures::stream::FusedStream for UpdaterEventStream {
205 fn is_terminated(&self) -> bool {
206 self.event_receiver.is_terminated()
207 }
208}
209
210impl futures::Stream for UpdaterEventStream {
211 type Item = Result<UpdaterEvent, fidl::Error>;
212
213 fn poll_next(
214 mut self: std::pin::Pin<&mut Self>,
215 cx: &mut std::task::Context<'_>,
216 ) -> std::task::Poll<Option<Self::Item>> {
217 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
218 &mut self.event_receiver,
219 cx
220 )?) {
221 Some(buf) => std::task::Poll::Ready(Some(UpdaterEvent::decode(buf))),
222 None => std::task::Poll::Ready(None),
223 }
224 }
225}
226
227#[derive(Debug)]
228pub enum UpdaterEvent {}
229
230impl UpdaterEvent {
231 fn decode(
233 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
234 ) -> Result<UpdaterEvent, fidl::Error> {
235 let (bytes, _handles) = buf.split_mut();
236 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
237 debug_assert_eq!(tx_header.tx_id, 0);
238 match tx_header.ordinal {
239 _ => Err(fidl::Error::UnknownOrdinal {
240 ordinal: tx_header.ordinal,
241 protocol_name: <UpdaterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
242 }),
243 }
244 }
245}
246
247pub struct UpdaterRequestStream {
249 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
250 is_terminated: bool,
251}
252
253impl std::marker::Unpin for UpdaterRequestStream {}
254
255impl futures::stream::FusedStream for UpdaterRequestStream {
256 fn is_terminated(&self) -> bool {
257 self.is_terminated
258 }
259}
260
261impl fidl::endpoints::RequestStream for UpdaterRequestStream {
262 type Protocol = UpdaterMarker;
263 type ControlHandle = UpdaterControlHandle;
264
265 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
266 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
267 }
268
269 fn control_handle(&self) -> Self::ControlHandle {
270 UpdaterControlHandle { inner: self.inner.clone() }
271 }
272
273 fn into_inner(
274 self,
275 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
276 {
277 (self.inner, self.is_terminated)
278 }
279
280 fn from_inner(
281 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
282 is_terminated: bool,
283 ) -> Self {
284 Self { inner, is_terminated }
285 }
286}
287
288impl futures::Stream for UpdaterRequestStream {
289 type Item = Result<UpdaterRequest, fidl::Error>;
290
291 fn poll_next(
292 mut self: std::pin::Pin<&mut Self>,
293 cx: &mut std::task::Context<'_>,
294 ) -> std::task::Poll<Option<Self::Item>> {
295 let this = &mut *self;
296 if this.inner.check_shutdown(cx) {
297 this.is_terminated = true;
298 return std::task::Poll::Ready(None);
299 }
300 if this.is_terminated {
301 panic!("polled UpdaterRequestStream after completion");
302 }
303 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
304 |bytes, handles| {
305 match this.inner.channel().read_etc(cx, bytes, handles) {
306 std::task::Poll::Ready(Ok(())) => {}
307 std::task::Poll::Pending => return std::task::Poll::Pending,
308 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
309 this.is_terminated = true;
310 return std::task::Poll::Ready(None);
311 }
312 std::task::Poll::Ready(Err(e)) => {
313 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
314 e.into(),
315 ))));
316 }
317 }
318
319 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
321
322 std::task::Poll::Ready(Some(match header.ordinal {
323 0x6e9c49ff8508aac7 => {
324 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
325 let mut req = fidl::new_empty!(
326 UpdaterUpdateRequest,
327 fidl::encoding::DefaultFuchsiaResourceDialect
328 );
329 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UpdaterUpdateRequest>(&header, _body_bytes, handles, &mut req)?;
330 let control_handle = UpdaterControlHandle { inner: this.inner.clone() };
331 Ok(UpdaterRequest::Update {
332 manifest_url: req.manifest_url,
333
334 responder: UpdaterUpdateResponder {
335 control_handle: std::mem::ManuallyDrop::new(control_handle),
336 tx_id: header.tx_id,
337 },
338 })
339 }
340 _ => Err(fidl::Error::UnknownOrdinal {
341 ordinal: header.ordinal,
342 protocol_name:
343 <UpdaterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
344 }),
345 }))
346 },
347 )
348 }
349}
350
351#[derive(Debug)]
353pub enum UpdaterRequest {
354 Update { manifest_url: String, responder: UpdaterUpdateResponder },
359}
360
361impl UpdaterRequest {
362 #[allow(irrefutable_let_patterns)]
363 pub fn into_update(self) -> Option<(String, UpdaterUpdateResponder)> {
364 if let UpdaterRequest::Update { manifest_url, responder } = self {
365 Some((manifest_url, responder))
366 } else {
367 None
368 }
369 }
370
371 pub fn method_name(&self) -> &'static str {
373 match *self {
374 UpdaterRequest::Update { .. } => "update",
375 }
376 }
377}
378
379#[derive(Debug, Clone)]
380pub struct UpdaterControlHandle {
381 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
382}
383
384impl fidl::endpoints::ControlHandle for UpdaterControlHandle {
385 fn shutdown(&self) {
386 self.inner.shutdown()
387 }
388 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
389 self.inner.shutdown_with_epitaph(status)
390 }
391
392 fn is_closed(&self) -> bool {
393 self.inner.channel().is_closed()
394 }
395 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
396 self.inner.channel().on_closed()
397 }
398
399 #[cfg(target_os = "fuchsia")]
400 fn signal_peer(
401 &self,
402 clear_mask: zx::Signals,
403 set_mask: zx::Signals,
404 ) -> Result<(), zx_status::Status> {
405 use fidl::Peered;
406 self.inner.channel().signal_peer(clear_mask, set_mask)
407 }
408}
409
410impl UpdaterControlHandle {}
411
412#[must_use = "FIDL methods require a response to be sent"]
413#[derive(Debug)]
414pub struct UpdaterUpdateResponder {
415 control_handle: std::mem::ManuallyDrop<UpdaterControlHandle>,
416 tx_id: u32,
417}
418
419impl std::ops::Drop for UpdaterUpdateResponder {
423 fn drop(&mut self) {
424 self.control_handle.shutdown();
425 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
427 }
428}
429
430impl fidl::endpoints::Responder for UpdaterUpdateResponder {
431 type ControlHandle = UpdaterControlHandle;
432
433 fn control_handle(&self) -> &UpdaterControlHandle {
434 &self.control_handle
435 }
436
437 fn drop_without_shutdown(mut self) {
438 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
440 std::mem::forget(self);
442 }
443}
444
445impl UpdaterUpdateResponder {
446 pub fn send(self) -> Result<(), fidl::Error> {
450 let _result = self.send_raw();
451 if _result.is_err() {
452 self.control_handle.shutdown();
453 }
454 self.drop_without_shutdown();
455 _result
456 }
457
458 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
460 let _result = self.send_raw();
461 self.drop_without_shutdown();
462 _result
463 }
464
465 fn send_raw(&self) -> Result<(), fidl::Error> {
466 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
467 (),
468 self.tx_id,
469 0x6e9c49ff8508aac7,
470 fidl::encoding::DynamicFlags::empty(),
471 )
472 }
473}
474
475mod internal {
476 use super::*;
477
478 impl fidl::encoding::ResourceTypeMarker for UpdaterUpdateRequest {
479 type Borrowed<'a> = &'a mut Self;
480 fn take_or_borrow<'a>(
481 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
482 ) -> Self::Borrowed<'a> {
483 value
484 }
485 }
486
487 unsafe impl fidl::encoding::TypeMarker for UpdaterUpdateRequest {
488 type Owned = Self;
489
490 #[inline(always)]
491 fn inline_align(_context: fidl::encoding::Context) -> usize {
492 8
493 }
494
495 #[inline(always)]
496 fn inline_size(_context: fidl::encoding::Context) -> usize {
497 16
498 }
499 }
500
501 unsafe impl
502 fidl::encoding::Encode<UpdaterUpdateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
503 for &mut UpdaterUpdateRequest
504 {
505 #[inline]
506 unsafe fn encode(
507 self,
508 encoder: &mut fidl::encoding::Encoder<
509 '_,
510 fidl::encoding::DefaultFuchsiaResourceDialect,
511 >,
512 offset: usize,
513 _depth: fidl::encoding::Depth,
514 ) -> fidl::Result<()> {
515 encoder.debug_check_bounds::<UpdaterUpdateRequest>(offset);
516 fidl::encoding::Encode::<
518 UpdaterUpdateRequest,
519 fidl::encoding::DefaultFuchsiaResourceDialect,
520 >::encode(
521 (<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(
522 &self.manifest_url,
523 ),),
524 encoder,
525 offset,
526 _depth,
527 )
528 }
529 }
530 unsafe impl<
531 T0: fidl::encoding::Encode<
532 fidl::encoding::BoundedString<4096>,
533 fidl::encoding::DefaultFuchsiaResourceDialect,
534 >,
535 >
536 fidl::encoding::Encode<UpdaterUpdateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
537 for (T0,)
538 {
539 #[inline]
540 unsafe fn encode(
541 self,
542 encoder: &mut fidl::encoding::Encoder<
543 '_,
544 fidl::encoding::DefaultFuchsiaResourceDialect,
545 >,
546 offset: usize,
547 depth: fidl::encoding::Depth,
548 ) -> fidl::Result<()> {
549 encoder.debug_check_bounds::<UpdaterUpdateRequest>(offset);
550 self.0.encode(encoder, offset + 0, depth)?;
554 Ok(())
555 }
556 }
557
558 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
559 for UpdaterUpdateRequest
560 {
561 #[inline(always)]
562 fn new_empty() -> Self {
563 Self {
564 manifest_url: fidl::new_empty!(
565 fidl::encoding::BoundedString<4096>,
566 fidl::encoding::DefaultFuchsiaResourceDialect
567 ),
568 }
569 }
570
571 #[inline]
572 unsafe fn decode(
573 &mut self,
574 decoder: &mut fidl::encoding::Decoder<
575 '_,
576 fidl::encoding::DefaultFuchsiaResourceDialect,
577 >,
578 offset: usize,
579 _depth: fidl::encoding::Depth,
580 ) -> fidl::Result<()> {
581 decoder.debug_check_bounds::<Self>(offset);
582 fidl::decode!(
584 fidl::encoding::BoundedString<4096>,
585 fidl::encoding::DefaultFuchsiaResourceDialect,
586 &mut self.manifest_url,
587 decoder,
588 offset + 0,
589 _depth
590 )?;
591 Ok(())
592 }
593 }
594}