feature(sender,receiver): enabled local and relay transfer

actually a clean close of the sender application is still missing and
has to be included
This commit is contained in:
Patryk Hegenberg 2024-05-01 17:46:04 +02:00
parent 300f688111
commit 2262fd9f75
9 changed files with 144 additions and 61 deletions

View file

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