Struct jenga::Frame
[−]
[src]
pub struct Frame<'a> { /* fields omitted */ }
An allocation Frame.
Data can be allocated using:
place
which allocates b bytes of type T and returns a mutable view to it.place_raw
if you really want unsafe code.place_iter
will drain the given iterator and return a mutable view to the data.cursor
gives you a gowing buffer that supportsio::Write
.writer
does the same, but supportsfmt::Write
and is can be turned into&str
All returned buffers are valid for the lifetime of the Frame
.
Methods
impl<'a> Frame<'a>
[src]
fn from_slice(s: &'a mut [u8]) -> Frame<'a>
Turn a slice of memory into an allocator Frame.
fn try_place<T>(&mut self, count: usize) -> Result<FArray<'a, T>, OutOfMemory> where
T: Default,
T: Default,
Allocate count
elements of T
.
Returns OutOfMemory
if there is not enough space left.
fn place<T>(&mut self, count: usize) -> FArray<'a, T> where
T: Default,
T: Default,
allocate count
elements of T
.
panics if there is not enough space left.
unsafe fn try_place_raw<T>(
&mut self,
count: usize
) -> Result<NonZero<*mut T>, OutOfMemory>
&mut self,
count: usize
) -> Result<NonZero<*mut T>, OutOfMemory>
Allocate count
elements of T
.
Returns OutOfMemory
if there is not enough space left.
The caller has to ensure the data does not outlife the Frame
unsafe fn place_raw<T>(&mut self, count: usize) -> *mut T
Allocate count
elements of T
.
panics if there is not enough space left.
The caller has to ensure the data does not outlife the Frame
fn place_iter<I, T>(&mut self, iter: I) -> Result<FArray<'a, T>, OutOfMemory> where
I: Iterator<Item = T>,
I: Iterator<Item = T>,
Drain the provided Iterator and return the resulting data. The iterator may not use the stack allocator. panics if the iterator attempts to use the stack allocator.
fn push<T>(&mut self) -> FramePlacer<'a, T>
Store something on the stack. To be used with the place syntax.
fn subframe(&mut self) -> Frame
Create a subframe. All allocations that happen within it, will be reset when it goes out if scope.
fn cursor<'b>(&'b mut self) -> Cursor<'a, 'b>
Create a growing Buffer that supports io::Write
call finish()
on the buffer to complete it.
fn writer<'b>(&'b mut self) -> Writer<'a, 'b>
Create a growing Buffer that supports fmt::Write
call finish()
on the buffer to complete it.