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 fidl::endpoints::ControlHandle for CloneableControlHandle {
359 fn shutdown(&self) {
360 self.inner.shutdown()
361 }
362
363 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
364 self.inner.shutdown_with_epitaph(status)
365 }
366
367 fn is_closed(&self) -> bool {
368 self.inner.channel().is_closed()
369 }
370 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
371 self.inner.channel().on_closed()
372 }
373
374 #[cfg(target_os = "fuchsia")]
375 fn signal_peer(
376 &self,
377 clear_mask: zx::Signals,
378 set_mask: zx::Signals,
379 ) -> Result<(), zx_status::Status> {
380 use fidl::Peered;
381 self.inner.channel().signal_peer(clear_mask, set_mask)
382 }
383}
384
385impl CloneableControlHandle {}
386
387#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
388pub struct CloseableMarker;
389
390impl fidl::endpoints::ProtocolMarker for CloseableMarker {
391 type Proxy = CloseableProxy;
392 type RequestStream = CloseableRequestStream;
393 #[cfg(target_os = "fuchsia")]
394 type SynchronousProxy = CloseableSynchronousProxy;
395
396 const DEBUG_NAME: &'static str = "(anonymous) Closeable";
397}
398pub type CloseableCloseResult = Result<(), i32>;
399
400pub trait CloseableProxyInterface: Send + Sync {
401 type CloseResponseFut: std::future::Future<Output = Result<CloseableCloseResult, fidl::Error>>
402 + Send;
403 fn r#close(&self) -> Self::CloseResponseFut;
404}
405#[derive(Debug)]
406#[cfg(target_os = "fuchsia")]
407pub struct CloseableSynchronousProxy {
408 client: fidl::client::sync::Client,
409}
410
411#[cfg(target_os = "fuchsia")]
412impl fidl::endpoints::SynchronousProxy for CloseableSynchronousProxy {
413 type Proxy = CloseableProxy;
414 type Protocol = CloseableMarker;
415
416 fn from_channel(inner: fidl::Channel) -> Self {
417 Self::new(inner)
418 }
419
420 fn into_channel(self) -> fidl::Channel {
421 self.client.into_channel()
422 }
423
424 fn as_channel(&self) -> &fidl::Channel {
425 self.client.as_channel()
426 }
427}
428
429#[cfg(target_os = "fuchsia")]
430impl CloseableSynchronousProxy {
431 pub fn new(channel: fidl::Channel) -> Self {
432 Self { client: fidl::client::sync::Client::new(channel) }
433 }
434
435 pub fn into_channel(self) -> fidl::Channel {
436 self.client.into_channel()
437 }
438
439 pub fn wait_for_event(
442 &self,
443 deadline: zx::MonotonicInstant,
444 ) -> Result<CloseableEvent, fidl::Error> {
445 CloseableEvent::decode(self.client.wait_for_event::<CloseableMarker>(deadline)?)
446 }
447
448 pub fn r#close(
459 &self,
460 ___deadline: zx::MonotonicInstant,
461 ) -> Result<CloseableCloseResult, fidl::Error> {
462 let _response = self.client.send_query::<
463 fidl::encoding::EmptyPayload,
464 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
465 CloseableMarker,
466 >(
467 (),
468 0x5ac5d459ad7f657e,
469 fidl::encoding::DynamicFlags::empty(),
470 ___deadline,
471 )?;
472 Ok(_response.map(|x| x))
473 }
474}
475
476#[cfg(target_os = "fuchsia")]
477impl From<CloseableSynchronousProxy> for zx::NullableHandle {
478 fn from(value: CloseableSynchronousProxy) -> Self {
479 value.into_channel().into()
480 }
481}
482
483#[cfg(target_os = "fuchsia")]
484impl From<fidl::Channel> for CloseableSynchronousProxy {
485 fn from(value: fidl::Channel) -> Self {
486 Self::new(value)
487 }
488}
489
490#[cfg(target_os = "fuchsia")]
491impl fidl::endpoints::FromClient for CloseableSynchronousProxy {
492 type Protocol = CloseableMarker;
493
494 fn from_client(value: fidl::endpoints::ClientEnd<CloseableMarker>) -> Self {
495 Self::new(value.into_channel())
496 }
497}
498
499#[derive(Debug, Clone)]
500pub struct CloseableProxy {
501 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
502}
503
504impl fidl::endpoints::Proxy for CloseableProxy {
505 type Protocol = CloseableMarker;
506
507 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
508 Self::new(inner)
509 }
510
511 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
512 self.client.into_channel().map_err(|client| Self { client })
513 }
514
515 fn as_channel(&self) -> &::fidl::AsyncChannel {
516 self.client.as_channel()
517 }
518}
519
520impl CloseableProxy {
521 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
523 let protocol_name = <CloseableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
524 Self { client: fidl::client::Client::new(channel, protocol_name) }
525 }
526
527 pub fn take_event_stream(&self) -> CloseableEventStream {
533 CloseableEventStream { event_receiver: self.client.take_event_receiver() }
534 }
535
536 pub fn r#close(
547 &self,
548 ) -> fidl::client::QueryResponseFut<
549 CloseableCloseResult,
550 fidl::encoding::DefaultFuchsiaResourceDialect,
551 > {
552 CloseableProxyInterface::r#close(self)
553 }
554}
555
556impl CloseableProxyInterface for CloseableProxy {
557 type CloseResponseFut = fidl::client::QueryResponseFut<
558 CloseableCloseResult,
559 fidl::encoding::DefaultFuchsiaResourceDialect,
560 >;
561 fn r#close(&self) -> Self::CloseResponseFut {
562 fn _decode(
563 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
564 ) -> Result<CloseableCloseResult, fidl::Error> {
565 let _response = fidl::client::decode_transaction_body::<
566 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
567 fidl::encoding::DefaultFuchsiaResourceDialect,
568 0x5ac5d459ad7f657e,
569 >(_buf?)?;
570 Ok(_response.map(|x| x))
571 }
572 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, CloseableCloseResult>(
573 (),
574 0x5ac5d459ad7f657e,
575 fidl::encoding::DynamicFlags::empty(),
576 _decode,
577 )
578 }
579}
580
581pub struct CloseableEventStream {
582 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
583}
584
585impl std::marker::Unpin for CloseableEventStream {}
586
587impl futures::stream::FusedStream for CloseableEventStream {
588 fn is_terminated(&self) -> bool {
589 self.event_receiver.is_terminated()
590 }
591}
592
593impl futures::Stream for CloseableEventStream {
594 type Item = Result<CloseableEvent, fidl::Error>;
595
596 fn poll_next(
597 mut self: std::pin::Pin<&mut Self>,
598 cx: &mut std::task::Context<'_>,
599 ) -> std::task::Poll<Option<Self::Item>> {
600 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
601 &mut self.event_receiver,
602 cx
603 )?) {
604 Some(buf) => std::task::Poll::Ready(Some(CloseableEvent::decode(buf))),
605 None => std::task::Poll::Ready(None),
606 }
607 }
608}
609
610#[derive(Debug)]
611pub enum CloseableEvent {}
612
613impl CloseableEvent {
614 fn decode(
616 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
617 ) -> Result<CloseableEvent, fidl::Error> {
618 let (bytes, _handles) = buf.split_mut();
619 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
620 debug_assert_eq!(tx_header.tx_id, 0);
621 match tx_header.ordinal {
622 _ => Err(fidl::Error::UnknownOrdinal {
623 ordinal: tx_header.ordinal,
624 protocol_name: <CloseableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
625 }),
626 }
627 }
628}
629
630pub struct CloseableRequestStream {
632 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
633 is_terminated: bool,
634}
635
636impl std::marker::Unpin for CloseableRequestStream {}
637
638impl futures::stream::FusedStream for CloseableRequestStream {
639 fn is_terminated(&self) -> bool {
640 self.is_terminated
641 }
642}
643
644impl fidl::endpoints::RequestStream for CloseableRequestStream {
645 type Protocol = CloseableMarker;
646 type ControlHandle = CloseableControlHandle;
647
648 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
649 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
650 }
651
652 fn control_handle(&self) -> Self::ControlHandle {
653 CloseableControlHandle { inner: self.inner.clone() }
654 }
655
656 fn into_inner(
657 self,
658 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
659 {
660 (self.inner, self.is_terminated)
661 }
662
663 fn from_inner(
664 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
665 is_terminated: bool,
666 ) -> Self {
667 Self { inner, is_terminated }
668 }
669}
670
671impl futures::Stream for CloseableRequestStream {
672 type Item = Result<CloseableRequest, fidl::Error>;
673
674 fn poll_next(
675 mut self: std::pin::Pin<&mut Self>,
676 cx: &mut std::task::Context<'_>,
677 ) -> std::task::Poll<Option<Self::Item>> {
678 let this = &mut *self;
679 if this.inner.check_shutdown(cx) {
680 this.is_terminated = true;
681 return std::task::Poll::Ready(None);
682 }
683 if this.is_terminated {
684 panic!("polled CloseableRequestStream after completion");
685 }
686 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
687 |bytes, handles| {
688 match this.inner.channel().read_etc(cx, bytes, handles) {
689 std::task::Poll::Ready(Ok(())) => {}
690 std::task::Poll::Pending => return std::task::Poll::Pending,
691 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
692 this.is_terminated = true;
693 return std::task::Poll::Ready(None);
694 }
695 std::task::Poll::Ready(Err(e)) => {
696 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
697 e.into(),
698 ))));
699 }
700 }
701
702 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
704
705 std::task::Poll::Ready(Some(match header.ordinal {
706 0x5ac5d459ad7f657e => {
707 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
708 let mut req = fidl::new_empty!(
709 fidl::encoding::EmptyPayload,
710 fidl::encoding::DefaultFuchsiaResourceDialect
711 );
712 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
713 let control_handle = CloseableControlHandle { inner: this.inner.clone() };
714 Ok(CloseableRequest::Close {
715 responder: CloseableCloseResponder {
716 control_handle: std::mem::ManuallyDrop::new(control_handle),
717 tx_id: header.tx_id,
718 },
719 })
720 }
721 _ => Err(fidl::Error::UnknownOrdinal {
722 ordinal: header.ordinal,
723 protocol_name:
724 <CloseableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
725 }),
726 }))
727 },
728 )
729 }
730}
731
732#[derive(Debug)]
734pub enum CloseableRequest {
735 Close { responder: CloseableCloseResponder },
746}
747
748impl CloseableRequest {
749 #[allow(irrefutable_let_patterns)]
750 pub fn into_close(self) -> Option<(CloseableCloseResponder)> {
751 if let CloseableRequest::Close { responder } = self { Some((responder)) } else { None }
752 }
753
754 pub fn method_name(&self) -> &'static str {
756 match *self {
757 CloseableRequest::Close { .. } => "close",
758 }
759 }
760}
761
762#[derive(Debug, Clone)]
763pub struct CloseableControlHandle {
764 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
765}
766
767impl fidl::endpoints::ControlHandle for CloseableControlHandle {
768 fn shutdown(&self) {
769 self.inner.shutdown()
770 }
771
772 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
773 self.inner.shutdown_with_epitaph(status)
774 }
775
776 fn is_closed(&self) -> bool {
777 self.inner.channel().is_closed()
778 }
779 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
780 self.inner.channel().on_closed()
781 }
782
783 #[cfg(target_os = "fuchsia")]
784 fn signal_peer(
785 &self,
786 clear_mask: zx::Signals,
787 set_mask: zx::Signals,
788 ) -> Result<(), zx_status::Status> {
789 use fidl::Peered;
790 self.inner.channel().signal_peer(clear_mask, set_mask)
791 }
792}
793
794impl CloseableControlHandle {}
795
796#[must_use = "FIDL methods require a response to be sent"]
797#[derive(Debug)]
798pub struct CloseableCloseResponder {
799 control_handle: std::mem::ManuallyDrop<CloseableControlHandle>,
800 tx_id: u32,
801}
802
803impl std::ops::Drop for CloseableCloseResponder {
807 fn drop(&mut self) {
808 self.control_handle.shutdown();
809 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
811 }
812}
813
814impl fidl::endpoints::Responder for CloseableCloseResponder {
815 type ControlHandle = CloseableControlHandle;
816
817 fn control_handle(&self) -> &CloseableControlHandle {
818 &self.control_handle
819 }
820
821 fn drop_without_shutdown(mut self) {
822 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
824 std::mem::forget(self);
826 }
827}
828
829impl CloseableCloseResponder {
830 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
834 let _result = self.send_raw(result);
835 if _result.is_err() {
836 self.control_handle.shutdown();
837 }
838 self.drop_without_shutdown();
839 _result
840 }
841
842 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
844 let _result = self.send_raw(result);
845 self.drop_without_shutdown();
846 _result
847 }
848
849 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
850 self.control_handle
851 .inner
852 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
853 result,
854 self.tx_id,
855 0x5ac5d459ad7f657e,
856 fidl::encoding::DynamicFlags::empty(),
857 )
858 }
859}
860
861#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
862pub struct QueryableMarker;
863
864impl fidl::endpoints::ProtocolMarker for QueryableMarker {
865 type Proxy = QueryableProxy;
866 type RequestStream = QueryableRequestStream;
867 #[cfg(target_os = "fuchsia")]
868 type SynchronousProxy = QueryableSynchronousProxy;
869
870 const DEBUG_NAME: &'static str = "(anonymous) Queryable";
871}
872
873pub trait QueryableProxyInterface: Send + Sync {
874 type QueryResponseFut: std::future::Future<Output = Result<Vec<u8>, fidl::Error>> + Send;
875 fn r#query(&self) -> Self::QueryResponseFut;
876}
877#[derive(Debug)]
878#[cfg(target_os = "fuchsia")]
879pub struct QueryableSynchronousProxy {
880 client: fidl::client::sync::Client,
881}
882
883#[cfg(target_os = "fuchsia")]
884impl fidl::endpoints::SynchronousProxy for QueryableSynchronousProxy {
885 type Proxy = QueryableProxy;
886 type Protocol = QueryableMarker;
887
888 fn from_channel(inner: fidl::Channel) -> Self {
889 Self::new(inner)
890 }
891
892 fn into_channel(self) -> fidl::Channel {
893 self.client.into_channel()
894 }
895
896 fn as_channel(&self) -> &fidl::Channel {
897 self.client.as_channel()
898 }
899}
900
901#[cfg(target_os = "fuchsia")]
902impl QueryableSynchronousProxy {
903 pub fn new(channel: fidl::Channel) -> Self {
904 Self { client: fidl::client::sync::Client::new(channel) }
905 }
906
907 pub fn into_channel(self) -> fidl::Channel {
908 self.client.into_channel()
909 }
910
911 pub fn wait_for_event(
914 &self,
915 deadline: zx::MonotonicInstant,
916 ) -> Result<QueryableEvent, fidl::Error> {
917 QueryableEvent::decode(self.client.wait_for_event::<QueryableMarker>(deadline)?)
918 }
919
920 pub fn r#query(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<u8>, fidl::Error> {
921 let _response = self
922 .client
923 .send_query::<fidl::encoding::EmptyPayload, QueryableQueryResponse, QueryableMarker>(
924 (),
925 0x2658edee9decfc06,
926 fidl::encoding::DynamicFlags::empty(),
927 ___deadline,
928 )?;
929 Ok(_response.protocol)
930 }
931}
932
933#[cfg(target_os = "fuchsia")]
934impl From<QueryableSynchronousProxy> for zx::NullableHandle {
935 fn from(value: QueryableSynchronousProxy) -> Self {
936 value.into_channel().into()
937 }
938}
939
940#[cfg(target_os = "fuchsia")]
941impl From<fidl::Channel> for QueryableSynchronousProxy {
942 fn from(value: fidl::Channel) -> Self {
943 Self::new(value)
944 }
945}
946
947#[cfg(target_os = "fuchsia")]
948impl fidl::endpoints::FromClient for QueryableSynchronousProxy {
949 type Protocol = QueryableMarker;
950
951 fn from_client(value: fidl::endpoints::ClientEnd<QueryableMarker>) -> Self {
952 Self::new(value.into_channel())
953 }
954}
955
956#[derive(Debug, Clone)]
957pub struct QueryableProxy {
958 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
959}
960
961impl fidl::endpoints::Proxy for QueryableProxy {
962 type Protocol = QueryableMarker;
963
964 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
965 Self::new(inner)
966 }
967
968 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
969 self.client.into_channel().map_err(|client| Self { client })
970 }
971
972 fn as_channel(&self) -> &::fidl::AsyncChannel {
973 self.client.as_channel()
974 }
975}
976
977impl QueryableProxy {
978 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
980 let protocol_name = <QueryableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
981 Self { client: fidl::client::Client::new(channel, protocol_name) }
982 }
983
984 pub fn take_event_stream(&self) -> QueryableEventStream {
990 QueryableEventStream { event_receiver: self.client.take_event_receiver() }
991 }
992
993 pub fn r#query(
994 &self,
995 ) -> fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>
996 {
997 QueryableProxyInterface::r#query(self)
998 }
999}
1000
1001impl QueryableProxyInterface for QueryableProxy {
1002 type QueryResponseFut =
1003 fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>;
1004 fn r#query(&self) -> Self::QueryResponseFut {
1005 fn _decode(
1006 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1007 ) -> Result<Vec<u8>, fidl::Error> {
1008 let _response = fidl::client::decode_transaction_body::<
1009 QueryableQueryResponse,
1010 fidl::encoding::DefaultFuchsiaResourceDialect,
1011 0x2658edee9decfc06,
1012 >(_buf?)?;
1013 Ok(_response.protocol)
1014 }
1015 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<u8>>(
1016 (),
1017 0x2658edee9decfc06,
1018 fidl::encoding::DynamicFlags::empty(),
1019 _decode,
1020 )
1021 }
1022}
1023
1024pub struct QueryableEventStream {
1025 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1026}
1027
1028impl std::marker::Unpin for QueryableEventStream {}
1029
1030impl futures::stream::FusedStream for QueryableEventStream {
1031 fn is_terminated(&self) -> bool {
1032 self.event_receiver.is_terminated()
1033 }
1034}
1035
1036impl futures::Stream for QueryableEventStream {
1037 type Item = Result<QueryableEvent, fidl::Error>;
1038
1039 fn poll_next(
1040 mut self: std::pin::Pin<&mut Self>,
1041 cx: &mut std::task::Context<'_>,
1042 ) -> std::task::Poll<Option<Self::Item>> {
1043 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1044 &mut self.event_receiver,
1045 cx
1046 )?) {
1047 Some(buf) => std::task::Poll::Ready(Some(QueryableEvent::decode(buf))),
1048 None => std::task::Poll::Ready(None),
1049 }
1050 }
1051}
1052
1053#[derive(Debug)]
1054pub enum QueryableEvent {}
1055
1056impl QueryableEvent {
1057 fn decode(
1059 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1060 ) -> Result<QueryableEvent, fidl::Error> {
1061 let (bytes, _handles) = buf.split_mut();
1062 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1063 debug_assert_eq!(tx_header.tx_id, 0);
1064 match tx_header.ordinal {
1065 _ => Err(fidl::Error::UnknownOrdinal {
1066 ordinal: tx_header.ordinal,
1067 protocol_name: <QueryableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1068 }),
1069 }
1070 }
1071}
1072
1073pub struct QueryableRequestStream {
1075 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1076 is_terminated: bool,
1077}
1078
1079impl std::marker::Unpin for QueryableRequestStream {}
1080
1081impl futures::stream::FusedStream for QueryableRequestStream {
1082 fn is_terminated(&self) -> bool {
1083 self.is_terminated
1084 }
1085}
1086
1087impl fidl::endpoints::RequestStream for QueryableRequestStream {
1088 type Protocol = QueryableMarker;
1089 type ControlHandle = QueryableControlHandle;
1090
1091 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1092 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1093 }
1094
1095 fn control_handle(&self) -> Self::ControlHandle {
1096 QueryableControlHandle { inner: self.inner.clone() }
1097 }
1098
1099 fn into_inner(
1100 self,
1101 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1102 {
1103 (self.inner, self.is_terminated)
1104 }
1105
1106 fn from_inner(
1107 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1108 is_terminated: bool,
1109 ) -> Self {
1110 Self { inner, is_terminated }
1111 }
1112}
1113
1114impl futures::Stream for QueryableRequestStream {
1115 type Item = Result<QueryableRequest, fidl::Error>;
1116
1117 fn poll_next(
1118 mut self: std::pin::Pin<&mut Self>,
1119 cx: &mut std::task::Context<'_>,
1120 ) -> std::task::Poll<Option<Self::Item>> {
1121 let this = &mut *self;
1122 if this.inner.check_shutdown(cx) {
1123 this.is_terminated = true;
1124 return std::task::Poll::Ready(None);
1125 }
1126 if this.is_terminated {
1127 panic!("polled QueryableRequestStream after completion");
1128 }
1129 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1130 |bytes, handles| {
1131 match this.inner.channel().read_etc(cx, bytes, handles) {
1132 std::task::Poll::Ready(Ok(())) => {}
1133 std::task::Poll::Pending => return std::task::Poll::Pending,
1134 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1135 this.is_terminated = true;
1136 return std::task::Poll::Ready(None);
1137 }
1138 std::task::Poll::Ready(Err(e)) => {
1139 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1140 e.into(),
1141 ))));
1142 }
1143 }
1144
1145 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1147
1148 std::task::Poll::Ready(Some(match header.ordinal {
1149 0x2658edee9decfc06 => {
1150 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1151 let mut req = fidl::new_empty!(
1152 fidl::encoding::EmptyPayload,
1153 fidl::encoding::DefaultFuchsiaResourceDialect
1154 );
1155 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1156 let control_handle = QueryableControlHandle { inner: this.inner.clone() };
1157 Ok(QueryableRequest::Query {
1158 responder: QueryableQueryResponder {
1159 control_handle: std::mem::ManuallyDrop::new(control_handle),
1160 tx_id: header.tx_id,
1161 },
1162 })
1163 }
1164 _ => Err(fidl::Error::UnknownOrdinal {
1165 ordinal: header.ordinal,
1166 protocol_name:
1167 <QueryableMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1168 }),
1169 }))
1170 },
1171 )
1172 }
1173}
1174
1175#[derive(Debug)]
1177pub enum QueryableRequest {
1178 Query { responder: QueryableQueryResponder },
1179}
1180
1181impl QueryableRequest {
1182 #[allow(irrefutable_let_patterns)]
1183 pub fn into_query(self) -> Option<(QueryableQueryResponder)> {
1184 if let QueryableRequest::Query { responder } = self { Some((responder)) } else { None }
1185 }
1186
1187 pub fn method_name(&self) -> &'static str {
1189 match *self {
1190 QueryableRequest::Query { .. } => "query",
1191 }
1192 }
1193}
1194
1195#[derive(Debug, Clone)]
1196pub struct QueryableControlHandle {
1197 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1198}
1199
1200impl fidl::endpoints::ControlHandle for QueryableControlHandle {
1201 fn shutdown(&self) {
1202 self.inner.shutdown()
1203 }
1204
1205 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1206 self.inner.shutdown_with_epitaph(status)
1207 }
1208
1209 fn is_closed(&self) -> bool {
1210 self.inner.channel().is_closed()
1211 }
1212 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1213 self.inner.channel().on_closed()
1214 }
1215
1216 #[cfg(target_os = "fuchsia")]
1217 fn signal_peer(
1218 &self,
1219 clear_mask: zx::Signals,
1220 set_mask: zx::Signals,
1221 ) -> Result<(), zx_status::Status> {
1222 use fidl::Peered;
1223 self.inner.channel().signal_peer(clear_mask, set_mask)
1224 }
1225}
1226
1227impl QueryableControlHandle {}
1228
1229#[must_use = "FIDL methods require a response to be sent"]
1230#[derive(Debug)]
1231pub struct QueryableQueryResponder {
1232 control_handle: std::mem::ManuallyDrop<QueryableControlHandle>,
1233 tx_id: u32,
1234}
1235
1236impl std::ops::Drop for QueryableQueryResponder {
1240 fn drop(&mut self) {
1241 self.control_handle.shutdown();
1242 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1244 }
1245}
1246
1247impl fidl::endpoints::Responder for QueryableQueryResponder {
1248 type ControlHandle = QueryableControlHandle;
1249
1250 fn control_handle(&self) -> &QueryableControlHandle {
1251 &self.control_handle
1252 }
1253
1254 fn drop_without_shutdown(mut self) {
1255 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1257 std::mem::forget(self);
1259 }
1260}
1261
1262impl QueryableQueryResponder {
1263 pub fn send(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1267 let _result = self.send_raw(protocol);
1268 if _result.is_err() {
1269 self.control_handle.shutdown();
1270 }
1271 self.drop_without_shutdown();
1272 _result
1273 }
1274
1275 pub fn send_no_shutdown_on_err(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1277 let _result = self.send_raw(protocol);
1278 self.drop_without_shutdown();
1279 _result
1280 }
1281
1282 fn send_raw(&self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
1283 self.control_handle.inner.send::<QueryableQueryResponse>(
1284 (protocol,),
1285 self.tx_id,
1286 0x2658edee9decfc06,
1287 fidl::encoding::DynamicFlags::empty(),
1288 )
1289 }
1290}
1291
1292mod internal {
1293 use super::*;
1294
1295 impl fidl::encoding::ResourceTypeMarker for CloneableCloneRequest {
1296 type Borrowed<'a> = &'a mut Self;
1297 fn take_or_borrow<'a>(
1298 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1299 ) -> Self::Borrowed<'a> {
1300 value
1301 }
1302 }
1303
1304 unsafe impl fidl::encoding::TypeMarker for CloneableCloneRequest {
1305 type Owned = Self;
1306
1307 #[inline(always)]
1308 fn inline_align(_context: fidl::encoding::Context) -> usize {
1309 4
1310 }
1311
1312 #[inline(always)]
1313 fn inline_size(_context: fidl::encoding::Context) -> usize {
1314 4
1315 }
1316 }
1317
1318 unsafe impl
1319 fidl::encoding::Encode<CloneableCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1320 for &mut CloneableCloneRequest
1321 {
1322 #[inline]
1323 unsafe fn encode(
1324 self,
1325 encoder: &mut fidl::encoding::Encoder<
1326 '_,
1327 fidl::encoding::DefaultFuchsiaResourceDialect,
1328 >,
1329 offset: usize,
1330 _depth: fidl::encoding::Depth,
1331 ) -> fidl::Result<()> {
1332 encoder.debug_check_bounds::<CloneableCloneRequest>(offset);
1333 fidl::encoding::Encode::<CloneableCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1335 (
1336 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<CloneableMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1337 ),
1338 encoder, offset, _depth
1339 )
1340 }
1341 }
1342 unsafe impl<
1343 T0: fidl::encoding::Encode<
1344 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<CloneableMarker>>,
1345 fidl::encoding::DefaultFuchsiaResourceDialect,
1346 >,
1347 >
1348 fidl::encoding::Encode<CloneableCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1349 for (T0,)
1350 {
1351 #[inline]
1352 unsafe fn encode(
1353 self,
1354 encoder: &mut fidl::encoding::Encoder<
1355 '_,
1356 fidl::encoding::DefaultFuchsiaResourceDialect,
1357 >,
1358 offset: usize,
1359 depth: fidl::encoding::Depth,
1360 ) -> fidl::Result<()> {
1361 encoder.debug_check_bounds::<CloneableCloneRequest>(offset);
1362 self.0.encode(encoder, offset + 0, depth)?;
1366 Ok(())
1367 }
1368 }
1369
1370 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1371 for CloneableCloneRequest
1372 {
1373 #[inline(always)]
1374 fn new_empty() -> Self {
1375 Self {
1376 request: fidl::new_empty!(
1377 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<CloneableMarker>>,
1378 fidl::encoding::DefaultFuchsiaResourceDialect
1379 ),
1380 }
1381 }
1382
1383 #[inline]
1384 unsafe fn decode(
1385 &mut self,
1386 decoder: &mut fidl::encoding::Decoder<
1387 '_,
1388 fidl::encoding::DefaultFuchsiaResourceDialect,
1389 >,
1390 offset: usize,
1391 _depth: fidl::encoding::Depth,
1392 ) -> fidl::Result<()> {
1393 decoder.debug_check_bounds::<Self>(offset);
1394 fidl::decode!(
1396 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<CloneableMarker>>,
1397 fidl::encoding::DefaultFuchsiaResourceDialect,
1398 &mut self.request,
1399 decoder,
1400 offset + 0,
1401 _depth
1402 )?;
1403 Ok(())
1404 }
1405 }
1406}