mkups 0.1.0

Toolkit for creating, applying, and inspecting .ups patches
Documentation
//! Common data types for handling UPS patches

/// UPS file header.
#[derive(Debug, PartialEq, Eq)]
pub struct Header {
    /// Source file length.
    pub src_len: usize,
    /// Destination file length.
    pub dst_len: usize,
}

/// UPS hunk. In the UPS file, each hunk is terminated by a zero byte. This
/// zero byte is *not* included in this struct.
#[derive(Debug, PartialEq, Eq)]
pub struct Hunk<'a> {
    /// Bytes to copy from the input file verbatim.
    pub skip: usize,
    /// Bytes to XOR with the input file.
    pub xor: &'a [u8],
}

/// UPS trailer containing checksums. These checksums are correctly generated by
/// [`create`](crate::create::create), but are not verified by [`apply`](crate::apply).
#[derive(Debug, PartialEq, Eq)]
pub struct Trailer {
    /// Checksum of the source file.
    pub src_crc: u32,
    /// Checksum of the destination file.
    pub dst_crc: u32,
    /// Checksum of the UPS patch. This field is not included in the checksum calculation.
    pub ups_crc: u32,
}

impl Trailer {
    /// Length of the trailer in bytes.
    pub const LENGTH: usize = 12;
}