Skip to main content

Extent

Enum Extent 

Source
pub enum Extent {
    Bytes(u64),
    Member(u32),
    Sum(Vec<Extent>),
    RoundUp(Box<Extent>, u64),
    Max(Vec<Extent>),
}
Expand description

How many bytes something is, where the answer is not a number here.

A member of a structure declared inside a function may be a variable length array, and then the size of the structure and the offsets of the members after that one are worked out where the declaration is reached rather than where it is written. This is the recipe for working one out: a small tree over the sizes of the members, which whoever generates code walks once it has a value for each of those.

A recipe rather than an expression because this crate has no expressions in it. What it names is a member by index, and the one thing a reader has to be able to do with that is ask how large the member’s type is, which is a question it already answers for every other type.

Variants§

§

Bytes(u64)

A number of bytes, known here.

§

Member(u32)

How large the type of the member at this index is.

§

Sum(Vec<Extent>)

The sum of these, which is where a member sits once what is in front of it is counted.

§

RoundUp(Box<Extent>, u64)

The first rounded up to a multiple of the second, which is an alignment.

§

Max(Vec<Extent>)

The largest of these, which is how long a union is.

Implementations§

Source§

impl Extent

Source

pub fn sum(parts: Vec<Extent>) -> Extent

The sum of the parts, folded where the parts are numbers.

Folding here rather than in the reader because nearly every one of these has a constant in it and most of them are nothing else: a member two members past the variable one is at the same place as the member before it plus a number, and adding the two numbers here is what keeps the recipe the size of the thing that varies rather than the size of the record.

Source

pub fn round_up(self, to: u64) -> Extent

The extent rounded up to a multiple of to, folded where it is a number.

Source

pub fn max(parts: Vec<Extent>) -> Extent

The largest of the parts, folded where the parts are numbers.

Trait Implementations§

Source§

impl Clone for Extent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Extent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Extent

Source§

impl PartialEq for Extent

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Extent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.