make bytes_total_limit optional

This commit is contained in:
yggverse 2024-12-09 14:14:01 +02:00
parent 8c298977f3
commit eb32db3d3b

View file

@ -17,7 +17,7 @@ pub fn move_all_from_stream_async(
priority: Priority,
bytes: (
usize, // bytes_in_chunk
usize, // bytes_total_limit
Option<usize>, // bytes_total_limit, `None` to unlimited
usize, // bytes_total
),
callback: (
@ -41,9 +41,11 @@ pub fn move_all_from_stream_async(
on_chunk((bytes.clone(), bytes_total));
// Validate max size
if let Some(bytes_total_limit) = bytes_total_limit {
if bytes_total > bytes_total_limit {
return on_complete(Err(Error::BytesTotal(bytes_total, bytes_total_limit)));
}
}
// No bytes were read, end of stream
if bytes.len() == 0 {