Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Buf_write.of_flow #796

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vog
Copy link

@vog vog commented Feb 9, 2025

For buffered serialization into a flow, at the moment there is only Buf_write.with_flow, so those serializers are expected to always run wrapped within a single function.

This PR introduces Buf_write.of_flow which allows a serializer to outlive its invocation, but instead being restricted by a surrounding Switch, as usual. Also, proper closing of the write is ensured by Switch.on_release in success as well as error cases.. This makes Buf_write more straight forward to use e.g. in network protocols, which otherwise need unfortunate workarounds like this one:

Moreover, Buf_write.with_flow is simplified by just calling Buf_write.of_flow within a local Switch.

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.

1 participant