near / borsh-rs

Rust implementation of Binary Object Representation Serializer for Hashing
https://borsh.io/
Apache License 2.0
310 stars 67 forks source link

noob: Serialize to specific array #28

Closed FrankC01 closed 3 years ago

FrankC01 commented 3 years ago

Early (rust, borsh, just about everything) learner.

Is it possible to provide the serialize a specific location to serialize into?

For example, if I have a 1 MB array and I would like to serialize to it after the 1024th byte.

Any help is appreciated.

frol commented 3 years ago

@FrankC01 Hey! You are welcome to rust, borsh, near learning!

All the structures implementing BorshSerialize trait has serialize method, which receives any writer to it. Thus, you can pass a vector or a slice into it. See the example in this PR #29

FrankC01 commented 3 years ago

Looks good, I'll give it a whirl! Thanks