Add 64-bit offset support for std::io traits

4
closed
ncpenke
ncpenke
Posted 4 months ago

Add 64-bit offset support for std::io traits #333

To make effective use of larger stable storage size, it would be useful to manipulate stable storage via std::io::Read and std::io::Write traits.

ncpenke
ncpenke
Created 4 months ago

This commit fixes this by introducing a new StableIO structure that implements both std::io::Read, and std::io::Write. The existing logic for StableWriter and StableReader is moved under this structure, andStableWriter and StableReader are reimplemented as wrappers around StableIO.

The motivation for this approach was to allow backwards compatibility with existing API, while layering the new functionality/API on top.

This also fixes https://github.com/dfinity/cdk-rs/issues/334.

If you're interested, I can submit a PR.

ncpenke
ncpenke
Created 4 months ago

A further iteration was made by my colleague https://github.com/dmidem/cdk-rs/commit/653892c8f5546cbf1bbd4d1c509443bd4df3389a to improve the readability by splitting logic into several files.

In general, happy to make the appropriate cleanup/changes if this functionality seems relevant to cdk-rs.

lwshang
lwshang
Created 4 months ago

Thanks for the suggestion. Please file a PR.

ncpenke
ncpenke
Created 4 months ago

Thanks @lwshang created a PR. Happy to incorporate any feedback.