feat: bidirectional transfer
This commit is contained in:
parent
864140da97
commit
b0531deb25
1 changed files with 28 additions and 15 deletions
43
src/main.rs
43
src/main.rs
|
@ -367,16 +367,8 @@ impl Connection
|
||||||
{
|
{
|
||||||
Ok(mut stream) =>
|
Ok(mut stream) =>
|
||||||
{
|
{
|
||||||
let mut stay = true;
|
println!("Connected");
|
||||||
while stay
|
send_or_receive(file_info, &mut stream, &debug_mode);
|
||||||
{
|
|
||||||
println!("Connected");
|
|
||||||
let start_time = Instant::now();
|
|
||||||
FileInfo::writing_operations(file_info, &mut stream, &debug_mode);
|
|
||||||
let finish_time = Instant::now();
|
|
||||||
println!("Passed: Total -> {:#?}", finish_time.duration_since(start_time));
|
|
||||||
stay = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Err(e) =>
|
Err(e) =>
|
||||||
{
|
{
|
||||||
|
@ -408,10 +400,7 @@ impl Connection
|
||||||
Ok(mut stream) =>
|
Ok(mut stream) =>
|
||||||
{
|
{
|
||||||
println!("Connected");
|
println!("Connected");
|
||||||
let start_time = Instant::now();
|
send_or_receive(file_info, &mut stream, &debug_mode);
|
||||||
FileInfo::reading_operations(file_info, &mut stream, &debug_mode);
|
|
||||||
let finish_time = Instant::now();
|
|
||||||
println!("Passed: Total -> {:#?}", finish_time.duration_since(start_time));
|
|
||||||
}
|
}
|
||||||
Err(e) =>
|
Err(e) =>
|
||||||
{
|
{
|
||||||
|
@ -421,7 +410,31 @@ impl Connection
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn send_or_receive(file_info:&mut FileInfo, stream:&mut TcpStream, debug_mode:&bool)
|
||||||
|
{
|
||||||
|
match &take_string("Input: Send 's', Receive 'r'".to_string())[..1]
|
||||||
|
{
|
||||||
|
"s" =>
|
||||||
|
{
|
||||||
|
println!("Connected");
|
||||||
|
let start_time = Instant::now();
|
||||||
|
FileInfo::reading_operations(file_info, stream, &debug_mode);
|
||||||
|
let finish_time = Instant::now();
|
||||||
|
println!("Passed: Total -> {:#?}", finish_time.duration_since(start_time));
|
||||||
|
}
|
||||||
|
"r" =>
|
||||||
|
{
|
||||||
|
let start_time = Instant::now();
|
||||||
|
FileInfo::writing_operations(file_info, stream, &debug_mode);
|
||||||
|
let finish_time = Instant::now();
|
||||||
|
println!("Passed: Total -> {:#?}", finish_time.duration_since(start_time));
|
||||||
|
}
|
||||||
|
input =>
|
||||||
|
{
|
||||||
|
println!("Error: Give Valid Input, You Gave : {}", input);
|
||||||
|
panic!() }
|
||||||
|
}
|
||||||
|
}
|
||||||
fn take_string(output:String) -> String
|
fn take_string(output:String) -> String
|
||||||
{
|
{
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue