diff --git a/Cargo.toml b/Cargo.toml index ad6792a..9954f46 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,9 @@ nanos_sdk = { git = "https://github.com/LedgerHQ/ledger-nanos-sdk.git" } nanos_ui = { git = "https://github.com/LedgerHQ/ledger-nanos-ui.git" } ledger-parser-combinators = { git = "https://github.com/alamgu/ledger-parser-combinators", branch="async-split-take-2" } +[patch."crates-io".arrayvec] +git = "https://github.com/obsidiansystems/arrayvec" +branch = "push-many-from-slice" [patch."https://github.com/LedgerHQ/ledger-nanos-sdk.git".nanos_sdk] git = "https://github.com/alamgu/ledger-nanos-sdk.git" branch = "relocating-loader-w-fixes" diff --git a/src/lib.rs b/src/lib.rs index 03531b2..b26d245 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -363,8 +363,8 @@ impl Readable for ByteStream { Err(_) => reject().await, }; let avail = &chunk[self.current_offset + HASH_LEN..]; - let consuming = core::cmp::min(avail.len(), buffer.remaining_capacity()); - buffer.try_extend_from_slice(&avail[0..consuming]).ok(); + let remaining = buffer.push_many_from_slice(&avail).len(); + let consuming = avail.len() - remaining; self.current_offset += consuming; if self.current_offset + HASH_LEN == chunk.len() { self.current_chunk = chunk[0..HASH_LEN].try_into().unwrap();