Struct Size
pub struct Size {
pub start_byte: usize,
pub end_byte: usize,
}
Expand description
A range of bytes.
Fields§
§start_byte: usize
The lowest index included in the range.
end_byte: usize
The highest index included in the range.
Implementations§
§impl Size
impl Size
pub const fn new(start_byte: usize, end_byte: usize) -> Self
pub const fn new(start_byte: usize, end_byte: usize) -> Self
Creates a new range from the provided values.
pub const fn qword() -> Self
pub const fn qword() -> Self
Returns Size::new(0, 7)
.
pub fn union(&self, other: &Self) -> Self
pub fn union(&self, other: &Self) -> Self
Returns a union of the two ranges.
pub fn overlapping_area(&self, other: Size) -> Option<Size>
pub fn overlapping_area(&self, other: Size) -> Option<Size>
Returns the overlapping area between the two sizes. If the two sizes do not overlap, returns None.
pub fn split_by_overlap(
&self,
existing_size: Size,
) -> Option<(Option<Size>, Size, Option<Size>)>
pub fn split_by_overlap( &self, existing_size: Size, ) -> Option<(Option<Size>, Size, Option<Size>)>
Computes the union of the two sizes, and splits it by overlapping area. Returns None is the sizes do not overlap.
Returns a triple of (before, overlapping, after)
.
before
is the area in the union < overlapping
.
overlapping
is the overlapping area between the two sizes.
after
is the area in the union > overlapping
.
pub fn try_glue(&self, other: &Size) -> Option<Size>
pub fn try_glue(&self, other: &Size) -> Option<Size>
If the size and other
occur consecutively one after the other, returns a size that contains both.
pub fn select_mask(&self, mask: Option<u64>) -> Option<u64>
pub fn select_mask(&self, mask: Option<u64>) -> Option<u64>
Crops mask
to only have bits set in the area described by this size.
pub fn iter_byte_indices(&self) -> impl Iterator<Item = usize>
pub fn iter_byte_indices(&self) -> impl Iterator<Item = usize>
Returns an iterator that yields all byte indices in this size
Trait Implementations§
§impl<'de> Deserialize<'de> for Size
impl<'de> Deserialize<'de> for Size
§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
§impl JsonSchema for Size
impl JsonSchema for Size
§fn schema_name() -> String
fn schema_name() -> String
§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more§impl Ord for Size
impl Ord for Size
§impl PartialOrd for Size
impl PartialOrd for Size
impl Copy for Size
impl Eq for Size
impl StructuralPartialEq for Size
Auto Trait Implementations§
impl Freeze for Size
impl RefUnwindSafe for Size
impl Send for Size
impl Sync for Size
impl Unpin for Size
impl UnwindSafe for Size
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more