Refactor Readable trait (#3309)

Currently Writable accepts trait Write as a type parameter but Readable
takes Read as a trait object, which is not symmetrical and also less performant. This PR changes Readable trait and all places where it's used
This commit is contained in:
hashmap
2020-04-30 17:42:19 +02:00
committed by GitHub
parent 9e51e86538
commit a82041d0ed
20 changed files with 98 additions and 100 deletions
+3 -3
View File
@@ -25,7 +25,7 @@ use chrono::prelude::Utc;
use rand::{thread_rng, Rng};
use std::cmp;
use std::fs::{self, File, OpenOptions};
use std::io::BufWriter;
use std::io::{BufWriter, Read};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Instant;
@@ -51,9 +51,9 @@ impl Protocol {
}
impl MessageHandler for Protocol {
fn consume(
fn consume<R: Read>(
&self,
mut msg: Message,
mut msg: Message<R>,
stopped: Arc<AtomicBool>,
tracker: Arc<Tracker>,
) -> Result<Option<Msg>, Error> {