Test reader/writer too

This commit is contained in:
John Doty 2022-10-08 16:22:38 +00:00
parent 5ab189461d
commit 0d79ccd068
2 changed files with 121 additions and 59 deletions

View file

@ -8,7 +8,6 @@ use tokio::process;
use tokio::sync::mpsc;
use tokio::sync::oneshot;
mod error;
mod message;
mod refresh;
@ -25,6 +24,42 @@ pub enum Error {
ConnectionReset,
}
impl PartialEq for Error {
fn eq(&self, other: &Error) -> bool {
use Error::*;
match self {
Protocol => match other {
Protocol => true,
_ => false,
},
ProtocolVersion => match other {
ProtocolVersion => true,
_ => false,
},
IO(s) => match other {
IO(o) => s.kind() == o.kind(),
_ => false,
},
MessageIncomplete => match other {
MessageIncomplete => true,
_ => false,
},
MessageUnknown => match other {
MessageUnknown => true,
_ => false,
},
MessageCorrupt => match other {
MessageCorrupt => true,
_ => false,
},
ConnectionReset => match other {
ConnectionReset => true,
_ => false,
},
}
}
}
async fn pump_write<T: AsyncWrite + Unpin>(
messages: &mut mpsc::Receiver<Message>,
writer: &mut MessageWriter<T>,