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_process_lifecycle__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct LifecycleOnEscrowRequest {
16 pub outgoing_dir: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>>,
20 pub escrowed_dictionary: Option<fidl_fuchsia_component_sandbox::DictionaryRef>,
33 #[doc(hidden)]
34 pub __source_breaking: fidl::marker::SourceBreaking,
35}
36
37impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LifecycleOnEscrowRequest {}
38
39#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
40pub struct LifecycleMarker;
41
42impl fidl::endpoints::ProtocolMarker for LifecycleMarker {
43 type Proxy = LifecycleProxy;
44 type RequestStream = LifecycleRequestStream;
45 #[cfg(target_os = "fuchsia")]
46 type SynchronousProxy = LifecycleSynchronousProxy;
47
48 const DEBUG_NAME: &'static str = "(anonymous) Lifecycle";
49}
50
51pub trait LifecycleProxyInterface: Send + Sync {
52 fn r#stop(&self) -> Result<(), fidl::Error>;
53}
54#[derive(Debug)]
55#[cfg(target_os = "fuchsia")]
56pub struct LifecycleSynchronousProxy {
57 client: fidl::client::sync::Client,
58}
59
60#[cfg(target_os = "fuchsia")]
61impl fidl::endpoints::SynchronousProxy for LifecycleSynchronousProxy {
62 type Proxy = LifecycleProxy;
63 type Protocol = LifecycleMarker;
64
65 fn from_channel(inner: fidl::Channel) -> Self {
66 Self::new(inner)
67 }
68
69 fn into_channel(self) -> fidl::Channel {
70 self.client.into_channel()
71 }
72
73 fn as_channel(&self) -> &fidl::Channel {
74 self.client.as_channel()
75 }
76}
77
78#[cfg(target_os = "fuchsia")]
79impl LifecycleSynchronousProxy {
80 pub fn new(channel: fidl::Channel) -> Self {
81 let protocol_name = <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
82 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
83 }
84
85 pub fn into_channel(self) -> fidl::Channel {
86 self.client.into_channel()
87 }
88
89 pub fn wait_for_event(
92 &self,
93 deadline: zx::MonotonicInstant,
94 ) -> Result<LifecycleEvent, fidl::Error> {
95 LifecycleEvent::decode(self.client.wait_for_event(deadline)?)
96 }
97
98 pub fn r#stop(&self) -> Result<(), fidl::Error> {
104 self.client.send::<fidl::encoding::EmptyPayload>(
105 (),
106 0x64b176f1744c6f15,
107 fidl::encoding::DynamicFlags::empty(),
108 )
109 }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<LifecycleSynchronousProxy> for zx::Handle {
114 fn from(value: LifecycleSynchronousProxy) -> Self {
115 value.into_channel().into()
116 }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<fidl::Channel> for LifecycleSynchronousProxy {
121 fn from(value: fidl::Channel) -> Self {
122 Self::new(value)
123 }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl fidl::endpoints::FromClient for LifecycleSynchronousProxy {
128 type Protocol = LifecycleMarker;
129
130 fn from_client(value: fidl::endpoints::ClientEnd<LifecycleMarker>) -> Self {
131 Self::new(value.into_channel())
132 }
133}
134
135#[derive(Debug, Clone)]
136pub struct LifecycleProxy {
137 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
138}
139
140impl fidl::endpoints::Proxy for LifecycleProxy {
141 type Protocol = LifecycleMarker;
142
143 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
144 Self::new(inner)
145 }
146
147 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
148 self.client.into_channel().map_err(|client| Self { client })
149 }
150
151 fn as_channel(&self) -> &::fidl::AsyncChannel {
152 self.client.as_channel()
153 }
154}
155
156impl LifecycleProxy {
157 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
159 let protocol_name = <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
160 Self { client: fidl::client::Client::new(channel, protocol_name) }
161 }
162
163 pub fn take_event_stream(&self) -> LifecycleEventStream {
169 LifecycleEventStream { event_receiver: self.client.take_event_receiver() }
170 }
171
172 pub fn r#stop(&self) -> Result<(), fidl::Error> {
178 LifecycleProxyInterface::r#stop(self)
179 }
180}
181
182impl LifecycleProxyInterface for LifecycleProxy {
183 fn r#stop(&self) -> Result<(), fidl::Error> {
184 self.client.send::<fidl::encoding::EmptyPayload>(
185 (),
186 0x64b176f1744c6f15,
187 fidl::encoding::DynamicFlags::empty(),
188 )
189 }
190}
191
192pub struct LifecycleEventStream {
193 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
194}
195
196impl std::marker::Unpin for LifecycleEventStream {}
197
198impl futures::stream::FusedStream for LifecycleEventStream {
199 fn is_terminated(&self) -> bool {
200 self.event_receiver.is_terminated()
201 }
202}
203
204impl futures::Stream for LifecycleEventStream {
205 type Item = Result<LifecycleEvent, fidl::Error>;
206
207 fn poll_next(
208 mut self: std::pin::Pin<&mut Self>,
209 cx: &mut std::task::Context<'_>,
210 ) -> std::task::Poll<Option<Self::Item>> {
211 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
212 &mut self.event_receiver,
213 cx
214 )?) {
215 Some(buf) => std::task::Poll::Ready(Some(LifecycleEvent::decode(buf))),
216 None => std::task::Poll::Ready(None),
217 }
218 }
219}
220
221#[derive(Debug)]
222pub enum LifecycleEvent {
223 OnEscrow { payload: LifecycleOnEscrowRequest },
224}
225
226impl LifecycleEvent {
227 #[allow(irrefutable_let_patterns)]
228 pub fn into_on_escrow(self) -> Option<LifecycleOnEscrowRequest> {
229 if let LifecycleEvent::OnEscrow { payload } = self { Some((payload)) } else { None }
230 }
231
232 fn decode(
234 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
235 ) -> Result<LifecycleEvent, fidl::Error> {
236 let (bytes, _handles) = buf.split_mut();
237 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
238 debug_assert_eq!(tx_header.tx_id, 0);
239 match tx_header.ordinal {
240 0x3de9c2fcb734ed48 => {
241 let mut out = fidl::new_empty!(
242 LifecycleOnEscrowRequest,
243 fidl::encoding::DefaultFuchsiaResourceDialect
244 );
245 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LifecycleOnEscrowRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
246 Ok((LifecycleEvent::OnEscrow { payload: out }))
247 }
248 _ => Err(fidl::Error::UnknownOrdinal {
249 ordinal: tx_header.ordinal,
250 protocol_name: <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
251 }),
252 }
253 }
254}
255
256pub struct LifecycleRequestStream {
258 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
259 is_terminated: bool,
260}
261
262impl std::marker::Unpin for LifecycleRequestStream {}
263
264impl futures::stream::FusedStream for LifecycleRequestStream {
265 fn is_terminated(&self) -> bool {
266 self.is_terminated
267 }
268}
269
270impl fidl::endpoints::RequestStream for LifecycleRequestStream {
271 type Protocol = LifecycleMarker;
272 type ControlHandle = LifecycleControlHandle;
273
274 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
275 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
276 }
277
278 fn control_handle(&self) -> Self::ControlHandle {
279 LifecycleControlHandle { inner: self.inner.clone() }
280 }
281
282 fn into_inner(
283 self,
284 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
285 {
286 (self.inner, self.is_terminated)
287 }
288
289 fn from_inner(
290 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
291 is_terminated: bool,
292 ) -> Self {
293 Self { inner, is_terminated }
294 }
295}
296
297impl futures::Stream for LifecycleRequestStream {
298 type Item = Result<LifecycleRequest, fidl::Error>;
299
300 fn poll_next(
301 mut self: std::pin::Pin<&mut Self>,
302 cx: &mut std::task::Context<'_>,
303 ) -> std::task::Poll<Option<Self::Item>> {
304 let this = &mut *self;
305 if this.inner.check_shutdown(cx) {
306 this.is_terminated = true;
307 return std::task::Poll::Ready(None);
308 }
309 if this.is_terminated {
310 panic!("polled LifecycleRequestStream after completion");
311 }
312 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
313 |bytes, handles| {
314 match this.inner.channel().read_etc(cx, bytes, handles) {
315 std::task::Poll::Ready(Ok(())) => {}
316 std::task::Poll::Pending => return std::task::Poll::Pending,
317 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
318 this.is_terminated = true;
319 return std::task::Poll::Ready(None);
320 }
321 std::task::Poll::Ready(Err(e)) => {
322 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
323 e.into(),
324 ))));
325 }
326 }
327
328 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
330
331 std::task::Poll::Ready(Some(match header.ordinal {
332 0x64b176f1744c6f15 => {
333 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
334 let mut req = fidl::new_empty!(
335 fidl::encoding::EmptyPayload,
336 fidl::encoding::DefaultFuchsiaResourceDialect
337 );
338 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
339 let control_handle = LifecycleControlHandle { inner: this.inner.clone() };
340 Ok(LifecycleRequest::Stop { control_handle })
341 }
342 _ => Err(fidl::Error::UnknownOrdinal {
343 ordinal: header.ordinal,
344 protocol_name:
345 <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
346 }),
347 }))
348 },
349 )
350 }
351}
352
353#[derive(Debug)]
361pub enum LifecycleRequest {
362 Stop { control_handle: LifecycleControlHandle },
368}
369
370impl LifecycleRequest {
371 #[allow(irrefutable_let_patterns)]
372 pub fn into_stop(self) -> Option<(LifecycleControlHandle)> {
373 if let LifecycleRequest::Stop { control_handle } = self {
374 Some((control_handle))
375 } else {
376 None
377 }
378 }
379
380 pub fn method_name(&self) -> &'static str {
382 match *self {
383 LifecycleRequest::Stop { .. } => "stop",
384 }
385 }
386}
387
388#[derive(Debug, Clone)]
389pub struct LifecycleControlHandle {
390 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
391}
392
393impl fidl::endpoints::ControlHandle for LifecycleControlHandle {
394 fn shutdown(&self) {
395 self.inner.shutdown()
396 }
397 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
398 self.inner.shutdown_with_epitaph(status)
399 }
400
401 fn is_closed(&self) -> bool {
402 self.inner.channel().is_closed()
403 }
404 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
405 self.inner.channel().on_closed()
406 }
407
408 #[cfg(target_os = "fuchsia")]
409 fn signal_peer(
410 &self,
411 clear_mask: zx::Signals,
412 set_mask: zx::Signals,
413 ) -> Result<(), zx_status::Status> {
414 use fidl::Peered;
415 self.inner.channel().signal_peer(clear_mask, set_mask)
416 }
417}
418
419impl LifecycleControlHandle {
420 pub fn send_on_escrow(&self, mut payload: LifecycleOnEscrowRequest) -> Result<(), fidl::Error> {
421 self.inner.send::<LifecycleOnEscrowRequest>(
422 &mut payload,
423 0,
424 0x3de9c2fcb734ed48,
425 fidl::encoding::DynamicFlags::empty(),
426 )
427 }
428}
429
430mod internal {
431 use super::*;
432
433 impl LifecycleOnEscrowRequest {
434 #[inline(always)]
435 fn max_ordinal_present(&self) -> u64 {
436 if let Some(_) = self.escrowed_dictionary {
437 return 2;
438 }
439 if let Some(_) = self.outgoing_dir {
440 return 1;
441 }
442 0
443 }
444 }
445
446 impl fidl::encoding::ResourceTypeMarker for LifecycleOnEscrowRequest {
447 type Borrowed<'a> = &'a mut Self;
448 fn take_or_borrow<'a>(
449 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
450 ) -> Self::Borrowed<'a> {
451 value
452 }
453 }
454
455 unsafe impl fidl::encoding::TypeMarker for LifecycleOnEscrowRequest {
456 type Owned = Self;
457
458 #[inline(always)]
459 fn inline_align(_context: fidl::encoding::Context) -> usize {
460 8
461 }
462
463 #[inline(always)]
464 fn inline_size(_context: fidl::encoding::Context) -> usize {
465 16
466 }
467 }
468
469 unsafe impl
470 fidl::encoding::Encode<
471 LifecycleOnEscrowRequest,
472 fidl::encoding::DefaultFuchsiaResourceDialect,
473 > for &mut LifecycleOnEscrowRequest
474 {
475 unsafe fn encode(
476 self,
477 encoder: &mut fidl::encoding::Encoder<
478 '_,
479 fidl::encoding::DefaultFuchsiaResourceDialect,
480 >,
481 offset: usize,
482 mut depth: fidl::encoding::Depth,
483 ) -> fidl::Result<()> {
484 encoder.debug_check_bounds::<LifecycleOnEscrowRequest>(offset);
485 let max_ordinal: u64 = self.max_ordinal_present();
487 encoder.write_num(max_ordinal, offset);
488 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
489 if max_ordinal == 0 {
491 return Ok(());
492 }
493 depth.increment()?;
494 let envelope_size = 8;
495 let bytes_len = max_ordinal as usize * envelope_size;
496 #[allow(unused_variables)]
497 let offset = encoder.out_of_line_offset(bytes_len);
498 let mut _prev_end_offset: usize = 0;
499 if 1 > max_ordinal {
500 return Ok(());
501 }
502
503 let cur_offset: usize = (1 - 1) * envelope_size;
506
507 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
509
510 fidl::encoding::encode_in_envelope_optional::<
515 fidl::encoding::Endpoint<
516 fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
517 >,
518 fidl::encoding::DefaultFuchsiaResourceDialect,
519 >(
520 self.outgoing_dir.as_mut().map(
521 <fidl::encoding::Endpoint<
522 fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
523 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
524 ),
525 encoder,
526 offset + cur_offset,
527 depth,
528 )?;
529
530 _prev_end_offset = cur_offset + envelope_size;
531 if 2 > max_ordinal {
532 return Ok(());
533 }
534
535 let cur_offset: usize = (2 - 1) * envelope_size;
538
539 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
541
542 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_component_sandbox::DictionaryRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
547 self.escrowed_dictionary.as_mut().map(<fidl_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
548 encoder, offset + cur_offset, depth
549 )?;
550
551 _prev_end_offset = cur_offset + envelope_size;
552
553 Ok(())
554 }
555 }
556
557 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
558 for LifecycleOnEscrowRequest
559 {
560 #[inline(always)]
561 fn new_empty() -> Self {
562 Self::default()
563 }
564
565 unsafe fn decode(
566 &mut self,
567 decoder: &mut fidl::encoding::Decoder<
568 '_,
569 fidl::encoding::DefaultFuchsiaResourceDialect,
570 >,
571 offset: usize,
572 mut depth: fidl::encoding::Depth,
573 ) -> fidl::Result<()> {
574 decoder.debug_check_bounds::<Self>(offset);
575 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
576 None => return Err(fidl::Error::NotNullable),
577 Some(len) => len,
578 };
579 if len == 0 {
581 return Ok(());
582 };
583 depth.increment()?;
584 let envelope_size = 8;
585 let bytes_len = len * envelope_size;
586 let offset = decoder.out_of_line_offset(bytes_len)?;
587 let mut _next_ordinal_to_read = 0;
589 let mut next_offset = offset;
590 let end_offset = offset + bytes_len;
591 _next_ordinal_to_read += 1;
592 if next_offset >= end_offset {
593 return Ok(());
594 }
595
596 while _next_ordinal_to_read < 1 {
598 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
599 _next_ordinal_to_read += 1;
600 next_offset += envelope_size;
601 }
602
603 let next_out_of_line = decoder.next_out_of_line();
604 let handles_before = decoder.remaining_handles();
605 if let Some((inlined, num_bytes, num_handles)) =
606 fidl::encoding::decode_envelope_header(decoder, next_offset)?
607 {
608 let member_inline_size = <fidl::encoding::Endpoint<
609 fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
610 > as fidl::encoding::TypeMarker>::inline_size(
611 decoder.context
612 );
613 if inlined != (member_inline_size <= 4) {
614 return Err(fidl::Error::InvalidInlineBitInEnvelope);
615 }
616 let inner_offset;
617 let mut inner_depth = depth.clone();
618 if inlined {
619 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
620 inner_offset = next_offset;
621 } else {
622 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
623 inner_depth.increment()?;
624 }
625 let val_ref = self.outgoing_dir.get_or_insert_with(|| {
626 fidl::new_empty!(
627 fidl::encoding::Endpoint<
628 fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
629 >,
630 fidl::encoding::DefaultFuchsiaResourceDialect
631 )
632 });
633 fidl::decode!(
634 fidl::encoding::Endpoint<
635 fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
636 >,
637 fidl::encoding::DefaultFuchsiaResourceDialect,
638 val_ref,
639 decoder,
640 inner_offset,
641 inner_depth
642 )?;
643 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
644 {
645 return Err(fidl::Error::InvalidNumBytesInEnvelope);
646 }
647 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
648 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
649 }
650 }
651
652 next_offset += envelope_size;
653 _next_ordinal_to_read += 1;
654 if next_offset >= end_offset {
655 return Ok(());
656 }
657
658 while _next_ordinal_to_read < 2 {
660 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
661 _next_ordinal_to_read += 1;
662 next_offset += envelope_size;
663 }
664
665 let next_out_of_line = decoder.next_out_of_line();
666 let handles_before = decoder.remaining_handles();
667 if let Some((inlined, num_bytes, num_handles)) =
668 fidl::encoding::decode_envelope_header(decoder, next_offset)?
669 {
670 let member_inline_size = <fidl_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
671 if inlined != (member_inline_size <= 4) {
672 return Err(fidl::Error::InvalidInlineBitInEnvelope);
673 }
674 let inner_offset;
675 let mut inner_depth = depth.clone();
676 if inlined {
677 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
678 inner_offset = next_offset;
679 } else {
680 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
681 inner_depth.increment()?;
682 }
683 let val_ref = self.escrowed_dictionary.get_or_insert_with(|| {
684 fidl::new_empty!(
685 fidl_fuchsia_component_sandbox::DictionaryRef,
686 fidl::encoding::DefaultFuchsiaResourceDialect
687 )
688 });
689 fidl::decode!(
690 fidl_fuchsia_component_sandbox::DictionaryRef,
691 fidl::encoding::DefaultFuchsiaResourceDialect,
692 val_ref,
693 decoder,
694 inner_offset,
695 inner_depth
696 )?;
697 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
698 {
699 return Err(fidl::Error::InvalidNumBytesInEnvelope);
700 }
701 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
702 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
703 }
704 }
705
706 next_offset += envelope_size;
707
708 while next_offset < end_offset {
710 _next_ordinal_to_read += 1;
711 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
712 next_offset += envelope_size;
713 }
714
715 Ok(())
716 }
717 }
718}