use std::ops::Deref;
use std::sync::Arc;
use crate::gmsol_store::{accounts::VirtualInventory, types::Pool};
#[derive(Debug, Clone)]
pub struct VirtualInventoryModel {
virtual_inventory: Arc<VirtualInventory>,
}
impl Deref for VirtualInventoryModel {
type Target = VirtualInventory;
fn deref(&self) -> &Self::Target {
&self.virtual_inventory
}
}
impl VirtualInventoryModel {
pub fn from_parts(virtual_inventory: Arc<VirtualInventory>) -> Self {
Self { virtual_inventory }
}
pub fn pool(&self) -> &Pool {
&self.virtual_inventory.pool.pool
}
pub fn pool_mut(&mut self) -> &mut Pool {
let vi = self.make_virtual_inventory_mut();
&mut vi.pool.pool
}
fn make_virtual_inventory_mut(&mut self) -> &mut VirtualInventory {
Arc::make_mut(&mut self.virtual_inventory)
}
}