Struct prusst::MemSegment [] [src]

pub struct MemSegment<'a> { /* fields omitted */ }

View of a contiguous memory segment.

The design of MemSegment is meant to allow allocation at arbitrary addresses while preventing memory aliasing. This is achieved by allowing segments to be recursively split and by borrowing segments upon object allocation, thus preventing further splitting and allocation until the allocated object goes out of scope. For this reason, segments are neither copyable nor clonable.

Methods

impl<'a> MemSegment<'a>
[src]

[src]

Allocates an object at the beginning of the segment.

Panics

This function will panic if the beginning of the segment is not properly aligned for type T or if the size of T exceeds its capacity.

[src]

Allocates an object at the begining of the segment without initializing it.

This can save some unecessary initialization if the PRU is anyway going to initialize memory before it will be read by the host. In some cases, it can also be used to avoid trashing the stack with a large temporary initialization object if for some reason the compiler cannot inline the call to alloc.

Undefined Behavior

Reading an uninitialized object is undefined behavior (even for Copy types).

Panics

This function will panic if the beginning of the segment is not properly aligned for type T or if the size of T exceeds its capacity.

[src]

Position at which the segment starts (in bytes).

[src]

Position at which the segment ends (in bytes).

[src]

Splits the memory segment into two at the given byte position.

Note that positions (addresses) are absolute and remain valid after the splitting operation. If for instance a segment is split at 0x00001000, the begin method of the second segment hence created will return 0x00001000 and not 0x00000000.

Trait Implementations

impl<'a> Send for MemSegment<'a>
[src]

impl<'a> Sync for MemSegment<'a>
[src]