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 {
383 Some((responder))
384 } else {
385 None
386 }
387 }
388
389 pub fn method_name(&self) -> &'static str {
391 match *self {
392 IteratorRequest::Get { .. } => "get",
393 }
394 }
395}
396
397#[derive(Debug, Clone)]
398pub struct IteratorControlHandle {
399 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
400}
401
402impl fidl::endpoints::ControlHandle for IteratorControlHandle {
403 fn shutdown(&self) {
404 self.inner.shutdown()
405 }
406 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
407 self.inner.shutdown_with_epitaph(status)
408 }
409
410 fn is_closed(&self) -> bool {
411 self.inner.channel().is_closed()
412 }
413 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
414 self.inner.channel().on_closed()
415 }
416
417 #[cfg(target_os = "fuchsia")]
418 fn signal_peer(
419 &self,
420 clear_mask: zx::Signals,
421 set_mask: zx::Signals,
422 ) -> Result<(), zx_status::Status> {
423 use fidl::Peered;
424 self.inner.channel().signal_peer(clear_mask, set_mask)
425 }
426}
427
428impl IteratorControlHandle {}
429
430#[must_use = "FIDL methods require a response to be sent"]
431#[derive(Debug)]
432pub struct IteratorGetResponder {
433 control_handle: std::mem::ManuallyDrop<IteratorControlHandle>,
434 tx_id: u32,
435}
436
437impl std::ops::Drop for IteratorGetResponder {
441 fn drop(&mut self) {
442 self.control_handle.shutdown();
443 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
445 }
446}
447
448impl fidl::endpoints::Responder for IteratorGetResponder {
449 type ControlHandle = IteratorControlHandle;
450
451 fn control_handle(&self) -> &IteratorControlHandle {
452 &self.control_handle
453 }
454
455 fn drop_without_shutdown(mut self) {
456 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
458 std::mem::forget(self);
460 }
461}
462
463impl IteratorGetResponder {
464 pub fn send(self, mut entries: &[String]) -> Result<(), fidl::Error> {
468 let _result = self.send_raw(entries);
469 if _result.is_err() {
470 self.control_handle.shutdown();
471 }
472 self.drop_without_shutdown();
473 _result
474 }
475
476 pub fn send_no_shutdown_on_err(self, mut entries: &[String]) -> Result<(), fidl::Error> {
478 let _result = self.send_raw(entries);
479 self.drop_without_shutdown();
480 _result
481 }
482
483 fn send_raw(&self, mut entries: &[String]) -> Result<(), fidl::Error> {
484 self.control_handle.inner.send::<IteratorGetResponse>(
485 (entries,),
486 self.tx_id,
487 0x6a62554b7d535882,
488 fidl::encoding::DynamicFlags::empty(),
489 )
490 }
491}
492
493#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
494pub struct StoreMarker;
495
496impl fidl::endpoints::ProtocolMarker for StoreMarker {
497 type Proxy = StoreProxy;
498 type RequestStream = StoreRequestStream;
499 #[cfg(target_os = "fuchsia")]
500 type SynchronousProxy = StoreSynchronousProxy;
501
502 const DEBUG_NAME: &'static str = "examples.keyvaluestore.additerator.Store";
503}
504impl fidl::endpoints::DiscoverableProtocolMarker for StoreMarker {}
505pub type StoreWriteItemResult = Result<(), WriteError>;
506pub type StoreIterateResult = Result<(), IterateConnectionError>;
507
508pub trait StoreProxyInterface: Send + Sync {
509 type WriteItemResponseFut: std::future::Future<Output = Result<StoreWriteItemResult, fidl::Error>>
510 + Send;
511 fn r#write_item(&self, attempt: &Item) -> Self::WriteItemResponseFut;
512 type IterateResponseFut: std::future::Future<Output = Result<StoreIterateResult, fidl::Error>>
513 + Send;
514 fn r#iterate(
515 &self,
516 starting_at: Option<&str>,
517 iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
518 ) -> Self::IterateResponseFut;
519}
520#[derive(Debug)]
521#[cfg(target_os = "fuchsia")]
522pub struct StoreSynchronousProxy {
523 client: fidl::client::sync::Client,
524}
525
526#[cfg(target_os = "fuchsia")]
527impl fidl::endpoints::SynchronousProxy for StoreSynchronousProxy {
528 type Proxy = StoreProxy;
529 type Protocol = StoreMarker;
530
531 fn from_channel(inner: fidl::Channel) -> Self {
532 Self::new(inner)
533 }
534
535 fn into_channel(self) -> fidl::Channel {
536 self.client.into_channel()
537 }
538
539 fn as_channel(&self) -> &fidl::Channel {
540 self.client.as_channel()
541 }
542}
543
544#[cfg(target_os = "fuchsia")]
545impl StoreSynchronousProxy {
546 pub fn new(channel: fidl::Channel) -> Self {
547 let protocol_name = <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
548 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
549 }
550
551 pub fn into_channel(self) -> fidl::Channel {
552 self.client.into_channel()
553 }
554
555 pub fn wait_for_event(
558 &self,
559 deadline: zx::MonotonicInstant,
560 ) -> Result<StoreEvent, fidl::Error> {
561 StoreEvent::decode(self.client.wait_for_event(deadline)?)
562 }
563
564 pub fn r#write_item(
566 &self,
567 mut attempt: &Item,
568 ___deadline: zx::MonotonicInstant,
569 ) -> Result<StoreWriteItemResult, fidl::Error> {
570 let _response = self.client.send_query::<
571 StoreWriteItemRequest,
572 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
573 >(
574 (attempt,),
575 0x3a714dd8953e97b2,
576 fidl::encoding::DynamicFlags::FLEXIBLE,
577 ___deadline,
578 )?
579 .into_result::<StoreMarker>("write_item")?;
580 Ok(_response.map(|x| x))
581 }
582
583 pub fn r#iterate(
590 &self,
591 mut starting_at: Option<&str>,
592 mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
593 ___deadline: zx::MonotonicInstant,
594 ) -> Result<StoreIterateResult, fidl::Error> {
595 let _response =
596 self.client
597 .send_query::<StoreIterateRequest, fidl::encoding::FlexibleResultType<
598 fidl::encoding::EmptyStruct,
599 IterateConnectionError,
600 >>(
601 (starting_at, iterator),
602 0x48ee436cb85c3f27,
603 fidl::encoding::DynamicFlags::FLEXIBLE,
604 ___deadline,
605 )?
606 .into_result::<StoreMarker>("iterate")?;
607 Ok(_response.map(|x| x))
608 }
609}
610
611#[cfg(target_os = "fuchsia")]
612impl From<StoreSynchronousProxy> for zx::Handle {
613 fn from(value: StoreSynchronousProxy) -> Self {
614 value.into_channel().into()
615 }
616}
617
618#[cfg(target_os = "fuchsia")]
619impl From<fidl::Channel> for StoreSynchronousProxy {
620 fn from(value: fidl::Channel) -> Self {
621 Self::new(value)
622 }
623}
624
625#[cfg(target_os = "fuchsia")]
626impl fidl::endpoints::FromClient for StoreSynchronousProxy {
627 type Protocol = StoreMarker;
628
629 fn from_client(value: fidl::endpoints::ClientEnd<StoreMarker>) -> Self {
630 Self::new(value.into_channel())
631 }
632}
633
634#[derive(Debug, Clone)]
635pub struct StoreProxy {
636 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
637}
638
639impl fidl::endpoints::Proxy for StoreProxy {
640 type Protocol = StoreMarker;
641
642 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
643 Self::new(inner)
644 }
645
646 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
647 self.client.into_channel().map_err(|client| Self { client })
648 }
649
650 fn as_channel(&self) -> &::fidl::AsyncChannel {
651 self.client.as_channel()
652 }
653}
654
655impl StoreProxy {
656 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
658 let protocol_name = <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
659 Self { client: fidl::client::Client::new(channel, protocol_name) }
660 }
661
662 pub fn take_event_stream(&self) -> StoreEventStream {
668 StoreEventStream { event_receiver: self.client.take_event_receiver() }
669 }
670
671 pub fn r#write_item(
673 &self,
674 mut attempt: &Item,
675 ) -> fidl::client::QueryResponseFut<
676 StoreWriteItemResult,
677 fidl::encoding::DefaultFuchsiaResourceDialect,
678 > {
679 StoreProxyInterface::r#write_item(self, attempt)
680 }
681
682 pub fn r#iterate(
689 &self,
690 mut starting_at: Option<&str>,
691 mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
692 ) -> fidl::client::QueryResponseFut<
693 StoreIterateResult,
694 fidl::encoding::DefaultFuchsiaResourceDialect,
695 > {
696 StoreProxyInterface::r#iterate(self, starting_at, iterator)
697 }
698}
699
700impl StoreProxyInterface for StoreProxy {
701 type WriteItemResponseFut = fidl::client::QueryResponseFut<
702 StoreWriteItemResult,
703 fidl::encoding::DefaultFuchsiaResourceDialect,
704 >;
705 fn r#write_item(&self, mut attempt: &Item) -> Self::WriteItemResponseFut {
706 fn _decode(
707 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
708 ) -> Result<StoreWriteItemResult, fidl::Error> {
709 let _response = fidl::client::decode_transaction_body::<
710 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
711 fidl::encoding::DefaultFuchsiaResourceDialect,
712 0x3a714dd8953e97b2,
713 >(_buf?)?
714 .into_result::<StoreMarker>("write_item")?;
715 Ok(_response.map(|x| x))
716 }
717 self.client.send_query_and_decode::<StoreWriteItemRequest, StoreWriteItemResult>(
718 (attempt,),
719 0x3a714dd8953e97b2,
720 fidl::encoding::DynamicFlags::FLEXIBLE,
721 _decode,
722 )
723 }
724
725 type IterateResponseFut = fidl::client::QueryResponseFut<
726 StoreIterateResult,
727 fidl::encoding::DefaultFuchsiaResourceDialect,
728 >;
729 fn r#iterate(
730 &self,
731 mut starting_at: Option<&str>,
732 mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
733 ) -> Self::IterateResponseFut {
734 fn _decode(
735 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
736 ) -> Result<StoreIterateResult, fidl::Error> {
737 let _response = fidl::client::decode_transaction_body::<
738 fidl::encoding::FlexibleResultType<
739 fidl::encoding::EmptyStruct,
740 IterateConnectionError,
741 >,
742 fidl::encoding::DefaultFuchsiaResourceDialect,
743 0x48ee436cb85c3f27,
744 >(_buf?)?
745 .into_result::<StoreMarker>("iterate")?;
746 Ok(_response.map(|x| x))
747 }
748 self.client.send_query_and_decode::<StoreIterateRequest, StoreIterateResult>(
749 (starting_at, iterator),
750 0x48ee436cb85c3f27,
751 fidl::encoding::DynamicFlags::FLEXIBLE,
752 _decode,
753 )
754 }
755}
756
757pub struct StoreEventStream {
758 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
759}
760
761impl std::marker::Unpin for StoreEventStream {}
762
763impl futures::stream::FusedStream for StoreEventStream {
764 fn is_terminated(&self) -> bool {
765 self.event_receiver.is_terminated()
766 }
767}
768
769impl futures::Stream for StoreEventStream {
770 type Item = Result<StoreEvent, fidl::Error>;
771
772 fn poll_next(
773 mut self: std::pin::Pin<&mut Self>,
774 cx: &mut std::task::Context<'_>,
775 ) -> std::task::Poll<Option<Self::Item>> {
776 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
777 &mut self.event_receiver,
778 cx
779 )?) {
780 Some(buf) => std::task::Poll::Ready(Some(StoreEvent::decode(buf))),
781 None => std::task::Poll::Ready(None),
782 }
783 }
784}
785
786#[derive(Debug)]
787pub enum StoreEvent {
788 #[non_exhaustive]
789 _UnknownEvent {
790 ordinal: u64,
792 },
793}
794
795impl StoreEvent {
796 fn decode(
798 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
799 ) -> Result<StoreEvent, fidl::Error> {
800 let (bytes, _handles) = buf.split_mut();
801 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
802 debug_assert_eq!(tx_header.tx_id, 0);
803 match tx_header.ordinal {
804 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
805 Ok(StoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
806 }
807 _ => Err(fidl::Error::UnknownOrdinal {
808 ordinal: tx_header.ordinal,
809 protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
810 }),
811 }
812 }
813}
814
815pub struct StoreRequestStream {
817 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
818 is_terminated: bool,
819}
820
821impl std::marker::Unpin for StoreRequestStream {}
822
823impl futures::stream::FusedStream for StoreRequestStream {
824 fn is_terminated(&self) -> bool {
825 self.is_terminated
826 }
827}
828
829impl fidl::endpoints::RequestStream for StoreRequestStream {
830 type Protocol = StoreMarker;
831 type ControlHandle = StoreControlHandle;
832
833 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
834 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
835 }
836
837 fn control_handle(&self) -> Self::ControlHandle {
838 StoreControlHandle { inner: self.inner.clone() }
839 }
840
841 fn into_inner(
842 self,
843 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
844 {
845 (self.inner, self.is_terminated)
846 }
847
848 fn from_inner(
849 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
850 is_terminated: bool,
851 ) -> Self {
852 Self { inner, is_terminated }
853 }
854}
855
856impl futures::Stream for StoreRequestStream {
857 type Item = Result<StoreRequest, fidl::Error>;
858
859 fn poll_next(
860 mut self: std::pin::Pin<&mut Self>,
861 cx: &mut std::task::Context<'_>,
862 ) -> std::task::Poll<Option<Self::Item>> {
863 let this = &mut *self;
864 if this.inner.check_shutdown(cx) {
865 this.is_terminated = true;
866 return std::task::Poll::Ready(None);
867 }
868 if this.is_terminated {
869 panic!("polled StoreRequestStream after completion");
870 }
871 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
872 |bytes, handles| {
873 match this.inner.channel().read_etc(cx, bytes, handles) {
874 std::task::Poll::Ready(Ok(())) => {}
875 std::task::Poll::Pending => return std::task::Poll::Pending,
876 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
877 this.is_terminated = true;
878 return std::task::Poll::Ready(None);
879 }
880 std::task::Poll::Ready(Err(e)) => {
881 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
882 e.into(),
883 ))))
884 }
885 }
886
887 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
889
890 std::task::Poll::Ready(Some(match header.ordinal {
891 0x3a714dd8953e97b2 => {
892 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
893 let mut req = fidl::new_empty!(
894 StoreWriteItemRequest,
895 fidl::encoding::DefaultFuchsiaResourceDialect
896 );
897 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreWriteItemRequest>(&header, _body_bytes, handles, &mut req)?;
898 let control_handle = StoreControlHandle { inner: this.inner.clone() };
899 Ok(StoreRequest::WriteItem {
900 attempt: req.attempt,
901
902 responder: StoreWriteItemResponder {
903 control_handle: std::mem::ManuallyDrop::new(control_handle),
904 tx_id: header.tx_id,
905 },
906 })
907 }
908 0x48ee436cb85c3f27 => {
909 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
910 let mut req = fidl::new_empty!(
911 StoreIterateRequest,
912 fidl::encoding::DefaultFuchsiaResourceDialect
913 );
914 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreIterateRequest>(&header, _body_bytes, handles, &mut req)?;
915 let control_handle = StoreControlHandle { inner: this.inner.clone() };
916 Ok(StoreRequest::Iterate {
917 starting_at: req.starting_at,
918 iterator: req.iterator,
919
920 responder: StoreIterateResponder {
921 control_handle: std::mem::ManuallyDrop::new(control_handle),
922 tx_id: header.tx_id,
923 },
924 })
925 }
926 _ if header.tx_id == 0
927 && header
928 .dynamic_flags()
929 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
930 {
931 Ok(StoreRequest::_UnknownMethod {
932 ordinal: header.ordinal,
933 control_handle: StoreControlHandle { inner: this.inner.clone() },
934 method_type: fidl::MethodType::OneWay,
935 })
936 }
937 _ if header
938 .dynamic_flags()
939 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
940 {
941 this.inner.send_framework_err(
942 fidl::encoding::FrameworkErr::UnknownMethod,
943 header.tx_id,
944 header.ordinal,
945 header.dynamic_flags(),
946 (bytes, handles),
947 )?;
948 Ok(StoreRequest::_UnknownMethod {
949 ordinal: header.ordinal,
950 control_handle: StoreControlHandle { inner: this.inner.clone() },
951 method_type: fidl::MethodType::TwoWay,
952 })
953 }
954 _ => Err(fidl::Error::UnknownOrdinal {
955 ordinal: header.ordinal,
956 protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
957 }),
958 }))
959 },
960 )
961 }
962}
963
964#[derive(Debug)]
966pub enum StoreRequest {
967 WriteItem { attempt: Item, responder: StoreWriteItemResponder },
969 Iterate {
976 starting_at: Option<String>,
977 iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
978 responder: StoreIterateResponder,
979 },
980 #[non_exhaustive]
982 _UnknownMethod {
983 ordinal: u64,
985 control_handle: StoreControlHandle,
986 method_type: fidl::MethodType,
987 },
988}
989
990impl StoreRequest {
991 #[allow(irrefutable_let_patterns)]
992 pub fn into_write_item(self) -> Option<(Item, StoreWriteItemResponder)> {
993 if let StoreRequest::WriteItem { attempt, responder } = self {
994 Some((attempt, responder))
995 } else {
996 None
997 }
998 }
999
1000 #[allow(irrefutable_let_patterns)]
1001 pub fn into_iterate(
1002 self,
1003 ) -> Option<(Option<String>, fidl::endpoints::ServerEnd<IteratorMarker>, StoreIterateResponder)>
1004 {
1005 if let StoreRequest::Iterate { starting_at, iterator, responder } = self {
1006 Some((starting_at, iterator, responder))
1007 } else {
1008 None
1009 }
1010 }
1011
1012 pub fn method_name(&self) -> &'static str {
1014 match *self {
1015 StoreRequest::WriteItem { .. } => "write_item",
1016 StoreRequest::Iterate { .. } => "iterate",
1017 StoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1018 "unknown one-way method"
1019 }
1020 StoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1021 "unknown two-way method"
1022 }
1023 }
1024 }
1025}
1026
1027#[derive(Debug, Clone)]
1028pub struct StoreControlHandle {
1029 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1030}
1031
1032impl fidl::endpoints::ControlHandle for StoreControlHandle {
1033 fn shutdown(&self) {
1034 self.inner.shutdown()
1035 }
1036 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1037 self.inner.shutdown_with_epitaph(status)
1038 }
1039
1040 fn is_closed(&self) -> bool {
1041 self.inner.channel().is_closed()
1042 }
1043 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1044 self.inner.channel().on_closed()
1045 }
1046
1047 #[cfg(target_os = "fuchsia")]
1048 fn signal_peer(
1049 &self,
1050 clear_mask: zx::Signals,
1051 set_mask: zx::Signals,
1052 ) -> Result<(), zx_status::Status> {
1053 use fidl::Peered;
1054 self.inner.channel().signal_peer(clear_mask, set_mask)
1055 }
1056}
1057
1058impl StoreControlHandle {}
1059
1060#[must_use = "FIDL methods require a response to be sent"]
1061#[derive(Debug)]
1062pub struct StoreWriteItemResponder {
1063 control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
1064 tx_id: u32,
1065}
1066
1067impl std::ops::Drop for StoreWriteItemResponder {
1071 fn drop(&mut self) {
1072 self.control_handle.shutdown();
1073 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1075 }
1076}
1077
1078impl fidl::endpoints::Responder for StoreWriteItemResponder {
1079 type ControlHandle = StoreControlHandle;
1080
1081 fn control_handle(&self) -> &StoreControlHandle {
1082 &self.control_handle
1083 }
1084
1085 fn drop_without_shutdown(mut self) {
1086 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1088 std::mem::forget(self);
1090 }
1091}
1092
1093impl StoreWriteItemResponder {
1094 pub fn send(self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
1098 let _result = self.send_raw(result);
1099 if _result.is_err() {
1100 self.control_handle.shutdown();
1101 }
1102 self.drop_without_shutdown();
1103 _result
1104 }
1105
1106 pub fn send_no_shutdown_on_err(
1108 self,
1109 mut result: Result<(), WriteError>,
1110 ) -> Result<(), fidl::Error> {
1111 let _result = self.send_raw(result);
1112 self.drop_without_shutdown();
1113 _result
1114 }
1115
1116 fn send_raw(&self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
1117 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1118 fidl::encoding::EmptyStruct,
1119 WriteError,
1120 >>(
1121 fidl::encoding::FlexibleResult::new(result),
1122 self.tx_id,
1123 0x3a714dd8953e97b2,
1124 fidl::encoding::DynamicFlags::FLEXIBLE,
1125 )
1126 }
1127}
1128
1129#[must_use = "FIDL methods require a response to be sent"]
1130#[derive(Debug)]
1131pub struct StoreIterateResponder {
1132 control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
1133 tx_id: u32,
1134}
1135
1136impl std::ops::Drop for StoreIterateResponder {
1140 fn drop(&mut self) {
1141 self.control_handle.shutdown();
1142 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1144 }
1145}
1146
1147impl fidl::endpoints::Responder for StoreIterateResponder {
1148 type ControlHandle = StoreControlHandle;
1149
1150 fn control_handle(&self) -> &StoreControlHandle {
1151 &self.control_handle
1152 }
1153
1154 fn drop_without_shutdown(mut self) {
1155 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1157 std::mem::forget(self);
1159 }
1160}
1161
1162impl StoreIterateResponder {
1163 pub fn send(self, mut result: Result<(), IterateConnectionError>) -> Result<(), fidl::Error> {
1167 let _result = self.send_raw(result);
1168 if _result.is_err() {
1169 self.control_handle.shutdown();
1170 }
1171 self.drop_without_shutdown();
1172 _result
1173 }
1174
1175 pub fn send_no_shutdown_on_err(
1177 self,
1178 mut result: Result<(), IterateConnectionError>,
1179 ) -> Result<(), fidl::Error> {
1180 let _result = self.send_raw(result);
1181 self.drop_without_shutdown();
1182 _result
1183 }
1184
1185 fn send_raw(&self, mut result: Result<(), IterateConnectionError>) -> Result<(), fidl::Error> {
1186 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1187 fidl::encoding::EmptyStruct,
1188 IterateConnectionError,
1189 >>(
1190 fidl::encoding::FlexibleResult::new(result),
1191 self.tx_id,
1192 0x48ee436cb85c3f27,
1193 fidl::encoding::DynamicFlags::FLEXIBLE,
1194 )
1195 }
1196}
1197
1198mod internal {
1199 use super::*;
1200
1201 impl fidl::encoding::ResourceTypeMarker for StoreIterateRequest {
1202 type Borrowed<'a> = &'a mut Self;
1203 fn take_or_borrow<'a>(
1204 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1205 ) -> Self::Borrowed<'a> {
1206 value
1207 }
1208 }
1209
1210 unsafe impl fidl::encoding::TypeMarker for StoreIterateRequest {
1211 type Owned = Self;
1212
1213 #[inline(always)]
1214 fn inline_align(_context: fidl::encoding::Context) -> usize {
1215 8
1216 }
1217
1218 #[inline(always)]
1219 fn inline_size(_context: fidl::encoding::Context) -> usize {
1220 24
1221 }
1222 }
1223
1224 unsafe impl
1225 fidl::encoding::Encode<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1226 for &mut StoreIterateRequest
1227 {
1228 #[inline]
1229 unsafe fn encode(
1230 self,
1231 encoder: &mut fidl::encoding::Encoder<
1232 '_,
1233 fidl::encoding::DefaultFuchsiaResourceDialect,
1234 >,
1235 offset: usize,
1236 _depth: fidl::encoding::Depth,
1237 ) -> fidl::Result<()> {
1238 encoder.debug_check_bounds::<StoreIterateRequest>(offset);
1239 fidl::encoding::Encode::<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1241 (
1242 <fidl::encoding::Optional<fidl::encoding::BoundedString<128>> as fidl::encoding::ValueTypeMarker>::borrow(&self.starting_at),
1243 <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
1244 ),
1245 encoder, offset, _depth
1246 )
1247 }
1248 }
1249 unsafe impl<
1250 T0: fidl::encoding::Encode<
1251 fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1252 fidl::encoding::DefaultFuchsiaResourceDialect,
1253 >,
1254 T1: fidl::encoding::Encode<
1255 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1256 fidl::encoding::DefaultFuchsiaResourceDialect,
1257 >,
1258 >
1259 fidl::encoding::Encode<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1260 for (T0, T1)
1261 {
1262 #[inline]
1263 unsafe fn encode(
1264 self,
1265 encoder: &mut fidl::encoding::Encoder<
1266 '_,
1267 fidl::encoding::DefaultFuchsiaResourceDialect,
1268 >,
1269 offset: usize,
1270 depth: fidl::encoding::Depth,
1271 ) -> fidl::Result<()> {
1272 encoder.debug_check_bounds::<StoreIterateRequest>(offset);
1273 unsafe {
1276 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1277 (ptr as *mut u64).write_unaligned(0);
1278 }
1279 self.0.encode(encoder, offset + 0, depth)?;
1281 self.1.encode(encoder, offset + 16, depth)?;
1282 Ok(())
1283 }
1284 }
1285
1286 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1287 for StoreIterateRequest
1288 {
1289 #[inline(always)]
1290 fn new_empty() -> Self {
1291 Self {
1292 starting_at: fidl::new_empty!(
1293 fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1294 fidl::encoding::DefaultFuchsiaResourceDialect
1295 ),
1296 iterator: fidl::new_empty!(
1297 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1298 fidl::encoding::DefaultFuchsiaResourceDialect
1299 ),
1300 }
1301 }
1302
1303 #[inline]
1304 unsafe fn decode(
1305 &mut self,
1306 decoder: &mut fidl::encoding::Decoder<
1307 '_,
1308 fidl::encoding::DefaultFuchsiaResourceDialect,
1309 >,
1310 offset: usize,
1311 _depth: fidl::encoding::Depth,
1312 ) -> fidl::Result<()> {
1313 decoder.debug_check_bounds::<Self>(offset);
1314 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1316 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1317 let mask = 0xffffffff00000000u64;
1318 let maskedval = padval & mask;
1319 if maskedval != 0 {
1320 return Err(fidl::Error::NonZeroPadding {
1321 padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1322 });
1323 }
1324 fidl::decode!(
1325 fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1326 fidl::encoding::DefaultFuchsiaResourceDialect,
1327 &mut self.starting_at,
1328 decoder,
1329 offset + 0,
1330 _depth
1331 )?;
1332 fidl::decode!(
1333 fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1334 fidl::encoding::DefaultFuchsiaResourceDialect,
1335 &mut self.iterator,
1336 decoder,
1337 offset + 16,
1338 _depth
1339 )?;
1340 Ok(())
1341 }
1342 }
1343}