pub trait MutSpace<'a> {
// Required method
fn allocate(
&mut self,
size: usize,
apply_padding: bool,
) -> Option<(usize, &'a mut [u8])>;
// Provided method
fn write_raw(
&mut self,
data: &[u8],
apply_padding: bool,
) -> Option<&'a mut [u8]> { ... }
}Expand description
A smart pointer that writes atom data to an internal slice.
The methods provided by this trait are fairly minimalistic. More convenient writing methods are implemented for dyn MutSpace.
Required Methods§
Sourcefn allocate(
&mut self,
size: usize,
apply_padding: bool,
) -> Option<(usize, &'a mut [u8])>
fn allocate( &mut self, size: usize, apply_padding: bool, ) -> Option<(usize, &'a mut [u8])>
Try to allocate memory on the internal data slice.
If apply_padding is true, the method will assure that the allocated memory is 64-bit-aligned. The first return value is the number of padding bytes that has been used and the second return value is a mutable slice referencing the allocated data.
After the memory has been allocated, the MutSpace can not allocate it again. The next allocated slice is directly behind it.
Provided Methods§
Implementations§
Source§impl<'a, 'b> dyn MutSpace<'a> + 'b
impl<'a, 'b> dyn MutSpace<'a> + 'b
Sourcepub fn write<T>(
&mut self,
instance: &T,
apply_padding: bool,
) -> Option<&'a mut T>
pub fn write<T>( &mut self, instance: &T, apply_padding: bool, ) -> Option<&'a mut T>
Write a sized object to the space.
If apply_padding is true, the method will assure that the written instance is 64-bit-aligned.
Sourcepub fn init<'c, A: Atom<'a, 'c>>(
&'c mut self,
urid: URID<A>,
parameter: A::WriteParameter,
) -> Option<A::WriteHandle>
pub fn init<'c, A: Atom<'a, 'c>>( &'c mut self, urid: URID<A>, parameter: A::WriteParameter, ) -> Option<A::WriteHandle>
Initialize a new atom in the space.