Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

token-2022: Introduce PackedSizeOf and relax BaseState trait #6332

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

joncinque
Copy link
Contributor

@joncinque joncinque commented Mar 5, 2024

Problem

As part of #6316, in order to create a Pod-compatible version of StateWithExtensions, we need to relax the requirement for BaseState to implement Pack, since it will implement Pod instead for the pod version of StateWithExtensions.

On the flip-side, we do need to know the size of the underlying type to move through the underlying buffer.

Solution

Introduce a new trait, PackedSizeOf, which only gives the packed length of a type. This is just a more limited version of the LEN on the Pack trait.

Relax the trait bound on BaseState so that it requires PackedSizeOf instead of Pack.

@joncinque joncinque requested a review from CriesofCarrots March 5, 2024 10:31
@joncinque joncinque merged commit c4239ba into solana-labs:master Mar 5, 2024
@joncinque joncinque deleted the tk22pso branch March 5, 2024 20:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants