use super::*;
pub type IParseResult<'a, F, I> = Result<(Mtbl<'a, F>, I), ParseError<'a, F>>;
pub trait CInliningFactory<'a, Ctx: Context<'a>>:
FactoryBase<'a> + ImplMode<Mode = InliningMode>
{
fn cextension_error(&self, tail: &[u8]) -> Self::ParseError;
fn cideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Self, I>;
}
pub trait InliningFactory<'a, Ctx: Context<'a>>:
FactoryBase<'a> + ParseMode<Mode = InliningMode>
{
fn extension_error(&self, tail: &[u8]) -> Self::ParseError;
fn ideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Self, I>;
}
impl<'a, Ctx: Context<'a>, F: FactoryModeParse<'a, Ctx> + ParseMode<Mode = InliningMode>>
InliningFactory<'a, Ctx> for F
{
fn extension_error(&self, tail: &[u8]) -> Self::ParseError {
self.mextend((), tail)
}
fn ideserialize<I: InCtx<'a, Ctx>>(&self, inctx: I) -> IParseResult<'a, Self, I> {
self.mdeserialize(inctx)
}
}
impl<'a, Ctx: Context<'a>, F: CInliningFactory<'a, Ctx>> FactoryModeProxy<'a, Ctx>
for WithMode<F, InliningMode>
{
type F = F;
fn pmdeserialize<I: InCtx<'a, Ctx>>(f: &Self::F, inctx: I) -> ModeResultM<'a, F, I> {
f.cideserialize(inctx)
}
fn pmextend(
f: &F,
_mentionable: ExtensionSourceM<'a, F>,
tail: &[u8],
) -> ExtensionResultM<'a, F> {
f.cextension_error(tail)
}
}