deser-pickle
Support for Python's pickle format for deser.
use ;
// `pickle.dumps({"user_id": 42, "roles": ["admin"]}, 4)`
let input = b"\x80\x04\x95$\x00\x00\x00\x00\x00\x00\x00}\x94(\x8c\x07user_id\x94K*\x8c\x05roles\x94]\x94\x8c\x05admin\x94au.";
let session: Session = from_slice.unwrap;
assert_eq!;
let output = to_vec.unwrap;
assert_eq!;
- Reads all protocols (0 to 5) like CPython's unpickler, but never imports or calls anything: objects are recorded with their class, arguments and state and passed on as their state (or items or arguments). The class is passed on out of band.
- Shared values are emitted at every place they are reached, values that contain themselves are cut with references. Both carry ids so that the graph can be restored.
- Writes protocols 2 to 5 (4 by default) that Python reads back, including objects of a class and shared and recursive values.
License and Links
- Documentation
- Issue Tracker
- License: Apache-2.0