use clone of shared reference instead of ref

This commit is contained in:
yggverse 2024-10-29 21:19:49 +02:00
parent 028ffa384d
commit 268dab6ed3

View file

@ -34,7 +34,7 @@ pub fn from_socket_connection_async(
priority: Priority, priority: Priority,
bytes_in_chunk: usize, bytes_in_chunk: usize,
bytes_total_limit: usize, bytes_total_limit: usize,
on_chunk: impl Fn((&Bytes, &usize)) + 'static, on_chunk: impl Fn((Bytes, usize)) + 'static,
on_complete: impl FnOnce(Result<MemoryInputStream, (Error, Option<&str>)>) + 'static, on_complete: impl FnOnce(Result<MemoryInputStream, (Error, Option<&str>)>) + 'static,
) { ) {
read_all_from_socket_connection_async( read_all_from_socket_connection_async(
@ -81,7 +81,7 @@ pub fn read_all_from_socket_connection_async(
bytes_in_chunk: usize, bytes_in_chunk: usize,
bytes_total_limit: usize, bytes_total_limit: usize,
bytes_total: usize, bytes_total: usize,
on_chunk: impl Fn((&Bytes, &usize)) + 'static, on_chunk: impl Fn((Bytes, usize)) + 'static,
on_complete: impl FnOnce(Result<MemoryInputStream, (Error, Option<&str>)>) + 'static, on_complete: impl FnOnce(Result<MemoryInputStream, (Error, Option<&str>)>) + 'static,
) { ) {
socket_connection.input_stream().read_bytes_async( socket_connection.input_stream().read_bytes_async(
@ -94,7 +94,7 @@ pub fn read_all_from_socket_connection_async(
let bytes_total = bytes_total + bytes.len(); let bytes_total = bytes_total + bytes.len();
// Callback chunk function // Callback chunk function
on_chunk((&bytes, &bytes_total)); on_chunk((bytes.clone(), bytes_total));
// Validate max size // Validate max size
if bytes_total > bytes_total_limit { if bytes_total > bytes_total_limit {