Skip to content

Commit 3958b13

Browse files
Merge branch 'main' into EXC-1404-memory-manager-support-freeing-a-memory
2 parents a58ba30 + 0375df2 commit 3958b13

File tree

6 files changed

+52
-6
lines changed

6 files changed

+52
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ic-stable-structures"
3-
version = "0.6.0-beta.0"
3+
version = "0.6.0-beta.1"
44
edition = "2021"
55
description = "A collection of data structures for fearless canister upgrades."
66
homepage = "https://docs.rs/ic-stable-structures"

examples/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/btreemap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ use allocator::Allocator;
3636
pub use iter::Iter;
3737
use iter::{Cursor, Index};
3838
use node::{DerivedPageSize, Entry, Node, NodeType, PageSize, Version};
39-
use std::borrow::Cow;
4039
use std::marker::PhantomData;
4140
use std::ops::{Bound, RangeBounds};
41+
use std::{borrow::Cow, fmt};
4242

4343
#[cfg(test)]
4444
mod proptests;
@@ -1194,8 +1194,8 @@ pub enum InsertError {
11941194
ValueTooLarge { given: usize, max: usize },
11951195
}
11961196

1197-
impl std::fmt::Display for InsertError {
1198-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1197+
impl fmt::Display for InsertError {
1198+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11991199
match self {
12001200
Self::KeyTooLarge { given, max } => {
12011201
write!(

src/cell.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
use crate::storable::Storable;
33
use crate::{Memory, WASM_PAGE_SIZE};
44
use std::borrow::{Borrow, Cow};
5+
use std::fmt;
56

67
#[cfg(test)]
78
mod tests;
@@ -45,6 +46,26 @@ pub enum InitError {
4546
ValueTooLarge { value_size: u64 },
4647
}
4748

49+
impl fmt::Display for InitError {
50+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51+
match self {
52+
InitError::IncompatibleVersion {
53+
last_supported_version,
54+
decoded_version,
55+
} => write!(
56+
f,
57+
"Incompatible version: last supported version is {}, but the memory contains version {}",
58+
last_supported_version, decoded_version
59+
),
60+
InitError::ValueTooLarge { value_size } => write!(
61+
f,
62+
"The initial value is too large to fit into the memory: {} bytes",
63+
value_size
64+
),
65+
}
66+
}
67+
}
68+
4869
/// Indicates a failure to set cell's value.
4970
#[derive(Debug, PartialEq, Eq)]
5071
pub enum ValueError {

src/log.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
use crate::{read_u64, safe_write, write_u64, Address, GrowFailed, Memory, Storable};
5858
use std::borrow::Cow;
5959
use std::cell::RefCell;
60+
use std::fmt;
6061
use std::marker::PhantomData;
6162
use std::thread::LocalKey;
6263

@@ -98,6 +99,30 @@ pub enum InitError {
9899
InvalidIndex,
99100
}
100101

102+
impl fmt::Display for InitError {
103+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104+
match self {
105+
InitError::IncompatibleDataVersion {
106+
last_supported_version,
107+
decoded_version,
108+
} => write!(
109+
f,
110+
"Incompatible data version: last supported version is {}, but decoded version is {}",
111+
last_supported_version, decoded_version
112+
),
113+
InitError::IncompatibleIndexVersion {
114+
last_supported_version,
115+
decoded_version,
116+
} => write!(
117+
f,
118+
"Incompatible index version: last supported version is {}, but decoded version is {}",
119+
last_supported_version, decoded_version
120+
),
121+
InitError::InvalidIndex => write!(f, "Invalid index"),
122+
}
123+
}
124+
}
125+
101126
#[derive(Debug, PartialEq, Eq)]
102127
pub enum WriteError {
103128
GrowFailed { current_size: u64, delta: u64 },

0 commit comments

Comments
 (0)