ttocsneb / mbon

Marked Binary Object Notation
3 stars 0 forks source link

Serde Interface #2

Open tryoxiss opened 8 months ago

tryoxiss commented 8 months ago

I'm not sure how feasable this is, my experince with serde is very limited, but having implementations for Serialize/Deserialize would be helpful for many cases (e.g., where a crate has a serde feature which auto-derives those traits) so this format can be used in more places. It would probably just end up being API calls to the underlying engine.

ttocsneb commented 8 months ago

It's definitely doable, and I plan on implementing it. I think it can really only be implemented in the final stages of the rewrite.

tryoxiss commented 8 months ago

Yeah thats about what I would expect. Still good to create tracking issues when we think of these things though!\

One suggestion however, currently the docs refrence crate::engine::Engine. I feel like since this may be used in conjuntion with other parsing engines (e.g., json), it should be more like crate::engine::Mbon (naming the type Mbon instead of Engine). That way its also more clear for assigned variables, as thier type would be Mbon instead of Engine which is ambigous. (so end users import mbon::engine::Mbon)

EDIT: Thinking about it more, the type should probably be at the root as its all people would be using the crate for, so they would import mbon::Mbon (which could of course just be a re-export of a type held deeper in for organisation)

Sorry I think about APIs and cleanliness more than I probably should.

ttocsneb commented 7 months ago

I just pushed a change afc76fe which adds Serializer/Deserializer implementations to Item. I think this would be the primary way that people would use serde with mbon where they could have the engine find a partial item in the data, then load the whole item into memory and deserialize into a custom type.