You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, StreamWriter either borrows or takes ownership of the underlying writer when it is constructed. There is no way to rescind that borrow while retaining the current encoding state, e.g. to get access to the underlying encoder or to remove the borrow. Also dropping the writer will always execute some amount of IO-code. Since Rust checks borrow at compile time using scopes, that leads to the unfortunate situation where you easily can't store the StreamWriter next to the struct it was borrowed from and encapsulate the stream writer state further except by choosing the 'static, owned version which you can't back out of and which consumes the raw png encoder.
One idea was to introduce a StreamWriter::pause method and a complementary continue function. They would be similar to into_raw/from_raw pairs in that the caller should uphold the proper usage of their values but safe since we 'merely' protect the written image from being faulty, not a memory safety invariant.
The main problem here is the underlying zlib stream. It contains some amount of state that must be preserved to ensure that at least proper usage leads to a functional image. However, it also wraps the stream and thus must be unwrapped or saved itself. It's not clear how to achieve this with deflate, yet the switch to miniz_oxide for encoding could probably achieve the effect.
The text was updated successfully, but these errors were encountered:
Currently,
StreamWriter
either borrows or takes ownership of the underlying writer when it is constructed. There is no way to rescind that borrow while retaining the current encoding state, e.g. to get access to the underlying encoder or to remove the borrow. Also dropping the writer will always execute some amount of IO-code. Since Rust checks borrow at compile time using scopes, that leads to the unfortunate situation where you easily can't store theStreamWriter
next to the struct it was borrowed from and encapsulate the stream writer state further except by choosing the'static
, owned version which you can't back out of and which consumes the raw png encoder.One idea was to introduce a
StreamWriter::pause
method and a complementary continue function. They would be similar tointo_raw/from_raw
pairs in that the caller should uphold the proper usage of their values but safe since we 'merely' protect the written image from being faulty, not a memory safety invariant.The main problem here is the underlying zlib stream. It contains some amount of state that must be preserved to ensure that at least proper usage leads to a functional image. However, it also wraps the stream and thus must be unwrapped or saved itself. It's not clear how to achieve this with
deflate
, yet the switch tominiz_oxide
for encoding could probably achieve the effect.The text was updated successfully, but these errors were encountered: