Simplify ReadWrite interface (#530)
Previously, ReadWrite had methods `is_poolable` and `written_bytes`, which were solely for the use of unittests. This replaces `written_bytes` and `TestStream` with a `struct Recorder` that implements `ReadWrite` and allows unittests to access its recorded bytes via an `Arc<Mutex<Vec<u8>>>`. It eliminates `is_poolable`; it's fine to pool a Stream of any kind. The new `Recorder` also has some convenience methods that abstract away boilerplate code from many of our unittests. I got rid of `Stream::from_vec` and `Stream::from_vec_poolable` because they depended on `TestStream`. They've been replaced by `NoopStream` for the pool.rs tests, and `ReadOnlyStream` for constructing `Response`s from `&str` and some test cases.
This commit is contained in:
committed by
GitHub
parent
0cf1f8dbb9
commit
9908c446d6
@@ -31,7 +31,4 @@ impl ReadWrite for native_tls::TlsStream<Box<dyn ReadWrite>> {
|
||||
fn socket(&self) -> Option<&TcpStream> {
|
||||
self.get_ref().socket()
|
||||
}
|
||||
fn is_poolable(&self) -> bool {
|
||||
self.get_ref().is_poolable()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user