[][src]Struct lv2_atom::space::SpaceHead

pub struct SpaceHead<'a> { /* fields omitted */ }

A mutable space that dynamically allocates memory.

This space uses a linked list of SpaceElements to allocate memory. Every time allocate is called, a new element is appended to the list and a new byte slice is created.

In order to use this space and retrieve the written data once it was written, you create a SpaceElement and create a new head with it. Then, you use the head like any other MutSpace and when you're done, you retrieve the written data by either calling to_vec or iter.

Usage example

// URID cache creation is omitted.
let urids: AtomURIDCollection = map.populate_collection().unwrap();

// Creating the first element in the list and the writing head.
let mut element = SpaceElement::default();
let mut head = SpaceHead::new(&mut element);

// Writing an integer.
(&mut head as &mut dyn MutSpace).init(urids.int, 42).unwrap();

// Retrieving a continuos vector with the written data and verifying it's contents.
let written_data: Vec<u8> = element.to_vec();
let atom = UnidentifiedAtom::new(Space::from_slice(written_data.as_ref()));
assert_eq!(42, atom.read(urids.int, ()).unwrap());

Implementations

impl<'a> SpaceHead<'a>[src]

pub fn new(element: &'a mut SpaceElement) -> Self[src]

Create a new head that references the given element.

Trait Implementations

impl<'a> MutSpace<'a> for SpaceHead<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for SpaceHead<'a>

impl<'a> Send for SpaceHead<'a>

impl<'a> Sync for SpaceHead<'a>

impl<'a> Unpin for SpaceHead<'a>

impl<'a> !UnwindSafe for SpaceHead<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.