Skip to content

Conversation

@Alon-Alexander
Copy link

Fixes #35

  • Combined from_stream and from_bytes by creating a as_stream utility.
  • Fixed a bug in from_stream where bytes hooks can change the field object (with code which already existed in from_bytes).
  • Renamed from_bytes_hook to pre_deserialization_hook but kept the old name there for backward-compatibility.

Add `from_stream` to all fields.
Create `as_stream` utility
Call `from_stream` from `from_bytes`
Copy link
Owner

@shustinm shustinm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great progress, but missed the point to remove code duplication

pre_bytes_hook = Struct.pre_bytes_hook
post_bytes_hook = Struct.post_bytes_hook
from_bytes_hook = Struct.from_bytes_hook
from_bytes_hook = Struct.pre_deserialization_hook
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not what this hook is about. The from_bytes_hook is a hook that happens during deserialization. So it should be renamed to deserialization_hook. The other hooks need to be renamed too. e. g. pre_bytes_hook -> pre_deserialization_hook

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, but notice that it is pre_serialization_hook (and post) and not pre_deserialization_hook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get rid of from_bytes/from_stream code duplication

2 participants