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

support streaming bytes, not only protocol messages #20

Closed
jrouquie opened this issue Oct 2, 2020 · 2 comments
Closed

support streaming bytes, not only protocol messages #20

jrouquie opened this issue Oct 2, 2020 · 2 comments

Comments

@jrouquie
Copy link

jrouquie commented Oct 2, 2020

Feature request:

The low-level method open supports reading a file and iterating over bytes, ie just before calling ParseFromString: https://github.com/cartoonist/pystream-protobuf/wiki/Reading-from-a-stream#low-level-method-open
How about adding the same support on the writing side, ie add an option not to call SerializeToString?

This would allows to use the library with anything that can be serialized to bytes, not only protocol messages.

cartoonist added a commit that referenced this issue Jan 27, 2021
This commit resolves issue #20.
@cartoonist
Copy link
Owner

cartoonist commented Jan 27, 2021

Hi @jrouquie,

Cool feature. This commit (61c25a2) adds a serialize keyword argument which gets a function. Any function can be given to Stream class by this argument which serializes input objects to byte strings. This can also be lambda obj: obj for your purpose. By default, it calls SerializeToString method of input objects.

@cartoonist
Copy link
Owner

cartoonist commented Jan 28, 2021

Merged to master and included in v1.6.3 release. Feel free to reopen if there is any problem.

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

No branches or pull requests

2 participants