Skip to main content

fidl_examples_keyvaluestore_addreaditem/
fidl_examples_keyvaluestore_addreaditem.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_addreaditem__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct StoreMarker;
16
17impl fidl::endpoints::ProtocolMarker for StoreMarker {
18    type Proxy = StoreProxy;
19    type RequestStream = StoreRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = StoreSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "examples.keyvaluestore.addreaditem.Store";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for StoreMarker {}
26pub type StoreWriteItemResult = Result<(), WriteError>;
27pub type StoreReadItemResult = Result<(String, Vec<u8>), ReadError>;
28
29pub trait StoreProxyInterface: Send + Sync {
30    type WriteItemResponseFut: std::future::Future<Output = Result<StoreWriteItemResult, fidl::Error>>
31        + Send;
32    fn r#write_item(&self, attempt: &Item) -> Self::WriteItemResponseFut;
33    type ReadItemResponseFut: std::future::Future<Output = Result<StoreReadItemResult, fidl::Error>>
34        + Send;
35    fn r#read_item(&self, key: &str) -> Self::ReadItemResponseFut;
36}
37#[derive(Debug)]
38#[cfg(target_os = "fuchsia")]
39pub struct StoreSynchronousProxy {
40    client: fidl::client::sync::Client,
41}
42
43#[cfg(target_os = "fuchsia")]
44impl fidl::endpoints::SynchronousProxy for StoreSynchronousProxy {
45    type Proxy = StoreProxy;
46    type Protocol = StoreMarker;
47
48    fn from_channel(inner: fidl::Channel) -> Self {
49        Self::new(inner)
50    }
51
52    fn into_channel(self) -> fidl::Channel {
53        self.client.into_channel()
54    }
55
56    fn as_channel(&self) -> &fidl::Channel {
57        self.client.as_channel()
58    }
59}
60
61#[cfg(target_os = "fuchsia")]
62impl StoreSynchronousProxy {
63    pub fn new(channel: fidl::Channel) -> Self {
64        Self { client: fidl::client::sync::Client::new(channel) }
65    }
66
67    pub fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    /// Waits until an event arrives and returns it. It is safe for other
72    /// threads to make concurrent requests while waiting for an event.
73    pub fn wait_for_event(
74        &self,
75        deadline: zx::MonotonicInstant,
76    ) -> Result<StoreEvent, fidl::Error> {
77        StoreEvent::decode(self.client.wait_for_event::<StoreMarker>(deadline)?)
78    }
79
80    /// Writes an item to the store.
81    pub fn r#write_item(
82        &self,
83        mut attempt: &Item,
84        ___deadline: zx::MonotonicInstant,
85    ) -> Result<StoreWriteItemResult, fidl::Error> {
86        let _response = self.client.send_query::<
87            StoreWriteItemRequest,
88            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
89            StoreMarker,
90        >(
91            (attempt,),
92            0x4dd6bb122b2022e9,
93            fidl::encoding::DynamicFlags::FLEXIBLE,
94            ___deadline,
95        )?
96        .into_result::<StoreMarker>("write_item")?;
97        Ok(_response.map(|x| x))
98    }
99
100    /// Reads an item from the store.
101    pub fn r#read_item(
102        &self,
103        mut key: &str,
104        ___deadline: zx::MonotonicInstant,
105    ) -> Result<StoreReadItemResult, fidl::Error> {
106        let _response = self.client.send_query::<
107            StoreReadItemRequest,
108            fidl::encoding::FlexibleResultType<Item, ReadError>,
109            StoreMarker,
110        >(
111            (key,),
112            0x67a246d566d1139c,
113            fidl::encoding::DynamicFlags::FLEXIBLE,
114            ___deadline,
115        )?
116        .into_result::<StoreMarker>("read_item")?;
117        Ok(_response.map(|x| (x.key, x.value)))
118    }
119}
120
121#[cfg(target_os = "fuchsia")]
122impl From<StoreSynchronousProxy> for zx::NullableHandle {
123    fn from(value: StoreSynchronousProxy) -> Self {
124        value.into_channel().into()
125    }
126}
127
128#[cfg(target_os = "fuchsia")]
129impl From<fidl::Channel> for StoreSynchronousProxy {
130    fn from(value: fidl::Channel) -> Self {
131        Self::new(value)
132    }
133}
134
135#[cfg(target_os = "fuchsia")]
136impl fidl::endpoints::FromClient for StoreSynchronousProxy {
137    type Protocol = StoreMarker;
138
139    fn from_client(value: fidl::endpoints::ClientEnd<StoreMarker>) -> Self {
140        Self::new(value.into_channel())
141    }
142}
143
144#[derive(Debug, Clone)]
145pub struct StoreProxy {
146    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
147}
148
149impl fidl::endpoints::Proxy for StoreProxy {
150    type Protocol = StoreMarker;
151
152    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
153        Self::new(inner)
154    }
155
156    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
157        self.client.into_channel().map_err(|client| Self { client })
158    }
159
160    fn as_channel(&self) -> &::fidl::AsyncChannel {
161        self.client.as_channel()
162    }
163}
164
165impl StoreProxy {
166    /// Create a new Proxy for examples.keyvaluestore.addreaditem/Store.
167    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
168        let protocol_name = <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
169        Self { client: fidl::client::Client::new(channel, protocol_name) }
170    }
171
172    /// Get a Stream of events from the remote end of the protocol.
173    ///
174    /// # Panics
175    ///
176    /// Panics if the event stream was already taken.
177    pub fn take_event_stream(&self) -> StoreEventStream {
178        StoreEventStream { event_receiver: self.client.take_event_receiver() }
179    }
180
181    /// Writes an item to the store.
182    pub fn r#write_item(
183        &self,
184        mut attempt: &Item,
185    ) -> fidl::client::QueryResponseFut<
186        StoreWriteItemResult,
187        fidl::encoding::DefaultFuchsiaResourceDialect,
188    > {
189        StoreProxyInterface::r#write_item(self, attempt)
190    }
191
192    /// Reads an item from the store.
193    pub fn r#read_item(
194        &self,
195        mut key: &str,
196    ) -> fidl::client::QueryResponseFut<
197        StoreReadItemResult,
198        fidl::encoding::DefaultFuchsiaResourceDialect,
199    > {
200        StoreProxyInterface::r#read_item(self, key)
201    }
202}
203
204impl StoreProxyInterface for StoreProxy {
205    type WriteItemResponseFut = fidl::client::QueryResponseFut<
206        StoreWriteItemResult,
207        fidl::encoding::DefaultFuchsiaResourceDialect,
208    >;
209    fn r#write_item(&self, mut attempt: &Item) -> Self::WriteItemResponseFut {
210        fn _decode(
211            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
212        ) -> Result<StoreWriteItemResult, fidl::Error> {
213            let _response = fidl::client::decode_transaction_body::<
214                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WriteError>,
215                fidl::encoding::DefaultFuchsiaResourceDialect,
216                0x4dd6bb122b2022e9,
217            >(_buf?)?
218            .into_result::<StoreMarker>("write_item")?;
219            Ok(_response.map(|x| x))
220        }
221        self.client.send_query_and_decode::<StoreWriteItemRequest, StoreWriteItemResult>(
222            (attempt,),
223            0x4dd6bb122b2022e9,
224            fidl::encoding::DynamicFlags::FLEXIBLE,
225            _decode,
226        )
227    }
228
229    type ReadItemResponseFut = fidl::client::QueryResponseFut<
230        StoreReadItemResult,
231        fidl::encoding::DefaultFuchsiaResourceDialect,
232    >;
233    fn r#read_item(&self, mut key: &str) -> Self::ReadItemResponseFut {
234        fn _decode(
235            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
236        ) -> Result<StoreReadItemResult, fidl::Error> {
237            let _response = fidl::client::decode_transaction_body::<
238                fidl::encoding::FlexibleResultType<Item, ReadError>,
239                fidl::encoding::DefaultFuchsiaResourceDialect,
240                0x67a246d566d1139c,
241            >(_buf?)?
242            .into_result::<StoreMarker>("read_item")?;
243            Ok(_response.map(|x| (x.key, x.value)))
244        }
245        self.client.send_query_and_decode::<StoreReadItemRequest, StoreReadItemResult>(
246            (key,),
247            0x67a246d566d1139c,
248            fidl::encoding::DynamicFlags::FLEXIBLE,
249            _decode,
250        )
251    }
252}
253
254pub struct StoreEventStream {
255    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
256}
257
258impl std::marker::Unpin for StoreEventStream {}
259
260impl futures::stream::FusedStream for StoreEventStream {
261    fn is_terminated(&self) -> bool {
262        self.event_receiver.is_terminated()
263    }
264}
265
266impl futures::Stream for StoreEventStream {
267    type Item = Result<StoreEvent, fidl::Error>;
268
269    fn poll_next(
270        mut self: std::pin::Pin<&mut Self>,
271        cx: &mut std::task::Context<'_>,
272    ) -> std::task::Poll<Option<Self::Item>> {
273        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
274            &mut self.event_receiver,
275            cx
276        )?) {
277            Some(buf) => std::task::Poll::Ready(Some(StoreEvent::decode(buf))),
278            None => std::task::Poll::Ready(None),
279        }
280    }
281}
282
283#[derive(Debug)]
284pub enum StoreEvent {
285    #[non_exhaustive]
286    _UnknownEvent {
287        /// Ordinal of the event that was sent.
288        ordinal: u64,
289    },
290}
291
292impl StoreEvent {
293    /// Decodes a message buffer as a [`StoreEvent`].
294    fn decode(
295        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
296    ) -> Result<StoreEvent, fidl::Error> {
297        let (bytes, _handles) = buf.split_mut();
298        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
299        debug_assert_eq!(tx_header.tx_id, 0);
300        match tx_header.ordinal {
301            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
302                Ok(StoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
303            }
304            _ => Err(fidl::Error::UnknownOrdinal {
305                ordinal: tx_header.ordinal,
306                protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
307            }),
308        }
309    }
310}
311
312/// A Stream of incoming requests for examples.keyvaluestore.addreaditem/Store.
313pub struct StoreRequestStream {
314    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
315    is_terminated: bool,
316}
317
318impl std::marker::Unpin for StoreRequestStream {}
319
320impl futures::stream::FusedStream for StoreRequestStream {
321    fn is_terminated(&self) -> bool {
322        self.is_terminated
323    }
324}
325
326impl fidl::endpoints::RequestStream for StoreRequestStream {
327    type Protocol = StoreMarker;
328    type ControlHandle = StoreControlHandle;
329
330    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
331        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
332    }
333
334    fn control_handle(&self) -> Self::ControlHandle {
335        StoreControlHandle { inner: self.inner.clone() }
336    }
337
338    fn into_inner(
339        self,
340    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
341    {
342        (self.inner, self.is_terminated)
343    }
344
345    fn from_inner(
346        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
347        is_terminated: bool,
348    ) -> Self {
349        Self { inner, is_terminated }
350    }
351}
352
353impl futures::Stream for StoreRequestStream {
354    type Item = Result<StoreRequest, fidl::Error>;
355
356    fn poll_next(
357        mut self: std::pin::Pin<&mut Self>,
358        cx: &mut std::task::Context<'_>,
359    ) -> std::task::Poll<Option<Self::Item>> {
360        let this = &mut *self;
361        if this.inner.check_shutdown(cx) {
362            this.is_terminated = true;
363            return std::task::Poll::Ready(None);
364        }
365        if this.is_terminated {
366            panic!("polled StoreRequestStream after completion");
367        }
368        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
369            |bytes, handles| {
370                match this.inner.channel().read_etc(cx, bytes, handles) {
371                    std::task::Poll::Ready(Ok(())) => {}
372                    std::task::Poll::Pending => return std::task::Poll::Pending,
373                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
374                        this.is_terminated = true;
375                        return std::task::Poll::Ready(None);
376                    }
377                    std::task::Poll::Ready(Err(e)) => {
378                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
379                            e.into(),
380                        ))));
381                    }
382                }
383
384                // A message has been received from the channel
385                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
386
387                std::task::Poll::Ready(Some(match header.ordinal {
388                    0x4dd6bb122b2022e9 => {
389                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
390                        let mut req = fidl::new_empty!(
391                            StoreWriteItemRequest,
392                            fidl::encoding::DefaultFuchsiaResourceDialect
393                        );
394                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreWriteItemRequest>(&header, _body_bytes, handles, &mut req)?;
395                        let control_handle = StoreControlHandle { inner: this.inner.clone() };
396                        Ok(StoreRequest::WriteItem {
397                            attempt: req.attempt,
398
399                            responder: StoreWriteItemResponder {
400                                control_handle: std::mem::ManuallyDrop::new(control_handle),
401                                tx_id: header.tx_id,
402                            },
403                        })
404                    }
405                    0x67a246d566d1139c => {
406                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
407                        let mut req = fidl::new_empty!(
408                            StoreReadItemRequest,
409                            fidl::encoding::DefaultFuchsiaResourceDialect
410                        );
411                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StoreReadItemRequest>(&header, _body_bytes, handles, &mut req)?;
412                        let control_handle = StoreControlHandle { inner: this.inner.clone() };
413                        Ok(StoreRequest::ReadItem {
414                            key: req.key,
415
416                            responder: StoreReadItemResponder {
417                                control_handle: std::mem::ManuallyDrop::new(control_handle),
418                                tx_id: header.tx_id,
419                            },
420                        })
421                    }
422                    _ if header.tx_id == 0
423                        && header
424                            .dynamic_flags()
425                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
426                    {
427                        Ok(StoreRequest::_UnknownMethod {
428                            ordinal: header.ordinal,
429                            control_handle: StoreControlHandle { inner: this.inner.clone() },
430                            method_type: fidl::MethodType::OneWay,
431                        })
432                    }
433                    _ if header
434                        .dynamic_flags()
435                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
436                    {
437                        this.inner.send_framework_err(
438                            fidl::encoding::FrameworkErr::UnknownMethod,
439                            header.tx_id,
440                            header.ordinal,
441                            header.dynamic_flags(),
442                            (bytes, handles),
443                        )?;
444                        Ok(StoreRequest::_UnknownMethod {
445                            ordinal: header.ordinal,
446                            control_handle: StoreControlHandle { inner: this.inner.clone() },
447                            method_type: fidl::MethodType::TwoWay,
448                        })
449                    }
450                    _ => Err(fidl::Error::UnknownOrdinal {
451                        ordinal: header.ordinal,
452                        protocol_name: <StoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
453                    }),
454                }))
455            },
456        )
457    }
458}
459
460/// A very basic key-value store - so basic, in fact, that one may only write to it, never read!
461#[derive(Debug)]
462pub enum StoreRequest {
463    /// Writes an item to the store.
464    WriteItem { attempt: Item, responder: StoreWriteItemResponder },
465    /// Reads an item from the store.
466    ReadItem { key: String, responder: StoreReadItemResponder },
467    /// An interaction was received which does not match any known method.
468    #[non_exhaustive]
469    _UnknownMethod {
470        /// Ordinal of the method that was called.
471        ordinal: u64,
472        control_handle: StoreControlHandle,
473        method_type: fidl::MethodType,
474    },
475}
476
477impl StoreRequest {
478    #[allow(irrefutable_let_patterns)]
479    pub fn into_write_item(self) -> Option<(Item, StoreWriteItemResponder)> {
480        if let StoreRequest::WriteItem { attempt, responder } = self {
481            Some((attempt, responder))
482        } else {
483            None
484        }
485    }
486
487    #[allow(irrefutable_let_patterns)]
488    pub fn into_read_item(self) -> Option<(String, StoreReadItemResponder)> {
489        if let StoreRequest::ReadItem { key, responder } = self {
490            Some((key, responder))
491        } else {
492            None
493        }
494    }
495
496    /// Name of the method defined in FIDL
497    pub fn method_name(&self) -> &'static str {
498        match *self {
499            StoreRequest::WriteItem { .. } => "write_item",
500            StoreRequest::ReadItem { .. } => "read_item",
501            StoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
502                "unknown one-way method"
503            }
504            StoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
505                "unknown two-way method"
506            }
507        }
508    }
509}
510
511#[derive(Debug, Clone)]
512pub struct StoreControlHandle {
513    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
514}
515
516impl fidl::endpoints::ControlHandle for StoreControlHandle {
517    fn shutdown(&self) {
518        self.inner.shutdown()
519    }
520
521    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
522        self.inner.shutdown_with_epitaph(status)
523    }
524
525    fn is_closed(&self) -> bool {
526        self.inner.channel().is_closed()
527    }
528    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
529        self.inner.channel().on_closed()
530    }
531
532    #[cfg(target_os = "fuchsia")]
533    fn signal_peer(
534        &self,
535        clear_mask: zx::Signals,
536        set_mask: zx::Signals,
537    ) -> Result<(), zx_status::Status> {
538        use fidl::Peered;
539        self.inner.channel().signal_peer(clear_mask, set_mask)
540    }
541}
542
543impl StoreControlHandle {}
544
545#[must_use = "FIDL methods require a response to be sent"]
546#[derive(Debug)]
547pub struct StoreWriteItemResponder {
548    control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
549    tx_id: u32,
550}
551
552/// Set the the channel to be shutdown (see [`StoreControlHandle::shutdown`])
553/// if the responder is dropped without sending a response, so that the client
554/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
555impl std::ops::Drop for StoreWriteItemResponder {
556    fn drop(&mut self) {
557        self.control_handle.shutdown();
558        // Safety: drops once, never accessed again
559        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
560    }
561}
562
563impl fidl::endpoints::Responder for StoreWriteItemResponder {
564    type ControlHandle = StoreControlHandle;
565
566    fn control_handle(&self) -> &StoreControlHandle {
567        &self.control_handle
568    }
569
570    fn drop_without_shutdown(mut self) {
571        // Safety: drops once, never accessed again due to mem::forget
572        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
573        // Prevent Drop from running (which would shut down the channel)
574        std::mem::forget(self);
575    }
576}
577
578impl StoreWriteItemResponder {
579    /// Sends a response to the FIDL transaction.
580    ///
581    /// Sets the channel to shutdown if an error occurs.
582    pub fn send(self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
583        let _result = self.send_raw(result);
584        if _result.is_err() {
585            self.control_handle.shutdown();
586        }
587        self.drop_without_shutdown();
588        _result
589    }
590
591    /// Similar to "send" but does not shutdown the channel if an error occurs.
592    pub fn send_no_shutdown_on_err(
593        self,
594        mut result: Result<(), WriteError>,
595    ) -> Result<(), fidl::Error> {
596        let _result = self.send_raw(result);
597        self.drop_without_shutdown();
598        _result
599    }
600
601    fn send_raw(&self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
602        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
603            fidl::encoding::EmptyStruct,
604            WriteError,
605        >>(
606            fidl::encoding::FlexibleResult::new(result),
607            self.tx_id,
608            0x4dd6bb122b2022e9,
609            fidl::encoding::DynamicFlags::FLEXIBLE,
610        )
611    }
612}
613
614#[must_use = "FIDL methods require a response to be sent"]
615#[derive(Debug)]
616pub struct StoreReadItemResponder {
617    control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
618    tx_id: u32,
619}
620
621/// Set the the channel to be shutdown (see [`StoreControlHandle::shutdown`])
622/// if the responder is dropped without sending a response, so that the client
623/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
624impl std::ops::Drop for StoreReadItemResponder {
625    fn drop(&mut self) {
626        self.control_handle.shutdown();
627        // Safety: drops once, never accessed again
628        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
629    }
630}
631
632impl fidl::endpoints::Responder for StoreReadItemResponder {
633    type ControlHandle = StoreControlHandle;
634
635    fn control_handle(&self) -> &StoreControlHandle {
636        &self.control_handle
637    }
638
639    fn drop_without_shutdown(mut self) {
640        // Safety: drops once, never accessed again due to mem::forget
641        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
642        // Prevent Drop from running (which would shut down the channel)
643        std::mem::forget(self);
644    }
645}
646
647impl StoreReadItemResponder {
648    /// Sends a response to the FIDL transaction.
649    ///
650    /// Sets the channel to shutdown if an error occurs.
651    pub fn send(self, mut result: Result<(&str, &[u8]), ReadError>) -> Result<(), fidl::Error> {
652        let _result = self.send_raw(result);
653        if _result.is_err() {
654            self.control_handle.shutdown();
655        }
656        self.drop_without_shutdown();
657        _result
658    }
659
660    /// Similar to "send" but does not shutdown the channel if an error occurs.
661    pub fn send_no_shutdown_on_err(
662        self,
663        mut result: Result<(&str, &[u8]), ReadError>,
664    ) -> Result<(), fidl::Error> {
665        let _result = self.send_raw(result);
666        self.drop_without_shutdown();
667        _result
668    }
669
670    fn send_raw(&self, mut result: Result<(&str, &[u8]), ReadError>) -> Result<(), fidl::Error> {
671        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<Item, ReadError>>(
672            fidl::encoding::FlexibleResult::new(result),
673            self.tx_id,
674            0x67a246d566d1139c,
675            fidl::encoding::DynamicFlags::FLEXIBLE,
676        )
677    }
678}
679
680mod internal {
681    use super::*;
682}