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: Packable trait #11136

Open
wants to merge 5 commits into
base: 01-10-refactor_using_u128_in_contract_function_args
Choose a base branch
from

Conversation

benesjan
Copy link
Contributor

@benesjan benesjan commented Jan 9, 2025

Fixes #11285
Fixes #7728

Copy link
Contributor Author

benesjan commented Jan 9, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@benesjan benesjan force-pushed the 01-09-feat_packable_trait branch from 2c8f7e1 to 67fafc2 Compare January 17, 2025 22:10
@benesjan benesjan changed the base branch from master to 01-10-refactor_using_u128_in_contract_function_args January 17, 2025 22:10
@benesjan benesjan marked this pull request as ready for review January 18, 2025 00:06
@olehmisar
Copy link
Contributor

Would this require users to implement Serialize, Deserialize and Packable traits for custom structs that will be used as function parameters and can be stored in the storage?

Does it make sense to add this blanket implementation, so users are not forced to impl Packable if the storage size is irrelevant or is not more efficient than Serialize?

impl<let N: u32> Packable<N> for T 
where 
    T: Serialize<N> + Deserialize<N> 
{
    fn pack(self) -> [Field; N] {
        self.serialize()
    }

    fn unpack(packed: [Field; N]) -> Self {
        Self::deserialize(packed)
    }
}

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

Successfully merging this pull request may close these issues.

Implement Packable trait and use it for storage Separate Noir and Noir<>TS concerns from Serialize
2 participants