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