diff --git a/src/client/response/meta.rs b/src/client/response/meta.rs index 7e8ba71..82b5f3e 100644 --- a/src/client/response/meta.rs +++ b/src/client/response/meta.rs @@ -43,7 +43,7 @@ impl Meta { match buffer.get(..if len > MAX_LEN { MAX_LEN } else { len }) { Some(slice) => { // Parse data - let data = Data::from_utf8(&slice); + let data = Data::from_utf8(slice); if let Err(reason) = data { return Err(( @@ -57,7 +57,7 @@ impl Meta { // MIME - let mime = Mime::from_utf8(&slice); + let mime = Mime::from_utf8(slice); if let Err(reason) = mime { return Err(( @@ -72,7 +72,7 @@ impl Meta { // Status - let status = Status::from_utf8(&slice); + let status = Status::from_utf8(slice); if let Err(reason) = status { return Err(( diff --git a/src/client/response/meta/data.rs b/src/client/response/meta/data.rs index b83054e..710d4f6 100644 --- a/src/client/response/meta/data.rs +++ b/src/client/response/meta/data.rs @@ -22,7 +22,7 @@ impl Data { /// from entire response or just header slice /// /// * result could be `None` for some [status codes](https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes) - /// that does not expect any data in header + /// that does not expect any data in header pub fn from_utf8(buffer: &[u8]) -> Result, Error> { // Define max buffer length for this method const MAX_LEN: usize = 0x400; // 1024 diff --git a/src/client/response/meta/mime.rs b/src/client/response/meta/mime.rs index 6dabf42..ec8849d 100644 --- a/src/client/response/meta/mime.rs +++ b/src/client/response/meta/mime.rs @@ -33,9 +33,9 @@ impl Mime { /// Create new `Self` from UTF-8 buffer (that includes **header**) /// /// * result could be `None` for some [status codes](https://geminiprotocol.net/docs/protocol-specification.gmi#status-codes) - /// that does not expect MIME type in header + /// that does not expect MIME type in header /// * includes `Self::from_string` parser, - /// it means that given buffer should contain some **header** (not filepath or any other type of strings) + /// it means that given buffer should contain some **header** (not filepath or any other type of strings) pub fn from_utf8(buffer: &[u8]) -> Result, Error> { // Define max buffer length for this method const MAX_LEN: usize = 0x400; // 1024 diff --git a/src/gio/memory_input_stream.rs b/src/gio/memory_input_stream.rs index 09f9339..ce7bb47 100644 --- a/src/gio/memory_input_stream.rs +++ b/src/gio/memory_input_stream.rs @@ -27,11 +27,8 @@ pub fn from_stream_async( base_io_stream, cancelable, priority, - bytes_in_chunk, - bytes_total_limit, - 0, // initial `bytes_total` value - on_chunk, - on_complete, + (bytes_in_chunk, bytes_total_limit, 0), + (on_chunk, on_complete), ); } @@ -43,12 +40,15 @@ pub fn read_all_from_stream_async( base_io_stream: impl IsA, cancelable: Option, priority: Priority, - bytes_in_chunk: usize, - bytes_total_limit: usize, - bytes_total: usize, - on_chunk: impl Fn((Bytes, usize)) + 'static, - on_complete: impl FnOnce(Result)>) + 'static, + bytes: (usize, usize, usize), + callback: ( + impl Fn((Bytes, usize)) + 'static, + impl FnOnce(Result)>) + 'static, + ), ) { + let (on_chunk, on_complete) = callback; + let (bytes_in_chunk, bytes_total_limit, bytes_total) = bytes; + base_io_stream.input_stream().read_bytes_async( bytes_in_chunk, priority, @@ -80,11 +80,8 @@ pub fn read_all_from_stream_async( base_io_stream, cancelable, priority, - bytes_in_chunk, - bytes_total_limit, - bytes_total, - on_chunk, - on_complete, + (bytes_in_chunk, bytes_total_limit, bytes_total), + (on_chunk, on_complete), ); } Err(reason) => {