mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
make bytes_total_limit optional
This commit is contained in:
parent
8c298977f3
commit
eb32db3d3b
1 changed files with 7 additions and 5 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue