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_examples_keyvaluestore_additerator__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct StoreIterateRequest {
16 pub starting_at: Option<String>,
18 pub iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
22}
23
24impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for StoreIterateRequest {}
25
26#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
27pub struct IteratorMarker;
28
29impl fidl::endpoints::ProtocolMarker for IteratorMarker {
30 type Proxy = IteratorProxy;
31 type RequestStream = IteratorRequestStream;
32 #[cfg(target_os = "fuchsia")]
33 type SynchronousProxy = IteratorSynchronousProxy;
34
35 const DEBUG_NAME: &'static str = "(anonymous) Iterator";
36}
37
38pub trait IteratorProxyInterface: Send + Sync {
39 type GetResponseFut: std::future::Future<Output = Result<Vec<String>, fidl::Error>> + Send;
40 fn r#get(&self) -> Self::GetResponseFut;
41}
42#[derive(Debug)]
43#[cfg(target_os = "fuchsia")]
44pub struct IteratorSynchronousProxy {
45 client: fidl::client::sync::Client,
46}
47
48#[cfg(target_os = "fuchsia")]
49impl fidl::endpoints::SynchronousProxy for IteratorSynchronousProxy {
50 type Proxy = IteratorProxy;
51 type Protocol = IteratorMarker;
52
53 fn from_channel(inner: fidl::Channel) -> Self {
54 Self::new(inner)
55 }
56
57 fn into_channel(self) -> fidl::Channel {
58 self.client.into_channel()
59 }
60
61 fn as_channel(&self) -> &fidl::Channel {
62 self.client.as_channel()
63 }
64}
65
66#[cfg(target_os = "fuchsia")]
67impl IteratorSynchronousProxy {
68 pub fn new(channel: fidl::Channel) -> Self {
69 let protocol_name = <IteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
70 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
71 }
72
73 pub fn into_channel(self) -> fidl::Channel {
74 self.client.into_channel()
75 }
76
77 pub fn wait_for_event(
80 &self,
81 deadline: zx::MonotonicInstant,
82 ) -> Result<IteratorEvent, fidl::Error> {
83 IteratorEvent::decode(self.client.wait_for_event(deadline)?)
84 }
85
86 pub fn r#get(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<String>, fidl::Error> {
94 let _response =
95 self.client.send_query::<fidl::encoding::EmptyPayload, IteratorGetResponse>(
96 (),
97 0x6a62554b7d535882,
98 fidl::encoding::DynamicFlags::empty(),
99 ___deadline,
100 )?;
101 Ok(_response.entries)
102 }
103}
104
105#[cfg(target_os = "fuchsia")]
106impl From<IteratorSynchronousProxy> for zx::Handle {
107 fn from(value: IteratorSynchronousProxy) -> Self {
108 value.into_channel().into()
109 }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<fidl::Channel> for IteratorSynchronousProxy {
114 fn from(value: fidl::Channel) -> Self {
115 Self::new(value)
116 }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl fidl::endpoints::FromClient for IteratorSynchronousProxy {
121 type Protocol = IteratorMarker;
122
123 fn from_client(value: fidl::endpoints::ClientEnd<IteratorMarker>) -> Self {
124 Self::new(value.into_channel())
125 }
126}
127
128#[derive(Debug, Clone)]
129pub struct IteratorProxy {
130 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
131}
132
133impl fidl::endpoints::Proxy for IteratorProxy {
134 type Protocol = IteratorMarker;
135
136 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
137 Self::new(inner)
138 }
139
140 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
141 self.client.into_channel().map_err(|client| Self { client })
142 }
143
144 fn as_channel(&self) -> &::fidl::AsyncChannel {
145 self.client.as_channel()
146 }
147}
148
149impl IteratorProxy {
150 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
152 let protocol_name = <IteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
153 Self { client: fidl::client::Client::new(channel, protocol_name) }
154 }
155
156 pub fn take_event_stream(&self) -> IteratorEventStream {
162 IteratorEventStream { event_receiver: self.client.take_event_receiver() }
163 }
164
165 pub fn r#get(
173 &self,
174 ) -> fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>
175 {
176 IteratorProxyInterface::r#get(self)
177 }
178}
179
180impl IteratorProxyInterface for IteratorProxy {
181 type GetResponseFut =
182 fidl::client::QueryResponseFut<Vec<String>, fidl::encoding::DefaultFuchsiaResourceDialect>;
183 fn r#get(&self) -> Self::GetResponseFut {
184 fn _decode(
185 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
186 ) -> Result<Vec<String>, fidl::Error> {
187 let _response = fidl::client::decode_transaction_body::<
188 IteratorGetResponse,
189 fidl::encoding::DefaultFuchsiaResourceDialect,
190 0x6a62554b7d535882,
191 >(_buf?)?;
192 Ok(_response.entries)
193 }
194 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<String>>(
195 (),
196 0x6a62554b7d535882,
197 fidl::encoding::DynamicFlags::empty(),
198 _decode,
199 )
200 }
201}
202
203pub struct IteratorEventStream {
204 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
205}
206
207impl std::marker::Unpin for IteratorEventStream {}
208
209impl futures::stream::FusedStream for IteratorEventStream {
210 fn is_terminated(&self) -> bool {
211 self.event_receiver.is_terminated()
212 }
213}
214
215impl futures::Stream for IteratorEventStream {
216 type Item = Result<IteratorEvent, fidl::Error>;
217
218 fn poll_next(
219 mut self: std::pin::Pin<&mut Self>,
220 cx: &mut std::task::Context<'_>,
221 ) -> std::task::Poll<Option<Self::Item>> {
222 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
223 &mut self.event_receiver,
224 cx
225 )?) {
226 Some(buf) => std::task::Poll::Ready(Some(IteratorEvent::decode(buf))),
227 None => std::task::Poll::Ready(None),
228 }
229 }
230}
231
232#[derive(Debug)]
233pub enum IteratorEvent {}
234
235impl IteratorEvent {
236 fn decode(
238 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
239 ) -> Result<IteratorEvent, fidl::Error> {
240 let (bytes, _handles) = buf.split_mut();
241 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
242 debug_assert_eq!(tx_header.tx_id, 0);
243 match tx_header.ordinal {
244 _ => Err(fidl::Error::UnknownOrdinal {
245 ordinal: tx_header.ordinal,
246 protocol_name: <IteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
247 }),
248 }
249 }
250}
251
252pub struct IteratorRequestStream {
254 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
255 is_terminated: bool,
256}
257
258impl std::marker::Unpin for IteratorRequestStream {}
259
260impl futures::stream::FusedStream for IteratorRequestStream {
261 fn is_terminated(&self) -> bool {
262 self.is_terminated
263 }
264}
265
266impl fidl::endpoints::RequestStream for IteratorRequestStream {
267 type Protocol = IteratorMarker;
268 type ControlHandle = IteratorControlHandle;
269
270 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
271 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
272 }
273
274 fn control_handle(&self) -> Self::ControlHandle {
275 IteratorControlHandle { inner: self.inner.clone() }
276 }
277
278 fn into_inner(
279 self,
280 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
281 {
282 (self.inner, self.is_terminated)
283 }
284
285 fn from_inner(
286 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
287 is_terminated: bool,
288 ) -> Self {
289 Self { inner, is_terminated }
290 }
291}
292
293impl futures::Stream for IteratorRequestStream {
294 type Item = Result<IteratorRequest, fidl::Error>;
295
296 fn poll_next(
297 mut self: std::pin::Pin<&mut Self>,
298 cx: &mut std::task::Context<'_>,
299 ) -> std::task::Poll<Option<Self::Item>> {
300 let this = &mut *self;
301 if this.inner.check_shutdown(cx) {
302 this.is_terminated = true;
303 return std::task::Poll::Ready(None);
304 }
305 if this.is_terminated {
306 panic!("polled IteratorRequestStream after completion");
307 }
308 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
309 |bytes, handles| {
310 match this.inner.channel().read_etc(cx, bytes, handles) {
311 std::task::Poll::Ready(Ok(())) => {}
312 std::task::Poll::Pending => return std::task::Poll::Pending,
313 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
314 this.is_terminated = true;
315 return std::task::Poll::Ready(None);
316 }
317 std::task::Poll::Ready(Err(e)) => {
318 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
319 e.into(),
320 ))));
321 }
322 }
323
324 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
326
327 std::task::Poll::Ready(Some(match header.ordinal {
328 0x6a62554b7d535882 => {
329 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
330 let mut req = fidl::new_empty!(
331 fidl::encoding::EmptyPayload,
332 fidl::encoding::DefaultFuchsiaResourceDialect
333 );
334 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
335 let control_handle = IteratorControlHandle { inner: this.inner.clone() };
336 Ok(IteratorRequest::Get {
337 responder: IteratorGetResponder {
338 control_handle: std::mem::ManuallyDrop::new(control_handle),
339 tx_id: header.tx_id,
340 },
341 })
342 }
343 _ => Err(fidl::Error::UnknownOrdinal {
344 ordinal: header.ordinal,
345 protocol_name:
346 <IteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
347 }),
348 }))
349 },
350 )
351 }
352}
353
354#[derive(Debug)]
368pub enum IteratorRequest {
369 Get { responder: IteratorGetResponder },
377}
378
379impl IteratorRequest {
380 #[allow(irrefutable_let_patterns)]
381 pub fn into_get(self) -> Option<(IteratorGetResponder)> {
382 if let IteratorRequest::Get { responder } = self { Some((responder)) } else { None }
383 }
384
385 pub fn method_name(&self) -> &'static str {
387 match *self {
388 IteratorRequest::Get { .. } => "get",
389 }
390 }
391}
392
393#[derive(Debug, Clone)]
394pub struct IteratorControlHandle {
395 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
396}
397
398impl fidl::endpoints::ControlHandle for IteratorControlHandle {
399 fn shutdown(&self) {
400 self.inner.shutdown()
401 }
402 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
403 self.inner.shutdown_with_epitaph(status)
404 }
405
406 fn is_closed(&self) -> bool {
407 self.inner.channel().is_closed()
408 }
409 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
410 self.inner.channel().on_closed()
411 }
412
413 #[cfg(target_os = "fuchsia")]
414 fn signal_peer(
415 &self,
416 clear_mask: zx::Signals,
417 set_mask: zx::Signals,
418 ) -> Result<(), zx_status::Status> {
419 use fidl::Peered;
420 self.inner.channel().signal_peer(clear_mask, set_mask)
421 }
422}
423
424impl IteratorControlHandle {}
425
426#[must_use = "FIDL methods require a response to be sent"]
427#[derive(Debug)]
428pub struct IteratorGetResponder {
429 control_handle: std::mem::ManuallyDrop<IteratorControlHandle>,
430 tx_id: u32,
431}
432
433impl std::ops::Drop for IteratorGetResponder {
437 fn drop(&mut self) {
438 self.control_handle.shutdown();
439 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
441 }
442}
443
444impl fidl::endpoints::Responder for IteratorGetResponder {
445 type ControlHandle = IteratorControlHandle;
446
447 fn control_handle(&self) -> &IteratorControlHandle {
448 &self.control_handle
449 }
450
451 fn drop_without_shutdown(mut self) {
452 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
454 std::mem::forget(self);
456 }
457}
458
459impl IteratorGetResponder {
460 pub fn send(self, mut entries: &[String]) -> Result<(), fidl::Error> {
464 let _result = self.send_raw(entries);
465 if _result.is_err() {
466 self.control_handle.shutdown();
467 }
468 self.drop_without_shutdown();
469 _result
470 }
471
472 pub fn send_no_shutdown_on_err(self, mut entries: &[String]) -> Result<(), fidl::Error> {
474 let _result = self.send_raw(entries);
475 self.drop_without_shutdown();
476 _result
477 }
478
479 fn send_raw(&self, mut entries: &[String]) -> Result<(), fidl::Error> {
480 self.control_handle.inner.send::<IteratorGetResponse>(
481 (entries,),
482 self.tx_id,
483 0x6a62554b7d535882,
484 fidl::encoding::DynamicFlags::empty(),
485 )
486 }
487}
488
489#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
490pub struct StoreMarker;
491
492impl fidl::endpoints::ProtocolMarker for StoreMarker {
493 type Proxy = StoreProxy;
494 type RequestStream = StoreRequestStream;
495 #[cfg(target_os = "fuchsia")]
496 type SynchronousProxy = StoreSynchronousProxy;
497
498 const DEBUG_NAME: &'static str = "examples.keyvaluestore.additerator.Store";
499}
500impl fidl::endpoints::DiscoverableProtocolMarker for StoreMarker {}
501pub type StoreWriteItemResult = Result<(), WriteError>;
502pub type StoreIterateResult = Result<(), IterateConnectionError>;
503
504pub trait StoreProxyInterface: Send + Sync {
505 type WriteItemResponseFut: std::future::Future<Output = Result<StoreWriteItemResult, fidl::Error>>
506 + Send;
507 fn r#write_item(&self, attempt: &Item) -> Self::WriteItemResponseFut;
508 type IterateResponseFut: std::future::Future<Output = Result<StoreIterateResult, fidl::Error>>
509 + Send;
510 fn r#iterate(
511 &self,
512 starting_at: Option<&str>,
513 iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
514 ) -> Self::IterateResponseFut;
515}
516#[derive(Debug)]
517#[cfg(target_os = "fuchsia")]
518pub struct StoreSynchronousProxy {
519 client: fidl::client::sync::Client,
520}
521
522#[cfg(target_os = "fuchsia")]
523impl fidl::endpoints::SynchronousProxy for StoreSynchronousProxy {
524 type Proxy = StoreProxy;
525 type Protocol = StoreMarker;
526
527 fn from_channel(inner: fidl::Channel) -> Self {
528 Self::new(inner)
529 }
530
531 fn into_channel(self) -> fidl::Channel {
532 self.client.into_channel()
533 }
534
535 fn as_channel(&self) -> &fidl::Channel {
536 self.client.as_channel()
537 }
538}
539
540#[cfg(target_os = "fuchsia")]
541impl StoreSynchronousProxy {
542 pub fn new(channel: fidl::Channel) -> Self {
543 let protocol_name = <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
544 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
545 }
546
547 pub fn into_channel(self) -> fidl::Channel {
548 self.client.into_channel()
549 }
550
551 pub fn wait_for_event(
554 &self,
555 deadline: zx::MonotonicInstant,
556 ) -> Result<StoreEvent, fidl::Error> {
557 StoreEvent::decode(self.client.wait_for_event(deadline)?)
558 }
559
560 pub fn r#write_item(
562 &self,
563 mut attempt: &Item,
564 ___deadline: zx::MonotonicInstant,
565 ) -> Result<StoreWriteItemResult, fidl::Error> {
566 let _response = self.client.send_query::<
567 StoreWriteItemRequest,
568 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
569 >(
570 (attempt,),
571 0x3a714dd8953e97b2,
572 fidl::encoding::DynamicFlags::FLEXIBLE,
573 ___deadline,
574 )?
575 .into_result::<StoreMarker>("write_item")?;
576 Ok(_response.map(|x| x))
577 }
578
579 pub fn r#iterate(
586 &self,
587 mut starting_at: Option<&str>,
588 mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
589 ___deadline: zx::MonotonicInstant,
590 ) -> Result<StoreIterateResult, fidl::Error> {
591 let _response =
592 self.client
593 .send_query::<StoreIterateRequest, fidl::encoding::FlexibleResultType<
594 fidl::encoding::EmptyStruct,
595 IterateConnectionError,
596 >>(
597 (starting_at, iterator),
598 0x48ee436cb85c3f27,
599 fidl::encoding::DynamicFlags::FLEXIBLE,
600 ___deadline,
601 )?
602 .into_result::<StoreMarker>("iterate")?;
603 Ok(_response.map(|x| x))
604 }
605}
606
607#[cfg(target_os = "fuchsia")]
608impl From<StoreSynchronousProxy> for zx::Handle {
609 fn from(value: StoreSynchronousProxy) -> Self {
610 value.into_channel().into()
611 }
612}
613
614#[cfg(target_os = "fuchsia")]
615impl From<fidl::Channel> for StoreSynchronousProxy {
616 fn from(value: fidl::Channel) -> Self {
617 Self::new(value)
618 }
619}
620
621#[cfg(target_os = "fuchsia")]
622impl fidl::endpoints::FromClient for StoreSynchronousProxy {
623 type Protocol = StoreMarker;
624
625 fn from_client(value: fidl::endpoints::ClientEnd<StoreMarker>) -> Self {
626 Self::new(value.into_channel())
627 }
628}
629
630#[derive(Debug, Clone)]
631pub struct StoreProxy {
632 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
633}
634
635impl fidl::endpoints::Proxy for StoreProxy {
636 type Protocol = StoreMarker;
637
638 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
639 Self::new(inner)
640 }
641
642 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
643 self.client.into_channel().map_err(|client| Self { client })
644 }
645
646 fn as_channel(&self) -> &::fidl::AsyncChannel {
647 self.client.as_channel()
648 }
649}
650
651impl StoreProxy {
652 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
654 let protocol_name = <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
655 Self { client: fidl::client::Client::new(channel, protocol_name) }
656 }
657
658 pub fn take_event_stream(&self) -> StoreEventStream {
664 StoreEventStream { event_receiver: self.client.take_event_receiver() }
665 }
666
667 pub fn r#write_item(
669 &self,
670 mut attempt: &Item,
671 ) -> fidl::client::QueryResponseFut<
672 StoreWriteItemResult,
673 fidl::encoding::DefaultFuchsiaResourceDialect,
674 > {
675 StoreProxyInterface::r#write_item(self, attempt)
676 }
677
678 pub fn r#iterate(
685 &self,
686 mut starting_at: Option<&str>,
687 mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
688 ) -> fidl::client::QueryResponseFut<
689 StoreIterateResult,
690 fidl::encoding::DefaultFuchsiaResourceDialect,
691 > {
692 StoreProxyInterface::r#iterate(self, starting_at, iterator)
693 }
694}
695
696impl StoreProxyInterface for StoreProxy {
697 type WriteItemResponseFut = fidl::client::QueryResponseFut<
698 StoreWriteItemResult,
699 fidl::encoding::DefaultFuchsiaResourceDialect,
700 >;
701 fn r#write_item(&self, mut attempt: &Item) -> Self::WriteItemResponseFut {
702 fn _decode(
703 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
704 ) -> Result<StoreWriteItemResult, fidl::Error> {
705 let _response = fidl::client::decode_transaction_body::<
706 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
707 fidl::encoding::DefaultFuchsiaResourceDialect,
708 0x3a714dd8953e97b2,
709 >(_buf?)?
710 .into_result::<StoreMarker>("write_item")?;
711 Ok(_response.map(|x| x))
712 }
713 self.client.send_query_and_decode::<StoreWriteItemRequest, StoreWriteItemResult>(
714 (attempt,),
715 0x3a714dd8953e97b2,
716 fidl::encoding::DynamicFlags::FLEXIBLE,
717 _decode,
718 )
719 }
720
721 type IterateResponseFut = fidl::client::QueryResponseFut<
722 StoreIterateResult,
723 fidl::encoding::DefaultFuchsiaResourceDialect,
724 >;
725 fn r#iterate(
726 &self,
727 mut starting_at: Option<&str>,
728 mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
729 ) -> Self::IterateResponseFut {
730 fn _decode(
731 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
732 ) -> Result<StoreIterateResult, fidl::Error> {
733 let _response = fidl::client::decode_transaction_body::<
734 fidl::encoding::FlexibleResultType<
735 fidl::encoding::EmptyStruct,
736 IterateConnectionError,
737 >,
738 fidl::encoding::DefaultFuchsiaResourceDialect,
739 0x48ee436cb85c3f27,
740 >(_buf?)?
741 .into_result::<StoreMarker>("iterate")?;
742 Ok(_response.map(|x| x))
743 }
744 self.client.send_query_and_decode::<StoreIterateRequest, StoreIterateResult>(
745 (starting_at, iterator),
746 0x48ee436cb85c3f27,
747 fidl::encoding::DynamicFlags::FLEXIBLE,
748 _decode,
749 )
750 }
751}
752
753pub struct StoreEventStream {
754 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
755}
756
757impl std::marker::Unpin for StoreEventStream {}
758
759impl futures::stream::FusedStream for StoreEventStream {
760 fn is_terminated(&self) -> bool {
761 self.event_receiver.is_terminated()
762 }
763}
764
765impl futures::Stream for StoreEventStream {
766 type Item = Result<StoreEvent, fidl::Error>;
767
768 fn poll_next(
769 mut self: std::pin::Pin<&mut Self>,
770 cx: &mut std::task::Context<'_>,
771 ) -> std::task::Poll<Option<Self::Item>> {
772 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
773 &mut self.event_receiver,
774 cx
775 )?) {
776 Some(buf) => std::task::Poll::Ready(Some(StoreEvent::decode(buf))),
777 None => std::task::Poll::Ready(None),
778 }
779 }
780}
781
782#[derive(Debug)]
783pub enum StoreEvent {
784 #[non_exhaustive]
785 _UnknownEvent {
786 ordinal: u64,
788 },
789}
790
791impl StoreEvent {
792 fn decode(
794 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
795 ) -> Result<StoreEvent, fidl::Error> {
796 let (bytes, _handles) = buf.split_mut();
797 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
798 debug_assert_eq!(tx_header.tx_id, 0);
799 match tx_header.ordinal {
800 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
801 Ok(StoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
802 }
803 _ => Err(fidl::Error::UnknownOrdinal {
804 ordinal: tx_header.ordinal,
805 protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
806 }),
807 }
808 }
809}
810
811pub struct StoreRequestStream {
813 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
814 is_terminated: bool,
815}
816
817impl std::marker::Unpin for StoreRequestStream {}
818
819impl futures::stream::FusedStream for StoreRequestStream {
820 fn is_terminated(&self) -> bool {
821 self.is_terminated
822 }
823}
824
825impl fidl::endpoints::RequestStream for StoreRequestStream {
826 type Protocol = StoreMarker;
827 type ControlHandle = StoreControlHandle;
828
829 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
830 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
831 }
832
833 fn control_handle(&self) -> Self::ControlHandle {
834 StoreControlHandle { inner: self.inner.clone() }
835 }
836
837 fn into_inner(
838 self,
839 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
840 {
841 (self.inner, self.is_terminated)
842 }
843
844 fn from_inner(
845 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
846 is_terminated: bool,
847 ) -> Self {
848 Self { inner, is_terminated }
849 }
850}
851
852impl futures::Stream for StoreRequestStream {
853 type Item = Result<StoreRequest, fidl::Error>;
854
855 fn poll_next(
856 mut self: std::pin::Pin<&mut Self>,
857 cx: &mut std::task::Context<'_>,
858 ) -> std::task::Poll<Option<Self::Item>> {
859 let this = &mut *self;
860 if this.inner.check_shutdown(cx) {
861 this.is_terminated = true;
862 return std::task::Poll::Ready(None);
863 }
864 if this.is_terminated {
865 panic!("polled StoreRequestStream after completion");
866 }
867 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
868 |bytes, handles| {
869 match this.inner.channel().read_etc(cx, bytes, handles) {
870 std::task::Poll::Ready(Ok(())) => {}
871 std::task::Poll::Pending => return std::task::Poll::Pending,
872 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
873 this.is_terminated = true;
874 return std::task::Poll::Ready(None);
875 }
876 std::task::Poll::Ready(Err(e)) => {
877 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
878 e.into(),
879 ))));
880 }
881 }
882
883 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
885
886 std::task::Poll::Ready(Some(match header.ordinal {
887 0x3a714dd8953e97b2 => {
888 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
889 let mut req = fidl::new_empty!(
890 StoreWriteItemRequest,
891 fidl::encoding::DefaultFuchsiaResourceDialect
892 );
893 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreWriteItemRequest>(&header, _body_bytes, handles, &mut req)?;
894 let control_handle = StoreControlHandle { inner: this.inner.clone() };
895 Ok(StoreRequest::WriteItem {
896 attempt: req.attempt,
897
898 responder: StoreWriteItemResponder {
899 control_handle: std::mem::ManuallyDrop::new(control_handle),
900 tx_id: header.tx_id,
901 },
902 })
903 }
904 0x48ee436cb85c3f27 => {
905 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
906 let mut req = fidl::new_empty!(
907 StoreIterateRequest,
908 fidl::encoding::DefaultFuchsiaResourceDialect
909 );
910 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreIterateRequest>(&header, _body_bytes, handles, &mut req)?;
911 let control_handle = StoreControlHandle { inner: this.inner.clone() };
912 Ok(StoreRequest::Iterate {
913 starting_at: req.starting_at,
914 iterator: req.iterator,
915
916 responder: StoreIterateResponder {
917 control_handle: std::mem::ManuallyDrop::new(control_handle),
918 tx_id: header.tx_id,
919 },
920 })
921 }
922 _ if header.tx_id == 0
923 && header
924 .dynamic_flags()
925 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
926 {
927 Ok(StoreRequest::_UnknownMethod {
928 ordinal: header.ordinal,
929 control_handle: StoreControlHandle { inner: this.inner.clone() },
930 method_type: fidl::MethodType::OneWay,
931 })
932 }
933 _ if header
934 .dynamic_flags()
935 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
936 {
937 this.inner.send_framework_err(
938 fidl::encoding::FrameworkErr::UnknownMethod,
939 header.tx_id,
940 header.ordinal,
941 header.dynamic_flags(),
942 (bytes, handles),
943 )?;
944 Ok(StoreRequest::_UnknownMethod {
945 ordinal: header.ordinal,
946 control_handle: StoreControlHandle { inner: this.inner.clone() },
947 method_type: fidl::MethodType::TwoWay,
948 })
949 }
950 _ => Err(fidl::Error::UnknownOrdinal {
951 ordinal: header.ordinal,
952 protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
953 }),
954 }))
955 },
956 )
957 }
958}
959
960#[derive(Debug)]
962pub enum StoreRequest {
963 WriteItem { attempt: Item, responder: StoreWriteItemResponder },
965 Iterate {
972 starting_at: Option<String>,
973 iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
974 responder: StoreIterateResponder,
975 },
976 #[non_exhaustive]
978 _UnknownMethod {
979 ordinal: u64,
981 control_handle: StoreControlHandle,
982 method_type: fidl::MethodType,
983 },
984}
985
986impl StoreRequest {
987 #[allow(irrefutable_let_patterns)]
988 pub fn into_write_item(self) -> Option<(Item, StoreWriteItemResponder)> {
989 if let StoreRequest::WriteItem { attempt, responder } = self {
990 Some((attempt, responder))
991 } else {
992 None
993 }
994 }
995
996 #[allow(irrefutable_let_patterns)]
997 pub fn into_iterate(
998 self,
999 ) -> Option<(Option<String>, fidl::endpoints::ServerEnd<IteratorMarker>, StoreIterateResponder)>
1000 {
1001 if let StoreRequest::Iterate { starting_at, iterator, responder } = self {
1002 Some((starting_at, iterator, responder))
1003 } else {
1004 None
1005 }
1006 }
1007
1008 pub fn method_name(&self) -> &'static str {
1010 match *self {
1011 StoreRequest::WriteItem { .. } => "write_item",
1012 StoreRequest::Iterate { .. } => "iterate",
1013 StoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1014 "unknown one-way method"
1015 }
1016 StoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1017 "unknown two-way method"
1018 }
1019 }
1020 }
1021}
1022
1023#[derive(Debug, Clone)]
1024pub struct StoreControlHandle {
1025 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1026}
1027
1028impl fidl::endpoints::ControlHandle for StoreControlHandle {
1029 fn shutdown(&self) {
1030 self.inner.shutdown()
1031 }
1032 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1033 self.inner.shutdown_with_epitaph(status)
1034 }
1035
1036 fn is_closed(&self) -> bool {
1037 self.inner.channel().is_closed()
1038 }
1039 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1040 self.inner.channel().on_closed()
1041 }
1042
1043 #[cfg(target_os = "fuchsia")]
1044 fn signal_peer(
1045 &self,
1046 clear_mask: zx::Signals,
1047 set_mask: zx::Signals,
1048 ) -> Result<(), zx_status::Status> {
1049 use fidl::Peered;
1050 self.inner.channel().signal_peer(clear_mask, set_mask)
1051 }
1052}
1053
1054impl StoreControlHandle {}
1055
1056#[must_use = "FIDL methods require a response to be sent"]
1057#[derive(Debug)]
1058pub struct StoreWriteItemResponder {
1059 control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
1060 tx_id: u32,
1061}
1062
1063impl std::ops::Drop for StoreWriteItemResponder {
1067 fn drop(&mut self) {
1068 self.control_handle.shutdown();
1069 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1071 }
1072}
1073
1074impl fidl::endpoints::Responder for StoreWriteItemResponder {
1075 type ControlHandle = StoreControlHandle;
1076
1077 fn control_handle(&self) -> &StoreControlHandle {
1078 &self.control_handle
1079 }
1080
1081 fn drop_without_shutdown(mut self) {
1082 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1084 std::mem::forget(self);
1086 }
1087}
1088
1089impl StoreWriteItemResponder {
1090 pub fn send(self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
1094 let _result = self.send_raw(result);
1095 if _result.is_err() {
1096 self.control_handle.shutdown();
1097 }
1098 self.drop_without_shutdown();
1099 _result
1100 }
1101
1102 pub fn send_no_shutdown_on_err(
1104 self,
1105 mut result: Result<(), WriteError>,
1106 ) -> Result<(), fidl::Error> {
1107 let _result = self.send_raw(result);
1108 self.drop_without_shutdown();
1109 _result
1110 }
1111
1112 fn send_raw(&self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
1113 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1114 fidl::encoding::EmptyStruct,
1115 WriteError,
1116 >>(
1117 fidl::encoding::FlexibleResult::new(result),
1118 self.tx_id,
1119 0x3a714dd8953e97b2,
1120 fidl::encoding::DynamicFlags::FLEXIBLE,
1121 )
1122 }
1123}
1124
1125#[must_use = "FIDL methods require a response to be sent"]
1126#[derive(Debug)]
1127pub struct StoreIterateResponder {
1128 control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
1129 tx_id: u32,
1130}
1131
1132impl std::ops::Drop for StoreIterateResponder {
1136 fn drop(&mut self) {
1137 self.control_handle.shutdown();
1138 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1140 }
1141}
1142
1143impl fidl::endpoints::Responder for StoreIterateResponder {
1144 type ControlHandle = StoreControlHandle;
1145
1146 fn control_handle(&self) -> &StoreControlHandle {
1147 &self.control_handle
1148 }
1149
1150 fn drop_without_shutdown(mut self) {
1151 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1153 std::mem::forget(self);
1155 }
1156}
1157
1158impl StoreIterateResponder {
1159 pub fn send(self, mut result: Result<(), IterateConnectionError>) -> Result<(), fidl::Error> {
1163 let _result = self.send_raw(result);
1164 if _result.is_err() {
1165 self.control_handle.shutdown();
1166 }
1167 self.drop_without_shutdown();
1168 _result
1169 }
1170
1171 pub fn send_no_shutdown_on_err(
1173 self,
1174 mut result: Result<(), IterateConnectionError>,
1175 ) -> Result<(), fidl::Error> {
1176 let _result = self.send_raw(result);
1177 self.drop_without_shutdown();
1178 _result
1179 }
1180
1181 fn send_raw(&self, mut result: Result<(), IterateConnectionError>) -> Result<(), fidl::Error> {
1182 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1183 fidl::encoding::EmptyStruct,
1184 IterateConnectionError,
1185 >>(
1186 fidl::encoding::FlexibleResult::new(result),
1187 self.tx_id,
1188 0x48ee436cb85c3f27,
1189 fidl::encoding::DynamicFlags::FLEXIBLE,
1190 )
1191 }
1192}
1193
1194mod internal {
1195 use super::*;
1196
1197 impl fidl::encoding::ResourceTypeMarker for StoreIterateRequest {
1198 type Borrowed<'a> = &'a mut Self;
1199 fn take_or_borrow<'a>(
1200 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1201 ) -> Self::Borrowed<'a> {
1202 value
1203 }
1204 }
1205
1206 unsafe impl fidl::encoding::TypeMarker for StoreIterateRequest {
1207 type Owned = Self;
1208
1209 #[inline(always)]
1210 fn inline_align(_context: fidl::encoding::Context) -> usize {
1211 8
1212 }
1213
1214 #[inline(always)]
1215 fn inline_size(_context: fidl::encoding::Context) -> usize {
1216 24
1217 }
1218 }
1219
1220 unsafe impl
1221 fidl::encoding::Encode<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1222 for &mut StoreIterateRequest
1223 {
1224 #[inline]
1225 unsafe fn encode(
1226 self,
1227 encoder: &mut fidl::encoding::Encoder<
1228 '_,
1229 fidl::encoding::DefaultFuchsiaResourceDialect,
1230 >,
1231 offset: usize,
1232 _depth: fidl::encoding::Depth,
1233 ) -> fidl::Result<()> {
1234 encoder.debug_check_bounds::<StoreIterateRequest>(offset);
1235 fidl::encoding::Encode::<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1237 (
1238 <fidl::encoding::Optional<fidl::encoding::BoundedString<128>> as fidl::encoding::ValueTypeMarker>::borrow(&self.starting_at),
1239 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
1240 ),
1241 encoder, offset, _depth
1242 )
1243 }
1244 }
1245 unsafe impl<
1246 T0: fidl::encoding::Encode<
1247 fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1248 fidl::encoding::DefaultFuchsiaResourceDialect,
1249 >,
1250 T1: fidl::encoding::Encode<
1251 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1252 fidl::encoding::DefaultFuchsiaResourceDialect,
1253 >,
1254 > fidl::encoding::Encode<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1255 for (T0, T1)
1256 {
1257 #[inline]
1258 unsafe fn encode(
1259 self,
1260 encoder: &mut fidl::encoding::Encoder<
1261 '_,
1262 fidl::encoding::DefaultFuchsiaResourceDialect,
1263 >,
1264 offset: usize,
1265 depth: fidl::encoding::Depth,
1266 ) -> fidl::Result<()> {
1267 encoder.debug_check_bounds::<StoreIterateRequest>(offset);
1268 unsafe {
1271 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1272 (ptr as *mut u64).write_unaligned(0);
1273 }
1274 self.0.encode(encoder, offset + 0, depth)?;
1276 self.1.encode(encoder, offset + 16, depth)?;
1277 Ok(())
1278 }
1279 }
1280
1281 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1282 for StoreIterateRequest
1283 {
1284 #[inline(always)]
1285 fn new_empty() -> Self {
1286 Self {
1287 starting_at: fidl::new_empty!(
1288 fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1289 fidl::encoding::DefaultFuchsiaResourceDialect
1290 ),
1291 iterator: fidl::new_empty!(
1292 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1293 fidl::encoding::DefaultFuchsiaResourceDialect
1294 ),
1295 }
1296 }
1297
1298 #[inline]
1299 unsafe fn decode(
1300 &mut self,
1301 decoder: &mut fidl::encoding::Decoder<
1302 '_,
1303 fidl::encoding::DefaultFuchsiaResourceDialect,
1304 >,
1305 offset: usize,
1306 _depth: fidl::encoding::Depth,
1307 ) -> fidl::Result<()> {
1308 decoder.debug_check_bounds::<Self>(offset);
1309 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1311 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1312 let mask = 0xffffffff00000000u64;
1313 let maskedval = padval & mask;
1314 if maskedval != 0 {
1315 return Err(fidl::Error::NonZeroPadding {
1316 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1317 });
1318 }
1319 fidl::decode!(
1320 fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1321 fidl::encoding::DefaultFuchsiaResourceDialect,
1322 &mut self.starting_at,
1323 decoder,
1324 offset + 0,
1325 _depth
1326 )?;
1327 fidl::decode!(
1328 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1329 fidl::encoding::DefaultFuchsiaResourceDialect,
1330 &mut self.iterator,
1331 decoder,
1332 offset + 16,
1333 _depth
1334 )?;
1335 Ok(())
1336 }
1337 }
1338}