[][src]Trait lv2_atom::Atom

pub trait Atom<'a, 'b>: UriBound where
    'a: 'b, 
{ type ReadParameter; type ReadHandle: 'a; type WriteParameter; type WriteHandle: 'b; fn read(
        body: Space<'a>,
        parameter: Self::ReadParameter
    ) -> Option<Self::ReadHandle>;
fn init(
        frame: FramedMutSpace<'a, 'b>,
        parameter: Self::WriteParameter
    ) -> Option<Self::WriteHandle>; }

Atom type.

This is the foundation of this crate: Types that implement Atom define the reading and writing functions for an atom type. However, these types will never be constructed; They are only names to be used for generic type arguments.

This trait has two lifetime parameters: The first one is the lifetime of the atom in memory. In practice, this will often be 'static, but it's good to keep it generic for testing purposes. The second parameter is the lifetime of the MutSpace borrowed by the FramedMutSpace parameter in the write method. Since the WriteParameter may contain this FramedMutSpace, it has to be assured that it lives long enough. Since the referenced MutSpace also has to borrow the atom, it may not live longer than the atom.

Associated Types

type ReadParameter

The atom-specific parameter of the read function.

If your atom does not need a reading parameter, you may set it to ().

type ReadHandle: 'a

The return value of the read function.

It may contain a reference to the atom and therefore may not outlive it.

type WriteParameter

The atom-specific parameter of the write function.

If your atom does not need a writing parameter, you may set it to ().

type WriteHandle: 'b

The return value of the write function.

It may contain a reference to a MutSpace and therefore may not outlive it.

Loading content...

Required methods

fn read(
    body: Space<'a>,
    parameter: Self::ReadParameter
) -> Option<Self::ReadHandle>

Read the body of the atom.

The passed space exactly covers the body of the atom, excluding the header. You may assume that the body is actually of your atom type, since the URID of the atom was checked beforehand.

If the atom is malformed, you may not panic and return None instead.

fn init(
    frame: FramedMutSpace<'a, 'b>,
    parameter: Self::WriteParameter
) -> Option<Self::WriteHandle>

Initialize the body of the atom.

In this method, the atom is prepared for the writing handle. Usually, the atom will not be valid when initializied; Users have to use the write handle to make it valid.

The frame of the atom was already initialized, containing the URID.

If space is insufficient, you may not panic and return None instead. The written results are assumed to be malformed.

Loading content...

Implementors

impl<'a, 'b> Atom<'a, 'b> for Chunk where
    'a: 'b, 
[src]

type ReadParameter = ()

type ReadHandle = &'a [u8]

type WriteParameter = ()

type WriteHandle = FramedMutSpace<'a, 'b>

impl<'a, 'b> Atom<'a, 'b> for Blank where
    'a: 'b, 
[src]

type ReadParameter = <Object as Atom<'a, 'b>>::ReadParameter

type ReadHandle = <Object as Atom<'a, 'b>>::ReadHandle

type WriteParameter = <Object as Atom<'a, 'b>>::WriteParameter

type WriteHandle = <Object as Atom<'a, 'b>>::WriteHandle

impl<'a, 'b> Atom<'a, 'b> for Object where
    'a: 'b, 
[src]

type ReadParameter = ()

type ReadHandle = (ObjectHeader, ObjectReader<'a>)

type WriteParameter = ObjectHeader

type WriteHandle = ObjectWriter<'a, 'b>

impl<'a, 'b> Atom<'a, 'b> for Sequence where
    'a: 'b, 
[src]

type ReadParameter = URID<Beat>

type ReadHandle = SequenceIterator<'a>

type WriteParameter = TimeStampURID

type WriteHandle = SequenceWriter<'a, 'b>

impl<'a, 'b> Atom<'a, 'b> for Literal where
    'a: 'b, 
[src]

type ReadParameter = ()

type ReadHandle = (LiteralInfo, &'a str)

type WriteParameter = LiteralInfo

type WriteHandle = StringWriter<'a, 'b>

impl<'a, 'b> Atom<'a, 'b> for String where
    'a: 'b, 
[src]

type ReadParameter = ()

type ReadHandle = &'a str

type WriteParameter = ()

type WriteHandle = StringWriter<'a, 'b>

impl<'a, 'b> Atom<'a, 'b> for Tuple where
    'a: 'b, 
[src]

type ReadParameter = ()

type ReadHandle = TupleIterator<'a>

type WriteParameter = ()

type WriteHandle = TupleWriter<'a, 'b>

impl<'a, 'b, A: ScalarAtom> Atom<'a, 'b> for A where
    'a: 'b, 
[src]

type ReadParameter = ()

type ReadHandle = A::InternalType

type WriteParameter = A::InternalType

type WriteHandle = &'a mut A::InternalType

impl<'a, 'b, C: ScalarAtom> Atom<'a, 'b> for Vector<C> where
    'a: 'b,
    C: 'b, 
[src]

type ReadParameter = URID<C>

type ReadHandle = &'a [C::InternalType]

type WriteParameter = URID<C>

type WriteHandle = VectorWriter<'a, 'b, C>

Loading content...