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::NullableHandle {
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
520    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
521        self.inner.shutdown_with_epitaph(status)
522    }
523
524    fn is_closed(&self) -> bool {
525        self.inner.channel().is_closed()
526    }
527    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
528        self.inner.channel().on_closed()
529    }
530
531    #[cfg(target_os = "fuchsia")]
532    fn signal_peer(
533        &self,
534        clear_mask: zx::Signals,
535        set_mask: zx::Signals,
536    ) -> Result<(), zx_status::Status> {
537        use fidl::Peered;
538        self.inner.channel().signal_peer(clear_mask, set_mask)
539    }
540}
541
542impl StoreControlHandle {}
543
544#[must_use = "FIDL methods require a response to be sent"]
545#[derive(Debug)]
546pub struct StoreWriteItemResponder {
547    control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
548    tx_id: u32,
549}
550
551/// Set the the channel to be shutdown (see [`StoreControlHandle::shutdown`])
552/// if the responder is dropped without sending a response, so that the client
553/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
554impl std::ops::Drop for StoreWriteItemResponder {
555    fn drop(&mut self) {
556        self.control_handle.shutdown();
557        // Safety: drops once, never accessed again
558        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
559    }
560}
561
562impl fidl::endpoints::Responder for StoreWriteItemResponder {
563    type ControlHandle = StoreControlHandle;
564
565    fn control_handle(&self) -> &StoreControlHandle {
566        &self.control_handle
567    }
568
569    fn drop_without_shutdown(mut self) {
570        // Safety: drops once, never accessed again due to mem::forget
571        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
572        // Prevent Drop from running (which would shut down the channel)
573        std::mem::forget(self);
574    }
575}
576
577impl StoreWriteItemResponder {
578    /// Sends a response to the FIDL transaction.
579    ///
580    /// Sets the channel to shutdown if an error occurs.
581    pub fn send(self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
582        let _result = self.send_raw(result);
583        if _result.is_err() {
584            self.control_handle.shutdown();
585        }
586        self.drop_without_shutdown();
587        _result
588    }
589
590    /// Similar to "send" but does not shutdown the channel if an error occurs.
591    pub fn send_no_shutdown_on_err(
592        self,
593        mut result: Result<(), WriteError>,
594    ) -> Result<(), fidl::Error> {
595        let _result = self.send_raw(result);
596        self.drop_without_shutdown();
597        _result
598    }
599
600    fn send_raw(&self, mut result: Result<(), WriteError>) -> Result<(), fidl::Error> {
601        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
602            fidl::encoding::EmptyStruct,
603            WriteError,
604        >>(
605            fidl::encoding::FlexibleResult::new(result),
606            self.tx_id,
607            0x4dd6bb122b2022e9,
608            fidl::encoding::DynamicFlags::FLEXIBLE,
609        )
610    }
611}
612
613#[must_use = "FIDL methods require a response to be sent"]
614#[derive(Debug)]
615pub struct StoreReadItemResponder {
616    control_handle: std::mem::ManuallyDrop<StoreControlHandle>,
617    tx_id: u32,
618}
619
620/// Set the the channel to be shutdown (see [`StoreControlHandle::shutdown`])
621/// if the responder is dropped without sending a response, so that the client
622/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
623impl std::ops::Drop for StoreReadItemResponder {
624    fn drop(&mut self) {
625        self.control_handle.shutdown();
626        // Safety: drops once, never accessed again
627        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
628    }
629}
630
631impl fidl::endpoints::Responder for StoreReadItemResponder {
632    type ControlHandle = StoreControlHandle;
633
634    fn control_handle(&self) -> &StoreControlHandle {
635        &self.control_handle
636    }
637
638    fn drop_without_shutdown(mut self) {
639        // Safety: drops once, never accessed again due to mem::forget
640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
641        // Prevent Drop from running (which would shut down the channel)
642        std::mem::forget(self);
643    }
644}
645
646impl StoreReadItemResponder {
647    /// Sends a response to the FIDL transaction.
648    ///
649    /// Sets the channel to shutdown if an error occurs.
650    pub fn send(self, mut result: Result<(&str, &[u8]), ReadError>) -> Result<(), fidl::Error> {
651        let _result = self.send_raw(result);
652        if _result.is_err() {
653            self.control_handle.shutdown();
654        }
655        self.drop_without_shutdown();
656        _result
657    }
658
659    /// Similar to "send" but does not shutdown the channel if an error occurs.
660    pub fn send_no_shutdown_on_err(
661        self,
662        mut result: Result<(&str, &[u8]), ReadError>,
663    ) -> Result<(), fidl::Error> {
664        let _result = self.send_raw(result);
665        self.drop_without_shutdown();
666        _result
667    }
668
669    fn send_raw(&self, mut result: Result<(&str, &[u8]), ReadError>) -> Result<(), fidl::Error> {
670        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<Item, ReadError>>(
671            fidl::encoding::FlexibleResult::new(result),
672            self.tx_id,
673            0x67a246d566d1139c,
674            fidl::encoding::DynamicFlags::FLEXIBLE,
675        )
676    }
677}
678
679mod internal {
680    use super::*;
681}