Merge pull request #77 from PatrykHegenberg/52-implement-transfer-struct

feature(relay): add transfer struct to store announced transfers
This commit is contained in:
PatrykHegenberg 2024-04-28 13:37:47 +02:00 committed by GitHub
commit 57bc73cbc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 0 deletions

View file

@ -2,6 +2,7 @@ pub mod appstate;
pub mod client;
pub mod room;
pub mod server;
pub mod transfer;
use serde::{Deserialize, Serialize};

35
src/relay/transfer.rs Normal file
View file

@ -0,0 +1,35 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Transfer {
pub name: String,
pub ip: String,
pub room_id: String,
}
impl Transfer {
pub fn new(name: String, ip: String, room_id: String) -> Self {
Self { name, ip, room_id }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_new() {
let transfer = Transfer {
name: "Test".to_string(),
ip: "127.0.0.1".to_string(),
room_id: "This_is_a_test_room_id".to_string(),
};
assert_eq!(
Transfer::new(
"Test".to_string(),
"127.0.0.1".to_string(),
"This_is_a_test_room_id".to_string()
),
transfer
)
}
}