From f3496ec348923fe59efd1e140a82587d5eafd1b3 Mon Sep 17 00:00:00 2001 From: Eric Swanson Date: Tue, 10 Dec 2024 02:52:50 -0800 Subject: [PATCH 1/2] feat: IDLBuilder.try_reserve_value_serializer_capacity --- Changelog.md | 6 ++++++ rust/candid/src/error.rs | 4 ++++ rust/candid/src/ser.rs | 14 +++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 22ff7790..2ae18323 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,12 @@ # Changelog +## 2024-12-10 + +### Candid 0.10.11 + +* Add `IDLBuilder.try_reserve_value_serializer_capacity()` to reserve capacity before serializing a large amount of data. + ## 2024-05-03 ### Candid 0.10.10 diff --git a/rust/candid/src/error.rs b/rust/candid/src/error.rs index 9caedf9b..f7f6d068 100644 --- a/rust/candid/src/error.rs +++ b/rust/candid/src/error.rs @@ -1,6 +1,7 @@ //! `candid::Result = Result>` use serde::{de, ser}; +use std::collections::TryReserveError; use std::{io, num::ParseIntError}; use thiserror::Error; @@ -17,6 +18,9 @@ pub enum Error { #[error("binary parser error: {}", .0.first().map_or_else(|| "io error".to_string(), |f| format!("{} at byte offset {}", f.message, f.pos/2)))] Binread(Vec