casey / casey/x-serialization-format
How to deal with errors?
- Dominant language
- Rust
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
The only error that can occur when serializing is an error from the underlying allocator:
- SliceAllocator: Out of space in slice
- VecAllocator: reserving space in vec failed
- FileAllocator: io::Error
During serialization, the underlying allocator is being written to with every call. It would be unfortunate to make every call return a result.
One possibility is, if the allocator encounters an error, the error is saved and all further writes are ignored. Then, when `.done()` is called, it should return `Result`. This has the advantage that only the final `done()` is fallible. It has the disadvantage that all the writes to the allocator after the error will be unnecessary.
Another possibility is to allow the user to select two versions of serialization, fallible and infallible, and be able to select between them. I do worry that the code for this will be quite messy and involve a lot of duplication.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.