[−][src]Trait lv2_atom::Atom
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.
Required methods
fn read(
body: Space<'a>,
parameter: Self::ReadParameter
) -> Option<Self::ReadHandle>
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>
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.
Implementors
impl<'a, 'b> Atom<'a, 'b> for Chunk where
'a: 'b,
[src]
'a: 'b,
type ReadParameter = ()
type ReadHandle = &'a [u8]
type WriteParameter = ()
type WriteHandle = FramedMutSpace<'a, 'b>
fn read(space: Space<'a>, _: ()) -> Option<&'a [u8]>
[src]
fn init(frame: FramedMutSpace<'a, 'b>, _: ()) -> Option<FramedMutSpace<'a, 'b>>
[src]
impl<'a, 'b> Atom<'a, 'b> for Blank where
'a: 'b,
[src]
'a: 'b,
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
fn read(
body: Space<'a>,
parameter: Self::ReadParameter
) -> Option<Self::ReadHandle>
[src]
body: Space<'a>,
parameter: Self::ReadParameter
) -> Option<Self::ReadHandle>
fn init(
frame: FramedMutSpace<'a, 'b>,
parameter: Self::WriteParameter
) -> Option<Self::WriteHandle>
[src]
frame: FramedMutSpace<'a, 'b>,
parameter: Self::WriteParameter
) -> Option<Self::WriteHandle>
impl<'a, 'b> Atom<'a, 'b> for Object where
'a: 'b,
[src]
'a: 'b,
type ReadParameter = ()
type ReadHandle = (ObjectHeader, ObjectReader<'a>)
type WriteParameter = ObjectHeader
type WriteHandle = ObjectWriter<'a, 'b>
fn read(body: Space<'a>, _: ()) -> Option<(ObjectHeader, ObjectReader<'a>)>
[src]
fn init(
frame: FramedMutSpace<'a, 'b>,
header: ObjectHeader
) -> Option<ObjectWriter<'a, 'b>>
[src]
frame: FramedMutSpace<'a, 'b>,
header: ObjectHeader
) -> Option<ObjectWriter<'a, 'b>>
impl<'a, 'b> Atom<'a, 'b> for Sequence where
'a: 'b,
[src]
'a: 'b,
type ReadParameter = URID<Beat>
type ReadHandle = SequenceIterator<'a>
type WriteParameter = TimeStampURID
type WriteHandle = SequenceWriter<'a, 'b>
fn read(body: Space<'_>, bpm_urid: URID<Beat>) -> Option<SequenceIterator<'_>>
[src]
fn init(
frame: FramedMutSpace<'a, 'b>,
unit: TimeStampURID
) -> Option<SequenceWriter<'a, 'b>>
[src]
frame: FramedMutSpace<'a, 'b>,
unit: TimeStampURID
) -> Option<SequenceWriter<'a, 'b>>
impl<'a, 'b> Atom<'a, 'b> for Literal where
'a: 'b,
[src]
'a: 'b,
type ReadParameter = ()
type ReadHandle = (LiteralInfo, &'a str)
type WriteParameter = LiteralInfo
type WriteHandle = StringWriter<'a, 'b>
fn read(body: Space<'a>, _: ()) -> Option<(LiteralInfo, &'a str)>
[src]
fn init(
frame: FramedMutSpace<'a, 'b>,
info: LiteralInfo
) -> Option<StringWriter<'a, 'b>>
[src]
frame: FramedMutSpace<'a, 'b>,
info: LiteralInfo
) -> Option<StringWriter<'a, 'b>>
impl<'a, 'b> Atom<'a, 'b> for String where
'a: 'b,
[src]
'a: 'b,
type ReadParameter = ()
type ReadHandle = &'a str
type WriteParameter = ()
type WriteHandle = StringWriter<'a, 'b>
fn read(body: Space<'a>, _: ()) -> Option<&'a str>
[src]
fn init(frame: FramedMutSpace<'a, 'b>, _: ()) -> Option<StringWriter<'a, 'b>>
[src]
impl<'a, 'b> Atom<'a, 'b> for Tuple where
'a: 'b,
[src]
'a: 'b,
type ReadParameter = ()
type ReadHandle = TupleIterator<'a>
type WriteParameter = ()
type WriteHandle = TupleWriter<'a, 'b>
fn read(body: Space<'a>, _: ()) -> Option<TupleIterator<'a>>
[src]
fn init(frame: FramedMutSpace<'a, 'b>, _: ()) -> Option<TupleWriter<'a, 'b>>
[src]
impl<'a, 'b, A: ScalarAtom> Atom<'a, 'b> for A where
'a: 'b,
[src]
'a: 'b,
type ReadParameter = ()
type ReadHandle = A::InternalType
type WriteParameter = A::InternalType
type WriteHandle = &'a mut A::InternalType
fn read(body: Space<'a>, _: ()) -> Option<A::InternalType>
[src]
fn init(
frame: FramedMutSpace<'a, 'b>,
value: A::InternalType
) -> Option<&'a mut A::InternalType>
[src]
frame: FramedMutSpace<'a, 'b>,
value: A::InternalType
) -> Option<&'a mut A::InternalType>
impl<'a, 'b, C: ScalarAtom> Atom<'a, 'b> for Vector<C> where
'a: 'b,
C: 'b,
[src]
'a: 'b,
C: 'b,
type ReadParameter = URID<C>
type ReadHandle = &'a [C::InternalType]
type WriteParameter = URID<C>
type WriteHandle = VectorWriter<'a, 'b, C>
fn read(body: Space<'a>, child_urid: URID<C>) -> Option<&'a [C::InternalType]>
[src]
fn init(
frame: FramedMutSpace<'a, 'b>,
child_urid: URID<C>
) -> Option<VectorWriter<'a, 'b, C>>
[src]
frame: FramedMutSpace<'a, 'b>,
child_urid: URID<C>
) -> Option<VectorWriter<'a, 'b, C>>