[−][src]Struct lv2_atom::space::SpaceHead
A mutable space that dynamically allocates memory.
This space uses a linked list of SpaceElement
s 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
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]
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>,