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
impl Extent
Sourcepub fn sum(parts: Vec<Extent>) -> Extent
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.