enarx / ciborium

CBOR utilities
Other
259 stars 61 forks source link

Request for zero-copy deserializing #36

Open bdbai opened 2 years ago

bdbai commented 2 years ago

When I tried deserializing a structure with borrowed strings, an error was returned, stating that an owned string was not expected. It would be great to support zero-copy deserializing.

sunny-g commented 2 years ago

FYI, this probably isn't possible unless the Deserializer is implemented with a buffer or reads the entire Read into memory first. https://stackoverflow.com/questions/60801133/how-do-i-use-serde-to-deserialize-structs-with-references-from-a-reader

bdbai commented 2 years ago

@sunny-g thanks for pointing that out. But all in all, zero copy could not be achieved without the deserializer supporting it regardless of how I use this library or serde.

ahmedcharles commented 9 months ago

I have been looking at the design of https://github.com/3Hren/msgpack-rust for insight into how to approach this in terms of api. Would anyone have a better idea? This is similar to how serde_json does the same thing. I would plan to keep ciborium-io's support for no_std, etc.