MutSpace

Trait MutSpace 

Source
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§

Source

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§

Source

fn write_raw( &mut self, data: &[u8], apply_padding: bool, ) -> Option<&'a mut [u8]>

Try to write data to the internal data slice.

The method allocates a slice with the allocate method and copies the data to the slice.

Implementations§

Source§

impl<'a, 'b> dyn MutSpace<'a> + 'b

Source

pub fn write<T>( &mut self, instance: &T, apply_padding: bool, ) -> Option<&'a mut T>
where T: Unpin + Copy + Send + Sync + Sized + 'static,

Write a sized object to the space.

If apply_padding is true, the method will assure that the written instance is 64-bit-aligned.

Source

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.

Implementors§

Source§

impl<'a> MutSpace<'a> for RootMutSpace<'a>

Source§

impl<'a> MutSpace<'a> for SpaceHead<'a>

Source§

impl<'a, 'b> MutSpace<'a> for FramedMutSpace<'a, 'b>