Skip to main content

fidl_fuchsia_examples_services/
fidl_fuchsia_examples_services.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_fuchsia_examples_services__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ReadOnlyAccountMarker;
16
17impl fidl::endpoints::ProtocolMarker for ReadOnlyAccountMarker {
18    type Proxy = ReadOnlyAccountProxy;
19    type RequestStream = ReadOnlyAccountRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ReadOnlyAccountSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "(anonymous) ReadOnlyAccount";
24}
25
26pub trait ReadOnlyAccountProxyInterface: Send + Sync {
27    type GetOwnerResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
28    fn r#get_owner(&self) -> Self::GetOwnerResponseFut;
29    type GetBalanceResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
30    fn r#get_balance(&self) -> Self::GetBalanceResponseFut;
31}
32#[derive(Debug)]
33#[cfg(target_os = "fuchsia")]
34pub struct ReadOnlyAccountSynchronousProxy {
35    client: fidl::client::sync::Client,
36}
37
38#[cfg(target_os = "fuchsia")]
39impl fidl::endpoints::SynchronousProxy for ReadOnlyAccountSynchronousProxy {
40    type Proxy = ReadOnlyAccountProxy;
41    type Protocol = ReadOnlyAccountMarker;
42
43    fn from_channel(inner: fidl::Channel) -> Self {
44        Self::new(inner)
45    }
46
47    fn into_channel(self) -> fidl::Channel {
48        self.client.into_channel()
49    }
50
51    fn as_channel(&self) -> &fidl::Channel {
52        self.client.as_channel()
53    }
54}
55
56#[cfg(target_os = "fuchsia")]
57impl ReadOnlyAccountSynchronousProxy {
58    pub fn new(channel: fidl::Channel) -> Self {
59        Self { client: fidl::client::sync::Client::new(channel) }
60    }
61
62    pub fn into_channel(self) -> fidl::Channel {
63        self.client.into_channel()
64    }
65
66    /// Waits until an event arrives and returns it. It is safe for other
67    /// threads to make concurrent requests while waiting for an event.
68    pub fn wait_for_event(
69        &self,
70        deadline: zx::MonotonicInstant,
71    ) -> Result<ReadOnlyAccountEvent, fidl::Error> {
72        ReadOnlyAccountEvent::decode(self.client.wait_for_event::<ReadOnlyAccountMarker>(deadline)?)
73    }
74
75    /// Returns the bank account owner's name.
76    pub fn r#get_owner(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
77        let _response = self.client.send_query::<
78            fidl::encoding::EmptyPayload,
79            ReadOnlyAccountGetOwnerResponse,
80            ReadOnlyAccountMarker,
81        >(
82            (),
83            0x553f661d27b2273a,
84            fidl::encoding::DynamicFlags::empty(),
85            ___deadline,
86        )?;
87        Ok(_response.owner)
88    }
89
90    /// Returns the bank account's current balance in cents.
91    pub fn r#get_balance(&self, ___deadline: zx::MonotonicInstant) -> Result<i64, fidl::Error> {
92        let _response = self.client.send_query::<
93            fidl::encoding::EmptyPayload,
94            ReadOnlyAccountGetBalanceResponse,
95            ReadOnlyAccountMarker,
96        >(
97            (),
98            0x35ffed4715b1b3ac,
99            fidl::encoding::DynamicFlags::empty(),
100            ___deadline,
101        )?;
102        Ok(_response.balance)
103    }
104}
105
106#[cfg(target_os = "fuchsia")]
107impl From<ReadOnlyAccountSynchronousProxy> for zx::NullableHandle {
108    fn from(value: ReadOnlyAccountSynchronousProxy) -> Self {
109        value.into_channel().into()
110    }
111}
112
113#[cfg(target_os = "fuchsia")]
114impl From<fidl::Channel> for ReadOnlyAccountSynchronousProxy {
115    fn from(value: fidl::Channel) -> Self {
116        Self::new(value)
117    }
118}
119
120#[cfg(target_os = "fuchsia")]
121impl fidl::endpoints::FromClient for ReadOnlyAccountSynchronousProxy {
122    type Protocol = ReadOnlyAccountMarker;
123
124    fn from_client(value: fidl::endpoints::ClientEnd<ReadOnlyAccountMarker>) -> Self {
125        Self::new(value.into_channel())
126    }
127}
128
129#[derive(Debug, Clone)]
130pub struct ReadOnlyAccountProxy {
131    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
132}
133
134impl fidl::endpoints::Proxy for ReadOnlyAccountProxy {
135    type Protocol = ReadOnlyAccountMarker;
136
137    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
138        Self::new(inner)
139    }
140
141    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
142        self.client.into_channel().map_err(|client| Self { client })
143    }
144
145    fn as_channel(&self) -> &::fidl::AsyncChannel {
146        self.client.as_channel()
147    }
148}
149
150impl ReadOnlyAccountProxy {
151    /// Create a new Proxy for fuchsia.examples.services/ReadOnlyAccount.
152    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
153        let protocol_name = <ReadOnlyAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
154        Self { client: fidl::client::Client::new(channel, protocol_name) }
155    }
156
157    /// Get a Stream of events from the remote end of the protocol.
158    ///
159    /// # Panics
160    ///
161    /// Panics if the event stream was already taken.
162    pub fn take_event_stream(&self) -> ReadOnlyAccountEventStream {
163        ReadOnlyAccountEventStream { event_receiver: self.client.take_event_receiver() }
164    }
165
166    /// Returns the bank account owner's name.
167    pub fn r#get_owner(
168        &self,
169    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
170        ReadOnlyAccountProxyInterface::r#get_owner(self)
171    }
172
173    /// Returns the bank account's current balance in cents.
174    pub fn r#get_balance(
175        &self,
176    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
177        ReadOnlyAccountProxyInterface::r#get_balance(self)
178    }
179}
180
181impl ReadOnlyAccountProxyInterface for ReadOnlyAccountProxy {
182    type GetOwnerResponseFut =
183        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
184    fn r#get_owner(&self) -> Self::GetOwnerResponseFut {
185        fn _decode(
186            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
187        ) -> Result<String, fidl::Error> {
188            let _response = fidl::client::decode_transaction_body::<
189                ReadOnlyAccountGetOwnerResponse,
190                fidl::encoding::DefaultFuchsiaResourceDialect,
191                0x553f661d27b2273a,
192            >(_buf?)?;
193            Ok(_response.owner)
194        }
195        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
196            (),
197            0x553f661d27b2273a,
198            fidl::encoding::DynamicFlags::empty(),
199            _decode,
200        )
201    }
202
203    type GetBalanceResponseFut =
204        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
205    fn r#get_balance(&self) -> Self::GetBalanceResponseFut {
206        fn _decode(
207            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
208        ) -> Result<i64, fidl::Error> {
209            let _response = fidl::client::decode_transaction_body::<
210                ReadOnlyAccountGetBalanceResponse,
211                fidl::encoding::DefaultFuchsiaResourceDialect,
212                0x35ffed4715b1b3ac,
213            >(_buf?)?;
214            Ok(_response.balance)
215        }
216        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
217            (),
218            0x35ffed4715b1b3ac,
219            fidl::encoding::DynamicFlags::empty(),
220            _decode,
221        )
222    }
223}
224
225pub struct ReadOnlyAccountEventStream {
226    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
227}
228
229impl std::marker::Unpin for ReadOnlyAccountEventStream {}
230
231impl futures::stream::FusedStream for ReadOnlyAccountEventStream {
232    fn is_terminated(&self) -> bool {
233        self.event_receiver.is_terminated()
234    }
235}
236
237impl futures::Stream for ReadOnlyAccountEventStream {
238    type Item = Result<ReadOnlyAccountEvent, fidl::Error>;
239
240    fn poll_next(
241        mut self: std::pin::Pin<&mut Self>,
242        cx: &mut std::task::Context<'_>,
243    ) -> std::task::Poll<Option<Self::Item>> {
244        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
245            &mut self.event_receiver,
246            cx
247        )?) {
248            Some(buf) => std::task::Poll::Ready(Some(ReadOnlyAccountEvent::decode(buf))),
249            None => std::task::Poll::Ready(None),
250        }
251    }
252}
253
254#[derive(Debug)]
255pub enum ReadOnlyAccountEvent {}
256
257impl ReadOnlyAccountEvent {
258    /// Decodes a message buffer as a [`ReadOnlyAccountEvent`].
259    fn decode(
260        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
261    ) -> Result<ReadOnlyAccountEvent, fidl::Error> {
262        let (bytes, _handles) = buf.split_mut();
263        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
264        debug_assert_eq!(tx_header.tx_id, 0);
265        match tx_header.ordinal {
266            _ => Err(fidl::Error::UnknownOrdinal {
267                ordinal: tx_header.ordinal,
268                protocol_name:
269                    <ReadOnlyAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
270            }),
271        }
272    }
273}
274
275/// A Stream of incoming requests for fuchsia.examples.services/ReadOnlyAccount.
276pub struct ReadOnlyAccountRequestStream {
277    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
278    is_terminated: bool,
279}
280
281impl std::marker::Unpin for ReadOnlyAccountRequestStream {}
282
283impl futures::stream::FusedStream for ReadOnlyAccountRequestStream {
284    fn is_terminated(&self) -> bool {
285        self.is_terminated
286    }
287}
288
289impl fidl::endpoints::RequestStream for ReadOnlyAccountRequestStream {
290    type Protocol = ReadOnlyAccountMarker;
291    type ControlHandle = ReadOnlyAccountControlHandle;
292
293    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
294        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
295    }
296
297    fn control_handle(&self) -> Self::ControlHandle {
298        ReadOnlyAccountControlHandle { inner: self.inner.clone() }
299    }
300
301    fn into_inner(
302        self,
303    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
304    {
305        (self.inner, self.is_terminated)
306    }
307
308    fn from_inner(
309        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
310        is_terminated: bool,
311    ) -> Self {
312        Self { inner, is_terminated }
313    }
314}
315
316impl futures::Stream for ReadOnlyAccountRequestStream {
317    type Item = Result<ReadOnlyAccountRequest, fidl::Error>;
318
319    fn poll_next(
320        mut self: std::pin::Pin<&mut Self>,
321        cx: &mut std::task::Context<'_>,
322    ) -> std::task::Poll<Option<Self::Item>> {
323        let this = &mut *self;
324        if this.inner.check_shutdown(cx) {
325            this.is_terminated = true;
326            return std::task::Poll::Ready(None);
327        }
328        if this.is_terminated {
329            panic!("polled ReadOnlyAccountRequestStream after completion");
330        }
331        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
332            |bytes, handles| {
333                match this.inner.channel().read_etc(cx, bytes, handles) {
334                    std::task::Poll::Ready(Ok(())) => {}
335                    std::task::Poll::Pending => return std::task::Poll::Pending,
336                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
337                        this.is_terminated = true;
338                        return std::task::Poll::Ready(None);
339                    }
340                    std::task::Poll::Ready(Err(e)) => {
341                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
342                            e.into(),
343                        ))));
344                    }
345                }
346
347                // A message has been received from the channel
348                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
349
350                std::task::Poll::Ready(Some(match header.ordinal {
351                    0x553f661d27b2273a => {
352                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
353                        let mut req = fidl::new_empty!(
354                            fidl::encoding::EmptyPayload,
355                            fidl::encoding::DefaultFuchsiaResourceDialect
356                        );
357                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
358                        let control_handle =
359                            ReadOnlyAccountControlHandle { inner: this.inner.clone() };
360                        Ok(ReadOnlyAccountRequest::GetOwner {
361                            responder: ReadOnlyAccountGetOwnerResponder {
362                                control_handle: std::mem::ManuallyDrop::new(control_handle),
363                                tx_id: header.tx_id,
364                            },
365                        })
366                    }
367                    0x35ffed4715b1b3ac => {
368                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
369                        let mut req = fidl::new_empty!(
370                            fidl::encoding::EmptyPayload,
371                            fidl::encoding::DefaultFuchsiaResourceDialect
372                        );
373                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
374                        let control_handle =
375                            ReadOnlyAccountControlHandle { inner: this.inner.clone() };
376                        Ok(ReadOnlyAccountRequest::GetBalance {
377                            responder: ReadOnlyAccountGetBalanceResponder {
378                                control_handle: std::mem::ManuallyDrop::new(control_handle),
379                                tx_id: header.tx_id,
380                            },
381                        })
382                    }
383                    _ => Err(fidl::Error::UnknownOrdinal {
384                        ordinal: header.ordinal,
385                        protocol_name:
386                            <ReadOnlyAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
387                    }),
388                }))
389            },
390        )
391    }
392}
393
394/// Provides read-only access to a bank account.
395#[derive(Debug)]
396pub enum ReadOnlyAccountRequest {
397    /// Returns the bank account owner's name.
398    GetOwner { responder: ReadOnlyAccountGetOwnerResponder },
399    /// Returns the bank account's current balance in cents.
400    GetBalance { responder: ReadOnlyAccountGetBalanceResponder },
401}
402
403impl ReadOnlyAccountRequest {
404    #[allow(irrefutable_let_patterns)]
405    pub fn into_get_owner(self) -> Option<(ReadOnlyAccountGetOwnerResponder)> {
406        if let ReadOnlyAccountRequest::GetOwner { responder } = self {
407            Some((responder))
408        } else {
409            None
410        }
411    }
412
413    #[allow(irrefutable_let_patterns)]
414    pub fn into_get_balance(self) -> Option<(ReadOnlyAccountGetBalanceResponder)> {
415        if let ReadOnlyAccountRequest::GetBalance { responder } = self {
416            Some((responder))
417        } else {
418            None
419        }
420    }
421
422    /// Name of the method defined in FIDL
423    pub fn method_name(&self) -> &'static str {
424        match *self {
425            ReadOnlyAccountRequest::GetOwner { .. } => "get_owner",
426            ReadOnlyAccountRequest::GetBalance { .. } => "get_balance",
427        }
428    }
429}
430
431#[derive(Debug, Clone)]
432pub struct ReadOnlyAccountControlHandle {
433    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
434}
435
436impl fidl::endpoints::ControlHandle for ReadOnlyAccountControlHandle {
437    fn shutdown(&self) {
438        self.inner.shutdown()
439    }
440
441    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
442        self.inner.shutdown_with_epitaph(status)
443    }
444
445    fn is_closed(&self) -> bool {
446        self.inner.channel().is_closed()
447    }
448    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
449        self.inner.channel().on_closed()
450    }
451
452    #[cfg(target_os = "fuchsia")]
453    fn signal_peer(
454        &self,
455        clear_mask: zx::Signals,
456        set_mask: zx::Signals,
457    ) -> Result<(), zx_status::Status> {
458        use fidl::Peered;
459        self.inner.channel().signal_peer(clear_mask, set_mask)
460    }
461}
462
463impl ReadOnlyAccountControlHandle {}
464
465#[must_use = "FIDL methods require a response to be sent"]
466#[derive(Debug)]
467pub struct ReadOnlyAccountGetOwnerResponder {
468    control_handle: std::mem::ManuallyDrop<ReadOnlyAccountControlHandle>,
469    tx_id: u32,
470}
471
472/// Set the the channel to be shutdown (see [`ReadOnlyAccountControlHandle::shutdown`])
473/// if the responder is dropped without sending a response, so that the client
474/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
475impl std::ops::Drop for ReadOnlyAccountGetOwnerResponder {
476    fn drop(&mut self) {
477        self.control_handle.shutdown();
478        // Safety: drops once, never accessed again
479        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
480    }
481}
482
483impl fidl::endpoints::Responder for ReadOnlyAccountGetOwnerResponder {
484    type ControlHandle = ReadOnlyAccountControlHandle;
485
486    fn control_handle(&self) -> &ReadOnlyAccountControlHandle {
487        &self.control_handle
488    }
489
490    fn drop_without_shutdown(mut self) {
491        // Safety: drops once, never accessed again due to mem::forget
492        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
493        // Prevent Drop from running (which would shut down the channel)
494        std::mem::forget(self);
495    }
496}
497
498impl ReadOnlyAccountGetOwnerResponder {
499    /// Sends a response to the FIDL transaction.
500    ///
501    /// Sets the channel to shutdown if an error occurs.
502    pub fn send(self, mut owner: &str) -> Result<(), fidl::Error> {
503        let _result = self.send_raw(owner);
504        if _result.is_err() {
505            self.control_handle.shutdown();
506        }
507        self.drop_without_shutdown();
508        _result
509    }
510
511    /// Similar to "send" but does not shutdown the channel if an error occurs.
512    pub fn send_no_shutdown_on_err(self, mut owner: &str) -> Result<(), fidl::Error> {
513        let _result = self.send_raw(owner);
514        self.drop_without_shutdown();
515        _result
516    }
517
518    fn send_raw(&self, mut owner: &str) -> Result<(), fidl::Error> {
519        self.control_handle.inner.send::<ReadOnlyAccountGetOwnerResponse>(
520            (owner,),
521            self.tx_id,
522            0x553f661d27b2273a,
523            fidl::encoding::DynamicFlags::empty(),
524        )
525    }
526}
527
528#[must_use = "FIDL methods require a response to be sent"]
529#[derive(Debug)]
530pub struct ReadOnlyAccountGetBalanceResponder {
531    control_handle: std::mem::ManuallyDrop<ReadOnlyAccountControlHandle>,
532    tx_id: u32,
533}
534
535/// Set the the channel to be shutdown (see [`ReadOnlyAccountControlHandle::shutdown`])
536/// if the responder is dropped without sending a response, so that the client
537/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
538impl std::ops::Drop for ReadOnlyAccountGetBalanceResponder {
539    fn drop(&mut self) {
540        self.control_handle.shutdown();
541        // Safety: drops once, never accessed again
542        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
543    }
544}
545
546impl fidl::endpoints::Responder for ReadOnlyAccountGetBalanceResponder {
547    type ControlHandle = ReadOnlyAccountControlHandle;
548
549    fn control_handle(&self) -> &ReadOnlyAccountControlHandle {
550        &self.control_handle
551    }
552
553    fn drop_without_shutdown(mut self) {
554        // Safety: drops once, never accessed again due to mem::forget
555        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
556        // Prevent Drop from running (which would shut down the channel)
557        std::mem::forget(self);
558    }
559}
560
561impl ReadOnlyAccountGetBalanceResponder {
562    /// Sends a response to the FIDL transaction.
563    ///
564    /// Sets the channel to shutdown if an error occurs.
565    pub fn send(self, mut balance: i64) -> Result<(), fidl::Error> {
566        let _result = self.send_raw(balance);
567        if _result.is_err() {
568            self.control_handle.shutdown();
569        }
570        self.drop_without_shutdown();
571        _result
572    }
573
574    /// Similar to "send" but does not shutdown the channel if an error occurs.
575    pub fn send_no_shutdown_on_err(self, mut balance: i64) -> Result<(), fidl::Error> {
576        let _result = self.send_raw(balance);
577        self.drop_without_shutdown();
578        _result
579    }
580
581    fn send_raw(&self, mut balance: i64) -> Result<(), fidl::Error> {
582        self.control_handle.inner.send::<ReadOnlyAccountGetBalanceResponse>(
583            (balance,),
584            self.tx_id,
585            0x35ffed4715b1b3ac,
586            fidl::encoding::DynamicFlags::empty(),
587        )
588    }
589}
590
591#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
592pub struct ReadWriteAccountMarker;
593
594impl fidl::endpoints::ProtocolMarker for ReadWriteAccountMarker {
595    type Proxy = ReadWriteAccountProxy;
596    type RequestStream = ReadWriteAccountRequestStream;
597    #[cfg(target_os = "fuchsia")]
598    type SynchronousProxy = ReadWriteAccountSynchronousProxy;
599
600    const DEBUG_NAME: &'static str = "(anonymous) ReadWriteAccount";
601}
602
603pub trait ReadWriteAccountProxyInterface: Send + Sync {
604    type GetOwnerResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
605    fn r#get_owner(&self) -> Self::GetOwnerResponseFut;
606    type GetBalanceResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
607    fn r#get_balance(&self) -> Self::GetBalanceResponseFut;
608    type DebitResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
609    fn r#debit(&self, amount: i64) -> Self::DebitResponseFut;
610    type CreditResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
611    fn r#credit(&self, amount: i64) -> Self::CreditResponseFut;
612}
613#[derive(Debug)]
614#[cfg(target_os = "fuchsia")]
615pub struct ReadWriteAccountSynchronousProxy {
616    client: fidl::client::sync::Client,
617}
618
619#[cfg(target_os = "fuchsia")]
620impl fidl::endpoints::SynchronousProxy for ReadWriteAccountSynchronousProxy {
621    type Proxy = ReadWriteAccountProxy;
622    type Protocol = ReadWriteAccountMarker;
623
624    fn from_channel(inner: fidl::Channel) -> Self {
625        Self::new(inner)
626    }
627
628    fn into_channel(self) -> fidl::Channel {
629        self.client.into_channel()
630    }
631
632    fn as_channel(&self) -> &fidl::Channel {
633        self.client.as_channel()
634    }
635}
636
637#[cfg(target_os = "fuchsia")]
638impl ReadWriteAccountSynchronousProxy {
639    pub fn new(channel: fidl::Channel) -> Self {
640        Self { client: fidl::client::sync::Client::new(channel) }
641    }
642
643    pub fn into_channel(self) -> fidl::Channel {
644        self.client.into_channel()
645    }
646
647    /// Waits until an event arrives and returns it. It is safe for other
648    /// threads to make concurrent requests while waiting for an event.
649    pub fn wait_for_event(
650        &self,
651        deadline: zx::MonotonicInstant,
652    ) -> Result<ReadWriteAccountEvent, fidl::Error> {
653        ReadWriteAccountEvent::decode(
654            self.client.wait_for_event::<ReadWriteAccountMarker>(deadline)?,
655        )
656    }
657
658    /// Returns the bank account owner's name.
659    pub fn r#get_owner(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
660        let _response = self.client.send_query::<
661            fidl::encoding::EmptyPayload,
662            ReadOnlyAccountGetOwnerResponse,
663            ReadWriteAccountMarker,
664        >(
665            (),
666            0x553f661d27b2273a,
667            fidl::encoding::DynamicFlags::empty(),
668            ___deadline,
669        )?;
670        Ok(_response.owner)
671    }
672
673    /// Returns the bank account's current balance in cents.
674    pub fn r#get_balance(&self, ___deadline: zx::MonotonicInstant) -> Result<i64, fidl::Error> {
675        let _response = self.client.send_query::<
676            fidl::encoding::EmptyPayload,
677            ReadOnlyAccountGetBalanceResponse,
678            ReadWriteAccountMarker,
679        >(
680            (),
681            0x35ffed4715b1b3ac,
682            fidl::encoding::DynamicFlags::empty(),
683            ___deadline,
684        )?;
685        Ok(_response.balance)
686    }
687
688    /// Withdraws `amount` cents from the bank account.
689    /// Returns false if the account had insufficient funds.
690    pub fn r#debit(
691        &self,
692        mut amount: i64,
693        ___deadline: zx::MonotonicInstant,
694    ) -> Result<bool, fidl::Error> {
695        let _response = self.client.send_query::<
696            ReadWriteAccountDebitRequest,
697            ReadWriteAccountDebitResponse,
698            ReadWriteAccountMarker,
699        >(
700            (amount,),
701            0x2fa6ce7839974858,
702            fidl::encoding::DynamicFlags::empty(),
703            ___deadline,
704        )?;
705        Ok(_response.succeeded)
706    }
707
708    /// Deposits `amount` cents to the bank account.
709    pub fn r#credit(
710        &self,
711        mut amount: i64,
712        ___deadline: zx::MonotonicInstant,
713    ) -> Result<(), fidl::Error> {
714        let _response = self.client.send_query::<
715            ReadWriteAccountCreditRequest,
716            fidl::encoding::EmptyPayload,
717            ReadWriteAccountMarker,
718        >(
719            (amount,),
720            0x37c216ac70d94bd5,
721            fidl::encoding::DynamicFlags::empty(),
722            ___deadline,
723        )?;
724        Ok(_response)
725    }
726}
727
728#[cfg(target_os = "fuchsia")]
729impl From<ReadWriteAccountSynchronousProxy> for zx::NullableHandle {
730    fn from(value: ReadWriteAccountSynchronousProxy) -> Self {
731        value.into_channel().into()
732    }
733}
734
735#[cfg(target_os = "fuchsia")]
736impl From<fidl::Channel> for ReadWriteAccountSynchronousProxy {
737    fn from(value: fidl::Channel) -> Self {
738        Self::new(value)
739    }
740}
741
742#[cfg(target_os = "fuchsia")]
743impl fidl::endpoints::FromClient for ReadWriteAccountSynchronousProxy {
744    type Protocol = ReadWriteAccountMarker;
745
746    fn from_client(value: fidl::endpoints::ClientEnd<ReadWriteAccountMarker>) -> Self {
747        Self::new(value.into_channel())
748    }
749}
750
751#[derive(Debug, Clone)]
752pub struct ReadWriteAccountProxy {
753    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
754}
755
756impl fidl::endpoints::Proxy for ReadWriteAccountProxy {
757    type Protocol = ReadWriteAccountMarker;
758
759    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
760        Self::new(inner)
761    }
762
763    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
764        self.client.into_channel().map_err(|client| Self { client })
765    }
766
767    fn as_channel(&self) -> &::fidl::AsyncChannel {
768        self.client.as_channel()
769    }
770}
771
772impl ReadWriteAccountProxy {
773    /// Create a new Proxy for fuchsia.examples.services/ReadWriteAccount.
774    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
775        let protocol_name = <ReadWriteAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
776        Self { client: fidl::client::Client::new(channel, protocol_name) }
777    }
778
779    /// Get a Stream of events from the remote end of the protocol.
780    ///
781    /// # Panics
782    ///
783    /// Panics if the event stream was already taken.
784    pub fn take_event_stream(&self) -> ReadWriteAccountEventStream {
785        ReadWriteAccountEventStream { event_receiver: self.client.take_event_receiver() }
786    }
787
788    /// Returns the bank account owner's name.
789    pub fn r#get_owner(
790        &self,
791    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
792        ReadWriteAccountProxyInterface::r#get_owner(self)
793    }
794
795    /// Returns the bank account's current balance in cents.
796    pub fn r#get_balance(
797        &self,
798    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
799        ReadWriteAccountProxyInterface::r#get_balance(self)
800    }
801
802    /// Withdraws `amount` cents from the bank account.
803    /// Returns false if the account had insufficient funds.
804    pub fn r#debit(
805        &self,
806        mut amount: i64,
807    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
808        ReadWriteAccountProxyInterface::r#debit(self, amount)
809    }
810
811    /// Deposits `amount` cents to the bank account.
812    pub fn r#credit(
813        &self,
814        mut amount: i64,
815    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
816        ReadWriteAccountProxyInterface::r#credit(self, amount)
817    }
818}
819
820impl ReadWriteAccountProxyInterface for ReadWriteAccountProxy {
821    type GetOwnerResponseFut =
822        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
823    fn r#get_owner(&self) -> Self::GetOwnerResponseFut {
824        fn _decode(
825            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
826        ) -> Result<String, fidl::Error> {
827            let _response = fidl::client::decode_transaction_body::<
828                ReadOnlyAccountGetOwnerResponse,
829                fidl::encoding::DefaultFuchsiaResourceDialect,
830                0x553f661d27b2273a,
831            >(_buf?)?;
832            Ok(_response.owner)
833        }
834        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
835            (),
836            0x553f661d27b2273a,
837            fidl::encoding::DynamicFlags::empty(),
838            _decode,
839        )
840    }
841
842    type GetBalanceResponseFut =
843        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
844    fn r#get_balance(&self) -> Self::GetBalanceResponseFut {
845        fn _decode(
846            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
847        ) -> Result<i64, fidl::Error> {
848            let _response = fidl::client::decode_transaction_body::<
849                ReadOnlyAccountGetBalanceResponse,
850                fidl::encoding::DefaultFuchsiaResourceDialect,
851                0x35ffed4715b1b3ac,
852            >(_buf?)?;
853            Ok(_response.balance)
854        }
855        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
856            (),
857            0x35ffed4715b1b3ac,
858            fidl::encoding::DynamicFlags::empty(),
859            _decode,
860        )
861    }
862
863    type DebitResponseFut =
864        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
865    fn r#debit(&self, mut amount: i64) -> Self::DebitResponseFut {
866        fn _decode(
867            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
868        ) -> Result<bool, fidl::Error> {
869            let _response = fidl::client::decode_transaction_body::<
870                ReadWriteAccountDebitResponse,
871                fidl::encoding::DefaultFuchsiaResourceDialect,
872                0x2fa6ce7839974858,
873            >(_buf?)?;
874            Ok(_response.succeeded)
875        }
876        self.client.send_query_and_decode::<ReadWriteAccountDebitRequest, bool>(
877            (amount,),
878            0x2fa6ce7839974858,
879            fidl::encoding::DynamicFlags::empty(),
880            _decode,
881        )
882    }
883
884    type CreditResponseFut =
885        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
886    fn r#credit(&self, mut amount: i64) -> Self::CreditResponseFut {
887        fn _decode(
888            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
889        ) -> Result<(), fidl::Error> {
890            let _response = fidl::client::decode_transaction_body::<
891                fidl::encoding::EmptyPayload,
892                fidl::encoding::DefaultFuchsiaResourceDialect,
893                0x37c216ac70d94bd5,
894            >(_buf?)?;
895            Ok(_response)
896        }
897        self.client.send_query_and_decode::<ReadWriteAccountCreditRequest, ()>(
898            (amount,),
899            0x37c216ac70d94bd5,
900            fidl::encoding::DynamicFlags::empty(),
901            _decode,
902        )
903    }
904}
905
906pub struct ReadWriteAccountEventStream {
907    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
908}
909
910impl std::marker::Unpin for ReadWriteAccountEventStream {}
911
912impl futures::stream::FusedStream for ReadWriteAccountEventStream {
913    fn is_terminated(&self) -> bool {
914        self.event_receiver.is_terminated()
915    }
916}
917
918impl futures::Stream for ReadWriteAccountEventStream {
919    type Item = Result<ReadWriteAccountEvent, fidl::Error>;
920
921    fn poll_next(
922        mut self: std::pin::Pin<&mut Self>,
923        cx: &mut std::task::Context<'_>,
924    ) -> std::task::Poll<Option<Self::Item>> {
925        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
926            &mut self.event_receiver,
927            cx
928        )?) {
929            Some(buf) => std::task::Poll::Ready(Some(ReadWriteAccountEvent::decode(buf))),
930            None => std::task::Poll::Ready(None),
931        }
932    }
933}
934
935#[derive(Debug)]
936pub enum ReadWriteAccountEvent {}
937
938impl ReadWriteAccountEvent {
939    /// Decodes a message buffer as a [`ReadWriteAccountEvent`].
940    fn decode(
941        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
942    ) -> Result<ReadWriteAccountEvent, fidl::Error> {
943        let (bytes, _handles) = buf.split_mut();
944        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
945        debug_assert_eq!(tx_header.tx_id, 0);
946        match tx_header.ordinal {
947            _ => Err(fidl::Error::UnknownOrdinal {
948                ordinal: tx_header.ordinal,
949                protocol_name:
950                    <ReadWriteAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
951            }),
952        }
953    }
954}
955
956/// A Stream of incoming requests for fuchsia.examples.services/ReadWriteAccount.
957pub struct ReadWriteAccountRequestStream {
958    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
959    is_terminated: bool,
960}
961
962impl std::marker::Unpin for ReadWriteAccountRequestStream {}
963
964impl futures::stream::FusedStream for ReadWriteAccountRequestStream {
965    fn is_terminated(&self) -> bool {
966        self.is_terminated
967    }
968}
969
970impl fidl::endpoints::RequestStream for ReadWriteAccountRequestStream {
971    type Protocol = ReadWriteAccountMarker;
972    type ControlHandle = ReadWriteAccountControlHandle;
973
974    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
975        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
976    }
977
978    fn control_handle(&self) -> Self::ControlHandle {
979        ReadWriteAccountControlHandle { inner: self.inner.clone() }
980    }
981
982    fn into_inner(
983        self,
984    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
985    {
986        (self.inner, self.is_terminated)
987    }
988
989    fn from_inner(
990        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
991        is_terminated: bool,
992    ) -> Self {
993        Self { inner, is_terminated }
994    }
995}
996
997impl futures::Stream for ReadWriteAccountRequestStream {
998    type Item = Result<ReadWriteAccountRequest, fidl::Error>;
999
1000    fn poll_next(
1001        mut self: std::pin::Pin<&mut Self>,
1002        cx: &mut std::task::Context<'_>,
1003    ) -> std::task::Poll<Option<Self::Item>> {
1004        let this = &mut *self;
1005        if this.inner.check_shutdown(cx) {
1006            this.is_terminated = true;
1007            return std::task::Poll::Ready(None);
1008        }
1009        if this.is_terminated {
1010            panic!("polled ReadWriteAccountRequestStream after completion");
1011        }
1012        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1013            |bytes, handles| {
1014                match this.inner.channel().read_etc(cx, bytes, handles) {
1015                    std::task::Poll::Ready(Ok(())) => {}
1016                    std::task::Poll::Pending => return std::task::Poll::Pending,
1017                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1018                        this.is_terminated = true;
1019                        return std::task::Poll::Ready(None);
1020                    }
1021                    std::task::Poll::Ready(Err(e)) => {
1022                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1023                            e.into(),
1024                        ))));
1025                    }
1026                }
1027
1028                // A message has been received from the channel
1029                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1030
1031                std::task::Poll::Ready(Some(match header.ordinal {
1032                    0x553f661d27b2273a => {
1033                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1034                        let mut req = fidl::new_empty!(
1035                            fidl::encoding::EmptyPayload,
1036                            fidl::encoding::DefaultFuchsiaResourceDialect
1037                        );
1038                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1039                        let control_handle =
1040                            ReadWriteAccountControlHandle { inner: this.inner.clone() };
1041                        Ok(ReadWriteAccountRequest::GetOwner {
1042                            responder: ReadWriteAccountGetOwnerResponder {
1043                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1044                                tx_id: header.tx_id,
1045                            },
1046                        })
1047                    }
1048                    0x35ffed4715b1b3ac => {
1049                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1050                        let mut req = fidl::new_empty!(
1051                            fidl::encoding::EmptyPayload,
1052                            fidl::encoding::DefaultFuchsiaResourceDialect
1053                        );
1054                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1055                        let control_handle =
1056                            ReadWriteAccountControlHandle { inner: this.inner.clone() };
1057                        Ok(ReadWriteAccountRequest::GetBalance {
1058                            responder: ReadWriteAccountGetBalanceResponder {
1059                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1060                                tx_id: header.tx_id,
1061                            },
1062                        })
1063                    }
1064                    0x2fa6ce7839974858 => {
1065                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1066                        let mut req = fidl::new_empty!(
1067                            ReadWriteAccountDebitRequest,
1068                            fidl::encoding::DefaultFuchsiaResourceDialect
1069                        );
1070                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReadWriteAccountDebitRequest>(&header, _body_bytes, handles, &mut req)?;
1071                        let control_handle =
1072                            ReadWriteAccountControlHandle { inner: this.inner.clone() };
1073                        Ok(ReadWriteAccountRequest::Debit {
1074                            amount: req.amount,
1075
1076                            responder: ReadWriteAccountDebitResponder {
1077                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1078                                tx_id: header.tx_id,
1079                            },
1080                        })
1081                    }
1082                    0x37c216ac70d94bd5 => {
1083                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1084                        let mut req = fidl::new_empty!(
1085                            ReadWriteAccountCreditRequest,
1086                            fidl::encoding::DefaultFuchsiaResourceDialect
1087                        );
1088                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReadWriteAccountCreditRequest>(&header, _body_bytes, handles, &mut req)?;
1089                        let control_handle =
1090                            ReadWriteAccountControlHandle { inner: this.inner.clone() };
1091                        Ok(ReadWriteAccountRequest::Credit {
1092                            amount: req.amount,
1093
1094                            responder: ReadWriteAccountCreditResponder {
1095                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1096                                tx_id: header.tx_id,
1097                            },
1098                        })
1099                    }
1100                    _ => Err(fidl::Error::UnknownOrdinal {
1101                        ordinal: header.ordinal,
1102                        protocol_name:
1103                            <ReadWriteAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1104                    }),
1105                }))
1106            },
1107        )
1108    }
1109}
1110
1111/// Provides read-write access to a bank account.
1112#[derive(Debug)]
1113pub enum ReadWriteAccountRequest {
1114    /// Returns the bank account owner's name.
1115    GetOwner { responder: ReadWriteAccountGetOwnerResponder },
1116    /// Returns the bank account's current balance in cents.
1117    GetBalance { responder: ReadWriteAccountGetBalanceResponder },
1118    /// Withdraws `amount` cents from the bank account.
1119    /// Returns false if the account had insufficient funds.
1120    Debit { amount: i64, responder: ReadWriteAccountDebitResponder },
1121    /// Deposits `amount` cents to the bank account.
1122    Credit { amount: i64, responder: ReadWriteAccountCreditResponder },
1123}
1124
1125impl ReadWriteAccountRequest {
1126    #[allow(irrefutable_let_patterns)]
1127    pub fn into_get_owner(self) -> Option<(ReadWriteAccountGetOwnerResponder)> {
1128        if let ReadWriteAccountRequest::GetOwner { responder } = self {
1129            Some((responder))
1130        } else {
1131            None
1132        }
1133    }
1134
1135    #[allow(irrefutable_let_patterns)]
1136    pub fn into_get_balance(self) -> Option<(ReadWriteAccountGetBalanceResponder)> {
1137        if let ReadWriteAccountRequest::GetBalance { responder } = self {
1138            Some((responder))
1139        } else {
1140            None
1141        }
1142    }
1143
1144    #[allow(irrefutable_let_patterns)]
1145    pub fn into_debit(self) -> Option<(i64, ReadWriteAccountDebitResponder)> {
1146        if let ReadWriteAccountRequest::Debit { amount, responder } = self {
1147            Some((amount, responder))
1148        } else {
1149            None
1150        }
1151    }
1152
1153    #[allow(irrefutable_let_patterns)]
1154    pub fn into_credit(self) -> Option<(i64, ReadWriteAccountCreditResponder)> {
1155        if let ReadWriteAccountRequest::Credit { amount, responder } = self {
1156            Some((amount, responder))
1157        } else {
1158            None
1159        }
1160    }
1161
1162    /// Name of the method defined in FIDL
1163    pub fn method_name(&self) -> &'static str {
1164        match *self {
1165            ReadWriteAccountRequest::GetOwner { .. } => "get_owner",
1166            ReadWriteAccountRequest::GetBalance { .. } => "get_balance",
1167            ReadWriteAccountRequest::Debit { .. } => "debit",
1168            ReadWriteAccountRequest::Credit { .. } => "credit",
1169        }
1170    }
1171}
1172
1173#[derive(Debug, Clone)]
1174pub struct ReadWriteAccountControlHandle {
1175    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1176}
1177
1178impl fidl::endpoints::ControlHandle for ReadWriteAccountControlHandle {
1179    fn shutdown(&self) {
1180        self.inner.shutdown()
1181    }
1182
1183    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1184        self.inner.shutdown_with_epitaph(status)
1185    }
1186
1187    fn is_closed(&self) -> bool {
1188        self.inner.channel().is_closed()
1189    }
1190    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1191        self.inner.channel().on_closed()
1192    }
1193
1194    #[cfg(target_os = "fuchsia")]
1195    fn signal_peer(
1196        &self,
1197        clear_mask: zx::Signals,
1198        set_mask: zx::Signals,
1199    ) -> Result<(), zx_status::Status> {
1200        use fidl::Peered;
1201        self.inner.channel().signal_peer(clear_mask, set_mask)
1202    }
1203}
1204
1205impl ReadWriteAccountControlHandle {}
1206
1207#[must_use = "FIDL methods require a response to be sent"]
1208#[derive(Debug)]
1209pub struct ReadWriteAccountGetOwnerResponder {
1210    control_handle: std::mem::ManuallyDrop<ReadWriteAccountControlHandle>,
1211    tx_id: u32,
1212}
1213
1214/// Set the the channel to be shutdown (see [`ReadWriteAccountControlHandle::shutdown`])
1215/// if the responder is dropped without sending a response, so that the client
1216/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1217impl std::ops::Drop for ReadWriteAccountGetOwnerResponder {
1218    fn drop(&mut self) {
1219        self.control_handle.shutdown();
1220        // Safety: drops once, never accessed again
1221        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1222    }
1223}
1224
1225impl fidl::endpoints::Responder for ReadWriteAccountGetOwnerResponder {
1226    type ControlHandle = ReadWriteAccountControlHandle;
1227
1228    fn control_handle(&self) -> &ReadWriteAccountControlHandle {
1229        &self.control_handle
1230    }
1231
1232    fn drop_without_shutdown(mut self) {
1233        // Safety: drops once, never accessed again due to mem::forget
1234        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1235        // Prevent Drop from running (which would shut down the channel)
1236        std::mem::forget(self);
1237    }
1238}
1239
1240impl ReadWriteAccountGetOwnerResponder {
1241    /// Sends a response to the FIDL transaction.
1242    ///
1243    /// Sets the channel to shutdown if an error occurs.
1244    pub fn send(self, mut owner: &str) -> Result<(), fidl::Error> {
1245        let _result = self.send_raw(owner);
1246        if _result.is_err() {
1247            self.control_handle.shutdown();
1248        }
1249        self.drop_without_shutdown();
1250        _result
1251    }
1252
1253    /// Similar to "send" but does not shutdown the channel if an error occurs.
1254    pub fn send_no_shutdown_on_err(self, mut owner: &str) -> Result<(), fidl::Error> {
1255        let _result = self.send_raw(owner);
1256        self.drop_without_shutdown();
1257        _result
1258    }
1259
1260    fn send_raw(&self, mut owner: &str) -> Result<(), fidl::Error> {
1261        self.control_handle.inner.send::<ReadOnlyAccountGetOwnerResponse>(
1262            (owner,),
1263            self.tx_id,
1264            0x553f661d27b2273a,
1265            fidl::encoding::DynamicFlags::empty(),
1266        )
1267    }
1268}
1269
1270#[must_use = "FIDL methods require a response to be sent"]
1271#[derive(Debug)]
1272pub struct ReadWriteAccountGetBalanceResponder {
1273    control_handle: std::mem::ManuallyDrop<ReadWriteAccountControlHandle>,
1274    tx_id: u32,
1275}
1276
1277/// Set the the channel to be shutdown (see [`ReadWriteAccountControlHandle::shutdown`])
1278/// if the responder is dropped without sending a response, so that the client
1279/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1280impl std::ops::Drop for ReadWriteAccountGetBalanceResponder {
1281    fn drop(&mut self) {
1282        self.control_handle.shutdown();
1283        // Safety: drops once, never accessed again
1284        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1285    }
1286}
1287
1288impl fidl::endpoints::Responder for ReadWriteAccountGetBalanceResponder {
1289    type ControlHandle = ReadWriteAccountControlHandle;
1290
1291    fn control_handle(&self) -> &ReadWriteAccountControlHandle {
1292        &self.control_handle
1293    }
1294
1295    fn drop_without_shutdown(mut self) {
1296        // Safety: drops once, never accessed again due to mem::forget
1297        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1298        // Prevent Drop from running (which would shut down the channel)
1299        std::mem::forget(self);
1300    }
1301}
1302
1303impl ReadWriteAccountGetBalanceResponder {
1304    /// Sends a response to the FIDL transaction.
1305    ///
1306    /// Sets the channel to shutdown if an error occurs.
1307    pub fn send(self, mut balance: i64) -> Result<(), fidl::Error> {
1308        let _result = self.send_raw(balance);
1309        if _result.is_err() {
1310            self.control_handle.shutdown();
1311        }
1312        self.drop_without_shutdown();
1313        _result
1314    }
1315
1316    /// Similar to "send" but does not shutdown the channel if an error occurs.
1317    pub fn send_no_shutdown_on_err(self, mut balance: i64) -> Result<(), fidl::Error> {
1318        let _result = self.send_raw(balance);
1319        self.drop_without_shutdown();
1320        _result
1321    }
1322
1323    fn send_raw(&self, mut balance: i64) -> Result<(), fidl::Error> {
1324        self.control_handle.inner.send::<ReadOnlyAccountGetBalanceResponse>(
1325            (balance,),
1326            self.tx_id,
1327            0x35ffed4715b1b3ac,
1328            fidl::encoding::DynamicFlags::empty(),
1329        )
1330    }
1331}
1332
1333#[must_use = "FIDL methods require a response to be sent"]
1334#[derive(Debug)]
1335pub struct ReadWriteAccountDebitResponder {
1336    control_handle: std::mem::ManuallyDrop<ReadWriteAccountControlHandle>,
1337    tx_id: u32,
1338}
1339
1340/// Set the the channel to be shutdown (see [`ReadWriteAccountControlHandle::shutdown`])
1341/// if the responder is dropped without sending a response, so that the client
1342/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1343impl std::ops::Drop for ReadWriteAccountDebitResponder {
1344    fn drop(&mut self) {
1345        self.control_handle.shutdown();
1346        // Safety: drops once, never accessed again
1347        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1348    }
1349}
1350
1351impl fidl::endpoints::Responder for ReadWriteAccountDebitResponder {
1352    type ControlHandle = ReadWriteAccountControlHandle;
1353
1354    fn control_handle(&self) -> &ReadWriteAccountControlHandle {
1355        &self.control_handle
1356    }
1357
1358    fn drop_without_shutdown(mut self) {
1359        // Safety: drops once, never accessed again due to mem::forget
1360        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1361        // Prevent Drop from running (which would shut down the channel)
1362        std::mem::forget(self);
1363    }
1364}
1365
1366impl ReadWriteAccountDebitResponder {
1367    /// Sends a response to the FIDL transaction.
1368    ///
1369    /// Sets the channel to shutdown if an error occurs.
1370    pub fn send(self, mut succeeded: bool) -> Result<(), fidl::Error> {
1371        let _result = self.send_raw(succeeded);
1372        if _result.is_err() {
1373            self.control_handle.shutdown();
1374        }
1375        self.drop_without_shutdown();
1376        _result
1377    }
1378
1379    /// Similar to "send" but does not shutdown the channel if an error occurs.
1380    pub fn send_no_shutdown_on_err(self, mut succeeded: bool) -> Result<(), fidl::Error> {
1381        let _result = self.send_raw(succeeded);
1382        self.drop_without_shutdown();
1383        _result
1384    }
1385
1386    fn send_raw(&self, mut succeeded: bool) -> Result<(), fidl::Error> {
1387        self.control_handle.inner.send::<ReadWriteAccountDebitResponse>(
1388            (succeeded,),
1389            self.tx_id,
1390            0x2fa6ce7839974858,
1391            fidl::encoding::DynamicFlags::empty(),
1392        )
1393    }
1394}
1395
1396#[must_use = "FIDL methods require a response to be sent"]
1397#[derive(Debug)]
1398pub struct ReadWriteAccountCreditResponder {
1399    control_handle: std::mem::ManuallyDrop<ReadWriteAccountControlHandle>,
1400    tx_id: u32,
1401}
1402
1403/// Set the the channel to be shutdown (see [`ReadWriteAccountControlHandle::shutdown`])
1404/// if the responder is dropped without sending a response, so that the client
1405/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1406impl std::ops::Drop for ReadWriteAccountCreditResponder {
1407    fn drop(&mut self) {
1408        self.control_handle.shutdown();
1409        // Safety: drops once, never accessed again
1410        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1411    }
1412}
1413
1414impl fidl::endpoints::Responder for ReadWriteAccountCreditResponder {
1415    type ControlHandle = ReadWriteAccountControlHandle;
1416
1417    fn control_handle(&self) -> &ReadWriteAccountControlHandle {
1418        &self.control_handle
1419    }
1420
1421    fn drop_without_shutdown(mut self) {
1422        // Safety: drops once, never accessed again due to mem::forget
1423        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1424        // Prevent Drop from running (which would shut down the channel)
1425        std::mem::forget(self);
1426    }
1427}
1428
1429impl ReadWriteAccountCreditResponder {
1430    /// Sends a response to the FIDL transaction.
1431    ///
1432    /// Sets the channel to shutdown if an error occurs.
1433    pub fn send(self) -> Result<(), fidl::Error> {
1434        let _result = self.send_raw();
1435        if _result.is_err() {
1436            self.control_handle.shutdown();
1437        }
1438        self.drop_without_shutdown();
1439        _result
1440    }
1441
1442    /// Similar to "send" but does not shutdown the channel if an error occurs.
1443    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1444        let _result = self.send_raw();
1445        self.drop_without_shutdown();
1446        _result
1447    }
1448
1449    fn send_raw(&self) -> Result<(), fidl::Error> {
1450        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1451            (),
1452            self.tx_id,
1453            0x37c216ac70d94bd5,
1454            fidl::encoding::DynamicFlags::empty(),
1455        )
1456    }
1457}
1458
1459#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1460pub struct BankAccountMarker;
1461
1462#[cfg(target_os = "fuchsia")]
1463impl fidl::endpoints::ServiceMarker for BankAccountMarker {
1464    type Proxy = BankAccountProxy;
1465    type Request = BankAccountRequest;
1466    const SERVICE_NAME: &'static str = "fuchsia.examples.services.BankAccount";
1467}
1468
1469/// A request for one of the member protocols of BankAccount.
1470///
1471/// A Service representing a BankAccount, with two views of the data: read-only, and read-write.
1472#[cfg(target_os = "fuchsia")]
1473pub enum BankAccountRequest {
1474    ReadOnly(ReadOnlyAccountRequestStream),
1475    ReadWrite(ReadWriteAccountRequestStream),
1476}
1477
1478#[cfg(target_os = "fuchsia")]
1479impl fidl::endpoints::ServiceRequest for BankAccountRequest {
1480    type Service = BankAccountMarker;
1481
1482    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1483        match name {
1484            "read_only" => Self::ReadOnly(
1485                <ReadOnlyAccountRequestStream as fidl::endpoints::RequestStream>::from_channel(
1486                    _channel,
1487                ),
1488            ),
1489            "read_write" => Self::ReadWrite(
1490                <ReadWriteAccountRequestStream as fidl::endpoints::RequestStream>::from_channel(
1491                    _channel,
1492                ),
1493            ),
1494            _ => panic!("no such member protocol name for service BankAccount"),
1495        }
1496    }
1497
1498    fn member_names() -> &'static [&'static str] {
1499        &["read_only", "read_write"]
1500    }
1501}
1502/// A Service representing a BankAccount, with two views of the data: read-only, and read-write.
1503#[cfg(target_os = "fuchsia")]
1504pub struct BankAccountProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1505
1506#[cfg(target_os = "fuchsia")]
1507impl fidl::endpoints::ServiceProxy for BankAccountProxy {
1508    type Service = BankAccountMarker;
1509
1510    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1511        Self(opener)
1512    }
1513}
1514
1515#[cfg(target_os = "fuchsia")]
1516impl BankAccountProxy {
1517    pub fn connect_to_read_only(&self) -> Result<ReadOnlyAccountProxy, fidl::Error> {
1518        let (proxy, server_end) = fidl::endpoints::create_proxy::<ReadOnlyAccountMarker>();
1519        self.connect_channel_to_read_only(server_end)?;
1520        Ok(proxy)
1521    }
1522
1523    /// Like `connect_to_read_only`, but returns a sync proxy.
1524    /// See [`Self::connect_to_read_only`] for more details.
1525    pub fn connect_to_read_only_sync(
1526        &self,
1527    ) -> Result<ReadOnlyAccountSynchronousProxy, fidl::Error> {
1528        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ReadOnlyAccountMarker>();
1529        self.connect_channel_to_read_only(server_end)?;
1530        Ok(proxy)
1531    }
1532
1533    /// Like `connect_to_read_only`, but accepts a server end.
1534    /// See [`Self::connect_to_read_only`] for more details.
1535    pub fn connect_channel_to_read_only(
1536        &self,
1537        server_end: fidl::endpoints::ServerEnd<ReadOnlyAccountMarker>,
1538    ) -> Result<(), fidl::Error> {
1539        self.0.open_member("read_only", server_end.into_channel())
1540    }
1541    pub fn connect_to_read_write(&self) -> Result<ReadWriteAccountProxy, fidl::Error> {
1542        let (proxy, server_end) = fidl::endpoints::create_proxy::<ReadWriteAccountMarker>();
1543        self.connect_channel_to_read_write(server_end)?;
1544        Ok(proxy)
1545    }
1546
1547    /// Like `connect_to_read_write`, but returns a sync proxy.
1548    /// See [`Self::connect_to_read_write`] for more details.
1549    pub fn connect_to_read_write_sync(
1550        &self,
1551    ) -> Result<ReadWriteAccountSynchronousProxy, fidl::Error> {
1552        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ReadWriteAccountMarker>();
1553        self.connect_channel_to_read_write(server_end)?;
1554        Ok(proxy)
1555    }
1556
1557    /// Like `connect_to_read_write`, but accepts a server end.
1558    /// See [`Self::connect_to_read_write`] for more details.
1559    pub fn connect_channel_to_read_write(
1560        &self,
1561        server_end: fidl::endpoints::ServerEnd<ReadWriteAccountMarker>,
1562    ) -> Result<(), fidl::Error> {
1563        self.0.open_member("read_write", server_end.into_channel())
1564    }
1565
1566    pub fn instance_name(&self) -> &str {
1567        self.0.instance_name()
1568    }
1569}
1570
1571mod internal {
1572    use super::*;
1573}