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