Struct ups::UpsPatch[][src]

pub struct UpsPatch {
    pub source_file_size: u64,
    pub target_file_size: u64,
    pub changes: Vec<(u64, Vec<u8>)>,
    pub source_crc32: u32,
    pub target_crc32: u32,
    pub patch_crc32: u32,
}
Expand description

Represents a ups patch

Fields

source_file_size: u64

The file size of the original file

target_file_size: u64

The file size of the final file

changes: Vec<(u64, Vec<u8>)>

The changes that have to be applied to the original file to get the final file. They are stored in a vector of tuples containing offset and change list where:

0, Offset: A u64 used as a pointer to the position where this change list begins

1, ChangeList: A vector of the XOR bytes that have to be applied to the source file in the current position.

source_crc32: u32

The crc32 checksum of the source file

target_crc32: u32

The crc32 checksum of the final file

patch_crc32: u32

The crc 32 checksum of the patch file itself

Implementations

Creates a Patch from the given source and target files

Arguments
  • source_content - The contents of the source/original file
  • target_content - The contents of the target/final file

Loads an already existing patch, if the given file contents don’t contain a valid UPS patch returns a UpsError

Arguments
  • content - The content of the patch file to load
Examples

Load a patch and throw a panic if the file isn’t a valid ups Patch

let patch = match UpsPatch::load(&file_content) {
    Ok(patch) => patch,
    Err(why) => panic!("Couldn't load UPS patch:{}", why)
};

Given the contents of a file, verifies that it is the expected source for the patch, applies the patch and verifies that the output is the expected target for the patch.

Arguments
  • source - The content of the source file
Examples

Load a patch, apply it and save to a variable if everything is ok or panic if something went wrong

Applies a patch to a given source file contents. This function doesn’t check for file to actually be the correct source file, it just applies the patch.

Returns a vector with the contents of the patch.ups file

Checks if the given file contents matches the source file for the UPS patch

Checks if the given file contents matches the target file for the UPS patch

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.