deser-php 0.10.1

PHP serialize format support for deser
Documentation
  • Coverage
  • 100%
    29 out of 29 items documented14 out of 14 items with examples
  • Size
  • Source code size: 164.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.2 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mitsuhiko/deser
    455 8 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mitsuhiko

deser-php

Support for PHP's serialization format (the format of PHP's serialize and unserialize) for deser.

use deser::{Deserialize, Serialize};

#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Session {
    user_id: u64,
    roles: Vec<String>,
}

let input = br#"a:2:{s:7:"user_id";i:42;s:5:"roles";a:1:{i:0;s:5:"admin";}}"#;
let session: Session = deser_php::from_slice(input).unwrap();
assert_eq!(session.roles, ["admin"]);
assert_eq!(deser_php::to_vec(&session).unwrap(), input);
  • Reads everything unserialize reads: arrays, objects (with their class and the visibility of their properties out of band), enum cases, custom serialized objects and the old escaped strings (S:). Arrays whose keys are 0, 1, ... are sequences, all others maps.
  • Never instantiates classes or runs code: objects are maps.
  • Writes what serialize writes, including PHP's float formatting.
  • References (r: and R:) are passed through as markers and are not resolved, which makes them mostly useless beyond writing the input back unchanged.

License and Links