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