feature(relay): Add new Transfer struct to AppState

To share the transfers between different routes and connections it is
necessary to hold all transfers in the AppState.
This commit is contained in:
Patryk Hegenberg 2024-04-28 13:53:39 +02:00
parent 57bc73cbc1
commit 4cd25a8442
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 crate::relay::room::Room;
use crate::relay::transfer::Transfer;
/// A struct that holds all of the rooms that the server knows about.
///
@ -11,6 +12,7 @@ use crate::relay::room::Room;
#[derive(Debug)]
pub struct AppState {
pub rooms: HashMap<String, Room>,
pub transfers: Vec<Transfer>,
}
impl AppState {
@ -44,15 +46,15 @@ impl AppState {
Arc::new(RwLock::new(AppState {
// Initialize the list of rooms to be empty.
rooms: HashMap::new(),
transfers: Vec::new(),
}))
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::sync::{Arc};
use std::sync::Arc;
#[test]
fn test_new() {
@ -60,4 +62,4 @@ mod tests {
assert!(Arc::ptr_eq(&app_state, &app_state.clone()));
}
}
}

View file

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