Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

## 2026-02-27

### Candid 0.10.24

* Non-breaking changes:
+ Implement `DataSize` for `Principal`, enabling `Principal` as an element type in `BoundedVec`

## 2026-02-20

### Candid 0.10.23
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions rust/bench/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions rust/candid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "candid"
# sync with the version in `candid_derive/Cargo.toml`
version = "0.10.23"
version = "0.10.24"
edition = "2021"
rust-version.workspace = true
authors = ["DFINITY Team"]
Expand All @@ -16,7 +16,7 @@ keywords = ["internet-computer", "idl", "candid", "dfinity"]
include = ["src", "Cargo.toml", "LICENSE", "README.md"]

[dependencies]
candid_derive = { path = "../candid_derive", version = "=0.10.23" }
candid_derive = { path = "../candid_derive", version = "=0.10.24" }
ic_principal = { path = "../ic_principal", version = "0.1.0" }
binread = { version = "2.2", features = ["debug_template"] }
byteorder = "1.5.0"
Expand Down
9 changes: 6 additions & 3 deletions rust/candid/src/types/bounded_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,6 @@ mod tests {
}

mod data_size {
// We implement a standalone trait `DataSize` here and use it
// instead of `CountBytes`.
Comment thread
dsarlis marked this conversation as resolved.

/// Trait to reasonably estimate the memory usage of a value in bytes.
///
/// Default implementation returns zero.
Expand Down Expand Up @@ -416,6 +413,12 @@ mod data_size {
}
}

impl DataSize for ic_principal::Principal {
fn data_size(&self) -> usize {
self.as_slice().len()
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion rust/candid_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "candid_derive"
# sync with the version in `candid/Cargo.toml`
version = "0.10.23"
version = "0.10.24"
edition = "2021"
rust-version.workspace = true
authors = ["DFINITY Team"]
Expand Down
19 changes: 19 additions & 0 deletions rust/ic_principal/tests/principal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,22 @@ fn rangemap_steplite_impl_works() {
assert!(set.contains(&p2));
assert!(!set.contains(&Principal::from_slice(&[0, 1, 4, 0])));
}

#[test]
fn as_slice_len_principal() {
let anonymous_principal = Principal::anonymous();
assert_eq!(anonymous_principal.as_slice().len(), 1);

let management_canister = Principal::management_canister();
assert_eq!(management_canister.as_slice().len(), 0);

let key = b"42";
let self_authenticating = Principal::self_authenticating(key);
assert_eq!(self_authenticating.as_slice().len(), 29);

let from_slice = Principal::from_slice(&TEST_CASE_BYTES);
assert_eq!(from_slice.as_slice().len(), 9);

let from_text = Principal::from_text(TEST_CASE_TEXT).unwrap();
assert_eq!(from_text.as_slice().len(), 9);
}
Loading