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

Streaming? #254

Closed
cedws opened this issue Oct 23, 2018 · 5 comments
Closed

Streaming? #254

cedws opened this issue Oct 23, 2018 · 5 comments

Comments

@cedws
Copy link

@cedws cedws commented Oct 23, 2018

Is streaming possible with bincode? It looks like all the serialisation functions have a Sized bound, but I'm fuzzy on how exactly this works.

I need to serialise a struct that will sometimes be too large to hold in memory all at one time, because it will have a field that contains file data. The only way I can see around this is to use a BufReader so that bytes can be read as a stream, but BufReader does not derive serde::Serialize.

Thanks.

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Oct 24, 2018

What do you mean by streaming?

Also, even if you managed to serialize the file via streaming, what would you do to deserialize it?

@cedws
Copy link
Author

@cedws cedws commented Oct 24, 2018

I mean Reader/Writer, the ability to process in chunks. I assume that I would be able to use the deserialize_from function in order to deserialize the large amount of data.

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Oct 25, 2018

are you serializing a bunch of smaller structs?

Rust doesn't deal with uninitialized data very well, so having partially constructed structs isn't really possible.

@cedws
Copy link
Author

@cedws cedws commented Oct 25, 2018

Not necessarily a bunch, it could be just one. One of the values in the struct will be the contents of a file though, which could be gigabytes, and might not always fit in memory all at once. I think I'm going to look into other methods of... chunked serialisation? I think flatbuffers might do it.

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Oct 25, 2018

Yeah, I don't think that Bincode can help you here.

@TyOverby TyOverby closed this Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.