How to use this crate without use of struct fields
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 384
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
I'm relatively new to Rust so bear with me. I'm working on a project that provides a Python API to Rust code via Pyo3. In my project I'm trying to enable fast serialization and deserialization using bincode. I read this crate can mitigate the performance issues I'm seeing (bincode takes 3 times longer than serialization/deserialization with serde_json).
It's not clear to me how to take advantage of this crate when I don't use a struct field to hold the data.
For reference, this is what the unedited, actual serialization and deserialization code snippet looks like, with the Pyo3 API intact:
pub fn to_bincode(&self) -> PyResult<Vec<u8>> {
Ok(serialize(&self).unwrap())
}
#[classmethod]
pub fn from_bincode(_cls: &PyType, encoded: Vec<u8>) -> PyResult<Self> {
Ok(deserialize(&encoded).unwrap())
}
With the API removed, I suppose would be the analogous code:
pub fn to_bincode(&self) -> Vec<u8> {
serialize(&self).unwrap()
}
pub fn from_bincode(encoded: Vec<u8>) -> Self {
deserialize(&encoded).unwrap()
}
See also: https://github.com/PyO3/pyo3/issues/100
How can I utilize this crate in this case?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rust serialization and deserialization snippets in the issue, along with the referenced PyO3 issue, and determine how this crate is intended to work when the data is not held in a struct field. Done means providing a clear, supported usage path for the shown PyO3 API or documenting why that usage is not supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- backend, data
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100