Stream::Read -> Stream::Cursor
This commit is contained in:
@@ -249,7 +249,7 @@ impl FromStr for Response {
|
|||||||
let bytes = s.as_bytes().to_owned();
|
let bytes = s.as_bytes().to_owned();
|
||||||
let mut cursor = Cursor::new(bytes);
|
let mut cursor = Cursor::new(bytes);
|
||||||
let mut resp = Self::do_from_read(&mut cursor)?;
|
let mut resp = Self::do_from_read(&mut cursor)?;
|
||||||
resp.set_stream(Stream::Read(Box::new(cursor)));
|
resp.set_stream(Stream::Cursor(cursor));
|
||||||
Ok(resp)
|
Ok(resp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use std::time::Duration;
|
|||||||
pub enum Stream {
|
pub enum Stream {
|
||||||
Http(TcpStream),
|
Http(TcpStream),
|
||||||
Https(TlsStream<TcpStream>),
|
Https(TlsStream<TcpStream>),
|
||||||
Read(Box<Read>),
|
Cursor(Cursor<Vec<u8>>),
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
Test(Box<Read + Send>, Vec<u8>),
|
Test(Box<Read + Send>, Vec<u8>),
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ impl Read for Stream {
|
|||||||
match self {
|
match self {
|
||||||
Stream::Http(sock) => sock.read(buf),
|
Stream::Http(sock) => sock.read(buf),
|
||||||
Stream::Https(stream) => stream.read(buf),
|
Stream::Https(stream) => stream.read(buf),
|
||||||
Stream::Read(read) => read.read(buf),
|
Stream::Cursor(read) => read.read(buf),
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
Stream::Test(reader, _) => reader.read(buf),
|
Stream::Test(reader, _) => reader.read(buf),
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ impl Write for Stream {
|
|||||||
match self {
|
match self {
|
||||||
Stream::Http(sock) => sock.write(buf),
|
Stream::Http(sock) => sock.write(buf),
|
||||||
Stream::Https(stream) => stream.write(buf),
|
Stream::Https(stream) => stream.write(buf),
|
||||||
Stream::Read(_) => panic!("Write to read stream"),
|
Stream::Cursor(_) => panic!("Write to read only stream"),
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
Stream::Test(_, writer) => writer.write(buf),
|
Stream::Test(_, writer) => writer.write(buf),
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ impl Write for Stream {
|
|||||||
match self {
|
match self {
|
||||||
Stream::Http(sock) => sock.flush(),
|
Stream::Http(sock) => sock.flush(),
|
||||||
Stream::Https(stream) => stream.flush(),
|
Stream::Https(stream) => stream.flush(),
|
||||||
Stream::Read(_) => panic!("Flush read stream"),
|
Stream::Cursor(_) => panic!("Flush read only stream"),
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
Stream::Test(_, writer) => writer.flush(),
|
Stream::Test(_, writer) => writer.flush(),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user