quinn-proto: rename read_chunk() to read()

This commit is contained in:
Dirkjan Ochtman
2021-01-25 21:00:29 +01:00
committed by Benjamin Saunders
parent ab98859756
commit f569495b71
5 changed files with 14 additions and 18 deletions
+2 -6
View File
@@ -904,12 +904,8 @@ where
}
/// Read the next ordered chunk from the given recv stream
pub fn read_chunk(
&mut self,
id: StreamId,
max_length: usize,
) -> Result<Option<Bytes>, ReadError> {
let result = self.streams.read_chunk(id, max_length);
pub fn read(&mut self, id: StreamId, max_length: usize) -> Result<Option<Bytes>, ReadError> {
let result = self.streams.read(id, max_length);
self.post_read(id, &result);
Ok(result?.map(|x| x.result))
}
+4 -4
View File
@@ -204,8 +204,8 @@ impl Streams {
self.try_read(id, |rs| rs.read_unordered())
}
pub(crate) fn read_chunk(&mut self, id: StreamId, max_length: usize) -> ReadResult<Bytes> {
self.try_read(id, |rs| rs.read_chunk(max_length))
pub(crate) fn read(&mut self, id: StreamId, max_length: usize) -> ReadResult<Bytes> {
self.try_read(id, |rs| rs.read(max_length))
}
pub(crate) fn read_chunks(
@@ -1006,7 +1006,7 @@ mod tests {
);
assert_eq!(client.data_recvd, 2048);
assert_eq!(client.local_max_data - initial_max, 0);
client.read_chunk(id, 1024).unwrap();
client.read(id, 1024).unwrap();
assert_eq!(client.local_max_data - initial_max, 1024);
assert_eq!(
client
@@ -1107,7 +1107,7 @@ mod tests {
}
);
assert!(client.stop(id).is_err());
assert_eq!(client.read_chunk(id, 0), Err(ReadError::UnknownStream));
assert_eq!(client.read(id, 0), Err(ReadError::UnknownStream));
assert_eq!(client.read_unordered(id), Err(ReadError::UnknownStream));
assert_eq!(client.local_max_data - initial_max, 32);
assert_eq!(
+1 -1
View File
@@ -73,7 +73,7 @@ impl Recv {
}
}
pub(super) fn read_chunk(&mut self, max_length: usize) -> StreamReadResult<Bytes> {
pub(super) fn read(&mut self, max_length: usize) -> StreamReadResult<Bytes> {
if self.assembler.is_stopped() {
return Err(ReadError::UnknownStream);
}
+5 -5
View File
@@ -752,13 +752,13 @@ fn key_update_reordered() {
let buf1 = pair
.server_conn_mut(server_ch)
.read_chunk(s, usize::MAX)
.read(s, usize::MAX)
.unwrap()
.unwrap();
assert_matches!(&*buf1, MSG1);
let buf2 = pair
.server_conn_mut(server_ch)
.read_chunk(s, usize::MAX)
.read(s, usize::MAX)
.unwrap()
.unwrap();
assert_eq!(buf2, MSG2);
@@ -978,7 +978,7 @@ fn test_flow_control(config: TransportConfig, window_size: usize) {
.unwrap();
pair.drive();
assert_eq!(
pair.server_conn_mut(server_conn).read_chunk(s, usize::MAX),
pair.server_conn_mut(server_conn).read(s, usize::MAX),
Err(ReadError::Reset(VarInt(42)))
);
@@ -997,7 +997,7 @@ fn test_flow_control(config: TransportConfig, window_size: usize) {
pair.drive();
let mut cursor = 0;
loop {
match pair.server_conn_mut(server_conn).read_chunk(s, usize::MAX) {
match pair.server_conn_mut(server_conn).read(s, usize::MAX) {
Ok(Some(buf)) => {
cursor += buf.len();
}
@@ -1028,7 +1028,7 @@ fn test_flow_control(config: TransportConfig, window_size: usize) {
pair.drive();
let mut cursor = 0;
loop {
match pair.server_conn_mut(server_conn).read_chunk(s, usize::MAX) {
match pair.server_conn_mut(server_conn).read(s, usize::MAX) {
Ok(Some(buf)) => {
cursor += buf.len();
}
+2 -2
View File
@@ -354,7 +354,7 @@ where
) -> Poll<Result<(), ReadError>> {
self.poll_read_generic(cx, |conn, stream| {
conn.inner
.read_chunk(stream, buf.remaining())
.read(stream, buf.remaining())
.map(|val| val.map(|chunk| buf.put_slice(&chunk)))
})
.map(|res| res.map(|_| ()))
@@ -398,7 +398,7 @@ where
cx: &mut Context,
max_length: usize,
) -> Poll<Result<Option<Bytes>, ReadError>> {
self.poll_read_generic(cx, |conn, stream| conn.inner.read_chunk(stream, max_length))
self.poll_read_generic(cx, |conn, stream| conn.inner.read(stream, max_length))
}
/// Read the next segments of data