mraphics_core/render/
conveyor_manager.rs1use std::{collections::HashMap, hash::Hash};
2
3use crate::Conveyor;
4
5pub struct ConveyorManager<Key: Hash + Eq + ToOwned<Owned = Key>> {
6 pub conveyor_pool: HashMap<Key, Conveyor>,
7}
8
9impl<Key: Hash + Eq + ToOwned<Owned = Key>> ConveyorManager<Key> {
10 pub fn new() -> Self {
11 Self {
12 conveyor_pool: HashMap::new(),
13 }
14 }
15
16 pub fn acquire_conveyor(&mut self, identifier: &Key) -> &mut Conveyor {
17 if !self.conveyor_pool.contains_key(identifier) {
18 let conveyor = Conveyor::new();
19 self.conveyor_pool.insert(identifier.to_owned(), conveyor);
20 }
21
22 self.conveyor_pool.get_mut(identifier).unwrap()
24 }
25}