From faab74e3b5c7fe1907e78e14c790c49fc9e48159 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Sun, 28 Apr 2024 13:27:52 +0200 Subject: [PATCH] feature(relay): add transfer struct to store announced transfers --- src/relay/mod.rs | 1 + src/relay/transfer.rs | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/relay/transfer.rs diff --git a/src/relay/mod.rs b/src/relay/mod.rs index fa42e40..817ed2a 100644 --- a/src/relay/mod.rs +++ b/src/relay/mod.rs @@ -2,6 +2,7 @@ pub mod appstate; pub mod client; pub mod room; pub mod server; +pub mod transfer; use serde::{Deserialize, Serialize}; diff --git a/src/relay/transfer.rs b/src/relay/transfer.rs new file mode 100644 index 0000000..db6bbb3 --- /dev/null +++ b/src/relay/transfer.rs @@ -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 + ) + } +}