Skip to content

Commit

Permalink
Change get_makers/takers to return HashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu-maeda committed Dec 21, 2023
1 parent cb46c80 commit 68da7c0
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Manager {
taker_accessors: RwLock<HashMap<Uuid, TakerAccess>>,
}

const DATA_DIR_PATH_STR: &str = "n3xb_data/";
const DATA_DIR_PATH_STR: &str = "n3xb_data";

impl Manager {
// Constructors
Expand Down Expand Up @@ -309,20 +309,12 @@ impl Manager {
Ok(taker_returned_accessor)
}

pub async fn get_makers(&self) -> Vec<(Uuid, MakerAccess)> {
let mut maker_accessors = self.maker_accessors.read().await.clone();
maker_accessors
.drain()
.map(|(uuid, maker_accessor)| (uuid, maker_accessor))
.collect()
pub async fn get_makers(&self) -> HashMap<Uuid, MakerAccess> {
self.maker_accessors.read().await.clone()
}

pub async fn get_takers(&self) -> Vec<(Uuid, TakerAccess)> {
let mut taker_accessors = self.taker_accessors.read().await.clone();
taker_accessors
.drain()
.map(|(uuid, taker_accessor)| (uuid, taker_accessor))
.collect()
pub async fn get_takers(&self) -> HashMap<Uuid, TakerAccess> {
self.taker_accessors.read().await.clone()
}

pub async fn shutdown(self) -> Result<(), JoinError> {
Expand Down

0 comments on commit 68da7c0

Please sign in to comment.