borsh-rs
borsh-rs copied to clipboard
Add derive macro attribute to specify borsh crate
Add derive macro attribute like serde container's crate
attr (test):
- To be able to work with byte blobs built with legacy borsh.
- To be able to use re-exported borsh crate for
BorshSerialize
,BorshDeserialize
derives.
#[derive(borsh::BorshSerialize)]
#[borsh(crate = "legacy_borsh")]
struct NearLog;
@quasiyoke Good point! Will you be up to prepare and submit a PR?
I have this need also, and i can try and prepare a PR
@cybersoulK do you work on this?
Can I work on this ?
@iho I didn't end up working on it, because my new implementation does not require it. Borsh is only a way to serialize data, which should be imported in the original project anyways. The library allows the user to implement its own serialization method, which is a much better approach. if you want to abstract borsh derives, you can use macro_rules_attribute to create a local abstraction, instead of making it opinionated in the library. I do this to abstract a common group of derives. but if it's only borsh, i would write it explicitely, since it's clearer on what's going in the whole picture of the codes.