spider-gazelle / bindata

BinData - Parsing Binary Data in Crystal Lang
MIT License
48 stars 5 forks source link

Update Object#to_io return type #5

Closed bcardiff closed 4 years ago

bcardiff commented 4 years ago

In Crystal 0.35 IO#write is supposed to return the written bytes. This propagates down to Object#to_io.

I didn't track how to get the information in bindata implementation. Since this is new feature no other shard is using it right now. I needed this patch to have a working version of https://github.com/crystal-community/jwt

Related to changes in shards 0.11 I recommend adding a crystal property in the shard.yml to state which crystal version are expected to be used with this shard.

If compatibility with older versions is wanted {% if compare_versions(Crystal::VERSION, "0.35.0-0") >= 0 %} can be used.

Feel free to close the PR and use it as input for an actual 🙈 migration.

stakach commented 4 years ago

Yeah, it'll require a little bit of thought to have it returning the actual bytes written efficiently. This works for now

bcardiff commented 4 years ago

@stakach I see that there is already a branch revert-io-write-size. Be aware that reverting it completely will prevent usage 0.35.0. Your call, I'm just raising awareness.

stakach commented 4 years ago

thanks, I'll see if I can keep it compatible with both