mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 09:05:45 +00:00
update comments
This commit is contained in:
parent
bb8c2273d4
commit
582744f830
1 changed files with 4 additions and 6 deletions
|
|
@ -55,26 +55,24 @@ pub fn for_memory_input_stream_async(
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
let len = bytes.len(); // calculate once
|
let len = bytes.len(); // calculate once
|
||||||
|
|
||||||
// is the end of stream
|
// is end of stream
|
||||||
if len == 0 {
|
if len == 0 {
|
||||||
return on_complete(Ok((memory_input_stream, total)));
|
return on_complete(Ok((memory_input_stream, total)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle the chunk
|
// callback chunk function
|
||||||
total += len;
|
total += len;
|
||||||
on_chunk(len, total);
|
on_chunk(len, total);
|
||||||
|
|
||||||
// push bytes into the memory pool
|
// push bytes into the memory pool
|
||||||
memory_input_stream.add_bytes(&bytes);
|
memory_input_stream.add_bytes(&bytes);
|
||||||
|
|
||||||
// prevent memory overflow on size `limit` reached
|
// prevent memory overflow
|
||||||
// * add last received bytes into the `memory_input_stream` anyway (to prevent data lost),
|
|
||||||
// it's safe because limited to the `chunk` size
|
|
||||||
if total > limit {
|
if total > limit {
|
||||||
return on_complete(Err(Error::BytesTotal(memory_input_stream, total, limit)));
|
return on_complete(Err(Error::BytesTotal(memory_input_stream, total, limit)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue reading..
|
// handle next chunk..
|
||||||
for_memory_input_stream_async(
|
for_memory_input_stream_async(
|
||||||
memory_input_stream,
|
memory_input_stream,
|
||||||
io_stream,
|
io_stream,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue