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