fidl_examples_keyvaluestore_supportexports/
fidl_examples_keyvaluestore_supportexports.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_supportexports__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct StoreExportRequest {
16    /// Note that the empty VMO has more rights than the filled one being returned: it has
17    /// `zx.Rights.WRITE` (via `zx.RIGHTS_IO`) so that the VMO may be filled with exported data,
18    /// and `zx.Rights.SET_PROPERTY` (via `zx.RIGHTS_PROPERTY`) so that it may be resized to
19    /// truncate any remaining empty buffer.
20    pub empty: fidl::Vmo,
21}
22
23impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for StoreExportRequest {}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct StoreExportResponse {
27    /// The `zx.Rights.WRITE` and `zx.Rights.SET_PROPERTY` rights have been removed from the now
28    /// filled VMO. No one, not even the client that requested the export, is able to modify
29    /// this VMO going forward.
30    pub filled: fidl::Vmo,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for StoreExportResponse {}
34
35#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
36pub struct StoreMarker;
37
38impl fidl::endpoints::ProtocolMarker for StoreMarker {
39    type Proxy = StoreProxy;
40    type RequestStream = StoreRequestStream;
41    #[cfg(target_os = "fuchsia")]
42    type SynchronousProxy = StoreSynchronousProxy;
43
44    const DEBUG_NAME: &'static str = "examples.keyvaluestore.supportexports.Store";
45}
46impl fidl::endpoints::DiscoverableProtocolMarker for StoreMarker {}
47pub type StoreWriteItemResult = Result<(), WriteError>;
48pub type StoreExportResult = Result<fidl::Vmo, ExportError>;
49
50pub trait StoreProxyInterface: Send + Sync {
51    type WriteItemResponseFut: std::future::Future<Output = Result<StoreWriteItemResult, fidl::Error>>
52        + Send;
53    fn r#write_item(&self, attempt: &Item) -> Self::WriteItemResponseFut;
54    type ExportResponseFut: std::future::Future<Output = Result<StoreExportResult, fidl::Error>>
55        + Send;
56    fn r#export(&self, empty: fidl::Vmo) -> Self::ExportResponseFut;
57}
58#[derive(Debug)]
59#[cfg(target_os = "fuchsia")]
60pub struct StoreSynchronousProxy {
61    client: fidl::client::sync::Client,
62}
63
64#[cfg(target_os = "fuchsia")]
65impl fidl::endpoints::SynchronousProxy for StoreSynchronousProxy {
66    type Proxy = StoreProxy;
67    type Protocol = StoreMarker;
68
69    fn from_channel(inner: fidl::Channel) -> Self {
70        Self::new(inner)
71    }
72
73    fn into_channel(self) -> fidl::Channel {
74        self.client.into_channel()
75    }
76
77    fn as_channel(&self) -> &fidl::Channel {
78        self.client.as_channel()
79    }
80}
81
82#[cfg(target_os = "fuchsia")]
83impl StoreSynchronousProxy {
84    pub fn new(channel: fidl::Channel) -> Self {
85        let protocol_name = <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
86        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
87    }
88
89    pub fn into_channel(self) -> fidl::Channel {
90        self.client.into_channel()
91    }
92
93    /// Waits until an event arrives and returns it. It is safe for other
94    /// threads to make concurrent requests while waiting for an event.
95    pub fn wait_for_event(
96        &self,
97        deadline: zx::MonotonicInstant,
98    ) -> Result<StoreEvent, fidl::Error> {
99        StoreEvent::decode(self.client.wait_for_event(deadline)?)
100    }
101
102    /// Writes an item to the store.
103    pub fn r#write_item(
104        &self,
105        mut attempt: &Item,
106        ___deadline: zx::MonotonicInstant,
107    ) -> Result<StoreWriteItemResult, fidl::Error> {
108        let _response = self.client.send_query::<
109            StoreWriteItemRequest,
110            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
111        >(
112            (attempt,),
113            0x2dfcbbf59cc8caac,
114            fidl::encoding::DynamicFlags::FLEXIBLE,
115            ___deadline,
116        )?
117        .into_result::<StoreMarker>("write_item")?;
118        Ok(_response.map(|x| x))
119    }
120
121    /// Exports the entire store as a persistent [`Exportable`] FIDL object into a VMO provided by
122    /// the client.
123    ///
124    /// By having the client provide (and speculatively size) the VMO, we force the party requesting
125    /// the relatively heavy load of generating a backup to acknowledge and bear some of the costs.
126    ///
127    /// This method operates by having the client supply an empty VMO, which the server then
128    /// attempts to fill. Notice that the server removes the `zx.Rights.WRITE` and
129    /// `zx.Rights.SET_PROPERTY` rights from the returned VMO - not even the requesting client may
130    /// alter the backup once it has been minted by the server.
131    pub fn r#export(
132        &self,
133        mut empty: fidl::Vmo,
134        ___deadline: zx::MonotonicInstant,
135    ) -> Result<StoreExportResult, fidl::Error> {
136        let _response = self.client.send_query::<
137            StoreExportRequest,
138            fidl::encoding::FlexibleResultType<StoreExportResponse, ExportError>,
139        >(
140            (empty,),
141            0x367b616d613ff80b,
142            fidl::encoding::DynamicFlags::FLEXIBLE,
143            ___deadline,
144        )?
145        .into_result::<StoreMarker>("export")?;
146        Ok(_response.map(|x| x.filled))
147    }
148}
149
150#[cfg(target_os = "fuchsia")]
151impl From<StoreSynchronousProxy> for zx::NullableHandle {
152    fn from(value: StoreSynchronousProxy) -> Self {
153        value.into_channel().into()
154    }
155}
156
157#[cfg(target_os = "fuchsia")]
158impl From<fidl::Channel> for StoreSynchronousProxy {
159    fn from(value: fidl::Channel) -> Self {
160        Self::new(value)
161    }
162}
163
164#[cfg(target_os = "fuchsia")]
165impl fidl::endpoints::FromClient for StoreSynchronousProxy {
166    type Protocol = StoreMarker;
167
168    fn from_client(value: fidl::endpoints::ClientEnd<StoreMarker>) -> Self {
169        Self::new(value.into_channel())
170    }
171}
172
173#[derive(Debug, Clone)]
174pub struct StoreProxy {
175    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
176}
177
178impl fidl::endpoints::Proxy for StoreProxy {
179    type Protocol = StoreMarker;
180
181    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
182        Self::new(inner)
183    }
184
185    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
186        self.client.into_channel().map_err(|client| Self { client })
187    }
188
189    fn as_channel(&self) -> &::fidl::AsyncChannel {
190        self.client.as_channel()
191    }
192}
193
194impl StoreProxy {
195    /// Create a new Proxy for examples.keyvaluestore.supportexports/Store.
196    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
197        let protocol_name = <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
198        Self { client: fidl::client::Client::new(channel, protocol_name) }
199    }
200
201    /// Get a Stream of events from the remote end of the protocol.
202    ///
203    /// # Panics
204    ///
205    /// Panics if the event stream was already taken.
206    pub fn take_event_stream(&self) -> StoreEventStream {
207        StoreEventStream { event_receiver: self.client.take_event_receiver() }
208    }
209
210    /// Writes an item to the store.
211    pub fn r#write_item(
212        &self,
213        mut attempt: &Item,
214    ) -> fidl::client::QueryResponseFut<
215        StoreWriteItemResult,
216        fidl::encoding::DefaultFuchsiaResourceDialect,
217    > {
218        StoreProxyInterface::r#write_item(self, attempt)
219    }
220
221    /// Exports the entire store as a persistent [`Exportable`] FIDL object into a VMO provided by
222    /// the client.
223    ///
224    /// By having the client provide (and speculatively size) the VMO, we force the party requesting
225    /// the relatively heavy load of generating a backup to acknowledge and bear some of the costs.
226    ///
227    /// This method operates by having the client supply an empty VMO, which the server then
228    /// attempts to fill. Notice that the server removes the `zx.Rights.WRITE` and
229    /// `zx.Rights.SET_PROPERTY` rights from the returned VMO - not even the requesting client may
230    /// alter the backup once it has been minted by the server.
231    pub fn r#export(
232        &self,
233        mut empty: fidl::Vmo,
234    ) -> fidl::client::QueryResponseFut<
235        StoreExportResult,
236        fidl::encoding::DefaultFuchsiaResourceDialect,
237    > {
238        StoreProxyInterface::r#export(self, empty)
239    }
240}
241
242impl StoreProxyInterface for StoreProxy {
243    type WriteItemResponseFut = fidl::client::QueryResponseFut<
244        StoreWriteItemResult,
245        fidl::encoding::DefaultFuchsiaResourceDialect,
246    >;
247    fn r#write_item(&self, mut attempt: &Item) -> Self::WriteItemResponseFut {
248        fn _decode(
249            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
250        ) -> Result<StoreWriteItemResult, fidl::Error> {
251            let _response = fidl::client::decode_transaction_body::<
252                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
253                fidl::encoding::DefaultFuchsiaResourceDialect,
254                0x2dfcbbf59cc8caac,
255            >(_buf?)?
256            .into_result::<StoreMarker>("write_item")?;
257            Ok(_response.map(|x| x))
258        }
259        self.client.send_query_and_decode::<StoreWriteItemRequest, StoreWriteItemResult>(
260            (attempt,),
261            0x2dfcbbf59cc8caac,
262            fidl::encoding::DynamicFlags::FLEXIBLE,
263            _decode,
264        )
265    }
266
267    type ExportResponseFut = fidl::client::QueryResponseFut<
268        StoreExportResult,
269        fidl::encoding::DefaultFuchsiaResourceDialect,
270    >;
271    fn r#export(&self, mut empty: fidl::Vmo) -> Self::ExportResponseFut {
272        fn _decode(
273            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
274        ) -> Result<StoreExportResult, fidl::Error> {
275            let _response = fidl::client::decode_transaction_body::<
276                fidl::encoding::FlexibleResultType<StoreExportResponse, ExportError>,
277                fidl::encoding::DefaultFuchsiaResourceDialect,
278                0x367b616d613ff80b,
279            >(_buf?)?
280            .into_result::<StoreMarker>("export")?;
281            Ok(_response.map(|x| x.filled))
282        }
283        self.client.send_query_and_decode::<StoreExportRequest, StoreExportResult>(
284            (empty,),
285            0x367b616d613ff80b,
286            fidl::encoding::DynamicFlags::FLEXIBLE,
287            _decode,
288        )
289    }
290}
291
292pub struct StoreEventStream {
293    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
294}
295
296impl std::marker::Unpin for StoreEventStream {}
297
298impl futures::stream::FusedStream for StoreEventStream {
299    fn is_terminated(&self) -> bool {
300        self.event_receiver.is_terminated()
301    }
302}
303
304impl futures::Stream for StoreEventStream {
305    type Item = Result<StoreEvent, fidl::Error>;
306
307    fn poll_next(
308        mut self: std::pin::Pin<&mut Self>,
309        cx: &mut std::task::Context<'_>,
310    ) -> std::task::Poll<Option<Self::Item>> {
311        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
312            &mut self.event_receiver,
313            cx
314        )?) {
315            Some(buf) => std::task::Poll::Ready(Some(StoreEvent::decode(buf))),
316            None => std::task::Poll::Ready(None),
317        }
318    }
319}
320
321#[derive(Debug)]
322pub enum StoreEvent {
323    #[non_exhaustive]
324    _UnknownEvent {
325        /// Ordinal of the event that was sent.
326        ordinal: u64,
327    },
328}
329
330impl StoreEvent {
331    /// Decodes a message buffer as a [`StoreEvent`].
332    fn decode(
333        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
334    ) -> Result<StoreEvent, fidl::Error> {
335        let (bytes, _handles) = buf.split_mut();
336        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
337        debug_assert_eq!(tx_header.tx_id, 0);
338        match tx_header.ordinal {
339            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
340                Ok(StoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
341            }
342            _ => Err(fidl::Error::UnknownOrdinal {
343                ordinal: tx_header.ordinal,
344                protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
345            }),
346        }
347    }
348}
349
350/// A Stream of incoming requests for examples.keyvaluestore.supportexports/Store.
351pub struct StoreRequestStream {
352    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
353    is_terminated: bool,
354}
355
356impl std::marker::Unpin for StoreRequestStream {}
357
358impl futures::stream::FusedStream for StoreRequestStream {
359    fn is_terminated(&self) -> bool {
360        self.is_terminated
361    }
362}
363
364impl fidl::endpoints::RequestStream for StoreRequestStream {
365    type Protocol = StoreMarker;
366    type ControlHandle = StoreControlHandle;
367
368    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
369        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
370    }
371
372    fn control_handle(&self) -> Self::ControlHandle {
373        StoreControlHandle { inner: self.inner.clone() }
374    }
375
376    fn into_inner(
377        self,
378    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
379    {
380        (self.inner, self.is_terminated)
381    }
382
383    fn from_inner(
384        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
385        is_terminated: bool,
386    ) -> Self {
387        Self { inner, is_terminated }
388    }
389}
390
391impl futures::Stream for StoreRequestStream {
392    type Item = Result<StoreRequest, fidl::Error>;
393
394    fn poll_next(
395        mut self: std::pin::Pin<&mut Self>,
396        cx: &mut std::task::Context<'_>,
397    ) -> std::task::Poll<Option<Self::Item>> {
398        let this = &mut *self;
399        if this.inner.check_shutdown(cx) {
400            this.is_terminated = true;
401            return std::task::Poll::Ready(None);
402        }
403        if this.is_terminated {
404            panic!("polled StoreRequestStream after completion");
405        }
406        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
407            |bytes, handles| {
408                match this.inner.channel().read_etc(cx, bytes, handles) {
409                    std::task::Poll::Ready(Ok(())) => {}
410                    std::task::Poll::Pending => return std::task::Poll::Pending,
411                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
412                        this.is_terminated = true;
413                        return std::task::Poll::Ready(None);
414                    }
415                    std::task::Poll::Ready(Err(e)) => {
416                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
417                            e.into(),
418                        ))));
419                    }
420                }
421
422                // A message has been received from the channel
423                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
424
425                std::task::Poll::Ready(Some(match header.ordinal {
426                    0x2dfcbbf59cc8caac => {
427                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
428                        let mut req = fidl::new_empty!(
429                            StoreWriteItemRequest,
430                            fidl::encoding::DefaultFuchsiaResourceDialect
431                        );
432                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreWriteItemRequest>(&header, _body_bytes, handles, &mut req)?;
433                        let control_handle = StoreControlHandle { inner: this.inner.clone() };
434                        Ok(StoreRequest::WriteItem {
435                            attempt: req.attempt,
436
437                            responder: StoreWriteItemResponder {
438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
439                                tx_id: header.tx_id,
440                            },
441                        })
442                    }
443                    0x367b616d613ff80b => {
444                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
445                        let mut req = fidl::new_empty!(
446                            StoreExportRequest,
447                            fidl::encoding::DefaultFuchsiaResourceDialect
448                        );
449                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreExportRequest>(&header, _body_bytes, handles, &mut req)?;
450                        let control_handle = StoreControlHandle { inner: this.inner.clone() };
451                        Ok(StoreRequest::Export {
452                            empty: req.empty,
453
454                            responder: StoreExportResponder {
455                                control_handle: std::mem::ManuallyDrop::new(control_handle),
456                                tx_id: header.tx_id,
457                            },
458                        })
459                    }
460                    _ if header.tx_id == 0
461                        && header
462                            .dynamic_flags()
463                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
464                    {
465                        Ok(StoreRequest::_UnknownMethod {
466                            ordinal: header.ordinal,
467                            control_handle: StoreControlHandle { inner: this.inner.clone() },
468                            method_type: fidl::MethodType::OneWay,
469                        })
470                    }
471                    _ if header
472                        .dynamic_flags()
473                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
474                    {
475                        this.inner.send_framework_err(
476                            fidl::encoding::FrameworkErr::UnknownMethod,
477                            header.tx_id,
478                            header.ordinal,
479                            header.dynamic_flags(),
480                            (bytes, handles),
481                        )?;
482                        Ok(StoreRequest::_UnknownMethod {
483                            ordinal: header.ordinal,
484                            control_handle: StoreControlHandle { inner: this.inner.clone() },
485                            method_type: fidl::MethodType::TwoWay,
486                        })
487                    }
488                    _ => Err(fidl::Error::UnknownOrdinal {
489                        ordinal: header.ordinal,
490                        protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
491                    }),
492                }))
493            },
494        )
495    }
496}
497
498/// A very basic key-value store - so basic, in fact, that one may only write to it, never read!
499#[derive(Debug)]
500pub enum StoreRequest {
501    /// Writes an item to the store.
502    WriteItem { attempt: Item, responder: StoreWriteItemResponder },
503    /// Exports the entire store as a persistent [`Exportable`] FIDL object into a VMO provided by
504    /// the client.
505    ///
506    /// By having the client provide (and speculatively size) the VMO, we force the party requesting
507    /// the relatively heavy load of generating a backup to acknowledge and bear some of the costs.
508    ///
509    /// This method operates by having the client supply an empty VMO, which the server then
510    /// attempts to fill. Notice that the server removes the `zx.Rights.WRITE` and
511    /// `zx.Rights.SET_PROPERTY` rights from the returned VMO - not even the requesting client may
512    /// alter the backup once it has been minted by the server.
513    Export { empty: fidl::Vmo, responder: StoreExportResponder },
514    /// An interaction was received which does not match any known method.
515    #[non_exhaustive]
516    _UnknownMethod {
517        /// Ordinal of the method that was called.
518        ordinal: u64,
519        control_handle: StoreControlHandle,
520        method_type: fidl::MethodType,
521    },
522}
523
524impl StoreRequest {
525    #[allow(irrefutable_let_patterns)]
526    pub fn into_write_item(self) -> Option<(Item, StoreWriteItemResponder)> {
527        if let StoreRequest::WriteItem { attempt, responder } = self {
528            Some((attempt, responder))
529        } else {
530            None
531        }
532    }
533
534    #[allow(irrefutable_let_patterns)]
535    pub fn into_export(self) -> Option<(fidl::Vmo, StoreExportResponder)> {
536        if let StoreRequest::Export { empty, responder } = self {
537            Some((empty, responder))
538        } else {
539            None
540        }
541    }
542
543    /// Name of the method defined in FIDL
544    pub fn method_name(&self) -> &'static str {
545        match *self {
546            StoreRequest::WriteItem { .. } => "write_item",
547            StoreRequest::Export { .. } => "export",
548            StoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
549                "unknown one-way method"
550            }
551            StoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
552                "unknown two-way method"
553            }
554        }
555    }
556}
557
558#[derive(Debug, Clone)]
559pub struct StoreControlHandle {
560    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
561}
562
563impl fidl::endpoints::ControlHandle for StoreControlHandle {
564    fn shutdown(&self) {
565        self.inner.shutdown()
566    }
567
568    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
569        self.inner.shutdown_with_epitaph(status)
570    }
571
572    fn is_closed(&self) -> bool {
573        self.inner.channel().is_closed()
574    }
575    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
576        self.inner.channel().on_closed()
577    }
578
579    #[cfg(target_os = "fuchsia")]
580    fn signal_peer(
581        &self,
582        clear_mask: zx::Signals,
583        set_mask: zx::Signals,
584    ) -> Result<(), zx_status::Status> {
585        use fidl::Peered;
586        self.inner.channel().signal_peer(clear_mask, set_mask)
587    }
588}
589
590impl StoreControlHandle {}
591
592#[must_use = "FIDL methods require a response to be sent"]
593#[derive(Debug)]
594pub struct StoreWriteItemResponder {
595    control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
596    tx_id: u32,
597}
598
599/// Set the the channel to be shutdown (see [`StoreControlHandle::shutdown`])
600/// if the responder is dropped without sending a response, so that the client
601/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
602impl std::ops::Drop for StoreWriteItemResponder {
603    fn drop(&mut self) {
604        self.control_handle.shutdown();
605        // Safety: drops once, never accessed again
606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
607    }
608}
609
610impl fidl::endpoints::Responder for StoreWriteItemResponder {
611    type ControlHandle = StoreControlHandle;
612
613    fn control_handle(&self) -> &StoreControlHandle {
614        &self.control_handle
615    }
616
617    fn drop_without_shutdown(mut self) {
618        // Safety: drops once, never accessed again due to mem::forget
619        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
620        // Prevent Drop from running (which would shut down the channel)
621        std::mem::forget(self);
622    }
623}
624
625impl StoreWriteItemResponder {
626    /// Sends a response to the FIDL transaction.
627    ///
628    /// Sets the channel to shutdown if an error occurs.
629    pub fn send(self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
630        let _result = self.send_raw(result);
631        if _result.is_err() {
632            self.control_handle.shutdown();
633        }
634        self.drop_without_shutdown();
635        _result
636    }
637
638    /// Similar to "send" but does not shutdown the channel if an error occurs.
639    pub fn send_no_shutdown_on_err(
640        self,
641        mut result: Result<(), WriteError>,
642    ) -> Result<(), fidl::Error> {
643        let _result = self.send_raw(result);
644        self.drop_without_shutdown();
645        _result
646    }
647
648    fn send_raw(&self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
649        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
650            fidl::encoding::EmptyStruct,
651            WriteError,
652        >>(
653            fidl::encoding::FlexibleResult::new(result),
654            self.tx_id,
655            0x2dfcbbf59cc8caac,
656            fidl::encoding::DynamicFlags::FLEXIBLE,
657        )
658    }
659}
660
661#[must_use = "FIDL methods require a response to be sent"]
662#[derive(Debug)]
663pub struct StoreExportResponder {
664    control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
665    tx_id: u32,
666}
667
668/// Set the the channel to be shutdown (see [`StoreControlHandle::shutdown`])
669/// if the responder is dropped without sending a response, so that the client
670/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
671impl std::ops::Drop for StoreExportResponder {
672    fn drop(&mut self) {
673        self.control_handle.shutdown();
674        // Safety: drops once, never accessed again
675        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
676    }
677}
678
679impl fidl::endpoints::Responder for StoreExportResponder {
680    type ControlHandle = StoreControlHandle;
681
682    fn control_handle(&self) -> &StoreControlHandle {
683        &self.control_handle
684    }
685
686    fn drop_without_shutdown(mut self) {
687        // Safety: drops once, never accessed again due to mem::forget
688        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
689        // Prevent Drop from running (which would shut down the channel)
690        std::mem::forget(self);
691    }
692}
693
694impl StoreExportResponder {
695    /// Sends a response to the FIDL transaction.
696    ///
697    /// Sets the channel to shutdown if an error occurs.
698    pub fn send(self, mut result: Result<fidl::Vmo, ExportError>) -> Result<(), fidl::Error> {
699        let _result = self.send_raw(result);
700        if _result.is_err() {
701            self.control_handle.shutdown();
702        }
703        self.drop_without_shutdown();
704        _result
705    }
706
707    /// Similar to "send" but does not shutdown the channel if an error occurs.
708    pub fn send_no_shutdown_on_err(
709        self,
710        mut result: Result<fidl::Vmo, ExportError>,
711    ) -> Result<(), fidl::Error> {
712        let _result = self.send_raw(result);
713        self.drop_without_shutdown();
714        _result
715    }
716
717    fn send_raw(&self, mut result: Result<fidl::Vmo, ExportError>) -> Result<(), fidl::Error> {
718        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
719            StoreExportResponse,
720            ExportError,
721        >>(
722            fidl::encoding::FlexibleResult::new(result.map(|filled| (filled,))),
723            self.tx_id,
724            0x367b616d613ff80b,
725            fidl::encoding::DynamicFlags::FLEXIBLE,
726        )
727    }
728}
729
730mod internal {
731    use super::*;
732
733    impl fidl::encoding::ResourceTypeMarker for StoreExportRequest {
734        type Borrowed<'a> = &'a mut Self;
735        fn take_or_borrow<'a>(
736            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
737        ) -> Self::Borrowed<'a> {
738            value
739        }
740    }
741
742    unsafe impl fidl::encoding::TypeMarker for StoreExportRequest {
743        type Owned = Self;
744
745        #[inline(always)]
746        fn inline_align(_context: fidl::encoding::Context) -> usize {
747            4
748        }
749
750        #[inline(always)]
751        fn inline_size(_context: fidl::encoding::Context) -> usize {
752            4
753        }
754    }
755
756    unsafe impl
757        fidl::encoding::Encode<StoreExportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
758        for &mut StoreExportRequest
759    {
760        #[inline]
761        unsafe fn encode(
762            self,
763            encoder: &mut fidl::encoding::Encoder<
764                '_,
765                fidl::encoding::DefaultFuchsiaResourceDialect,
766            >,
767            offset: usize,
768            _depth: fidl::encoding::Depth,
769        ) -> fidl::Result<()> {
770            encoder.debug_check_bounds::<StoreExportRequest>(offset);
771            // Delegate to tuple encoding.
772            fidl::encoding::Encode::<
773                StoreExportRequest,
774                fidl::encoding::DefaultFuchsiaResourceDialect,
775            >::encode(
776                (<fidl::encoding::HandleType<
777                    fidl::Vmo,
778                    { fidl::ObjectType::VMO.into_raw() },
779                    49359,
780                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
781                    &mut self.empty
782                ),),
783                encoder,
784                offset,
785                _depth,
786            )
787        }
788    }
789    unsafe impl<
790        T0: fidl::encoding::Encode<
791                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49359>,
792                fidl::encoding::DefaultFuchsiaResourceDialect,
793            >,
794    > fidl::encoding::Encode<StoreExportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
795        for (T0,)
796    {
797        #[inline]
798        unsafe fn encode(
799            self,
800            encoder: &mut fidl::encoding::Encoder<
801                '_,
802                fidl::encoding::DefaultFuchsiaResourceDialect,
803            >,
804            offset: usize,
805            depth: fidl::encoding::Depth,
806        ) -> fidl::Result<()> {
807            encoder.debug_check_bounds::<StoreExportRequest>(offset);
808            // Zero out padding regions. There's no need to apply masks
809            // because the unmasked parts will be overwritten by fields.
810            // Write the fields.
811            self.0.encode(encoder, offset + 0, depth)?;
812            Ok(())
813        }
814    }
815
816    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
817        for StoreExportRequest
818    {
819        #[inline(always)]
820        fn new_empty() -> Self {
821            Self {
822                empty: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49359>, fidl::encoding::DefaultFuchsiaResourceDialect),
823            }
824        }
825
826        #[inline]
827        unsafe fn decode(
828            &mut self,
829            decoder: &mut fidl::encoding::Decoder<
830                '_,
831                fidl::encoding::DefaultFuchsiaResourceDialect,
832            >,
833            offset: usize,
834            _depth: fidl::encoding::Depth,
835        ) -> fidl::Result<()> {
836            decoder.debug_check_bounds::<Self>(offset);
837            // Verify that padding bytes are zero.
838            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49359>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.empty, decoder, offset + 0, _depth)?;
839            Ok(())
840        }
841    }
842
843    impl fidl::encoding::ResourceTypeMarker for StoreExportResponse {
844        type Borrowed<'a> = &'a mut Self;
845        fn take_or_borrow<'a>(
846            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
847        ) -> Self::Borrowed<'a> {
848            value
849        }
850    }
851
852    unsafe impl fidl::encoding::TypeMarker for StoreExportResponse {
853        type Owned = Self;
854
855        #[inline(always)]
856        fn inline_align(_context: fidl::encoding::Context) -> usize {
857            4
858        }
859
860        #[inline(always)]
861        fn inline_size(_context: fidl::encoding::Context) -> usize {
862            4
863        }
864    }
865
866    unsafe impl
867        fidl::encoding::Encode<StoreExportResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
868        for &mut StoreExportResponse
869    {
870        #[inline]
871        unsafe fn encode(
872            self,
873            encoder: &mut fidl::encoding::Encoder<
874                '_,
875                fidl::encoding::DefaultFuchsiaResourceDialect,
876            >,
877            offset: usize,
878            _depth: fidl::encoding::Depth,
879        ) -> fidl::Result<()> {
880            encoder.debug_check_bounds::<StoreExportResponse>(offset);
881            // Delegate to tuple encoding.
882            fidl::encoding::Encode::<
883                StoreExportResponse,
884                fidl::encoding::DefaultFuchsiaResourceDialect,
885            >::encode(
886                (<fidl::encoding::HandleType<
887                    fidl::Vmo,
888                    { fidl::ObjectType::VMO.into_raw() },
889                    49223,
890                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
891                    &mut self.filled
892                ),),
893                encoder,
894                offset,
895                _depth,
896            )
897        }
898    }
899    unsafe impl<
900        T0: fidl::encoding::Encode<
901                fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49223>,
902                fidl::encoding::DefaultFuchsiaResourceDialect,
903            >,
904    > fidl::encoding::Encode<StoreExportResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
905        for (T0,)
906    {
907        #[inline]
908        unsafe fn encode(
909            self,
910            encoder: &mut fidl::encoding::Encoder<
911                '_,
912                fidl::encoding::DefaultFuchsiaResourceDialect,
913            >,
914            offset: usize,
915            depth: fidl::encoding::Depth,
916        ) -> fidl::Result<()> {
917            encoder.debug_check_bounds::<StoreExportResponse>(offset);
918            // Zero out padding regions. There's no need to apply masks
919            // because the unmasked parts will be overwritten by fields.
920            // Write the fields.
921            self.0.encode(encoder, offset + 0, depth)?;
922            Ok(())
923        }
924    }
925
926    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
927        for StoreExportResponse
928    {
929        #[inline(always)]
930        fn new_empty() -> Self {
931            Self {
932                filled: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49223>, fidl::encoding::DefaultFuchsiaResourceDialect),
933            }
934        }
935
936        #[inline]
937        unsafe fn decode(
938            &mut self,
939            decoder: &mut fidl::encoding::Decoder<
940                '_,
941                fidl::encoding::DefaultFuchsiaResourceDialect,
942            >,
943            offset: usize,
944            _depth: fidl::encoding::Depth,
945        ) -> fidl::Result<()> {
946            decoder.debug_check_bounds::<Self>(offset);
947            // Verify that padding bytes are zero.
948            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49223>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.filled, decoder, offset + 0, _depth)?;
949            Ok(())
950        }
951    }
952}