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

Serialize/Deserialize to/from Vec<u8> #57

Open
cisaacson opened this issue Jun 13, 2020 · 5 comments
Open

Serialize/Deserialize to/from Vec<u8> #57

cisaacson opened this issue Jun 13, 2020 · 5 comments

Comments

@cisaacson
Copy link

cisaacson commented Jun 13, 2020

Is there a way to serialize hibitset to bytes? I could implement Serde and use bincode, but wanted to know if there is an existing way to do this.

I tested adding optional serde to the source code and it works fine, if you like I can fork and submit a pull request.

@WaDelma
Copy link
Member

WaDelma commented Jun 14, 2020

I don't think there is a way to currently serialize hibitset.

@cisaacson
Copy link
Author

The optional serde patch I tried works fine, let me know if you would like a pull request.

To use it looks like this, super easy to use:

let serde_len = bincode::serialized_size(&set1).unwrap();
        let set1_buf = bincode::serialize(&set1).unwrap();

        let result_set1: BitSet = bincode::deserialize(&set1_buf).unwrap();

@WaDelma
Copy link
Member

WaDelma commented Jun 14, 2020

I wouldn't resist adding such feature, so if you want to create PR it would be appreciated.

We most likely want to have it under a feature flag so we wont incur unnecessary dependencies users of the library.

@cisaacson
Copy link
Author

Exactly how I implemented it (as an optional feature) :) I will submit a PR when I have fully tested it.

@cisaacson
Copy link
Author

The PR has been submitted, let me know if you need anything else.

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