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