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 ReadOnlyAccountControlHandle {
437    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
438        self.inner.shutdown_with_epitaph(status.into())
439    }
440}
441
442impl fidl::endpoints::ControlHandle for ReadOnlyAccountControlHandle {
443    fn shutdown(&self) {
444        self.inner.shutdown()
445    }
446
447    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
448        self.inner.shutdown_with_epitaph(status)
449    }
450
451    fn is_closed(&self) -> bool {
452        self.inner.channel().is_closed()
453    }
454    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
455        self.inner.channel().on_closed()
456    }
457
458    #[cfg(target_os = "fuchsia")]
459    fn signal_peer(
460        &self,
461        clear_mask: zx::Signals,
462        set_mask: zx::Signals,
463    ) -> Result<(), zx_status::Status> {
464        use fidl::Peered;
465        self.inner.channel().signal_peer(clear_mask, set_mask)
466    }
467}
468
469impl ReadOnlyAccountControlHandle {}
470
471#[must_use = "FIDL methods require a response to be sent"]
472#[derive(Debug)]
473pub struct ReadOnlyAccountGetOwnerResponder {
474    control_handle: std::mem::ManuallyDrop<ReadOnlyAccountControlHandle>,
475    tx_id: u32,
476}
477
478/// Set the the channel to be shutdown (see [`ReadOnlyAccountControlHandle::shutdown`])
479/// if the responder is dropped without sending a response, so that the client
480/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
481impl std::ops::Drop for ReadOnlyAccountGetOwnerResponder {
482    fn drop(&mut self) {
483        self.control_handle.shutdown();
484        // Safety: drops once, never accessed again
485        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
486    }
487}
488
489impl fidl::endpoints::Responder for ReadOnlyAccountGetOwnerResponder {
490    type ControlHandle = ReadOnlyAccountControlHandle;
491
492    fn control_handle(&self) -> &ReadOnlyAccountControlHandle {
493        &self.control_handle
494    }
495
496    fn drop_without_shutdown(mut self) {
497        // Safety: drops once, never accessed again due to mem::forget
498        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
499        // Prevent Drop from running (which would shut down the channel)
500        std::mem::forget(self);
501    }
502}
503
504impl ReadOnlyAccountGetOwnerResponder {
505    /// Sends a response to the FIDL transaction.
506    ///
507    /// Sets the channel to shutdown if an error occurs.
508    pub fn send(self, mut owner: &str) -> Result<(), fidl::Error> {
509        let _result = self.send_raw(owner);
510        if _result.is_err() {
511            self.control_handle.shutdown();
512        }
513        self.drop_without_shutdown();
514        _result
515    }
516
517    /// Similar to "send" but does not shutdown the channel if an error occurs.
518    pub fn send_no_shutdown_on_err(self, mut owner: &str) -> Result<(), fidl::Error> {
519        let _result = self.send_raw(owner);
520        self.drop_without_shutdown();
521        _result
522    }
523
524    fn send_raw(&self, mut owner: &str) -> Result<(), fidl::Error> {
525        self.control_handle.inner.send::<ReadOnlyAccountGetOwnerResponse>(
526            (owner,),
527            self.tx_id,
528            0x553f661d27b2273a,
529            fidl::encoding::DynamicFlags::empty(),
530        )
531    }
532}
533
534#[must_use = "FIDL methods require a response to be sent"]
535#[derive(Debug)]
536pub struct ReadOnlyAccountGetBalanceResponder {
537    control_handle: std::mem::ManuallyDrop<ReadOnlyAccountControlHandle>,
538    tx_id: u32,
539}
540
541/// Set the the channel to be shutdown (see [`ReadOnlyAccountControlHandle::shutdown`])
542/// if the responder is dropped without sending a response, so that the client
543/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
544impl std::ops::Drop for ReadOnlyAccountGetBalanceResponder {
545    fn drop(&mut self) {
546        self.control_handle.shutdown();
547        // Safety: drops once, never accessed again
548        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
549    }
550}
551
552impl fidl::endpoints::Responder for ReadOnlyAccountGetBalanceResponder {
553    type ControlHandle = ReadOnlyAccountControlHandle;
554
555    fn control_handle(&self) -> &ReadOnlyAccountControlHandle {
556        &self.control_handle
557    }
558
559    fn drop_without_shutdown(mut self) {
560        // Safety: drops once, never accessed again due to mem::forget
561        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
562        // Prevent Drop from running (which would shut down the channel)
563        std::mem::forget(self);
564    }
565}
566
567impl ReadOnlyAccountGetBalanceResponder {
568    /// Sends a response to the FIDL transaction.
569    ///
570    /// Sets the channel to shutdown if an error occurs.
571    pub fn send(self, mut balance: i64) -> Result<(), fidl::Error> {
572        let _result = self.send_raw(balance);
573        if _result.is_err() {
574            self.control_handle.shutdown();
575        }
576        self.drop_without_shutdown();
577        _result
578    }
579
580    /// Similar to "send" but does not shutdown the channel if an error occurs.
581    pub fn send_no_shutdown_on_err(self, mut balance: i64) -> Result<(), fidl::Error> {
582        let _result = self.send_raw(balance);
583        self.drop_without_shutdown();
584        _result
585    }
586
587    fn send_raw(&self, mut balance: i64) -> Result<(), fidl::Error> {
588        self.control_handle.inner.send::<ReadOnlyAccountGetBalanceResponse>(
589            (balance,),
590            self.tx_id,
591            0x35ffed4715b1b3ac,
592            fidl::encoding::DynamicFlags::empty(),
593        )
594    }
595}
596
597#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
598pub struct ReadWriteAccountMarker;
599
600impl fidl::endpoints::ProtocolMarker for ReadWriteAccountMarker {
601    type Proxy = ReadWriteAccountProxy;
602    type RequestStream = ReadWriteAccountRequestStream;
603    #[cfg(target_os = "fuchsia")]
604    type SynchronousProxy = ReadWriteAccountSynchronousProxy;
605
606    const DEBUG_NAME: &'static str = "(anonymous) ReadWriteAccount";
607}
608
609pub trait ReadWriteAccountProxyInterface: Send + Sync {
610    type GetOwnerResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
611    fn r#get_owner(&self) -> Self::GetOwnerResponseFut;
612    type GetBalanceResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
613    fn r#get_balance(&self) -> Self::GetBalanceResponseFut;
614    type DebitResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
615    fn r#debit(&self, amount: i64) -> Self::DebitResponseFut;
616    type CreditResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
617    fn r#credit(&self, amount: i64) -> Self::CreditResponseFut;
618}
619#[derive(Debug)]
620#[cfg(target_os = "fuchsia")]
621pub struct ReadWriteAccountSynchronousProxy {
622    client: fidl::client::sync::Client,
623}
624
625#[cfg(target_os = "fuchsia")]
626impl fidl::endpoints::SynchronousProxy for ReadWriteAccountSynchronousProxy {
627    type Proxy = ReadWriteAccountProxy;
628    type Protocol = ReadWriteAccountMarker;
629
630    fn from_channel(inner: fidl::Channel) -> Self {
631        Self::new(inner)
632    }
633
634    fn into_channel(self) -> fidl::Channel {
635        self.client.into_channel()
636    }
637
638    fn as_channel(&self) -> &fidl::Channel {
639        self.client.as_channel()
640    }
641}
642
643#[cfg(target_os = "fuchsia")]
644impl ReadWriteAccountSynchronousProxy {
645    pub fn new(channel: fidl::Channel) -> Self {
646        Self { client: fidl::client::sync::Client::new(channel) }
647    }
648
649    pub fn into_channel(self) -> fidl::Channel {
650        self.client.into_channel()
651    }
652
653    /// Waits until an event arrives and returns it. It is safe for other
654    /// threads to make concurrent requests while waiting for an event.
655    pub fn wait_for_event(
656        &self,
657        deadline: zx::MonotonicInstant,
658    ) -> Result<ReadWriteAccountEvent, fidl::Error> {
659        ReadWriteAccountEvent::decode(
660            self.client.wait_for_event::<ReadWriteAccountMarker>(deadline)?,
661        )
662    }
663
664    /// Returns the bank account owner's name.
665    pub fn r#get_owner(&self, ___deadline: zx::MonotonicInstant) -> Result<String, fidl::Error> {
666        let _response = self.client.send_query::<
667            fidl::encoding::EmptyPayload,
668            ReadOnlyAccountGetOwnerResponse,
669            ReadWriteAccountMarker,
670        >(
671            (),
672            0x553f661d27b2273a,
673            fidl::encoding::DynamicFlags::empty(),
674            ___deadline,
675        )?;
676        Ok(_response.owner)
677    }
678
679    /// Returns the bank account's current balance in cents.
680    pub fn r#get_balance(&self, ___deadline: zx::MonotonicInstant) -> Result<i64, fidl::Error> {
681        let _response = self.client.send_query::<
682            fidl::encoding::EmptyPayload,
683            ReadOnlyAccountGetBalanceResponse,
684            ReadWriteAccountMarker,
685        >(
686            (),
687            0x35ffed4715b1b3ac,
688            fidl::encoding::DynamicFlags::empty(),
689            ___deadline,
690        )?;
691        Ok(_response.balance)
692    }
693
694    /// Withdraws `amount` cents from the bank account.
695    /// Returns false if the account had insufficient funds.
696    pub fn r#debit(
697        &self,
698        mut amount: i64,
699        ___deadline: zx::MonotonicInstant,
700    ) -> Result<bool, fidl::Error> {
701        let _response = self.client.send_query::<
702            ReadWriteAccountDebitRequest,
703            ReadWriteAccountDebitResponse,
704            ReadWriteAccountMarker,
705        >(
706            (amount,),
707            0x2fa6ce7839974858,
708            fidl::encoding::DynamicFlags::empty(),
709            ___deadline,
710        )?;
711        Ok(_response.succeeded)
712    }
713
714    /// Deposits `amount` cents to the bank account.
715    pub fn r#credit(
716        &self,
717        mut amount: i64,
718        ___deadline: zx::MonotonicInstant,
719    ) -> Result<(), fidl::Error> {
720        let _response = self.client.send_query::<
721            ReadWriteAccountCreditRequest,
722            fidl::encoding::EmptyPayload,
723            ReadWriteAccountMarker,
724        >(
725            (amount,),
726            0x37c216ac70d94bd5,
727            fidl::encoding::DynamicFlags::empty(),
728            ___deadline,
729        )?;
730        Ok(_response)
731    }
732}
733
734#[cfg(target_os = "fuchsia")]
735impl From<ReadWriteAccountSynchronousProxy> for zx::NullableHandle {
736    fn from(value: ReadWriteAccountSynchronousProxy) -> Self {
737        value.into_channel().into()
738    }
739}
740
741#[cfg(target_os = "fuchsia")]
742impl From<fidl::Channel> for ReadWriteAccountSynchronousProxy {
743    fn from(value: fidl::Channel) -> Self {
744        Self::new(value)
745    }
746}
747
748#[cfg(target_os = "fuchsia")]
749impl fidl::endpoints::FromClient for ReadWriteAccountSynchronousProxy {
750    type Protocol = ReadWriteAccountMarker;
751
752    fn from_client(value: fidl::endpoints::ClientEnd<ReadWriteAccountMarker>) -> Self {
753        Self::new(value.into_channel())
754    }
755}
756
757#[derive(Debug, Clone)]
758pub struct ReadWriteAccountProxy {
759    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
760}
761
762impl fidl::endpoints::Proxy for ReadWriteAccountProxy {
763    type Protocol = ReadWriteAccountMarker;
764
765    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
766        Self::new(inner)
767    }
768
769    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
770        self.client.into_channel().map_err(|client| Self { client })
771    }
772
773    fn as_channel(&self) -> &::fidl::AsyncChannel {
774        self.client.as_channel()
775    }
776}
777
778impl ReadWriteAccountProxy {
779    /// Create a new Proxy for fuchsia.examples.services/ReadWriteAccount.
780    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
781        let protocol_name = <ReadWriteAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
782        Self { client: fidl::client::Client::new(channel, protocol_name) }
783    }
784
785    /// Get a Stream of events from the remote end of the protocol.
786    ///
787    /// # Panics
788    ///
789    /// Panics if the event stream was already taken.
790    pub fn take_event_stream(&self) -> ReadWriteAccountEventStream {
791        ReadWriteAccountEventStream { event_receiver: self.client.take_event_receiver() }
792    }
793
794    /// Returns the bank account owner's name.
795    pub fn r#get_owner(
796        &self,
797    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
798        ReadWriteAccountProxyInterface::r#get_owner(self)
799    }
800
801    /// Returns the bank account's current balance in cents.
802    pub fn r#get_balance(
803        &self,
804    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
805        ReadWriteAccountProxyInterface::r#get_balance(self)
806    }
807
808    /// Withdraws `amount` cents from the bank account.
809    /// Returns false if the account had insufficient funds.
810    pub fn r#debit(
811        &self,
812        mut amount: i64,
813    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
814        ReadWriteAccountProxyInterface::r#debit(self, amount)
815    }
816
817    /// Deposits `amount` cents to the bank account.
818    pub fn r#credit(
819        &self,
820        mut amount: i64,
821    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
822        ReadWriteAccountProxyInterface::r#credit(self, amount)
823    }
824}
825
826impl ReadWriteAccountProxyInterface for ReadWriteAccountProxy {
827    type GetOwnerResponseFut =
828        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
829    fn r#get_owner(&self) -> Self::GetOwnerResponseFut {
830        fn _decode(
831            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
832        ) -> Result<String, fidl::Error> {
833            let _response = fidl::client::decode_transaction_body::<
834                ReadOnlyAccountGetOwnerResponse,
835                fidl::encoding::DefaultFuchsiaResourceDialect,
836                0x553f661d27b2273a,
837            >(_buf?)?;
838            Ok(_response.owner)
839        }
840        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, String>(
841            (),
842            0x553f661d27b2273a,
843            fidl::encoding::DynamicFlags::empty(),
844            _decode,
845        )
846    }
847
848    type GetBalanceResponseFut =
849        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
850    fn r#get_balance(&self) -> Self::GetBalanceResponseFut {
851        fn _decode(
852            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
853        ) -> Result<i64, fidl::Error> {
854            let _response = fidl::client::decode_transaction_body::<
855                ReadOnlyAccountGetBalanceResponse,
856                fidl::encoding::DefaultFuchsiaResourceDialect,
857                0x35ffed4715b1b3ac,
858            >(_buf?)?;
859            Ok(_response.balance)
860        }
861        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
862            (),
863            0x35ffed4715b1b3ac,
864            fidl::encoding::DynamicFlags::empty(),
865            _decode,
866        )
867    }
868
869    type DebitResponseFut =
870        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
871    fn r#debit(&self, mut amount: i64) -> Self::DebitResponseFut {
872        fn _decode(
873            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
874        ) -> Result<bool, fidl::Error> {
875            let _response = fidl::client::decode_transaction_body::<
876                ReadWriteAccountDebitResponse,
877                fidl::encoding::DefaultFuchsiaResourceDialect,
878                0x2fa6ce7839974858,
879            >(_buf?)?;
880            Ok(_response.succeeded)
881        }
882        self.client.send_query_and_decode::<ReadWriteAccountDebitRequest, bool>(
883            (amount,),
884            0x2fa6ce7839974858,
885            fidl::encoding::DynamicFlags::empty(),
886            _decode,
887        )
888    }
889
890    type CreditResponseFut =
891        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
892    fn r#credit(&self, mut amount: i64) -> Self::CreditResponseFut {
893        fn _decode(
894            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
895        ) -> Result<(), fidl::Error> {
896            let _response = fidl::client::decode_transaction_body::<
897                fidl::encoding::EmptyPayload,
898                fidl::encoding::DefaultFuchsiaResourceDialect,
899                0x37c216ac70d94bd5,
900            >(_buf?)?;
901            Ok(_response)
902        }
903        self.client.send_query_and_decode::<ReadWriteAccountCreditRequest, ()>(
904            (amount,),
905            0x37c216ac70d94bd5,
906            fidl::encoding::DynamicFlags::empty(),
907            _decode,
908        )
909    }
910}
911
912pub struct ReadWriteAccountEventStream {
913    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
914}
915
916impl std::marker::Unpin for ReadWriteAccountEventStream {}
917
918impl futures::stream::FusedStream for ReadWriteAccountEventStream {
919    fn is_terminated(&self) -> bool {
920        self.event_receiver.is_terminated()
921    }
922}
923
924impl futures::Stream for ReadWriteAccountEventStream {
925    type Item = Result<ReadWriteAccountEvent, fidl::Error>;
926
927    fn poll_next(
928        mut self: std::pin::Pin<&mut Self>,
929        cx: &mut std::task::Context<'_>,
930    ) -> std::task::Poll<Option<Self::Item>> {
931        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
932            &mut self.event_receiver,
933            cx
934        )?) {
935            Some(buf) => std::task::Poll::Ready(Some(ReadWriteAccountEvent::decode(buf))),
936            None => std::task::Poll::Ready(None),
937        }
938    }
939}
940
941#[derive(Debug)]
942pub enum ReadWriteAccountEvent {}
943
944impl ReadWriteAccountEvent {
945    /// Decodes a message buffer as a [`ReadWriteAccountEvent`].
946    fn decode(
947        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
948    ) -> Result<ReadWriteAccountEvent, fidl::Error> {
949        let (bytes, _handles) = buf.split_mut();
950        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
951        debug_assert_eq!(tx_header.tx_id, 0);
952        match tx_header.ordinal {
953            _ => Err(fidl::Error::UnknownOrdinal {
954                ordinal: tx_header.ordinal,
955                protocol_name:
956                    <ReadWriteAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
957            }),
958        }
959    }
960}
961
962/// A Stream of incoming requests for fuchsia.examples.services/ReadWriteAccount.
963pub struct ReadWriteAccountRequestStream {
964    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
965    is_terminated: bool,
966}
967
968impl std::marker::Unpin for ReadWriteAccountRequestStream {}
969
970impl futures::stream::FusedStream for ReadWriteAccountRequestStream {
971    fn is_terminated(&self) -> bool {
972        self.is_terminated
973    }
974}
975
976impl fidl::endpoints::RequestStream for ReadWriteAccountRequestStream {
977    type Protocol = ReadWriteAccountMarker;
978    type ControlHandle = ReadWriteAccountControlHandle;
979
980    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
981        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
982    }
983
984    fn control_handle(&self) -> Self::ControlHandle {
985        ReadWriteAccountControlHandle { inner: self.inner.clone() }
986    }
987
988    fn into_inner(
989        self,
990    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
991    {
992        (self.inner, self.is_terminated)
993    }
994
995    fn from_inner(
996        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
997        is_terminated: bool,
998    ) -> Self {
999        Self { inner, is_terminated }
1000    }
1001}
1002
1003impl futures::Stream for ReadWriteAccountRequestStream {
1004    type Item = Result<ReadWriteAccountRequest, fidl::Error>;
1005
1006    fn poll_next(
1007        mut self: std::pin::Pin<&mut Self>,
1008        cx: &mut std::task::Context<'_>,
1009    ) -> std::task::Poll<Option<Self::Item>> {
1010        let this = &mut *self;
1011        if this.inner.check_shutdown(cx) {
1012            this.is_terminated = true;
1013            return std::task::Poll::Ready(None);
1014        }
1015        if this.is_terminated {
1016            panic!("polled ReadWriteAccountRequestStream after completion");
1017        }
1018        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1019            |bytes, handles| {
1020                match this.inner.channel().read_etc(cx, bytes, handles) {
1021                    std::task::Poll::Ready(Ok(())) => {}
1022                    std::task::Poll::Pending => return std::task::Poll::Pending,
1023                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1024                        this.is_terminated = true;
1025                        return std::task::Poll::Ready(None);
1026                    }
1027                    std::task::Poll::Ready(Err(e)) => {
1028                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1029                            e.into(),
1030                        ))));
1031                    }
1032                }
1033
1034                // A message has been received from the channel
1035                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1036
1037                std::task::Poll::Ready(Some(match header.ordinal {
1038                    0x553f661d27b2273a => {
1039                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1040                        let mut req = fidl::new_empty!(
1041                            fidl::encoding::EmptyPayload,
1042                            fidl::encoding::DefaultFuchsiaResourceDialect
1043                        );
1044                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1045                        let control_handle =
1046                            ReadWriteAccountControlHandle { inner: this.inner.clone() };
1047                        Ok(ReadWriteAccountRequest::GetOwner {
1048                            responder: ReadWriteAccountGetOwnerResponder {
1049                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1050                                tx_id: header.tx_id,
1051                            },
1052                        })
1053                    }
1054                    0x35ffed4715b1b3ac => {
1055                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1056                        let mut req = fidl::new_empty!(
1057                            fidl::encoding::EmptyPayload,
1058                            fidl::encoding::DefaultFuchsiaResourceDialect
1059                        );
1060                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1061                        let control_handle =
1062                            ReadWriteAccountControlHandle { inner: this.inner.clone() };
1063                        Ok(ReadWriteAccountRequest::GetBalance {
1064                            responder: ReadWriteAccountGetBalanceResponder {
1065                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1066                                tx_id: header.tx_id,
1067                            },
1068                        })
1069                    }
1070                    0x2fa6ce7839974858 => {
1071                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1072                        let mut req = fidl::new_empty!(
1073                            ReadWriteAccountDebitRequest,
1074                            fidl::encoding::DefaultFuchsiaResourceDialect
1075                        );
1076                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReadWriteAccountDebitRequest>(&header, _body_bytes, handles, &mut req)?;
1077                        let control_handle =
1078                            ReadWriteAccountControlHandle { inner: this.inner.clone() };
1079                        Ok(ReadWriteAccountRequest::Debit {
1080                            amount: req.amount,
1081
1082                            responder: ReadWriteAccountDebitResponder {
1083                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1084                                tx_id: header.tx_id,
1085                            },
1086                        })
1087                    }
1088                    0x37c216ac70d94bd5 => {
1089                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1090                        let mut req = fidl::new_empty!(
1091                            ReadWriteAccountCreditRequest,
1092                            fidl::encoding::DefaultFuchsiaResourceDialect
1093                        );
1094                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ReadWriteAccountCreditRequest>(&header, _body_bytes, handles, &mut req)?;
1095                        let control_handle =
1096                            ReadWriteAccountControlHandle { inner: this.inner.clone() };
1097                        Ok(ReadWriteAccountRequest::Credit {
1098                            amount: req.amount,
1099
1100                            responder: ReadWriteAccountCreditResponder {
1101                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1102                                tx_id: header.tx_id,
1103                            },
1104                        })
1105                    }
1106                    _ => Err(fidl::Error::UnknownOrdinal {
1107                        ordinal: header.ordinal,
1108                        protocol_name:
1109                            <ReadWriteAccountMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1110                    }),
1111                }))
1112            },
1113        )
1114    }
1115}
1116
1117/// Provides read-write access to a bank account.
1118#[derive(Debug)]
1119pub enum ReadWriteAccountRequest {
1120    /// Returns the bank account owner's name.
1121    GetOwner { responder: ReadWriteAccountGetOwnerResponder },
1122    /// Returns the bank account's current balance in cents.
1123    GetBalance { responder: ReadWriteAccountGetBalanceResponder },
1124    /// Withdraws `amount` cents from the bank account.
1125    /// Returns false if the account had insufficient funds.
1126    Debit { amount: i64, responder: ReadWriteAccountDebitResponder },
1127    /// Deposits `amount` cents to the bank account.
1128    Credit { amount: i64, responder: ReadWriteAccountCreditResponder },
1129}
1130
1131impl ReadWriteAccountRequest {
1132    #[allow(irrefutable_let_patterns)]
1133    pub fn into_get_owner(self) -> Option<(ReadWriteAccountGetOwnerResponder)> {
1134        if let ReadWriteAccountRequest::GetOwner { responder } = self {
1135            Some((responder))
1136        } else {
1137            None
1138        }
1139    }
1140
1141    #[allow(irrefutable_let_patterns)]
1142    pub fn into_get_balance(self) -> Option<(ReadWriteAccountGetBalanceResponder)> {
1143        if let ReadWriteAccountRequest::GetBalance { responder } = self {
1144            Some((responder))
1145        } else {
1146            None
1147        }
1148    }
1149
1150    #[allow(irrefutable_let_patterns)]
1151    pub fn into_debit(self) -> Option<(i64, ReadWriteAccountDebitResponder)> {
1152        if let ReadWriteAccountRequest::Debit { amount, responder } = self {
1153            Some((amount, responder))
1154        } else {
1155            None
1156        }
1157    }
1158
1159    #[allow(irrefutable_let_patterns)]
1160    pub fn into_credit(self) -> Option<(i64, ReadWriteAccountCreditResponder)> {
1161        if let ReadWriteAccountRequest::Credit { amount, responder } = self {
1162            Some((amount, responder))
1163        } else {
1164            None
1165        }
1166    }
1167
1168    /// Name of the method defined in FIDL
1169    pub fn method_name(&self) -> &'static str {
1170        match *self {
1171            ReadWriteAccountRequest::GetOwner { .. } => "get_owner",
1172            ReadWriteAccountRequest::GetBalance { .. } => "get_balance",
1173            ReadWriteAccountRequest::Debit { .. } => "debit",
1174            ReadWriteAccountRequest::Credit { .. } => "credit",
1175        }
1176    }
1177}
1178
1179#[derive(Debug, Clone)]
1180pub struct ReadWriteAccountControlHandle {
1181    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1182}
1183
1184impl ReadWriteAccountControlHandle {
1185    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1186        self.inner.shutdown_with_epitaph(status.into())
1187    }
1188}
1189
1190impl fidl::endpoints::ControlHandle for ReadWriteAccountControlHandle {
1191    fn shutdown(&self) {
1192        self.inner.shutdown()
1193    }
1194
1195    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1196        self.inner.shutdown_with_epitaph(status)
1197    }
1198
1199    fn is_closed(&self) -> bool {
1200        self.inner.channel().is_closed()
1201    }
1202    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1203        self.inner.channel().on_closed()
1204    }
1205
1206    #[cfg(target_os = "fuchsia")]
1207    fn signal_peer(
1208        &self,
1209        clear_mask: zx::Signals,
1210        set_mask: zx::Signals,
1211    ) -> Result<(), zx_status::Status> {
1212        use fidl::Peered;
1213        self.inner.channel().signal_peer(clear_mask, set_mask)
1214    }
1215}
1216
1217impl ReadWriteAccountControlHandle {}
1218
1219#[must_use = "FIDL methods require a response to be sent"]
1220#[derive(Debug)]
1221pub struct ReadWriteAccountGetOwnerResponder {
1222    control_handle: std::mem::ManuallyDrop<ReadWriteAccountControlHandle>,
1223    tx_id: u32,
1224}
1225
1226/// Set the the channel to be shutdown (see [`ReadWriteAccountControlHandle::shutdown`])
1227/// if the responder is dropped without sending a response, so that the client
1228/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1229impl std::ops::Drop for ReadWriteAccountGetOwnerResponder {
1230    fn drop(&mut self) {
1231        self.control_handle.shutdown();
1232        // Safety: drops once, never accessed again
1233        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1234    }
1235}
1236
1237impl fidl::endpoints::Responder for ReadWriteAccountGetOwnerResponder {
1238    type ControlHandle = ReadWriteAccountControlHandle;
1239
1240    fn control_handle(&self) -> &ReadWriteAccountControlHandle {
1241        &self.control_handle
1242    }
1243
1244    fn drop_without_shutdown(mut self) {
1245        // Safety: drops once, never accessed again due to mem::forget
1246        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1247        // Prevent Drop from running (which would shut down the channel)
1248        std::mem::forget(self);
1249    }
1250}
1251
1252impl ReadWriteAccountGetOwnerResponder {
1253    /// Sends a response to the FIDL transaction.
1254    ///
1255    /// Sets the channel to shutdown if an error occurs.
1256    pub fn send(self, mut owner: &str) -> Result<(), fidl::Error> {
1257        let _result = self.send_raw(owner);
1258        if _result.is_err() {
1259            self.control_handle.shutdown();
1260        }
1261        self.drop_without_shutdown();
1262        _result
1263    }
1264
1265    /// Similar to "send" but does not shutdown the channel if an error occurs.
1266    pub fn send_no_shutdown_on_err(self, mut owner: &str) -> Result<(), fidl::Error> {
1267        let _result = self.send_raw(owner);
1268        self.drop_without_shutdown();
1269        _result
1270    }
1271
1272    fn send_raw(&self, mut owner: &str) -> Result<(), fidl::Error> {
1273        self.control_handle.inner.send::<ReadOnlyAccountGetOwnerResponse>(
1274            (owner,),
1275            self.tx_id,
1276            0x553f661d27b2273a,
1277            fidl::encoding::DynamicFlags::empty(),
1278        )
1279    }
1280}
1281
1282#[must_use = "FIDL methods require a response to be sent"]
1283#[derive(Debug)]
1284pub struct ReadWriteAccountGetBalanceResponder {
1285    control_handle: std::mem::ManuallyDrop<ReadWriteAccountControlHandle>,
1286    tx_id: u32,
1287}
1288
1289/// Set the the channel to be shutdown (see [`ReadWriteAccountControlHandle::shutdown`])
1290/// if the responder is dropped without sending a response, so that the client
1291/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1292impl std::ops::Drop for ReadWriteAccountGetBalanceResponder {
1293    fn drop(&mut self) {
1294        self.control_handle.shutdown();
1295        // Safety: drops once, never accessed again
1296        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1297    }
1298}
1299
1300impl fidl::endpoints::Responder for ReadWriteAccountGetBalanceResponder {
1301    type ControlHandle = ReadWriteAccountControlHandle;
1302
1303    fn control_handle(&self) -> &ReadWriteAccountControlHandle {
1304        &self.control_handle
1305    }
1306
1307    fn drop_without_shutdown(mut self) {
1308        // Safety: drops once, never accessed again due to mem::forget
1309        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1310        // Prevent Drop from running (which would shut down the channel)
1311        std::mem::forget(self);
1312    }
1313}
1314
1315impl ReadWriteAccountGetBalanceResponder {
1316    /// Sends a response to the FIDL transaction.
1317    ///
1318    /// Sets the channel to shutdown if an error occurs.
1319    pub fn send(self, mut balance: i64) -> Result<(), fidl::Error> {
1320        let _result = self.send_raw(balance);
1321        if _result.is_err() {
1322            self.control_handle.shutdown();
1323        }
1324        self.drop_without_shutdown();
1325        _result
1326    }
1327
1328    /// Similar to "send" but does not shutdown the channel if an error occurs.
1329    pub fn send_no_shutdown_on_err(self, mut balance: i64) -> Result<(), fidl::Error> {
1330        let _result = self.send_raw(balance);
1331        self.drop_without_shutdown();
1332        _result
1333    }
1334
1335    fn send_raw(&self, mut balance: i64) -> Result<(), fidl::Error> {
1336        self.control_handle.inner.send::<ReadOnlyAccountGetBalanceResponse>(
1337            (balance,),
1338            self.tx_id,
1339            0x35ffed4715b1b3ac,
1340            fidl::encoding::DynamicFlags::empty(),
1341        )
1342    }
1343}
1344
1345#[must_use = "FIDL methods require a response to be sent"]
1346#[derive(Debug)]
1347pub struct ReadWriteAccountDebitResponder {
1348    control_handle: std::mem::ManuallyDrop<ReadWriteAccountControlHandle>,
1349    tx_id: u32,
1350}
1351
1352/// Set the the channel to be shutdown (see [`ReadWriteAccountControlHandle::shutdown`])
1353/// if the responder is dropped without sending a response, so that the client
1354/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1355impl std::ops::Drop for ReadWriteAccountDebitResponder {
1356    fn drop(&mut self) {
1357        self.control_handle.shutdown();
1358        // Safety: drops once, never accessed again
1359        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1360    }
1361}
1362
1363impl fidl::endpoints::Responder for ReadWriteAccountDebitResponder {
1364    type ControlHandle = ReadWriteAccountControlHandle;
1365
1366    fn control_handle(&self) -> &ReadWriteAccountControlHandle {
1367        &self.control_handle
1368    }
1369
1370    fn drop_without_shutdown(mut self) {
1371        // Safety: drops once, never accessed again due to mem::forget
1372        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1373        // Prevent Drop from running (which would shut down the channel)
1374        std::mem::forget(self);
1375    }
1376}
1377
1378impl ReadWriteAccountDebitResponder {
1379    /// Sends a response to the FIDL transaction.
1380    ///
1381    /// Sets the channel to shutdown if an error occurs.
1382    pub fn send(self, mut succeeded: bool) -> Result<(), fidl::Error> {
1383        let _result = self.send_raw(succeeded);
1384        if _result.is_err() {
1385            self.control_handle.shutdown();
1386        }
1387        self.drop_without_shutdown();
1388        _result
1389    }
1390
1391    /// Similar to "send" but does not shutdown the channel if an error occurs.
1392    pub fn send_no_shutdown_on_err(self, mut succeeded: bool) -> Result<(), fidl::Error> {
1393        let _result = self.send_raw(succeeded);
1394        self.drop_without_shutdown();
1395        _result
1396    }
1397
1398    fn send_raw(&self, mut succeeded: bool) -> Result<(), fidl::Error> {
1399        self.control_handle.inner.send::<ReadWriteAccountDebitResponse>(
1400            (succeeded,),
1401            self.tx_id,
1402            0x2fa6ce7839974858,
1403            fidl::encoding::DynamicFlags::empty(),
1404        )
1405    }
1406}
1407
1408#[must_use = "FIDL methods require a response to be sent"]
1409#[derive(Debug)]
1410pub struct ReadWriteAccountCreditResponder {
1411    control_handle: std::mem::ManuallyDrop<ReadWriteAccountControlHandle>,
1412    tx_id: u32,
1413}
1414
1415/// Set the the channel to be shutdown (see [`ReadWriteAccountControlHandle::shutdown`])
1416/// if the responder is dropped without sending a response, so that the client
1417/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1418impl std::ops::Drop for ReadWriteAccountCreditResponder {
1419    fn drop(&mut self) {
1420        self.control_handle.shutdown();
1421        // Safety: drops once, never accessed again
1422        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1423    }
1424}
1425
1426impl fidl::endpoints::Responder for ReadWriteAccountCreditResponder {
1427    type ControlHandle = ReadWriteAccountControlHandle;
1428
1429    fn control_handle(&self) -> &ReadWriteAccountControlHandle {
1430        &self.control_handle
1431    }
1432
1433    fn drop_without_shutdown(mut self) {
1434        // Safety: drops once, never accessed again due to mem::forget
1435        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1436        // Prevent Drop from running (which would shut down the channel)
1437        std::mem::forget(self);
1438    }
1439}
1440
1441impl ReadWriteAccountCreditResponder {
1442    /// Sends a response to the FIDL transaction.
1443    ///
1444    /// Sets the channel to shutdown if an error occurs.
1445    pub fn send(self) -> Result<(), fidl::Error> {
1446        let _result = self.send_raw();
1447        if _result.is_err() {
1448            self.control_handle.shutdown();
1449        }
1450        self.drop_without_shutdown();
1451        _result
1452    }
1453
1454    /// Similar to "send" but does not shutdown the channel if an error occurs.
1455    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1456        let _result = self.send_raw();
1457        self.drop_without_shutdown();
1458        _result
1459    }
1460
1461    fn send_raw(&self) -> Result<(), fidl::Error> {
1462        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1463            (),
1464            self.tx_id,
1465            0x37c216ac70d94bd5,
1466            fidl::encoding::DynamicFlags::empty(),
1467        )
1468    }
1469}
1470
1471#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1472pub struct BankAccountMarker;
1473
1474#[cfg(target_os = "fuchsia")]
1475impl fidl::endpoints::ServiceMarker for BankAccountMarker {
1476    type Proxy = BankAccountProxy;
1477    type Request = BankAccountRequest;
1478    const SERVICE_NAME: &'static str = "fuchsia.examples.services.BankAccount";
1479}
1480
1481/// A request for one of the member protocols of BankAccount.
1482///
1483/// A Service representing a BankAccount, with two views of the data: read-only, and read-write.
1484#[cfg(target_os = "fuchsia")]
1485pub enum BankAccountRequest {
1486    ReadOnly(ReadOnlyAccountRequestStream),
1487    ReadWrite(ReadWriteAccountRequestStream),
1488}
1489
1490#[cfg(target_os = "fuchsia")]
1491impl fidl::endpoints::ServiceRequest for BankAccountRequest {
1492    type Service = BankAccountMarker;
1493
1494    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1495        match name {
1496            "read_only" => Self::ReadOnly(
1497                <ReadOnlyAccountRequestStream as fidl::endpoints::RequestStream>::from_channel(
1498                    _channel,
1499                ),
1500            ),
1501            "read_write" => Self::ReadWrite(
1502                <ReadWriteAccountRequestStream as fidl::endpoints::RequestStream>::from_channel(
1503                    _channel,
1504                ),
1505            ),
1506            _ => panic!("no such member protocol name for service BankAccount"),
1507        }
1508    }
1509
1510    fn member_names() -> &'static [&'static str] {
1511        &["read_only", "read_write"]
1512    }
1513}
1514/// A Service representing a BankAccount, with two views of the data: read-only, and read-write.
1515#[cfg(target_os = "fuchsia")]
1516pub struct BankAccountProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1517
1518#[cfg(target_os = "fuchsia")]
1519impl fidl::endpoints::ServiceProxy for BankAccountProxy {
1520    type Service = BankAccountMarker;
1521
1522    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1523        Self(opener)
1524    }
1525}
1526
1527#[cfg(target_os = "fuchsia")]
1528impl BankAccountProxy {
1529    pub fn connect_to_read_only(&self) -> Result<ReadOnlyAccountProxy, fidl::Error> {
1530        let (proxy, server_end) = fidl::endpoints::create_proxy::<ReadOnlyAccountMarker>();
1531        self.connect_channel_to_read_only(server_end)?;
1532        Ok(proxy)
1533    }
1534
1535    /// Like `connect_to_read_only`, but returns a sync proxy.
1536    /// See [`Self::connect_to_read_only`] for more details.
1537    pub fn connect_to_read_only_sync(
1538        &self,
1539    ) -> Result<ReadOnlyAccountSynchronousProxy, fidl::Error> {
1540        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ReadOnlyAccountMarker>();
1541        self.connect_channel_to_read_only(server_end)?;
1542        Ok(proxy)
1543    }
1544
1545    /// Like `connect_to_read_only`, but accepts a server end.
1546    /// See [`Self::connect_to_read_only`] for more details.
1547    pub fn connect_channel_to_read_only(
1548        &self,
1549        server_end: fidl::endpoints::ServerEnd<ReadOnlyAccountMarker>,
1550    ) -> Result<(), fidl::Error> {
1551        self.0.open_member("read_only", server_end.into_channel())
1552    }
1553    pub fn connect_to_read_write(&self) -> Result<ReadWriteAccountProxy, fidl::Error> {
1554        let (proxy, server_end) = fidl::endpoints::create_proxy::<ReadWriteAccountMarker>();
1555        self.connect_channel_to_read_write(server_end)?;
1556        Ok(proxy)
1557    }
1558
1559    /// Like `connect_to_read_write`, but returns a sync proxy.
1560    /// See [`Self::connect_to_read_write`] for more details.
1561    pub fn connect_to_read_write_sync(
1562        &self,
1563    ) -> Result<ReadWriteAccountSynchronousProxy, fidl::Error> {
1564        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ReadWriteAccountMarker>();
1565        self.connect_channel_to_read_write(server_end)?;
1566        Ok(proxy)
1567    }
1568
1569    /// Like `connect_to_read_write`, but accepts a server end.
1570    /// See [`Self::connect_to_read_write`] for more details.
1571    pub fn connect_channel_to_read_write(
1572        &self,
1573        server_end: fidl::endpoints::ServerEnd<ReadWriteAccountMarker>,
1574    ) -> Result<(), fidl::Error> {
1575        self.0.open_member("read_write", server_end.into_channel())
1576    }
1577
1578    pub fn instance_name(&self) -> &str {
1579        self.0.instance_name()
1580    }
1581}
1582
1583mod internal {
1584    use super::*;
1585}