Refactor {send,read}_message() #11

Merged
eNV25 merged 2 commits from main into main 2024-02-16 09:53:21 +01:00
Showing only changes of commit 9489bc6bfd - Show all commits

View file

@ -27,8 +27,9 @@ fn read_message() -> Result<String, io::Error> {
stdin.read_exact(&mut len)?; stdin.read_exact(&mut len)?;
let len = u32::from_ne_bytes(len); let len = u32::from_ne_bytes(len);
let mut reader = stdin.take(len as u64);
let mut msg = String::with_capacity(len as usize); let mut msg = String::with_capacity(len as usize);
stdin.take(len as u64).read_to_string(&mut msg)?; reader.read_to_string(&mut msg)?;
Ok(msg) Ok(msg)
} }