Crate pupper[−][src]
Expand description
A Sony PlayStation 3 PUP (PlayStation Update Package) implementation.
Overview
The PS3 receives software updates in a file format called ‘PUP’. These packages are essentially ‘flat’ file systems: they contain individual files, or ‘segments’, but lack any hierarchical structure.
This crate facilitates the creation and (de)serialization of PUPs.
Examples
Let’s first create a new Pup
and assign it an image version:
use pupper::{Pup, Segment}; let segments = Vec::<Segment>::new(); let image_version: u64 = 0xAAAA_BBBB; let pup = Pup::new(segments.clone(), image_version); assert_eq!(segments, pup.segments); assert_eq!(image_version, pup.image_version);
As you can see, Pup
is, for most intents and purposes, a POD type. Pup::image_version
is a public u64
, and Pup::segments
is transparently a Vec<Segment>
.
Let’s now create a segment and add it to the Pup
we previously created:
use pupper::SegmentId; let id = SegmentId(0x100); let data = std::fs::read("foo.txt").unwrap(); let segment = Segment::new(id, data.clone()); // Segment is (mostly) a POD type, too! assert_eq!(id, segment.id); assert_eq!(data, segment.data); pup.segments.push(segment.clone()); assert_eq!(segment, pup.segments[0]);
Finally, let’s serialize the entire Pup
. Afterwards, we’ll deserialize it to confirm the
conversions were lossless:
use pupper::Pup; use std::convert::TryFrom as _; // Serialize the PUP. let data = Vec::<u8>::from(&pup); // Deserialize the PUP. assert_eq!(Ok(pup), Pup::try_from(data.as_slice()));
Structs
Digest | A SHA-1 digest. |
Magic | The file magic of a PUP. Always |
Pup | A PS3 PUP (PlayStation Update Package). |
Segment | An individual file contained in a |
SegmentId | The ID of a |
Enums
Error | An erroneous result returned by |
Constants
HMAC_KEY | The PUP HMAC key. |
Traits
FixedSize | Has a fixed, or constant, size. |