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_unknown_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct CloneableCloneRequest {
16 pub request: fidl::endpoints::ServerEnd<CloneableMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CloneableCloneRequest {}
20
21#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22pub struct CloneableMarker;
23
24impl fidl::endpoints::ProtocolMarker for CloneableMarker {
25 type Proxy = CloneableProxy;
26 type RequestStream = CloneableRequestStream;
27 #[cfg(target_os = "fuchsia")]
28 type SynchronousProxy = CloneableSynchronousProxy;
29
30 const DEBUG_NAME: &'static str = "(anonymous) Cloneable";
31}
32
33pub trait CloneableProxyInterface: Send + Sync {
34 fn r#clone(
35 &self,
36 request: fidl::endpoints::ServerEnd<CloneableMarker>,
37 ) -> Result<(), fidl::Error>;
38}
39#[derive(Debug)]
40#[cfg(target_os = "fuchsia")]
41pub struct CloneableSynchronousProxy {
42 client: fidl::client::sync::Client,
43}
44
45#[cfg(target_os = "fuchsia")]
46impl fidl::endpoints::SynchronousProxy for CloneableSynchronousProxy {
47 type Proxy = CloneableProxy;
48 type Protocol = CloneableMarker;
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 CloneableSynchronousProxy {
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<CloneableEvent, fidl::Error> {
79 CloneableEvent::decode(self.client.wait_for_event::<CloneableMarker>(deadline)?)
80 }
81
82 pub fn r#clone(
83 &self,
84 mut request: fidl::endpoints::ServerEnd<CloneableMarker>,
85 ) -> Result<(), fidl::Error> {
86 self.client.send::<CloneableCloneRequest>(
87 (request,),
88 0x20d8a7aba2168a79,
89 fidl::encoding::DynamicFlags::empty(),
90 )
91 }
92}
93
94#[cfg(target_os = "fuchsia")]
95impl From<CloneableSynchronousProxy> for zx::NullableHandle {
96 fn from(value: CloneableSynchronousProxy) -> Self {
97 value.into_channel().into()
98 }
99}
100
101#[cfg(target_os = "fuchsia")]
102impl From<fidl::Channel> for CloneableSynchronousProxy {
103 fn from(value: fidl::Channel) -> Self {
104 Self::new(value)
105 }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl fidl::endpoints::FromClient for CloneableSynchronousProxy {
110 type Protocol = CloneableMarker;
111
112 fn from_client(value: fidl::endpoints::ClientEnd<CloneableMarker>) -> Self {
113 Self::new(value.into_channel())
114 }
115}
116
117#[derive(Debug, Clone)]
118pub struct CloneableProxy {
119 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
120}
121
122impl fidl::endpoints::Proxy for CloneableProxy {
123 type Protocol = CloneableMarker;
124
125 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
126 Self::new(inner)
127 }
128
129 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
130 self.client.into_channel().map_err(|client| Self { client })
131 }
132
133 fn as_channel(&self) -> &::fidl::AsyncChannel {
134 self.client.as_channel()
135 }
136}
137
138impl CloneableProxy {
139 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
141 let protocol_name = <CloneableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
142 Self { client: fidl::client::Client::new(channel, protocol_name) }
143 }
144
145 pub fn take_event_stream(&self) -> CloneableEventStream {
151 CloneableEventStream { event_receiver: self.client.take_event_receiver() }
152 }
153
154 pub fn r#clone(
155 &self,
156 mut request: fidl::endpoints::ServerEnd<CloneableMarker>,
157 ) -> Result<(), fidl::Error> {
158 CloneableProxyInterface::r#clone(self, request)
159 }
160}
161
162impl CloneableProxyInterface for CloneableProxy {
163 fn r#clone(
164 &self,
165 mut request: fidl::endpoints::ServerEnd<CloneableMarker>,
166 ) -> Result<(), fidl::Error> {
167 self.client.send::<CloneableCloneRequest>(
168 (request,),
169 0x20d8a7aba2168a79,
170 fidl::encoding::DynamicFlags::empty(),
171 )
172 }
173}
174
175pub struct CloneableEventStream {
176 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
177}
178
179impl std::marker::Unpin for CloneableEventStream {}
180
181impl futures::stream::FusedStream for CloneableEventStream {
182 fn is_terminated(&self) -> bool {
183 self.event_receiver.is_terminated()
184 }
185}
186
187impl futures::Stream for CloneableEventStream {
188 type Item = Result<CloneableEvent, fidl::Error>;
189
190 fn poll_next(
191 mut self: std::pin::Pin<&mut Self>,
192 cx: &mut std::task::Context<'_>,
193 ) -> std::task::Poll<Option<Self::Item>> {
194 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
195 &mut self.event_receiver,
196 cx
197 )?) {
198 Some(buf) => std::task::Poll::Ready(Some(CloneableEvent::decode(buf))),
199 None => std::task::Poll::Ready(None),
200 }
201 }
202}
203
204#[derive(Debug)]
205pub enum CloneableEvent {}
206
207impl CloneableEvent {
208 fn decode(
210 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
211 ) -> Result<CloneableEvent, fidl::Error> {
212 let (bytes, _handles) = buf.split_mut();
213 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
214 debug_assert_eq!(tx_header.tx_id, 0);
215 match tx_header.ordinal {
216 _ => Err(fidl::Error::UnknownOrdinal {
217 ordinal: tx_header.ordinal,
218 protocol_name: <CloneableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
219 }),
220 }
221 }
222}
223
224pub struct CloneableRequestStream {
226 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
227 is_terminated: bool,
228}
229
230impl std::marker::Unpin for CloneableRequestStream {}
231
232impl futures::stream::FusedStream for CloneableRequestStream {
233 fn is_terminated(&self) -> bool {
234 self.is_terminated
235 }
236}
237
238impl fidl::endpoints::RequestStream for CloneableRequestStream {
239 type Protocol = CloneableMarker;
240 type ControlHandle = CloneableControlHandle;
241
242 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
243 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
244 }
245
246 fn control_handle(&self) -> Self::ControlHandle {
247 CloneableControlHandle { inner: self.inner.clone() }
248 }
249
250 fn into_inner(
251 self,
252 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
253 {
254 (self.inner, self.is_terminated)
255 }
256
257 fn from_inner(
258 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
259 is_terminated: bool,
260 ) -> Self {
261 Self { inner, is_terminated }
262 }
263}
264
265impl futures::Stream for CloneableRequestStream {
266 type Item = Result<CloneableRequest, fidl::Error>;
267
268 fn poll_next(
269 mut self: std::pin::Pin<&mut Self>,
270 cx: &mut std::task::Context<'_>,
271 ) -> std::task::Poll<Option<Self::Item>> {
272 let this = &mut *self;
273 if this.inner.check_shutdown(cx) {
274 this.is_terminated = true;
275 return std::task::Poll::Ready(None);
276 }
277 if this.is_terminated {
278 panic!("polled CloneableRequestStream after completion");
279 }
280 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
281 |bytes, handles| {
282 match this.inner.channel().read_etc(cx, bytes, handles) {
283 std::task::Poll::Ready(Ok(())) => {}
284 std::task::Poll::Pending => return std::task::Poll::Pending,
285 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
286 this.is_terminated = true;
287 return std::task::Poll::Ready(None);
288 }
289 std::task::Poll::Ready(Err(e)) => {
290 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
291 e.into(),
292 ))));
293 }
294 }
295
296 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
298
299 std::task::Poll::Ready(Some(match header.ordinal {
300 0x20d8a7aba2168a79 => {
301 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
302 let mut req = fidl::new_empty!(
303 CloneableCloneRequest,
304 fidl::encoding::DefaultFuchsiaResourceDialect
305 );
306 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CloneableCloneRequest>(&header, _body_bytes, handles, &mut req)?;
307 let control_handle = CloneableControlHandle { inner: this.inner.clone() };
308 Ok(CloneableRequest::Clone { request: req.request, control_handle })
309 }
310 _ => Err(fidl::Error::UnknownOrdinal {
311 ordinal: header.ordinal,
312 protocol_name:
313 <CloneableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
314 }),
315 }))
316 },
317 )
318 }
319}
320
321#[derive(Debug)]
326pub enum CloneableRequest {
327 Clone {
328 request: fidl::endpoints::ServerEnd<CloneableMarker>,
329 control_handle: CloneableControlHandle,
330 },
331}
332
333impl CloneableRequest {
334 #[allow(irrefutable_let_patterns)]
335 pub fn into_clone(
336 self,
337 ) -> Option<(fidl::endpoints::ServerEnd<CloneableMarker>, CloneableControlHandle)> {
338 if let CloneableRequest::Clone { request, control_handle } = self {
339 Some((request, control_handle))
340 } else {
341 None
342 }
343 }
344
345 pub fn method_name(&self) -> &'static str {
347 match *self {
348 CloneableRequest::Clone { .. } => "clone",
349 }
350 }
351}
352
353#[derive(Debug, Clone)]
354pub struct CloneableControlHandle {
355 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
356}
357
358impl CloneableControlHandle {
359 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
360 self.inner.shutdown_with_epitaph(status.into())
361 }
362}
363
364impl fidl::endpoints::ControlHandle for CloneableControlHandle {
365 fn shutdown(&self) {
366 self.inner.shutdown()
367 }
368
369 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
370 self.inner.shutdown_with_epitaph(status)
371 }
372
373 fn is_closed(&self) -> bool {
374 self.inner.channel().is_closed()
375 }
376 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
377 self.inner.channel().on_closed()
378 }
379
380 #[cfg(target_os = "fuchsia")]
381 fn signal_peer(
382 &self,
383 clear_mask: zx::Signals,
384 set_mask: zx::Signals,
385 ) -> Result<(), zx_status::Status> {
386 use fidl::Peered;
387 self.inner.channel().signal_peer(clear_mask, set_mask)
388 }
389}
390
391impl CloneableControlHandle {}
392
393#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
394pub struct CloseableMarker;
395
396impl fidl::endpoints::ProtocolMarker for CloseableMarker {
397 type Proxy = CloseableProxy;
398 type RequestStream = CloseableRequestStream;
399 #[cfg(target_os = "fuchsia")]
400 type SynchronousProxy = CloseableSynchronousProxy;
401
402 const DEBUG_NAME: &'static str = "(anonymous) Closeable";
403}
404pub type CloseableCloseResult = Result<(), i32>;
405
406pub trait CloseableProxyInterface: Send + Sync {
407 type CloseResponseFut: std::future::Future<Output = Result<CloseableCloseResult, fidl::Error>>
408 + Send;
409 fn r#close(&self) -> Self::CloseResponseFut;
410}
411#[derive(Debug)]
412#[cfg(target_os = "fuchsia")]
413pub struct CloseableSynchronousProxy {
414 client: fidl::client::sync::Client,
415}
416
417#[cfg(target_os = "fuchsia")]
418impl fidl::endpoints::SynchronousProxy for CloseableSynchronousProxy {
419 type Proxy = CloseableProxy;
420 type Protocol = CloseableMarker;
421
422 fn from_channel(inner: fidl::Channel) -> Self {
423 Self::new(inner)
424 }
425
426 fn into_channel(self) -> fidl::Channel {
427 self.client.into_channel()
428 }
429
430 fn as_channel(&self) -> &fidl::Channel {
431 self.client.as_channel()
432 }
433}
434
435#[cfg(target_os = "fuchsia")]
436impl CloseableSynchronousProxy {
437 pub fn new(channel: fidl::Channel) -> Self {
438 Self { client: fidl::client::sync::Client::new(channel) }
439 }
440
441 pub fn into_channel(self) -> fidl::Channel {
442 self.client.into_channel()
443 }
444
445 pub fn wait_for_event(
448 &self,
449 deadline: zx::MonotonicInstant,
450 ) -> Result<CloseableEvent, fidl::Error> {
451 CloseableEvent::decode(self.client.wait_for_event::<CloseableMarker>(deadline)?)
452 }
453
454 pub fn r#close(
465 &self,
466 ___deadline: zx::MonotonicInstant,
467 ) -> Result<CloseableCloseResult, fidl::Error> {
468 let _response = self.client.send_query::<
469 fidl::encoding::EmptyPayload,
470 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
471 CloseableMarker,
472 >(
473 (),
474 0x5ac5d459ad7f657e,
475 fidl::encoding::DynamicFlags::empty(),
476 ___deadline,
477 )?;
478 Ok(_response.map(|x| x))
479 }
480}
481
482#[cfg(target_os = "fuchsia")]
483impl From<CloseableSynchronousProxy> for zx::NullableHandle {
484 fn from(value: CloseableSynchronousProxy) -> Self {
485 value.into_channel().into()
486 }
487}
488
489#[cfg(target_os = "fuchsia")]
490impl From<fidl::Channel> for CloseableSynchronousProxy {
491 fn from(value: fidl::Channel) -> Self {
492 Self::new(value)
493 }
494}
495
496#[cfg(target_os = "fuchsia")]
497impl fidl::endpoints::FromClient for CloseableSynchronousProxy {
498 type Protocol = CloseableMarker;
499
500 fn from_client(value: fidl::endpoints::ClientEnd<CloseableMarker>) -> Self {
501 Self::new(value.into_channel())
502 }
503}
504
505#[derive(Debug, Clone)]
506pub struct CloseableProxy {
507 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
508}
509
510impl fidl::endpoints::Proxy for CloseableProxy {
511 type Protocol = CloseableMarker;
512
513 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
514 Self::new(inner)
515 }
516
517 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
518 self.client.into_channel().map_err(|client| Self { client })
519 }
520
521 fn as_channel(&self) -> &::fidl::AsyncChannel {
522 self.client.as_channel()
523 }
524}
525
526impl CloseableProxy {
527 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
529 let protocol_name = <CloseableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
530 Self { client: fidl::client::Client::new(channel, protocol_name) }
531 }
532
533 pub fn take_event_stream(&self) -> CloseableEventStream {
539 CloseableEventStream { event_receiver: self.client.take_event_receiver() }
540 }
541
542 pub fn r#close(
553 &self,
554 ) -> fidl::client::QueryResponseFut<
555 CloseableCloseResult,
556 fidl::encoding::DefaultFuchsiaResourceDialect,
557 > {
558 CloseableProxyInterface::r#close(self)
559 }
560}
561
562impl CloseableProxyInterface for CloseableProxy {
563 type CloseResponseFut = fidl::client::QueryResponseFut<
564 CloseableCloseResult,
565 fidl::encoding::DefaultFuchsiaResourceDialect,
566 >;
567 fn r#close(&self) -> Self::CloseResponseFut {
568 fn _decode(
569 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
570 ) -> Result<CloseableCloseResult, fidl::Error> {
571 let _response = fidl::client::decode_transaction_body::<
572 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
573 fidl::encoding::DefaultFuchsiaResourceDialect,
574 0x5ac5d459ad7f657e,
575 >(_buf?)?;
576 Ok(_response.map(|x| x))
577 }
578 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, CloseableCloseResult>(
579 (),
580 0x5ac5d459ad7f657e,
581 fidl::encoding::DynamicFlags::empty(),
582 _decode,
583 )
584 }
585}
586
587pub struct CloseableEventStream {
588 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
589}
590
591impl std::marker::Unpin for CloseableEventStream {}
592
593impl futures::stream::FusedStream for CloseableEventStream {
594 fn is_terminated(&self) -> bool {
595 self.event_receiver.is_terminated()
596 }
597}
598
599impl futures::Stream for CloseableEventStream {
600 type Item = Result<CloseableEvent, fidl::Error>;
601
602 fn poll_next(
603 mut self: std::pin::Pin<&mut Self>,
604 cx: &mut std::task::Context<'_>,
605 ) -> std::task::Poll<Option<Self::Item>> {
606 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
607 &mut self.event_receiver,
608 cx
609 )?) {
610 Some(buf) => std::task::Poll::Ready(Some(CloseableEvent::decode(buf))),
611 None => std::task::Poll::Ready(None),
612 }
613 }
614}
615
616#[derive(Debug)]
617pub enum CloseableEvent {}
618
619impl CloseableEvent {
620 fn decode(
622 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
623 ) -> Result<CloseableEvent, fidl::Error> {
624 let (bytes, _handles) = buf.split_mut();
625 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
626 debug_assert_eq!(tx_header.tx_id, 0);
627 match tx_header.ordinal {
628 _ => Err(fidl::Error::UnknownOrdinal {
629 ordinal: tx_header.ordinal,
630 protocol_name: <CloseableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
631 }),
632 }
633 }
634}
635
636pub struct CloseableRequestStream {
638 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
639 is_terminated: bool,
640}
641
642impl std::marker::Unpin for CloseableRequestStream {}
643
644impl futures::stream::FusedStream for CloseableRequestStream {
645 fn is_terminated(&self) -> bool {
646 self.is_terminated
647 }
648}
649
650impl fidl::endpoints::RequestStream for CloseableRequestStream {
651 type Protocol = CloseableMarker;
652 type ControlHandle = CloseableControlHandle;
653
654 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
655 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
656 }
657
658 fn control_handle(&self) -> Self::ControlHandle {
659 CloseableControlHandle { inner: self.inner.clone() }
660 }
661
662 fn into_inner(
663 self,
664 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
665 {
666 (self.inner, self.is_terminated)
667 }
668
669 fn from_inner(
670 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
671 is_terminated: bool,
672 ) -> Self {
673 Self { inner, is_terminated }
674 }
675}
676
677impl futures::Stream for CloseableRequestStream {
678 type Item = Result<CloseableRequest, fidl::Error>;
679
680 fn poll_next(
681 mut self: std::pin::Pin<&mut Self>,
682 cx: &mut std::task::Context<'_>,
683 ) -> std::task::Poll<Option<Self::Item>> {
684 let this = &mut *self;
685 if this.inner.check_shutdown(cx) {
686 this.is_terminated = true;
687 return std::task::Poll::Ready(None);
688 }
689 if this.is_terminated {
690 panic!("polled CloseableRequestStream after completion");
691 }
692 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
693 |bytes, handles| {
694 match this.inner.channel().read_etc(cx, bytes, handles) {
695 std::task::Poll::Ready(Ok(())) => {}
696 std::task::Poll::Pending => return std::task::Poll::Pending,
697 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
698 this.is_terminated = true;
699 return std::task::Poll::Ready(None);
700 }
701 std::task::Poll::Ready(Err(e)) => {
702 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
703 e.into(),
704 ))));
705 }
706 }
707
708 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
710
711 std::task::Poll::Ready(Some(match header.ordinal {
712 0x5ac5d459ad7f657e => {
713 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
714 let mut req = fidl::new_empty!(
715 fidl::encoding::EmptyPayload,
716 fidl::encoding::DefaultFuchsiaResourceDialect
717 );
718 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
719 let control_handle = CloseableControlHandle { inner: this.inner.clone() };
720 Ok(CloseableRequest::Close {
721 responder: CloseableCloseResponder {
722 control_handle: std::mem::ManuallyDrop::new(control_handle),
723 tx_id: header.tx_id,
724 },
725 })
726 }
727 _ => Err(fidl::Error::UnknownOrdinal {
728 ordinal: header.ordinal,
729 protocol_name:
730 <CloseableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
731 }),
732 }))
733 },
734 )
735 }
736}
737
738#[derive(Debug)]
740pub enum CloseableRequest {
741 Close { responder: CloseableCloseResponder },
752}
753
754impl CloseableRequest {
755 #[allow(irrefutable_let_patterns)]
756 pub fn into_close(self) -> Option<(CloseableCloseResponder)> {
757 if let CloseableRequest::Close { responder } = self { Some((responder)) } else { None }
758 }
759
760 pub fn method_name(&self) -> &'static str {
762 match *self {
763 CloseableRequest::Close { .. } => "close",
764 }
765 }
766}
767
768#[derive(Debug, Clone)]
769pub struct CloseableControlHandle {
770 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
771}
772
773impl CloseableControlHandle {
774 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
775 self.inner.shutdown_with_epitaph(status.into())
776 }
777}
778
779impl fidl::endpoints::ControlHandle for CloseableControlHandle {
780 fn shutdown(&self) {
781 self.inner.shutdown()
782 }
783
784 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
785 self.inner.shutdown_with_epitaph(status)
786 }
787
788 fn is_closed(&self) -> bool {
789 self.inner.channel().is_closed()
790 }
791 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
792 self.inner.channel().on_closed()
793 }
794
795 #[cfg(target_os = "fuchsia")]
796 fn signal_peer(
797 &self,
798 clear_mask: zx::Signals,
799 set_mask: zx::Signals,
800 ) -> Result<(), zx_status::Status> {
801 use fidl::Peered;
802 self.inner.channel().signal_peer(clear_mask, set_mask)
803 }
804}
805
806impl CloseableControlHandle {}
807
808#[must_use = "FIDL methods require a response to be sent"]
809#[derive(Debug)]
810pub struct CloseableCloseResponder {
811 control_handle: std::mem::ManuallyDrop<CloseableControlHandle>,
812 tx_id: u32,
813}
814
815impl std::ops::Drop for CloseableCloseResponder {
819 fn drop(&mut self) {
820 self.control_handle.shutdown();
821 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
823 }
824}
825
826impl fidl::endpoints::Responder for CloseableCloseResponder {
827 type ControlHandle = CloseableControlHandle;
828
829 fn control_handle(&self) -> &CloseableControlHandle {
830 &self.control_handle
831 }
832
833 fn drop_without_shutdown(mut self) {
834 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
836 std::mem::forget(self);
838 }
839}
840
841impl CloseableCloseResponder {
842 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
846 let _result = self.send_raw(result);
847 if _result.is_err() {
848 self.control_handle.shutdown();
849 }
850 self.drop_without_shutdown();
851 _result
852 }
853
854 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
856 let _result = self.send_raw(result);
857 self.drop_without_shutdown();
858 _result
859 }
860
861 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
862 self.control_handle
863 .inner
864 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
865 result,
866 self.tx_id,
867 0x5ac5d459ad7f657e,
868 fidl::encoding::DynamicFlags::empty(),
869 )
870 }
871}
872
873#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
874pub struct QueryableMarker;
875
876impl fidl::endpoints::ProtocolMarker for QueryableMarker {
877 type Proxy = QueryableProxy;
878 type RequestStream = QueryableRequestStream;
879 #[cfg(target_os = "fuchsia")]
880 type SynchronousProxy = QueryableSynchronousProxy;
881
882 const DEBUG_NAME: &'static str = "(anonymous) Queryable";
883}
884
885pub trait QueryableProxyInterface: Send + Sync {
886 type QueryResponseFut: std::future::Future<Output = Result<Vec<u8>, fidl::Error>> + Send;
887 fn r#query(&self) -> Self::QueryResponseFut;
888}
889#[derive(Debug)]
890#[cfg(target_os = "fuchsia")]
891pub struct QueryableSynchronousProxy {
892 client: fidl::client::sync::Client,
893}
894
895#[cfg(target_os = "fuchsia")]
896impl fidl::endpoints::SynchronousProxy for QueryableSynchronousProxy {
897 type Proxy = QueryableProxy;
898 type Protocol = QueryableMarker;
899
900 fn from_channel(inner: fidl::Channel) -> Self {
901 Self::new(inner)
902 }
903
904 fn into_channel(self) -> fidl::Channel {
905 self.client.into_channel()
906 }
907
908 fn as_channel(&self) -> &fidl::Channel {
909 self.client.as_channel()
910 }
911}
912
913#[cfg(target_os = "fuchsia")]
914impl QueryableSynchronousProxy {
915 pub fn new(channel: fidl::Channel) -> Self {
916 Self { client: fidl::client::sync::Client::new(channel) }
917 }
918
919 pub fn into_channel(self) -> fidl::Channel {
920 self.client.into_channel()
921 }
922
923 pub fn wait_for_event(
926 &self,
927 deadline: zx::MonotonicInstant,
928 ) -> Result<QueryableEvent, fidl::Error> {
929 QueryableEvent::decode(self.client.wait_for_event::<QueryableMarker>(deadline)?)
930 }
931
932 pub fn r#query(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<u8>, fidl::Error> {
933 let _response = self
934 .client
935 .send_query::<fidl::encoding::EmptyPayload, QueryableQueryResponse, QueryableMarker>(
936 (),
937 0x2658edee9decfc06,
938 fidl::encoding::DynamicFlags::empty(),
939 ___deadline,
940 )?;
941 Ok(_response.protocol)
942 }
943}
944
945#[cfg(target_os = "fuchsia")]
946impl From<QueryableSynchronousProxy> for zx::NullableHandle {
947 fn from(value: QueryableSynchronousProxy) -> Self {
948 value.into_channel().into()
949 }
950}
951
952#[cfg(target_os = "fuchsia")]
953impl From<fidl::Channel> for QueryableSynchronousProxy {
954 fn from(value: fidl::Channel) -> Self {
955 Self::new(value)
956 }
957}
958
959#[cfg(target_os = "fuchsia")]
960impl fidl::endpoints::FromClient for QueryableSynchronousProxy {
961 type Protocol = QueryableMarker;
962
963 fn from_client(value: fidl::endpoints::ClientEnd<QueryableMarker>) -> Self {
964 Self::new(value.into_channel())
965 }
966}
967
968#[derive(Debug, Clone)]
969pub struct QueryableProxy {
970 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
971}
972
973impl fidl::endpoints::Proxy for QueryableProxy {
974 type Protocol = QueryableMarker;
975
976 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
977 Self::new(inner)
978 }
979
980 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
981 self.client.into_channel().map_err(|client| Self { client })
982 }
983
984 fn as_channel(&self) -> &::fidl::AsyncChannel {
985 self.client.as_channel()
986 }
987}
988
989impl QueryableProxy {
990 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
992 let protocol_name = <QueryableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
993 Self { client: fidl::client::Client::new(channel, protocol_name) }
994 }
995
996 pub fn take_event_stream(&self) -> QueryableEventStream {
1002 QueryableEventStream { event_receiver: self.client.take_event_receiver() }
1003 }
1004
1005 pub fn r#query(
1006 &self,
1007 ) -> fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>
1008 {
1009 QueryableProxyInterface::r#query(self)
1010 }
1011}
1012
1013impl QueryableProxyInterface for QueryableProxy {
1014 type QueryResponseFut =
1015 fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>;
1016 fn r#query(&self) -> Self::QueryResponseFut {
1017 fn _decode(
1018 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1019 ) -> Result<Vec<u8>, fidl::Error> {
1020 let _response = fidl::client::decode_transaction_body::<
1021 QueryableQueryResponse,
1022 fidl::encoding::DefaultFuchsiaResourceDialect,
1023 0x2658edee9decfc06,
1024 >(_buf?)?;
1025 Ok(_response.protocol)
1026 }
1027 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<u8>>(
1028 (),
1029 0x2658edee9decfc06,
1030 fidl::encoding::DynamicFlags::empty(),
1031 _decode,
1032 )
1033 }
1034}
1035
1036pub struct QueryableEventStream {
1037 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1038}
1039
1040impl std::marker::Unpin for QueryableEventStream {}
1041
1042impl futures::stream::FusedStream for QueryableEventStream {
1043 fn is_terminated(&self) -> bool {
1044 self.event_receiver.is_terminated()
1045 }
1046}
1047
1048impl futures::Stream for QueryableEventStream {
1049 type Item = Result<QueryableEvent, fidl::Error>;
1050
1051 fn poll_next(
1052 mut self: std::pin::Pin<&mut Self>,
1053 cx: &mut std::task::Context<'_>,
1054 ) -> std::task::Poll<Option<Self::Item>> {
1055 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1056 &mut self.event_receiver,
1057 cx
1058 )?) {
1059 Some(buf) => std::task::Poll::Ready(Some(QueryableEvent::decode(buf))),
1060 None => std::task::Poll::Ready(None),
1061 }
1062 }
1063}
1064
1065#[derive(Debug)]
1066pub enum QueryableEvent {}
1067
1068impl QueryableEvent {
1069 fn decode(
1071 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1072 ) -> Result<QueryableEvent, fidl::Error> {
1073 let (bytes, _handles) = buf.split_mut();
1074 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1075 debug_assert_eq!(tx_header.tx_id, 0);
1076 match tx_header.ordinal {
1077 _ => Err(fidl::Error::UnknownOrdinal {
1078 ordinal: tx_header.ordinal,
1079 protocol_name: <QueryableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1080 }),
1081 }
1082 }
1083}
1084
1085pub struct QueryableRequestStream {
1087 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1088 is_terminated: bool,
1089}
1090
1091impl std::marker::Unpin for QueryableRequestStream {}
1092
1093impl futures::stream::FusedStream for QueryableRequestStream {
1094 fn is_terminated(&self) -> bool {
1095 self.is_terminated
1096 }
1097}
1098
1099impl fidl::endpoints::RequestStream for QueryableRequestStream {
1100 type Protocol = QueryableMarker;
1101 type ControlHandle = QueryableControlHandle;
1102
1103 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1104 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1105 }
1106
1107 fn control_handle(&self) -> Self::ControlHandle {
1108 QueryableControlHandle { inner: self.inner.clone() }
1109 }
1110
1111 fn into_inner(
1112 self,
1113 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1114 {
1115 (self.inner, self.is_terminated)
1116 }
1117
1118 fn from_inner(
1119 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1120 is_terminated: bool,
1121 ) -> Self {
1122 Self { inner, is_terminated }
1123 }
1124}
1125
1126impl futures::Stream for QueryableRequestStream {
1127 type Item = Result<QueryableRequest, fidl::Error>;
1128
1129 fn poll_next(
1130 mut self: std::pin::Pin<&mut Self>,
1131 cx: &mut std::task::Context<'_>,
1132 ) -> std::task::Poll<Option<Self::Item>> {
1133 let this = &mut *self;
1134 if this.inner.check_shutdown(cx) {
1135 this.is_terminated = true;
1136 return std::task::Poll::Ready(None);
1137 }
1138 if this.is_terminated {
1139 panic!("polled QueryableRequestStream after completion");
1140 }
1141 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1142 |bytes, handles| {
1143 match this.inner.channel().read_etc(cx, bytes, handles) {
1144 std::task::Poll::Ready(Ok(())) => {}
1145 std::task::Poll::Pending => return std::task::Poll::Pending,
1146 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1147 this.is_terminated = true;
1148 return std::task::Poll::Ready(None);
1149 }
1150 std::task::Poll::Ready(Err(e)) => {
1151 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1152 e.into(),
1153 ))));
1154 }
1155 }
1156
1157 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1159
1160 std::task::Poll::Ready(Some(match header.ordinal {
1161 0x2658edee9decfc06 => {
1162 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1163 let mut req = fidl::new_empty!(
1164 fidl::encoding::EmptyPayload,
1165 fidl::encoding::DefaultFuchsiaResourceDialect
1166 );
1167 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1168 let control_handle = QueryableControlHandle { inner: this.inner.clone() };
1169 Ok(QueryableRequest::Query {
1170 responder: QueryableQueryResponder {
1171 control_handle: std::mem::ManuallyDrop::new(control_handle),
1172 tx_id: header.tx_id,
1173 },
1174 })
1175 }
1176 _ => Err(fidl::Error::UnknownOrdinal {
1177 ordinal: header.ordinal,
1178 protocol_name:
1179 <QueryableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1180 }),
1181 }))
1182 },
1183 )
1184 }
1185}
1186
1187#[derive(Debug)]
1189pub enum QueryableRequest {
1190 Query { responder: QueryableQueryResponder },
1191}
1192
1193impl QueryableRequest {
1194 #[allow(irrefutable_let_patterns)]
1195 pub fn into_query(self) -> Option<(QueryableQueryResponder)> {
1196 if let QueryableRequest::Query { responder } = self { Some((responder)) } else { None }
1197 }
1198
1199 pub fn method_name(&self) -> &'static str {
1201 match *self {
1202 QueryableRequest::Query { .. } => "query",
1203 }
1204 }
1205}
1206
1207#[derive(Debug, Clone)]
1208pub struct QueryableControlHandle {
1209 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1210}
1211
1212impl QueryableControlHandle {
1213 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1214 self.inner.shutdown_with_epitaph(status.into())
1215 }
1216}
1217
1218impl fidl::endpoints::ControlHandle for QueryableControlHandle {
1219 fn shutdown(&self) {
1220 self.inner.shutdown()
1221 }
1222
1223 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1224 self.inner.shutdown_with_epitaph(status)
1225 }
1226
1227 fn is_closed(&self) -> bool {
1228 self.inner.channel().is_closed()
1229 }
1230 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1231 self.inner.channel().on_closed()
1232 }
1233
1234 #[cfg(target_os = "fuchsia")]
1235 fn signal_peer(
1236 &self,
1237 clear_mask: zx::Signals,
1238 set_mask: zx::Signals,
1239 ) -> Result<(), zx_status::Status> {
1240 use fidl::Peered;
1241 self.inner.channel().signal_peer(clear_mask, set_mask)
1242 }
1243}
1244
1245impl QueryableControlHandle {}
1246
1247#[must_use = "FIDL methods require a response to be sent"]
1248#[derive(Debug)]
1249pub struct QueryableQueryResponder {
1250 control_handle: std::mem::ManuallyDrop<QueryableControlHandle>,
1251 tx_id: u32,
1252}
1253
1254impl std::ops::Drop for QueryableQueryResponder {
1258 fn drop(&mut self) {
1259 self.control_handle.shutdown();
1260 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1262 }
1263}
1264
1265impl fidl::endpoints::Responder for QueryableQueryResponder {
1266 type ControlHandle = QueryableControlHandle;
1267
1268 fn control_handle(&self) -> &QueryableControlHandle {
1269 &self.control_handle
1270 }
1271
1272 fn drop_without_shutdown(mut self) {
1273 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1275 std::mem::forget(self);
1277 }
1278}
1279
1280impl QueryableQueryResponder {
1281 pub fn send(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1285 let _result = self.send_raw(protocol);
1286 if _result.is_err() {
1287 self.control_handle.shutdown();
1288 }
1289 self.drop_without_shutdown();
1290 _result
1291 }
1292
1293 pub fn send_no_shutdown_on_err(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1295 let _result = self.send_raw(protocol);
1296 self.drop_without_shutdown();
1297 _result
1298 }
1299
1300 fn send_raw(&self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1301 self.control_handle.inner.send::<QueryableQueryResponse>(
1302 (protocol,),
1303 self.tx_id,
1304 0x2658edee9decfc06,
1305 fidl::encoding::DynamicFlags::empty(),
1306 )
1307 }
1308}
1309
1310mod internal {
1311 use super::*;
1312
1313 impl fidl::encoding::ResourceTypeMarker for CloneableCloneRequest {
1314 type Borrowed<'a> = &'a mut Self;
1315 fn take_or_borrow<'a>(
1316 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1317 ) -> Self::Borrowed<'a> {
1318 value
1319 }
1320 }
1321
1322 unsafe impl fidl::encoding::TypeMarker for CloneableCloneRequest {
1323 type Owned = Self;
1324
1325 #[inline(always)]
1326 fn inline_align(_context: fidl::encoding::Context) -> usize {
1327 4
1328 }
1329
1330 #[inline(always)]
1331 fn inline_size(_context: fidl::encoding::Context) -> usize {
1332 4
1333 }
1334 }
1335
1336 unsafe impl
1337 fidl::encoding::Encode<CloneableCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1338 for &mut CloneableCloneRequest
1339 {
1340 #[inline]
1341 unsafe fn encode(
1342 self,
1343 encoder: &mut fidl::encoding::Encoder<
1344 '_,
1345 fidl::encoding::DefaultFuchsiaResourceDialect,
1346 >,
1347 offset: usize,
1348 _depth: fidl::encoding::Depth,
1349 ) -> fidl::Result<()> {
1350 encoder.debug_check_bounds::<CloneableCloneRequest>(offset);
1351 fidl::encoding::Encode::<CloneableCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1353 (
1354 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<CloneableMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1355 ),
1356 encoder, offset, _depth
1357 )
1358 }
1359 }
1360 unsafe impl<
1361 T0: fidl::encoding::Encode<
1362 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<CloneableMarker>>,
1363 fidl::encoding::DefaultFuchsiaResourceDialect,
1364 >,
1365 >
1366 fidl::encoding::Encode<CloneableCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1367 for (T0,)
1368 {
1369 #[inline]
1370 unsafe fn encode(
1371 self,
1372 encoder: &mut fidl::encoding::Encoder<
1373 '_,
1374 fidl::encoding::DefaultFuchsiaResourceDialect,
1375 >,
1376 offset: usize,
1377 depth: fidl::encoding::Depth,
1378 ) -> fidl::Result<()> {
1379 encoder.debug_check_bounds::<CloneableCloneRequest>(offset);
1380 self.0.encode(encoder, offset + 0, depth)?;
1384 Ok(())
1385 }
1386 }
1387
1388 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1389 for CloneableCloneRequest
1390 {
1391 #[inline(always)]
1392 fn new_empty() -> Self {
1393 Self {
1394 request: fidl::new_empty!(
1395 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<CloneableMarker>>,
1396 fidl::encoding::DefaultFuchsiaResourceDialect
1397 ),
1398 }
1399 }
1400
1401 #[inline]
1402 unsafe fn decode(
1403 &mut self,
1404 decoder: &mut fidl::encoding::Decoder<
1405 '_,
1406 fidl::encoding::DefaultFuchsiaResourceDialect,
1407 >,
1408 offset: usize,
1409 _depth: fidl::encoding::Depth,
1410 ) -> fidl::Result<()> {
1411 decoder.debug_check_bounds::<Self>(offset);
1412 fidl::decode!(
1414 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<CloneableMarker>>,
1415 fidl::encoding::DefaultFuchsiaResourceDialect,
1416 &mut self.request,
1417 decoder,
1418 offset + 0,
1419 _depth
1420 )?;
1421 Ok(())
1422 }
1423 }
1424}