Struct memoverlay::Patch

source ·
pub struct Patch { /* private fields */ }
Expand description

represents a memory patch. It is not allowed to create an empty patch

Example

use memoverlay::{SolidPatch, Patch};
assert!(Patch::new(10, &[0,1,2,3,4,5,6,7,8,9][..]).is_ok());
assert!(Patch::new(10, &[][..]).is_err());
assert!(Patch::new(10, &[0,1,2,3,4,5,6,7,8,9][3..3]).is_err());

Implementations§

returns a unique id of this patch. Two patches have the same id if they have the same position and the same length. If two patches have the same offset, than the patch with the greater length has te greater id

returns the offset of the first byte of this patch

returns the offset of the first byte after this patch

returns the offset of the first byte of this patch

returns the offset of the last byte of this patch, or None if the patch has a length of zero

checks if two patches overlap each other

Example
use memoverlay::{SolidPatch, Patch};

let patch1 = Patch::new(10, &[0,1,2,3,4,5,6,7,8,9][..]).unwrap();
assert!(patch1.overlaps(&patch1));

let patch2 = Patch::new(12, &[1,2,3][..]).unwrap();
assert!(patch1.overlaps(&patch2));
assert!(patch2.overlaps(&patch1));

let patch3 = Patch::new(15, &[1,2,3,4,5][..]).unwrap();
assert!(patch1.overlaps(&patch3));
assert!(! patch2.overlaps(&patch3));

let patch4 = Patch::new(0, &[0,1,2,3,4,5,6,7,8,9][..]).unwrap();
assert!(! patch1.overlaps(&patch4));

Trait Implementations§

Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.