Skip to main content

fidl_examples_keyvaluestore_additerator/
fidl_examples_keyvaluestore_additerator.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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    /// If present, requests to start the iteration at this item.
17    pub starting_at: Option<String>,
18    /// The [`Iterator`] server endpoint. The client creates both ends of the channel and
19    /// retains the `client_end` locally to use for pulling iteration pages, while sending the
20    /// `server_end` off to be fulfilled by the server.
21    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        Self { client: fidl::client::sync::Client::new(channel) }
70    }
71
72    pub fn into_channel(self) -> fidl::Channel {
73        self.client.into_channel()
74    }
75
76    /// Waits until an event arrives and returns it. It is safe for other
77    /// threads to make concurrent requests while waiting for an event.
78    pub fn wait_for_event(
79        &self,
80        deadline: zx::MonotonicInstant,
81    ) -> Result<IteratorEvent, fidl::Error> {
82        IteratorEvent::decode(self.client.wait_for_event::<IteratorMarker>(deadline)?)
83    }
84
85    /// Gets the next batch of keys.
86    ///
87    /// The client pulls keys rather than having the server proactively push them, to implement
88    /// [flow control][flow-control] over the messages.
89    ///
90    /// [flow-control]:
91    ///     https://fuchsia.dev/fuchsia-src/development/api/fidl?hl=en#prefer_pull_to_push
92    pub fn r#get(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<String>, fidl::Error> {
93        let _response = self
94            .client
95            .send_query::<fidl::encoding::EmptyPayload, IteratorGetResponse, IteratorMarker>(
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::NullableHandle {
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    /// Create a new Proxy for examples.keyvaluestore.additerator/Iterator.
151    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    /// Get a Stream of events from the remote end of the protocol.
157    ///
158    /// # Panics
159    ///
160    /// Panics if the event stream was already taken.
161    pub fn take_event_stream(&self) -> IteratorEventStream {
162        IteratorEventStream { event_receiver: self.client.take_event_receiver() }
163    }
164
165    /// Gets the next batch of keys.
166    ///
167    /// The client pulls keys rather than having the server proactively push them, to implement
168    /// [flow control][flow-control] over the messages.
169    ///
170    /// [flow-control]:
171    ///     https://fuchsia.dev/fuchsia-src/development/api/fidl?hl=en#prefer_pull_to_push
172    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    /// Decodes a message buffer as a [`IteratorEvent`].
237    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
252/// A Stream of incoming requests for examples.keyvaluestore.additerator/Iterator.
253pub 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                // A message has been received from the channel
325                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/// An iterator for the key-value store. Note that this protocol makes no guarantee of atomicity -
355/// the values may change between pulls from the iterator. Unlike the `Store` protocol above, this
356/// protocol is not `@discoverable`: it is not independently published by the component that
357/// implements it, but rather must have one of its two protocol ends transmitted over an existing
358/// FIDL connection.
359///
360/// As is often the case with iterators, the client indicates that they are done with an instance of
361/// the iterator by simply closing their end of the connection.
362///
363/// Since the iterator is associated only with the Iterate method, it is declared as closed rather
364/// than open. This is because changes to how iteration works are more likely to require replacing
365/// the Iterate method completely (which is fine because that method is flexible) rather than
366/// evolving the Iterator protocol.
367#[derive(Debug)]
368pub enum IteratorRequest {
369    /// Gets the next batch of keys.
370    ///
371    /// The client pulls keys rather than having the server proactively push them, to implement
372    /// [flow control][flow-control] over the messages.
373    ///
374    /// [flow-control]:
375    ///     https://fuchsia.dev/fuchsia-src/development/api/fidl?hl=en#prefer_pull_to_push
376    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    /// Name of the method defined in FIDL
386    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 IteratorControlHandle {
399    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
400        self.inner.shutdown_with_epitaph(status.into())
401    }
402}
403
404impl fidl::endpoints::ControlHandle for IteratorControlHandle {
405    fn shutdown(&self) {
406        self.inner.shutdown()
407    }
408
409    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
410        self.inner.shutdown_with_epitaph(status)
411    }
412
413    fn is_closed(&self) -> bool {
414        self.inner.channel().is_closed()
415    }
416    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
417        self.inner.channel().on_closed()
418    }
419
420    #[cfg(target_os = "fuchsia")]
421    fn signal_peer(
422        &self,
423        clear_mask: zx::Signals,
424        set_mask: zx::Signals,
425    ) -> Result<(), zx_status::Status> {
426        use fidl::Peered;
427        self.inner.channel().signal_peer(clear_mask, set_mask)
428    }
429}
430
431impl IteratorControlHandle {}
432
433#[must_use = "FIDL methods require a response to be sent"]
434#[derive(Debug)]
435pub struct IteratorGetResponder {
436    control_handle: std::mem::ManuallyDrop<IteratorControlHandle>,
437    tx_id: u32,
438}
439
440/// Set the the channel to be shutdown (see [`IteratorControlHandle::shutdown`])
441/// if the responder is dropped without sending a response, so that the client
442/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
443impl std::ops::Drop for IteratorGetResponder {
444    fn drop(&mut self) {
445        self.control_handle.shutdown();
446        // Safety: drops once, never accessed again
447        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
448    }
449}
450
451impl fidl::endpoints::Responder for IteratorGetResponder {
452    type ControlHandle = IteratorControlHandle;
453
454    fn control_handle(&self) -> &IteratorControlHandle {
455        &self.control_handle
456    }
457
458    fn drop_without_shutdown(mut self) {
459        // Safety: drops once, never accessed again due to mem::forget
460        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
461        // Prevent Drop from running (which would shut down the channel)
462        std::mem::forget(self);
463    }
464}
465
466impl IteratorGetResponder {
467    /// Sends a response to the FIDL transaction.
468    ///
469    /// Sets the channel to shutdown if an error occurs.
470    pub fn send(self, mut entries: &[String]) -> Result<(), fidl::Error> {
471        let _result = self.send_raw(entries);
472        if _result.is_err() {
473            self.control_handle.shutdown();
474        }
475        self.drop_without_shutdown();
476        _result
477    }
478
479    /// Similar to "send" but does not shutdown the channel if an error occurs.
480    pub fn send_no_shutdown_on_err(self, mut entries: &[String]) -> Result<(), fidl::Error> {
481        let _result = self.send_raw(entries);
482        self.drop_without_shutdown();
483        _result
484    }
485
486    fn send_raw(&self, mut entries: &[String]) -> Result<(), fidl::Error> {
487        self.control_handle.inner.send::<IteratorGetResponse>(
488            (entries,),
489            self.tx_id,
490            0x6a62554b7d535882,
491            fidl::encoding::DynamicFlags::empty(),
492        )
493    }
494}
495
496#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
497pub struct StoreMarker;
498
499impl fidl::endpoints::ProtocolMarker for StoreMarker {
500    type Proxy = StoreProxy;
501    type RequestStream = StoreRequestStream;
502    #[cfg(target_os = "fuchsia")]
503    type SynchronousProxy = StoreSynchronousProxy;
504
505    const DEBUG_NAME: &'static str = "examples.keyvaluestore.additerator.Store";
506}
507impl fidl::endpoints::DiscoverableProtocolMarker for StoreMarker {}
508pub type StoreWriteItemResult = Result<(), WriteError>;
509pub type StoreIterateResult = Result<(), IterateConnectionError>;
510
511pub trait StoreProxyInterface: Send + Sync {
512    type WriteItemResponseFut: std::future::Future<Output = Result<StoreWriteItemResult, fidl::Error>>
513        + Send;
514    fn r#write_item(&self, attempt: &Item) -> Self::WriteItemResponseFut;
515    type IterateResponseFut: std::future::Future<Output = Result<StoreIterateResult, fidl::Error>>
516        + Send;
517    fn r#iterate(
518        &self,
519        starting_at: Option<&str>,
520        iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
521    ) -> Self::IterateResponseFut;
522}
523#[derive(Debug)]
524#[cfg(target_os = "fuchsia")]
525pub struct StoreSynchronousProxy {
526    client: fidl::client::sync::Client,
527}
528
529#[cfg(target_os = "fuchsia")]
530impl fidl::endpoints::SynchronousProxy for StoreSynchronousProxy {
531    type Proxy = StoreProxy;
532    type Protocol = StoreMarker;
533
534    fn from_channel(inner: fidl::Channel) -> Self {
535        Self::new(inner)
536    }
537
538    fn into_channel(self) -> fidl::Channel {
539        self.client.into_channel()
540    }
541
542    fn as_channel(&self) -> &fidl::Channel {
543        self.client.as_channel()
544    }
545}
546
547#[cfg(target_os = "fuchsia")]
548impl StoreSynchronousProxy {
549    pub fn new(channel: fidl::Channel) -> Self {
550        Self { client: fidl::client::sync::Client::new(channel) }
551    }
552
553    pub fn into_channel(self) -> fidl::Channel {
554        self.client.into_channel()
555    }
556
557    /// Waits until an event arrives and returns it. It is safe for other
558    /// threads to make concurrent requests while waiting for an event.
559    pub fn wait_for_event(
560        &self,
561        deadline: zx::MonotonicInstant,
562    ) -> Result<StoreEvent, fidl::Error> {
563        StoreEvent::decode(self.client.wait_for_event::<StoreMarker>(deadline)?)
564    }
565
566    /// Writes an item to the store.
567    pub fn r#write_item(
568        &self,
569        mut attempt: &Item,
570        ___deadline: zx::MonotonicInstant,
571    ) -> Result<StoreWriteItemResult, fidl::Error> {
572        let _response = self.client.send_query::<
573            StoreWriteItemRequest,
574            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
575            StoreMarker,
576        >(
577            (attempt,),
578            0x3a714dd8953e97b2,
579            fidl::encoding::DynamicFlags::FLEXIBLE,
580            ___deadline,
581        )?
582        .into_result::<StoreMarker>("write_item")?;
583        Ok(_response.map(|x| x))
584    }
585
586    /// Iterates over the items in the store, using lexicographic ordering over the keys.
587    ///
588    /// The [`iterator`] is [pipelined][pipelining] to the server, such that the client can
589    /// immediately send requests over the new connection.
590    ///
591    /// [pipelining]: https://fuchsia.dev/fuchsia-src/development/api/fidl?hl=en#request-pipelining
592    pub fn r#iterate(
593        &self,
594        mut starting_at: Option<&str>,
595        mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
596        ___deadline: zx::MonotonicInstant,
597    ) -> Result<StoreIterateResult, fidl::Error> {
598        let _response =
599            self.client
600                .send_query::<StoreIterateRequest, fidl::encoding::FlexibleResultType<
601                    fidl::encoding::EmptyStruct,
602                    IterateConnectionError,
603                >, StoreMarker>(
604                    (starting_at, iterator),
605                    0x48ee436cb85c3f27,
606                    fidl::encoding::DynamicFlags::FLEXIBLE,
607                    ___deadline,
608                )?
609                .into_result::<StoreMarker>("iterate")?;
610        Ok(_response.map(|x| x))
611    }
612}
613
614#[cfg(target_os = "fuchsia")]
615impl From<StoreSynchronousProxy> for zx::NullableHandle {
616    fn from(value: StoreSynchronousProxy) -> Self {
617        value.into_channel().into()
618    }
619}
620
621#[cfg(target_os = "fuchsia")]
622impl From<fidl::Channel> for StoreSynchronousProxy {
623    fn from(value: fidl::Channel) -> Self {
624        Self::new(value)
625    }
626}
627
628#[cfg(target_os = "fuchsia")]
629impl fidl::endpoints::FromClient for StoreSynchronousProxy {
630    type Protocol = StoreMarker;
631
632    fn from_client(value: fidl::endpoints::ClientEnd<StoreMarker>) -> Self {
633        Self::new(value.into_channel())
634    }
635}
636
637#[derive(Debug, Clone)]
638pub struct StoreProxy {
639    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
640}
641
642impl fidl::endpoints::Proxy for StoreProxy {
643    type Protocol = StoreMarker;
644
645    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
646        Self::new(inner)
647    }
648
649    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
650        self.client.into_channel().map_err(|client| Self { client })
651    }
652
653    fn as_channel(&self) -> &::fidl::AsyncChannel {
654        self.client.as_channel()
655    }
656}
657
658impl StoreProxy {
659    /// Create a new Proxy for examples.keyvaluestore.additerator/Store.
660    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
661        let protocol_name = <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
662        Self { client: fidl::client::Client::new(channel, protocol_name) }
663    }
664
665    /// Get a Stream of events from the remote end of the protocol.
666    ///
667    /// # Panics
668    ///
669    /// Panics if the event stream was already taken.
670    pub fn take_event_stream(&self) -> StoreEventStream {
671        StoreEventStream { event_receiver: self.client.take_event_receiver() }
672    }
673
674    /// Writes an item to the store.
675    pub fn r#write_item(
676        &self,
677        mut attempt: &Item,
678    ) -> fidl::client::QueryResponseFut<
679        StoreWriteItemResult,
680        fidl::encoding::DefaultFuchsiaResourceDialect,
681    > {
682        StoreProxyInterface::r#write_item(self, attempt)
683    }
684
685    /// Iterates over the items in the store, using lexicographic ordering over the keys.
686    ///
687    /// The [`iterator`] is [pipelined][pipelining] to the server, such that the client can
688    /// immediately send requests over the new connection.
689    ///
690    /// [pipelining]: https://fuchsia.dev/fuchsia-src/development/api/fidl?hl=en#request-pipelining
691    pub fn r#iterate(
692        &self,
693        mut starting_at: Option<&str>,
694        mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
695    ) -> fidl::client::QueryResponseFut<
696        StoreIterateResult,
697        fidl::encoding::DefaultFuchsiaResourceDialect,
698    > {
699        StoreProxyInterface::r#iterate(self, starting_at, iterator)
700    }
701}
702
703impl StoreProxyInterface for StoreProxy {
704    type WriteItemResponseFut = fidl::client::QueryResponseFut<
705        StoreWriteItemResult,
706        fidl::encoding::DefaultFuchsiaResourceDialect,
707    >;
708    fn r#write_item(&self, mut attempt: &Item) -> Self::WriteItemResponseFut {
709        fn _decode(
710            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
711        ) -> Result<StoreWriteItemResult, fidl::Error> {
712            let _response = fidl::client::decode_transaction_body::<
713                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
714                fidl::encoding::DefaultFuchsiaResourceDialect,
715                0x3a714dd8953e97b2,
716            >(_buf?)?
717            .into_result::<StoreMarker>("write_item")?;
718            Ok(_response.map(|x| x))
719        }
720        self.client.send_query_and_decode::<StoreWriteItemRequest, StoreWriteItemResult>(
721            (attempt,),
722            0x3a714dd8953e97b2,
723            fidl::encoding::DynamicFlags::FLEXIBLE,
724            _decode,
725        )
726    }
727
728    type IterateResponseFut = fidl::client::QueryResponseFut<
729        StoreIterateResult,
730        fidl::encoding::DefaultFuchsiaResourceDialect,
731    >;
732    fn r#iterate(
733        &self,
734        mut starting_at: Option<&str>,
735        mut iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
736    ) -> Self::IterateResponseFut {
737        fn _decode(
738            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
739        ) -> Result<StoreIterateResult, fidl::Error> {
740            let _response = fidl::client::decode_transaction_body::<
741                fidl::encoding::FlexibleResultType<
742                    fidl::encoding::EmptyStruct,
743                    IterateConnectionError,
744                >,
745                fidl::encoding::DefaultFuchsiaResourceDialect,
746                0x48ee436cb85c3f27,
747            >(_buf?)?
748            .into_result::<StoreMarker>("iterate")?;
749            Ok(_response.map(|x| x))
750        }
751        self.client.send_query_and_decode::<StoreIterateRequest, StoreIterateResult>(
752            (starting_at, iterator),
753            0x48ee436cb85c3f27,
754            fidl::encoding::DynamicFlags::FLEXIBLE,
755            _decode,
756        )
757    }
758}
759
760pub struct StoreEventStream {
761    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
762}
763
764impl std::marker::Unpin for StoreEventStream {}
765
766impl futures::stream::FusedStream for StoreEventStream {
767    fn is_terminated(&self) -> bool {
768        self.event_receiver.is_terminated()
769    }
770}
771
772impl futures::Stream for StoreEventStream {
773    type Item = Result<StoreEvent, fidl::Error>;
774
775    fn poll_next(
776        mut self: std::pin::Pin<&mut Self>,
777        cx: &mut std::task::Context<'_>,
778    ) -> std::task::Poll<Option<Self::Item>> {
779        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
780            &mut self.event_receiver,
781            cx
782        )?) {
783            Some(buf) => std::task::Poll::Ready(Some(StoreEvent::decode(buf))),
784            None => std::task::Poll::Ready(None),
785        }
786    }
787}
788
789#[derive(Debug)]
790pub enum StoreEvent {
791    #[non_exhaustive]
792    _UnknownEvent {
793        /// Ordinal of the event that was sent.
794        ordinal: u64,
795    },
796}
797
798impl StoreEvent {
799    /// Decodes a message buffer as a [`StoreEvent`].
800    fn decode(
801        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
802    ) -> Result<StoreEvent, fidl::Error> {
803        let (bytes, _handles) = buf.split_mut();
804        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
805        debug_assert_eq!(tx_header.tx_id, 0);
806        match tx_header.ordinal {
807            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
808                Ok(StoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
809            }
810            _ => Err(fidl::Error::UnknownOrdinal {
811                ordinal: tx_header.ordinal,
812                protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
813            }),
814        }
815    }
816}
817
818/// A Stream of incoming requests for examples.keyvaluestore.additerator/Store.
819pub struct StoreRequestStream {
820    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
821    is_terminated: bool,
822}
823
824impl std::marker::Unpin for StoreRequestStream {}
825
826impl futures::stream::FusedStream for StoreRequestStream {
827    fn is_terminated(&self) -> bool {
828        self.is_terminated
829    }
830}
831
832impl fidl::endpoints::RequestStream for StoreRequestStream {
833    type Protocol = StoreMarker;
834    type ControlHandle = StoreControlHandle;
835
836    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
837        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
838    }
839
840    fn control_handle(&self) -> Self::ControlHandle {
841        StoreControlHandle { inner: self.inner.clone() }
842    }
843
844    fn into_inner(
845        self,
846    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
847    {
848        (self.inner, self.is_terminated)
849    }
850
851    fn from_inner(
852        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
853        is_terminated: bool,
854    ) -> Self {
855        Self { inner, is_terminated }
856    }
857}
858
859impl futures::Stream for StoreRequestStream {
860    type Item = Result<StoreRequest, fidl::Error>;
861
862    fn poll_next(
863        mut self: std::pin::Pin<&mut Self>,
864        cx: &mut std::task::Context<'_>,
865    ) -> std::task::Poll<Option<Self::Item>> {
866        let this = &mut *self;
867        if this.inner.check_shutdown(cx) {
868            this.is_terminated = true;
869            return std::task::Poll::Ready(None);
870        }
871        if this.is_terminated {
872            panic!("polled StoreRequestStream after completion");
873        }
874        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
875            |bytes, handles| {
876                match this.inner.channel().read_etc(cx, bytes, handles) {
877                    std::task::Poll::Ready(Ok(())) => {}
878                    std::task::Poll::Pending => return std::task::Poll::Pending,
879                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
880                        this.is_terminated = true;
881                        return std::task::Poll::Ready(None);
882                    }
883                    std::task::Poll::Ready(Err(e)) => {
884                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
885                            e.into(),
886                        ))));
887                    }
888                }
889
890                // A message has been received from the channel
891                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
892
893                std::task::Poll::Ready(Some(match header.ordinal {
894                    0x3a714dd8953e97b2 => {
895                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
896                        let mut req = fidl::new_empty!(
897                            StoreWriteItemRequest,
898                            fidl::encoding::DefaultFuchsiaResourceDialect
899                        );
900                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreWriteItemRequest>(&header, _body_bytes, handles, &mut req)?;
901                        let control_handle = StoreControlHandle { inner: this.inner.clone() };
902                        Ok(StoreRequest::WriteItem {
903                            attempt: req.attempt,
904
905                            responder: StoreWriteItemResponder {
906                                control_handle: std::mem::ManuallyDrop::new(control_handle),
907                                tx_id: header.tx_id,
908                            },
909                        })
910                    }
911                    0x48ee436cb85c3f27 => {
912                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
913                        let mut req = fidl::new_empty!(
914                            StoreIterateRequest,
915                            fidl::encoding::DefaultFuchsiaResourceDialect
916                        );
917                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreIterateRequest>(&header, _body_bytes, handles, &mut req)?;
918                        let control_handle = StoreControlHandle { inner: this.inner.clone() };
919                        Ok(StoreRequest::Iterate {
920                            starting_at: req.starting_at,
921                            iterator: req.iterator,
922
923                            responder: StoreIterateResponder {
924                                control_handle: std::mem::ManuallyDrop::new(control_handle),
925                                tx_id: header.tx_id,
926                            },
927                        })
928                    }
929                    _ if header.tx_id == 0
930                        && header
931                            .dynamic_flags()
932                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
933                    {
934                        Ok(StoreRequest::_UnknownMethod {
935                            ordinal: header.ordinal,
936                            control_handle: StoreControlHandle { inner: this.inner.clone() },
937                            method_type: fidl::MethodType::OneWay,
938                        })
939                    }
940                    _ if header
941                        .dynamic_flags()
942                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
943                    {
944                        this.inner.send_framework_err(
945                            fidl::encoding::FrameworkErr::UnknownMethod,
946                            header.tx_id,
947                            header.ordinal,
948                            header.dynamic_flags(),
949                            (bytes, handles),
950                        )?;
951                        Ok(StoreRequest::_UnknownMethod {
952                            ordinal: header.ordinal,
953                            control_handle: StoreControlHandle { inner: this.inner.clone() },
954                            method_type: fidl::MethodType::TwoWay,
955                        })
956                    }
957                    _ => Err(fidl::Error::UnknownOrdinal {
958                        ordinal: header.ordinal,
959                        protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
960                    }),
961                }))
962            },
963        )
964    }
965}
966
967/// A key-value store which supports insertion and iteration.
968#[derive(Debug)]
969pub enum StoreRequest {
970    /// Writes an item to the store.
971    WriteItem { attempt: Item, responder: StoreWriteItemResponder },
972    /// Iterates over the items in the store, using lexicographic ordering over the keys.
973    ///
974    /// The [`iterator`] is [pipelined][pipelining] to the server, such that the client can
975    /// immediately send requests over the new connection.
976    ///
977    /// [pipelining]: https://fuchsia.dev/fuchsia-src/development/api/fidl?hl=en#request-pipelining
978    Iterate {
979        starting_at: Option<String>,
980        iterator: fidl::endpoints::ServerEnd<IteratorMarker>,
981        responder: StoreIterateResponder,
982    },
983    /// An interaction was received which does not match any known method.
984    #[non_exhaustive]
985    _UnknownMethod {
986        /// Ordinal of the method that was called.
987        ordinal: u64,
988        control_handle: StoreControlHandle,
989        method_type: fidl::MethodType,
990    },
991}
992
993impl StoreRequest {
994    #[allow(irrefutable_let_patterns)]
995    pub fn into_write_item(self) -> Option<(Item, StoreWriteItemResponder)> {
996        if let StoreRequest::WriteItem { attempt, responder } = self {
997            Some((attempt, responder))
998        } else {
999            None
1000        }
1001    }
1002
1003    #[allow(irrefutable_let_patterns)]
1004    pub fn into_iterate(
1005        self,
1006    ) -> Option<(Option<String>, fidl::endpoints::ServerEnd<IteratorMarker>, StoreIterateResponder)>
1007    {
1008        if let StoreRequest::Iterate { starting_at, iterator, responder } = self {
1009            Some((starting_at, iterator, responder))
1010        } else {
1011            None
1012        }
1013    }
1014
1015    /// Name of the method defined in FIDL
1016    pub fn method_name(&self) -> &'static str {
1017        match *self {
1018            StoreRequest::WriteItem { .. } => "write_item",
1019            StoreRequest::Iterate { .. } => "iterate",
1020            StoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1021                "unknown one-way method"
1022            }
1023            StoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1024                "unknown two-way method"
1025            }
1026        }
1027    }
1028}
1029
1030#[derive(Debug, Clone)]
1031pub struct StoreControlHandle {
1032    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1033}
1034
1035impl StoreControlHandle {
1036    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1037        self.inner.shutdown_with_epitaph(status.into())
1038    }
1039}
1040
1041impl fidl::endpoints::ControlHandle for StoreControlHandle {
1042    fn shutdown(&self) {
1043        self.inner.shutdown()
1044    }
1045
1046    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1047        self.inner.shutdown_with_epitaph(status)
1048    }
1049
1050    fn is_closed(&self) -> bool {
1051        self.inner.channel().is_closed()
1052    }
1053    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1054        self.inner.channel().on_closed()
1055    }
1056
1057    #[cfg(target_os = "fuchsia")]
1058    fn signal_peer(
1059        &self,
1060        clear_mask: zx::Signals,
1061        set_mask: zx::Signals,
1062    ) -> Result<(), zx_status::Status> {
1063        use fidl::Peered;
1064        self.inner.channel().signal_peer(clear_mask, set_mask)
1065    }
1066}
1067
1068impl StoreControlHandle {}
1069
1070#[must_use = "FIDL methods require a response to be sent"]
1071#[derive(Debug)]
1072pub struct StoreWriteItemResponder {
1073    control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
1074    tx_id: u32,
1075}
1076
1077/// Set the the channel to be shutdown (see [`StoreControlHandle::shutdown`])
1078/// if the responder is dropped without sending a response, so that the client
1079/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1080impl std::ops::Drop for StoreWriteItemResponder {
1081    fn drop(&mut self) {
1082        self.control_handle.shutdown();
1083        // Safety: drops once, never accessed again
1084        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1085    }
1086}
1087
1088impl fidl::endpoints::Responder for StoreWriteItemResponder {
1089    type ControlHandle = StoreControlHandle;
1090
1091    fn control_handle(&self) -> &StoreControlHandle {
1092        &self.control_handle
1093    }
1094
1095    fn drop_without_shutdown(mut self) {
1096        // Safety: drops once, never accessed again due to mem::forget
1097        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1098        // Prevent Drop from running (which would shut down the channel)
1099        std::mem::forget(self);
1100    }
1101}
1102
1103impl StoreWriteItemResponder {
1104    /// Sends a response to the FIDL transaction.
1105    ///
1106    /// Sets the channel to shutdown if an error occurs.
1107    pub fn send(self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
1108        let _result = self.send_raw(result);
1109        if _result.is_err() {
1110            self.control_handle.shutdown();
1111        }
1112        self.drop_without_shutdown();
1113        _result
1114    }
1115
1116    /// Similar to "send" but does not shutdown the channel if an error occurs.
1117    pub fn send_no_shutdown_on_err(
1118        self,
1119        mut result: Result<(), WriteError>,
1120    ) -> Result<(), fidl::Error> {
1121        let _result = self.send_raw(result);
1122        self.drop_without_shutdown();
1123        _result
1124    }
1125
1126    fn send_raw(&self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
1127        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1128            fidl::encoding::EmptyStruct,
1129            WriteError,
1130        >>(
1131            fidl::encoding::FlexibleResult::new(result),
1132            self.tx_id,
1133            0x3a714dd8953e97b2,
1134            fidl::encoding::DynamicFlags::FLEXIBLE,
1135        )
1136    }
1137}
1138
1139#[must_use = "FIDL methods require a response to be sent"]
1140#[derive(Debug)]
1141pub struct StoreIterateResponder {
1142    control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
1143    tx_id: u32,
1144}
1145
1146/// Set the the channel to be shutdown (see [`StoreControlHandle::shutdown`])
1147/// if the responder is dropped without sending a response, so that the client
1148/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1149impl std::ops::Drop for StoreIterateResponder {
1150    fn drop(&mut self) {
1151        self.control_handle.shutdown();
1152        // Safety: drops once, never accessed again
1153        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1154    }
1155}
1156
1157impl fidl::endpoints::Responder for StoreIterateResponder {
1158    type ControlHandle = StoreControlHandle;
1159
1160    fn control_handle(&self) -> &StoreControlHandle {
1161        &self.control_handle
1162    }
1163
1164    fn drop_without_shutdown(mut self) {
1165        // Safety: drops once, never accessed again due to mem::forget
1166        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1167        // Prevent Drop from running (which would shut down the channel)
1168        std::mem::forget(self);
1169    }
1170}
1171
1172impl StoreIterateResponder {
1173    /// Sends a response to the FIDL transaction.
1174    ///
1175    /// Sets the channel to shutdown if an error occurs.
1176    pub fn send(self, mut result: Result<(), IterateConnectionError>) -> Result<(), fidl::Error> {
1177        let _result = self.send_raw(result);
1178        if _result.is_err() {
1179            self.control_handle.shutdown();
1180        }
1181        self.drop_without_shutdown();
1182        _result
1183    }
1184
1185    /// Similar to "send" but does not shutdown the channel if an error occurs.
1186    pub fn send_no_shutdown_on_err(
1187        self,
1188        mut result: Result<(), IterateConnectionError>,
1189    ) -> Result<(), fidl::Error> {
1190        let _result = self.send_raw(result);
1191        self.drop_without_shutdown();
1192        _result
1193    }
1194
1195    fn send_raw(&self, mut result: Result<(), IterateConnectionError>) -> Result<(), fidl::Error> {
1196        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1197            fidl::encoding::EmptyStruct,
1198            IterateConnectionError,
1199        >>(
1200            fidl::encoding::FlexibleResult::new(result),
1201            self.tx_id,
1202            0x48ee436cb85c3f27,
1203            fidl::encoding::DynamicFlags::FLEXIBLE,
1204        )
1205    }
1206}
1207
1208mod internal {
1209    use super::*;
1210
1211    impl fidl::encoding::ResourceTypeMarker for StoreIterateRequest {
1212        type Borrowed<'a> = &'a mut Self;
1213        fn take_or_borrow<'a>(
1214            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1215        ) -> Self::Borrowed<'a> {
1216            value
1217        }
1218    }
1219
1220    unsafe impl fidl::encoding::TypeMarker for StoreIterateRequest {
1221        type Owned = Self;
1222
1223        #[inline(always)]
1224        fn inline_align(_context: fidl::encoding::Context) -> usize {
1225            8
1226        }
1227
1228        #[inline(always)]
1229        fn inline_size(_context: fidl::encoding::Context) -> usize {
1230            24
1231        }
1232    }
1233
1234    unsafe impl
1235        fidl::encoding::Encode<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1236        for &mut StoreIterateRequest
1237    {
1238        #[inline]
1239        unsafe fn encode(
1240            self,
1241            encoder: &mut fidl::encoding::Encoder<
1242                '_,
1243                fidl::encoding::DefaultFuchsiaResourceDialect,
1244            >,
1245            offset: usize,
1246            _depth: fidl::encoding::Depth,
1247        ) -> fidl::Result<()> {
1248            encoder.debug_check_bounds::<StoreIterateRequest>(offset);
1249            // Delegate to tuple encoding.
1250            fidl::encoding::Encode::<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1251                (
1252                    <fidl::encoding::Optional<fidl::encoding::BoundedString<128>> as fidl::encoding::ValueTypeMarker>::borrow(&self.starting_at),
1253                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
1254                ),
1255                encoder, offset, _depth
1256            )
1257        }
1258    }
1259    unsafe impl<
1260        T0: fidl::encoding::Encode<
1261                fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1262                fidl::encoding::DefaultFuchsiaResourceDialect,
1263            >,
1264        T1: fidl::encoding::Encode<
1265                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1266                fidl::encoding::DefaultFuchsiaResourceDialect,
1267            >,
1268    > fidl::encoding::Encode<StoreIterateRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1269        for (T0, T1)
1270    {
1271        #[inline]
1272        unsafe fn encode(
1273            self,
1274            encoder: &mut fidl::encoding::Encoder<
1275                '_,
1276                fidl::encoding::DefaultFuchsiaResourceDialect,
1277            >,
1278            offset: usize,
1279            depth: fidl::encoding::Depth,
1280        ) -> fidl::Result<()> {
1281            encoder.debug_check_bounds::<StoreIterateRequest>(offset);
1282            // Zero out padding regions. There's no need to apply masks
1283            // because the unmasked parts will be overwritten by fields.
1284            unsafe {
1285                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1286                (ptr as *mut u64).write_unaligned(0);
1287            }
1288            // Write the fields.
1289            self.0.encode(encoder, offset + 0, depth)?;
1290            self.1.encode(encoder, offset + 16, depth)?;
1291            Ok(())
1292        }
1293    }
1294
1295    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1296        for StoreIterateRequest
1297    {
1298        #[inline(always)]
1299        fn new_empty() -> Self {
1300            Self {
1301                starting_at: fidl::new_empty!(
1302                    fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1303                    fidl::encoding::DefaultFuchsiaResourceDialect
1304                ),
1305                iterator: fidl::new_empty!(
1306                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1307                    fidl::encoding::DefaultFuchsiaResourceDialect
1308                ),
1309            }
1310        }
1311
1312        #[inline]
1313        unsafe fn decode(
1314            &mut self,
1315            decoder: &mut fidl::encoding::Decoder<
1316                '_,
1317                fidl::encoding::DefaultFuchsiaResourceDialect,
1318            >,
1319            offset: usize,
1320            _depth: fidl::encoding::Depth,
1321        ) -> fidl::Result<()> {
1322            decoder.debug_check_bounds::<Self>(offset);
1323            // Verify that padding bytes are zero.
1324            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1325            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1326            let mask = 0xffffffff00000000u64;
1327            let maskedval = padval & mask;
1328            if maskedval != 0 {
1329                return Err(fidl::Error::NonZeroPadding {
1330                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1331                });
1332            }
1333            fidl::decode!(
1334                fidl::encoding::Optional<fidl::encoding::BoundedString<128>>,
1335                fidl::encoding::DefaultFuchsiaResourceDialect,
1336                &mut self.starting_at,
1337                decoder,
1338                offset + 0,
1339                _depth
1340            )?;
1341            fidl::decode!(
1342                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<IteratorMarker>>,
1343                fidl::encoding::DefaultFuchsiaResourceDialect,
1344                &mut self.iterator,
1345                decoder,
1346                offset + 16,
1347                _depth
1348            )?;
1349            Ok(())
1350        }
1351    }
1352}