[−][src]Struct xalloc::ring::Ring
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 useu32
oru64
for this.
Implementations
impl<T: BinaryUInteger> Ring<T>
[src]
pub fn new(size: T) -> Self
[src]
Construct a RingRegion
.
size
must be smaller than T::max_value() >> 1
(this is a precaution
taken not to cause unintentional overflows).
pub fn is_empty(&self) -> bool
[src]
Return true
if Ring
has no allocated regions.
pub fn is_full(&self) -> bool
[src]
Return true
if Ring
has no free space.
pub fn alloc_back(&mut self, size: T) -> Option<(RingRegion<T>, T)>
[src]
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.
pub fn alloc_front(&mut self, size: T) -> Option<(RingRegion<T>, T)>
[src]
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.
pub fn alloc_back_aligned(
&mut self,
size: T,
align: T
) -> Option<(RingRegion<T>, T)>
[src]
&mut self,
size: T,
align: T
) -> Option<(RingRegion<T>, T)>
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.
pub fn alloc_front_aligned(
&mut self,
size: T,
align: T
) -> Option<(RingRegion<T>, T)>
[src]
&mut self,
size: T,
align: T
) -> Option<(RingRegion<T>, T)>
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.
pub fn dealloc_front_until(&mut self, r: RingRegion<T>)
[src]
Deallocate frontmost (first) regions until r
becomes the new frontmost
region. r
is not removed.
r
must be in Ring
.
Otherwise, Ring
might enter an inconsistent state and/or panic, but
does not cause an undefined behavior.
pub fn dealloc_back_until(&mut self, r: RingRegion<T>)
[src]
Deallocate backmost (last) regions until r
becomes the new backmost
region. r
is not removed.
r
must be in Ring
.
Otherwise, Ring
might enter an inconsistent state and/or panic, but
does not cause an undefined behavior.
pub fn dealloc_front(&mut self, r: RingRegion<T>)
[src]
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.
pub fn dealloc_back(&mut self, r: RingRegion<T>)
[src]
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
Auto Trait Implementations
impl<T> RefUnwindSafe for Ring<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Ring<T> where
T: Send,
T: Send,
impl<T> Sync for Ring<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Ring<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Ring<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,