Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Serde Serialize and Deserialize traits for the RbTree in the ic-certified-map crate. #399

Merged
merged 15 commits into from
Jan 12, 2024
Merged

feat: Serde Serialize and Deserialize traits for the RbTree in the ic-certified-map crate. #399

merged 15 commits into from
Jan 12, 2024

Conversation

levifeldman
Copy link
Contributor

@levifeldman levifeldman commented May 27, 2023

This change adds the CandidType, serde Serialize and Deserialize traits to the RbTree in the ic-certified-map crate.
Useful for serializing a canister's certified data during upgrades.

This PR changes the 'static generic lifetime bounds on the RbTree impl blocks and replaces it with a custom lifetime 't.

How Has This Been Tested?

library/ic-certified-map/src/rbtree/test.rs

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@ghost ghost added the cla:agreed label May 27, 2023
Copy link
Contributor

@adamspofford-dfinity adamspofford-dfinity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be implemented as a plain map serialization rather than encoding the full tree structure. Unlike the HashTree structure, the RbTree internal structure is not relevant to the user.

@levifeldman
Copy link
Contributor Author

Hey, I replaced the 'static generic lifetime bounds on the RbTree impl blocks for a custom lifetime 't.

@levifeldman
Copy link
Contributor Author

and added a test

@levifeldman
Copy link
Contributor Author

Looks like the new canister import functionality is messing with the PR check: https://github.com/dfinity/cdk-rs/actions/runs/6156757139/job/16706101327?pr=399

Some binary formats like bincode need the size of the map known before serializing the map items.

Added bincode serialization in the serde test.
@levifeldman
Copy link
Contributor Author

levifeldman commented Jan 9, 2024

Hey @adamspofford-dfinity, can you merge this?

@adamspofford-dfinity adamspofford-dfinity merged commit 1da310b into dfinity:main Jan 12, 2024
16 checks passed
@levifeldman levifeldman deleted the levi-rbtree-serialize-deserialize branch January 15, 2024 14:46
@levifeldman
Copy link
Contributor Author

Thanks Adam @adamspofford-dfinity for the review and merge.

My apologies for putting off addressing your feedback for a while there. Won't happen again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants