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