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 Self { client: fidl::client::sync::Client::new(channel) }
67 }
68
69 pub fn into_channel(self) -> fidl::Channel {
70 self.client.into_channel()
71 }
72
73 pub fn wait_for_event(
76 &self,
77 deadline: zx::MonotonicInstant,
78 ) -> Result<UpdaterEvent, fidl::Error> {
79 UpdaterEvent::decode(self.client.wait_for_event::<UpdaterMarker>(deadline)?)
80 }
81
82 pub fn r#update(
87 &self,
88 mut manifest_url: &str,
89 ___deadline: zx::MonotonicInstant,
90 ) -> Result<(), fidl::Error> {
91 let _response = self
92 .client
93 .send_query::<UpdaterUpdateRequest, fidl::encoding::EmptyPayload, UpdaterMarker>(
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::NullableHandle {
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
389 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
390 self.inner.shutdown_with_epitaph(status)
391 }
392
393 fn is_closed(&self) -> bool {
394 self.inner.channel().is_closed()
395 }
396 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
397 self.inner.channel().on_closed()
398 }
399
400 #[cfg(target_os = "fuchsia")]
401 fn signal_peer(
402 &self,
403 clear_mask: zx::Signals,
404 set_mask: zx::Signals,
405 ) -> Result<(), zx_status::Status> {
406 use fidl::Peered;
407 self.inner.channel().signal_peer(clear_mask, set_mask)
408 }
409}
410
411impl UpdaterControlHandle {}
412
413#[must_use = "FIDL methods require a response to be sent"]
414#[derive(Debug)]
415pub struct UpdaterUpdateResponder {
416 control_handle: std::mem::ManuallyDrop<UpdaterControlHandle>,
417 tx_id: u32,
418}
419
420impl std::ops::Drop for UpdaterUpdateResponder {
424 fn drop(&mut self) {
425 self.control_handle.shutdown();
426 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
428 }
429}
430
431impl fidl::endpoints::Responder for UpdaterUpdateResponder {
432 type ControlHandle = UpdaterControlHandle;
433
434 fn control_handle(&self) -> &UpdaterControlHandle {
435 &self.control_handle
436 }
437
438 fn drop_without_shutdown(mut self) {
439 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
441 std::mem::forget(self);
443 }
444}
445
446impl UpdaterUpdateResponder {
447 pub fn send(self) -> Result<(), fidl::Error> {
451 let _result = self.send_raw();
452 if _result.is_err() {
453 self.control_handle.shutdown();
454 }
455 self.drop_without_shutdown();
456 _result
457 }
458
459 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
461 let _result = self.send_raw();
462 self.drop_without_shutdown();
463 _result
464 }
465
466 fn send_raw(&self) -> Result<(), fidl::Error> {
467 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
468 (),
469 self.tx_id,
470 0x6e9c49ff8508aac7,
471 fidl::encoding::DynamicFlags::empty(),
472 )
473 }
474}
475
476mod internal {
477 use super::*;
478
479 impl fidl::encoding::ResourceTypeMarker for UpdaterUpdateRequest {
480 type Borrowed<'a> = &'a mut Self;
481 fn take_or_borrow<'a>(
482 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
483 ) -> Self::Borrowed<'a> {
484 value
485 }
486 }
487
488 unsafe impl fidl::encoding::TypeMarker for UpdaterUpdateRequest {
489 type Owned = Self;
490
491 #[inline(always)]
492 fn inline_align(_context: fidl::encoding::Context) -> usize {
493 8
494 }
495
496 #[inline(always)]
497 fn inline_size(_context: fidl::encoding::Context) -> usize {
498 16
499 }
500 }
501
502 unsafe impl
503 fidl::encoding::Encode<UpdaterUpdateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
504 for &mut UpdaterUpdateRequest
505 {
506 #[inline]
507 unsafe fn encode(
508 self,
509 encoder: &mut fidl::encoding::Encoder<
510 '_,
511 fidl::encoding::DefaultFuchsiaResourceDialect,
512 >,
513 offset: usize,
514 _depth: fidl::encoding::Depth,
515 ) -> fidl::Result<()> {
516 encoder.debug_check_bounds::<UpdaterUpdateRequest>(offset);
517 fidl::encoding::Encode::<
519 UpdaterUpdateRequest,
520 fidl::encoding::DefaultFuchsiaResourceDialect,
521 >::encode(
522 (<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(
523 &self.manifest_url,
524 ),),
525 encoder,
526 offset,
527 _depth,
528 )
529 }
530 }
531 unsafe impl<
532 T0: fidl::encoding::Encode<
533 fidl::encoding::BoundedString<4096>,
534 fidl::encoding::DefaultFuchsiaResourceDialect,
535 >,
536 >
537 fidl::encoding::Encode<UpdaterUpdateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
538 for (T0,)
539 {
540 #[inline]
541 unsafe fn encode(
542 self,
543 encoder: &mut fidl::encoding::Encoder<
544 '_,
545 fidl::encoding::DefaultFuchsiaResourceDialect,
546 >,
547 offset: usize,
548 depth: fidl::encoding::Depth,
549 ) -> fidl::Result<()> {
550 encoder.debug_check_bounds::<UpdaterUpdateRequest>(offset);
551 self.0.encode(encoder, offset + 0, depth)?;
555 Ok(())
556 }
557 }
558
559 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
560 for UpdaterUpdateRequest
561 {
562 #[inline(always)]
563 fn new_empty() -> Self {
564 Self {
565 manifest_url: fidl::new_empty!(
566 fidl::encoding::BoundedString<4096>,
567 fidl::encoding::DefaultFuchsiaResourceDialect
568 ),
569 }
570 }
571
572 #[inline]
573 unsafe fn decode(
574 &mut self,
575 decoder: &mut fidl::encoding::Decoder<
576 '_,
577 fidl::encoding::DefaultFuchsiaResourceDialect,
578 >,
579 offset: usize,
580 _depth: fidl::encoding::Depth,
581 ) -> fidl::Result<()> {
582 decoder.debug_check_bounds::<Self>(offset);
583 fidl::decode!(
585 fidl::encoding::BoundedString<4096>,
586 fidl::encoding::DefaultFuchsiaResourceDialect,
587 &mut self.manifest_url,
588 decoder,
589 offset + 0,
590 _depth
591 )?;
592 Ok(())
593 }
594 }
595}