// SPDX-FileCopyrightText: 2023 Aravinth Manivannan // // SPDX-License-Identifier: AGPL-3.0-or-later use std::rc::Rc; use rust_decimal::prelude::*; use crate::actor::*; pub trait Purchasable { fn cost(&self) -> Decimal; fn name(&self) -> &str; fn paid_by(&self) -> Rc; } pub struct Item { cost: Decimal, name: String, payer: Rc, } impl Item { pub fn new(name: String, cost: Decimal, payer: Rc) -> Self { Self { cost, name, payer } } } impl Purchasable for Item { fn cost(&self) -> Decimal { self.cost } fn name(&self) -> &str { &self.name } fn paid_by(&self) -> Rc { self.payer.clone() } }