Closed FrankC01 closed 2 years ago
@nearmax Any input to my question above?
@FrankC01 borsh-rs is designed to be static, so it is going to be a completely separate effort to implement a dynamic version of it. It would even make sense to consider using serde
and publish it as a new crate.
let c = B::try_from_slice(&b).unwrap(); // THROWS EXCEPTION
What would be the type of variable c
in your example? You cannot expect it to be of type B
, right? Type B
is an empty struct.
So after chatting on Discord I realize that my example was based on a misunderstanding on my part. I'm working on what I needed by parsing the inbound YAML and instantiating necessary constructs which reflect Type and then use standard Borsh deserialize
on the input vector
@FrankC01 I see. Let's close this issue. Feel free to create a new one once you have clarity on your side
@nearmax
I have a yaml file describing a struct. I would like to create a process that can interpret the yaml declaration and deserialize from a data buffer where the actual
struct
(or whatever valid and supported Borsh type) has been serialized.Is there a way, using BorshSchema???, to accomplish this?
Here is what I thought I needed to do, however; the last line throws exception: