[][src]Trait lv2rs_atom::frame::WritingFrameExt

pub trait WritingFrameExt<'a, A: AtomBody + ?Sized>: WritingFrame<'a> + Sized {
    unsafe fn write_sized<T: Sized>(
        &mut self,
        object: &T
    ) -> Result<&'a mut T, ()> { ... }
unsafe fn create_nested_frame<'b, C: AtomBody + ?Sized>(
        &'b mut self,
        urids: &mut CachedMap
    ) -> Result<NestedFrame<'b, 'a, C>, ()> { ... }
unsafe fn get_atom_body<'b>(
        &'b self,
        urids: &mut CachedMap
    ) -> Result<&'b A, GetBodyError> { ... } }

Extended functionality for writing frames.

This extension trait makes WritingFrames really usefull. First of all, this trait is generic for the managed atom type. This means that one can implement additional functions for writing frames that manage a specific type of atom body.

Also, you can write sized objects to the atom using the write_sized method without needing to turn a reference to a u8 slice. Last but not least, it can create new, nested writing frames using create_nested_frame.

Provided methods

unsafe fn write_sized<T: Sized>(&mut self, object: &T) -> Result<&'a mut T, ()>

Try to write a sized object into the atom space.

The data will be written directly after the previously written data and no padding will be applied.

If writing was successfull, a reference to the writen object is returned. In case of insufficient atom space, this function will return an error.

Also, this function is unsafe since it does not check the resulting structure for consistency. You have to know what you are doing!

unsafe fn create_nested_frame<'b, C: AtomBody + ?Sized>(
    &'b mut self,
    urids: &mut CachedMap
) -> Result<NestedFrame<'b, 'a, C>, ()>

Create a new atom header and return a nested writing frame for it.

This function can be used for container atoms. Please note that this function only writes the atom header and does not initialize the atom body.

Also, this function is unsafe since one can mess up atom structures.

unsafe fn get_atom_body<'b>(
    &'b self,
    urids: &mut CachedMap
) -> Result<&'b A, GetBodyError>

Try to get a reference to the body from our atom header.

This is just a shortcut for A::widen_ref(frame.get_header(), urids).

Loading content...

Implementors

impl<'a, 'b, A: AtomBody + ?Sized> WritingFrameExt<'b, A> for NestedFrame<'a, 'b, A>[src]

unsafe fn write_sized<T: Sized>(&mut self, object: &T) -> Result<&'a mut T, ()>[src]

unsafe fn create_nested_frame<'b, C: AtomBody + ?Sized>(
    &'b mut self,
    urids: &mut CachedMap
) -> Result<NestedFrame<'b, 'a, C>, ()>
[src]

unsafe fn get_atom_body<'b>(
    &'b self,
    urids: &mut CachedMap
) -> Result<&'b A, GetBodyError>
[src]

impl<'a, A: AtomBody + ?Sized> WritingFrameExt<'a, A> for RootFrame<'a, A>[src]

unsafe fn write_sized<T: Sized>(&mut self, object: &T) -> Result<&'a mut T, ()>[src]

unsafe fn create_nested_frame<'b, C: AtomBody + ?Sized>(
    &'b mut self,
    urids: &mut CachedMap
) -> Result<NestedFrame<'b, 'a, C>, ()>
[src]

unsafe fn get_atom_body<'b>(
    &'b self,
    urids: &mut CachedMap
) -> Result<&'b A, GetBodyError>
[src]

Loading content...