Struct xalloc::ring::Ring

source ·
pub struct Ring<T> { /* private fields */ }
Expand description

A dynamic external memory allocator providing the functionality of a circular buffer.

See the module-level documentation for more.

Type parameters

  • T is an integer type used to represent region sizes. You usually use u32 or u64 for this.

Implementations

Construct a RingRegion.

size must be smaller than T::max_value() >> 1 (this is a precaution taken not to cause unintentional overflows).

Return true if Ring has no allocated regions.

Return true if Ring has no free space.

Allocate a region of the size size to the back of the allocated region.

Returns a handle of the allocated region and its offset if the allocation succeeds. Returns None otherwise.

size must not be zero.

Allocate a region of the size size to the front of the allocated region.

Returns a handle of the allocated region and its offset if the allocation succeeds. Returns None otherwise.

size must not be zero.

Allocate a region of the size size with a given alignment requirement to the back of the allocated region.

Returns a handle of the allocated region and its offset if the allocation succeeds. Returns None otherwise.

  • align must be a power of two.
  • size must not be zero.

Allocate a region of the size size with a given alignment requirement to the front of the allocated region.

Returns a handle of the allocated region and its offset if the allocation succeeds. Returns None otherwise.

  • align must be a power of two.
  • size must not be zero.

Deallocate the frontmost (first) region.

r must be the current frontmost region of Ring. Otherwise, Ring might enter an inconsistent state and/or panic, but does not cause an undefined behavior.

Deallocate the backmost (last) region.

r must be the current backmost region of Ring. Otherwise, Ring might enter an inconsistent state and/or panic, but does not cause an undefined behavior.

Trait Implementations

Formats the value using the given formatter. 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

Returns the argument unchanged.

Calls U::from(self).

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

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.