| // Copyright 2020 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.examples.services; |
| |
| /// A Service representing a BankAccount, with two views of the data: read-only, and read-write. |
| service BankAccount { |
| read_only client_end:ReadOnlyAccount; |
| read_write client_end:ReadWriteAccount; |
| }; |
| |
| /// Provides read-only access to a bank account. |
| protocol ReadOnlyAccount { |
| /// Returns the bank account owner's name. |
| GetOwner() -> (struct { |
| owner string:MAX; |
| }); |
| |
| /// Returns the bank account's current balance in cents. |
| GetBalance() -> (struct { |
| balance int64; |
| }); |
| }; |
| |
| /// Provides read-write access to a bank account. |
| protocol ReadWriteAccount { |
| compose ReadOnlyAccount; |
| |
| /// Withdraws `amount` cents from the bank account. |
| /// Returns false if the account had insufficient funds. |
| Debit(struct { |
| amount int64; |
| }) -> (struct { |
| succeeded bool; |
| }); |
| |
| /// Deposits `amount` cents to the bank account. |
| Credit(struct { |
| amount int64; |
| }) -> (); |
| }; |