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

RFC - Stream deserialize #296

Open
dantswain opened this issue Oct 21, 2017 · 2 comments
Open

RFC - Stream deserialize #296

dantswain opened this issue Oct 21, 2017 · 2 comments

Comments

@dantswain
Copy link
Collaborator

Example use cases are streaming IO and large files.

It should be feasible to do something like this:

def deserialize_stream(stream, prototype_object \\ %__MODULE__{}) do
  Stream.transform(stream, {prototype_object, ""}, fn data, {object, pvs_remainder} ->
    __MODULE__.deserialize_partial(object, pvs_remainder <> data)
  end)
end

where deserialize_partial(t, binary) :: {t, binary} would deserialize as much of an object as it can get from the input data, merge it with the input object, and return the new object along with whatever data was left over (e.g., a partial field).

@jparise jparise added the rfc label Oct 22, 2017
@jparise
Copy link
Collaborator

jparise commented Oct 22, 2017

That sounds useful to me. How would errors propagate?

@dantswain
Copy link
Collaborator Author

dantswain commented Oct 23, 2017 via email

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

No branches or pull requests

2 participants