return bytes total on_complete

This commit is contained in:
yggverse 2024-12-09 14:50:31 +02:00
parent f33e53e51b
commit 1911b0ad95
2 changed files with 7 additions and 7 deletions

View file

@ -21,8 +21,8 @@ pub fn move_all_from_stream_async(
usize, // bytes_total
),
callback: (
impl Fn(Bytes, usize) + 'static, // on_chunk
impl FnOnce(Result<FileOutputStream, Error>) + 'static, // on_complete
impl Fn(Bytes, usize) + 'static, // on_chunk
impl FnOnce(Result<(FileOutputStream, usize), Error>) + 'static, // on_complete
),
) {
let (on_chunk, on_complete) = callback;
@ -49,7 +49,7 @@ pub fn move_all_from_stream_async(
// No bytes were read, end of stream
if bytes.len() == 0 {
return on_complete(Ok(file_output_stream));
return on_complete(Ok((file_output_stream, bytes_total)));
}
// Write chunk bytes

View file

@ -20,7 +20,7 @@ pub fn from_stream_async(
bytes_in_chunk: usize,
bytes_total_limit: usize,
on_chunk: impl Fn(Bytes, usize) + 'static,
on_complete: impl FnOnce(Result<MemoryInputStream, Error>) + 'static,
on_complete: impl FnOnce(Result<(MemoryInputStream, usize), Error>) + 'static,
) {
move_all_from_stream_async(
base_io_stream,
@ -46,8 +46,8 @@ pub fn move_all_from_stream_async(
usize, // bytes_total
),
callback: (
impl Fn(Bytes, usize) + 'static, // on_chunk
impl FnOnce(Result<MemoryInputStream, Error>) + 'static, // on_complete
impl Fn(Bytes, usize) + 'static, // on_chunk
impl FnOnce(Result<(MemoryInputStream, usize), Error>) + 'static, // on_complete
),
) {
let (on_chunk, on_complete) = callback;
@ -72,7 +72,7 @@ pub fn move_all_from_stream_async(
// No bytes were read, end of stream
if bytes.len() == 0 {
return on_complete(Ok(memory_input_stream));
return on_complete(Ok((memory_input_stream, bytes_total)));
}
// Write chunk bytes