FactoryModeProxy
This commit is contained in:
parent
ecdefe53cd
commit
e655d40ecd
@ -75,6 +75,42 @@ where
|
|||||||
type _Mtbl = Self::Mtbl;
|
type _Mtbl = Self::Mtbl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type ParseResultM<'a, Ctx, F, I> =
|
||||||
|
<<F as ParseMode>::Mode as Mode>::ParseResult<Mtbl<'a, Ctx, F>, ParseError<'a, Ctx, F>, I>;
|
||||||
|
|
||||||
|
pub type ExtensionResultM<'a, Ctx, F> =
|
||||||
|
<<F as ParseMode>::Mode as Mode>::ExtensionResult<Mtbl<'a, Ctx, F>, ParseError<'a, Ctx, F>>;
|
||||||
|
|
||||||
|
pub trait FactoryModeParse<'a, Ctx: Context<'a>>: FactoryBase<'a, Ctx> + ParseMode {
|
||||||
|
fn mdeserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> ParseResultM<'a, Ctx, Self, I>;
|
||||||
|
fn mextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ExtensionResultM<'a, Ctx, Self>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FactoryModeProxy<'a, Ctx: Context<'a>> {
|
||||||
|
type F: FactoryBase<'a, Ctx> + ParseMode;
|
||||||
|
|
||||||
|
fn pmdeserialize<I: InCtx<'a, Ctx>>(f: &Self::F, inctx: I)
|
||||||
|
-> ParseResultM<'a, Ctx, Self::F, I>;
|
||||||
|
fn pmextend(
|
||||||
|
f: &Self::F,
|
||||||
|
mentionable: Mtbl<'a, Ctx, Self::F>,
|
||||||
|
tail: &[u8],
|
||||||
|
) -> ExtensionResultM<'a, Ctx, Self::F>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx> + WithParseMode> FactoryModeParse<'a, Ctx> for F
|
||||||
|
where
|
||||||
|
F::WithMode: FactoryModeProxy<'a, Ctx, F = F>,
|
||||||
|
{
|
||||||
|
fn mdeserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> ParseResultM<'a, Ctx, Self, I> {
|
||||||
|
<F::WithMode as FactoryModeProxy<'a, Ctx>>::pmdeserialize(self, inctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ExtensionResultM<'a, Ctx, Self> {
|
||||||
|
<F::WithMode as FactoryModeProxy<'a, Ctx>>::pmextend(self, mentionable, tail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct RegularMode;
|
pub struct RegularMode;
|
||||||
|
|
||||||
impl Mode for RegularMode {
|
impl Mode for RegularMode {
|
||||||
|
Loading…
Reference in New Issue
Block a user