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