From 1911b0ad95d9dff2239d12996cf4679bc62e608c Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 9 Dec 2024 14:50:31 +0200 Subject: [PATCH] return bytes total `on_complete` --- src/gio/file_output_stream.rs | 6 +++--- src/gio/memory_input_stream.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gio/file_output_stream.rs b/src/gio/file_output_stream.rs index c4a1e2d..b34b507 100644 --- a/src/gio/file_output_stream.rs +++ b/src/gio/file_output_stream.rs @@ -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) + '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 diff --git a/src/gio/memory_input_stream.rs b/src/gio/memory_input_stream.rs index 1ab065f..30f9fd8 100644 --- a/src/gio/memory_input_stream.rs +++ b/src/gio/memory_input_stream.rs @@ -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) + '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) + '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