Merge pull request #78 from PatrykHegenberg/76-add-transfer-struct-to-appstate

76 add transfer struct to appstate
This commit is contained in:
PatrykHegenberg 2024-04-28 13:58:59 +02:00 committed by GitHub
commit 4be4af63cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 6 deletions

View file

@ -2,6 +2,7 @@ use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock; use tokio::sync::RwLock;
use crate::relay::room::Room; use crate::relay::room::Room;
use crate::relay::transfer::Transfer;
/// A struct that holds all of the rooms that the server knows about. /// A struct that holds all of the rooms that the server knows about.
/// ///
@ -11,6 +12,7 @@ use crate::relay::room::Room;
#[derive(Debug)] #[derive(Debug)]
pub struct AppState { pub struct AppState {
pub rooms: HashMap<String, Room>, pub rooms: HashMap<String, Room>,
pub transfers: Vec<Transfer>,
} }
impl AppState { impl AppState {
@ -44,15 +46,15 @@ impl AppState {
Arc::new(RwLock::new(AppState { Arc::new(RwLock::new(AppState {
// Initialize the list of rooms to be empty. // Initialize the list of rooms to be empty.
rooms: HashMap::new(), rooms: HashMap::new(),
transfers: Vec::new(),
})) }))
} }
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::sync::{Arc}; use std::sync::Arc;
#[test] #[test]
fn test_new() { fn test_new() {
@ -60,4 +62,4 @@ mod tests {
assert!(Arc::ptr_eq(&app_state, &app_state.clone())); assert!(Arc::ptr_eq(&app_state, &app_state.clone()));
} }
} }

View file

@ -491,6 +491,5 @@ impl Client {
// TODO: Add tests // TODO: Add tests
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; // use super::*;
}
}