Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: Enhance Bound Enum with Utility Methods and Refactor Storable Trait #142

Merged
merged 7 commits into from
Sep 22, 2023

Conversation

b3hr4d
Copy link
Contributor

@b3hr4d b3hr4d commented Sep 21, 2023

Description:

This PR introduces utility methods to the Bound enum, enhancing its functionality and usability. These methods are used to refactor the Storable trait, making it cleaner and more maintainable.

Use-Case:

I am developing a library aimed at simplifying the use of stable memory structures. For example, consider a TaskTimerEntry struct defined as:

pub struct TaskTimerEntry<T> {
    pub time: NanoTimeStamp,
    pub task: T,
}

To make this struct bounded, I can now easily specify:

const BOUND: Bound = Bound::Bounded {
    is_fixed_size: false,
    max_size: 8 + T::BOUND.max_size(),
};

Key Changes:

Introduced max_size and is_fixed_size methods to Bound enum.

Impact on Storable Trait:

The utility methods have been integrated into the Storable trait, enhancing its readability and maintainability without altering its core functionality.

Types of Changes:

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

@b3hr4d b3hr4d requested review from roman-kashitsyn and a team as code owners September 21, 2023 12:59
@ghost ghost added cla:agreed labels Sep 21, 2023
@b3hr4d b3hr4d changed the title feat - Enhance Bound Enum with Utility Methods and Refactor Storable Trait feat: Enhance Bound Enum with Utility Methods and Refactor Storable Trait Sep 21, 2023
src/storable.rs Outdated Show resolved Hide resolved
src/storable.rs Show resolved Hide resolved
src/storable.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ielashi ielashi left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! It'd be great if you could update the description to fit the new changes.

src/storable.rs Outdated Show resolved Hide resolved
@ielashi ielashi merged commit 4f7c8cb into dfinity:main Sep 22, 2023
4 checks passed
ielashi added a commit that referenced this pull request Sep 25, 2023
#142 introduced some utility methods in the `Bound` struct. We had
copies of these utility methods elsewhere, which are no longer needed
and are removed in this commit.
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants