Struct test_assembler::Section[][src]

pub struct Section {
    pub endian: Endian,
    // some fields omitted
}
Expand description

A section is a sequence of bytes, constructed by appending bytes to the end.

Sections have a convenient and flexible set of member functions for appending data in various formats: big-endian and little-endian signed and unsigned values of different sizes, and raw blocks of bytes.

There are methods for appending each of u8, u16, u32, and u64 in each of big, little, or the Section’s default endianness. The method names are {D,L,B}{8,16,32,64} for each variant, so D16 writes a u16 in the Section’s default endianness, and L64 writes a u64 in little-endian byte order.

Each of these methods also accepts a Label to write non-constant values.

See the module-level documentation for examples.

Fields

endian: Endian

The current endianness of the writer.

This sets the behavior of the D appending functions.

Implementations

Construct a Section with platform-default endianness.

Construct a Section with endian endianness.

Return the current size of the section.

Return a Label that will resolve to the final size of the section.

This label is undefined until get_contents is called.

Get the contents of this section as a slice of bytes.

Consumes the section. If there were still undefined labels, return None.

Return a label representing the start of the section.

It is up to the user whether this label represents the section’s position in an object file, the section’s address in memory, or what have you; some applications may need both, in which case this simple-minded interface won’t be enough. This class only provides a single start label, for use with the here and mark methods.

A label representing the point at which the next appended item will appear in the section, relative to start.

Set the value of start to value.

Set label to here, and return this section.

Append data to the end of this section, and return this section.

Append section’s contents to the end of this section.

Any Labels that were appended to section will not be resolved until this section is finalized. Return this section.

Append count copies of byte to the end of this section.

Return this section.

Jump to the next location aligned on an alignment-byte boundary, relative to the start of the section.

Fill the gap with zeroes. alignment must be a power of two. Return this section.

Append byte with the Section’s default endianness.

byte may be a Label or a u8. Return this section.

Append byte as little-endian (identical to D8).

Return this section.

Append byte as big-endian (identical to D8).

Return this section.

Append word with the Section’s default endianness.

word may be a Label or a u16. Return this section.

Append word as little-endian.

word may be a Label or a u16. Return this section.

Append word as big-endian.

word may be a Label or a u16. Return this section.

Append dword with the Section’s default endianness.

dword may be a Label or a u32. Return this section.

Append dword as little-endian.

dword may be a Label or a u32. Return this section.

Append dword as big-endian.

dword may be a Label or a u32. Return this section.

Append qword with the Section’s default endianness.

qword may be a Label or a u32. Return this section.

Append qword as little-endian.

qword may be a Label or a u32. Return this section.

Append qword as big-endian.

qword may be a Label or a u32. Return this section.

Trait Implementations

Returns the “default value” for a type. 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

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.