[][src]Trait kul_core::parser::DatumAllocator

pub trait DatumAllocator {
    type TT: Text;
    type ET;
    type DR: DerefTryMut<Target = Datum<Self::TT, Self::ET, Self::DR>>;
    fn new_datum(
        &mut self,
        from: Datum<Self::TT, Self::ET, Self::DR>
    ) -> Result<Self::DR, AllocError>; }

Allocator of space for Datum values that a Parser constructs.

Enables the parsing logic to be generic over this aspect so that various approaches may be chosen depending on the application. E.g. heap vs. stack allocation.

Associated Types

type TT: Text

The Text type for our Datum type. It should also implement TextConcat<Self> so it supports concatenation which the parsing requires.

Such a bound is not required here, to avoid difficulties that otherwise would happen with needing to have the bound where not really needed and where unresolvable mutually-recursive bounds would result. The bound is instead placed on the methods of ParseIter and SourceStream implementations where it's really needed.

type ET

The "extra" type for our Datum type.

type DR: DerefTryMut<Target = Datum<Self::TT, Self::ET, Self::DR>>

The type of references to Datums yielded by our parsing.

Loading content...

Required methods

fn new_datum(
    &mut self,
    from: Datum<Self::TT, Self::ET, Self::DR>
) -> Result<Self::DR, AllocError>

Allocate a fresh Datum, in whatever way the particular implementation wants, and set its initial value to that of the from argument. An AllocError is returned if allocation fails for any reason.

Loading content...

Implementors

impl<'a, TT, ET> DatumAllocator for SliceDatumAllocator<'a, TT, ET> where
    TT: Text
[src]

type TT = TT

type ET = ET

type DR = DatumMutRef<'a, Self::TT, Self::ET>

Loading content...