The exact implementation details for this need to be worked out, but the main idea is that any BorshDeserialize, BorshSerialize or ShankAccount struct will have a byte_size() method added via an implderive.
This will avoid hard coded consts which need to be manually updated each time a struct is changed.
The task is easy for fixed sized structs with fixed sized fields, but once Option, Vec and strings are included the developer will need to annotate that field in order to allow calculating the max length.
The exact implementation details for this need to be worked out, but the main idea is that any
BorshDeserialize
,BorshSerialize
orShankAccount
struct will have abyte_size()
method added via animpl
derive.This will avoid hard coded
const
s which need to be manually updated each time a struct is changed.The task is easy for fixed sized structs with fixed sized fields, but once
Option
,Vec
andstring
s are included the developer will need to annotate that field in order to allow calculating the max length.