InliningFactory
docs
This commit is contained in:
parent
ce65688e47
commit
96018d80dd
@ -1,21 +1,28 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
/// Inlining version of [`ParseResult`]. Preserves the parser.
|
||||||
pub type IParseResult<'a, Ctx, F, I> = Result<(Mtbl<'a, Ctx, F>, I), ParseError<'a, Ctx, F>>;
|
pub type IParseResult<'a, Ctx, F, I> = Result<(Mtbl<'a, Ctx, F>, I), ParseError<'a, Ctx, F>>;
|
||||||
|
|
||||||
|
/// For auto-deriving [`InliningFactory`] from concrete implementations.
|
||||||
pub trait CInliningFactory<'a, Ctx: Context<'a>>:
|
pub trait CInliningFactory<'a, Ctx: Context<'a>>:
|
||||||
FactoryBase<'a, Ctx> + ImplMode<Mode = InliningMode>
|
FactoryBase<'a, Ctx> + ImplMode<Mode = InliningMode>
|
||||||
{
|
{
|
||||||
|
/// Concrete implementation of [`InliningFactory::extension_error`].
|
||||||
fn cextension_error(&self, tail: &[u8]) -> Self::ParseError;
|
fn cextension_error(&self, tail: &[u8]) -> Self::ParseError;
|
||||||
|
|
||||||
|
/// Concrete implementation of [`InliningFactory::ideserialize`].
|
||||||
fn cideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I>;
|
fn cideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This factory should return an error on EOF.
|
/// Factory preserving the parser on success.
|
||||||
pub trait InliningFactory<'a, Ctx: Context<'a>>:
|
pub trait InliningFactory<'a, Ctx: Context<'a>>:
|
||||||
FactoryBase<'a, Ctx> + ParseMode<Mode = InliningMode>
|
FactoryBase<'a, Ctx> + ParseMode<Mode = InliningMode>
|
||||||
{
|
{
|
||||||
|
/// Always fail on extension,
|
||||||
|
/// as parsing of an inlining object should be determined without reaching EOF.
|
||||||
fn extension_error(&self, tail: &[u8]) -> Self::ParseError;
|
fn extension_error(&self, tail: &[u8]) -> Self::ParseError;
|
||||||
|
|
||||||
|
/// Inlining version of [`FactoryParse::deserialize`]. Preserves the parser.
|
||||||
fn ideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I>;
|
fn ideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ pub trait CRegularFactory<'a, Ctx: Context<'a>>:
|
|||||||
{
|
{
|
||||||
/// Concrete implementation of [`RegularFactory::rdeserialize`].
|
/// Concrete implementation of [`RegularFactory::rdeserialize`].
|
||||||
fn crdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>;
|
fn crdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>;
|
||||||
|
|
||||||
/// Concrete implementation of [`RegularFactory::rextend`].
|
/// Concrete implementation of [`RegularFactory::rextend`].
|
||||||
fn crextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self>;
|
fn crextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self>;
|
||||||
}
|
}
|
||||||
@ -16,6 +17,7 @@ pub trait RegularFactory<'a, Ctx: Context<'a>>:
|
|||||||
{
|
{
|
||||||
/// Same as [`FactoryModeParse::mdeserialize`].
|
/// Same as [`FactoryModeParse::mdeserialize`].
|
||||||
fn rdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>;
|
fn rdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>;
|
||||||
|
|
||||||
/// Same as [`FactoryModeParse::mextend`].
|
/// Same as [`FactoryModeParse::mextend`].
|
||||||
fn rextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self>;
|
fn rextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self>;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user