From 96018d80dd314a0da19c8334946ee01ab9fdff87 Mon Sep 17 00:00:00 2001 From: timofey Date: Sun, 30 Jul 2023 20:23:16 +0000 Subject: [PATCH] `InliningFactory` docs --- src/rcore/inlining.rs | 9 ++++++++- src/rcore/regular.rs | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/rcore/inlining.rs b/src/rcore/inlining.rs index ac68c78..13d12ce 100644 --- a/src/rcore/inlining.rs +++ b/src/rcore/inlining.rs @@ -1,21 +1,28 @@ 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>>; +/// For auto-deriving [`InliningFactory`] from concrete implementations. pub trait CInliningFactory<'a, Ctx: Context<'a>>: FactoryBase<'a, Ctx> + ImplMode { + /// Concrete implementation of [`InliningFactory::extension_error`]. fn cextension_error(&self, tail: &[u8]) -> Self::ParseError; + /// Concrete implementation of [`InliningFactory::ideserialize`]. fn cideserialize>(&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>>: FactoryBase<'a, Ctx> + ParseMode { + /// Always fail on extension, + /// as parsing of an inlining object should be determined without reaching EOF. fn extension_error(&self, tail: &[u8]) -> Self::ParseError; + /// Inlining version of [`FactoryParse::deserialize`]. Preserves the parser. fn ideserialize>(&self, inctx: I) -> IParseResult<'a, Ctx, Self, I>; } diff --git a/src/rcore/regular.rs b/src/rcore/regular.rs index 120e461..8ff7c59 100644 --- a/src/rcore/regular.rs +++ b/src/rcore/regular.rs @@ -6,6 +6,7 @@ pub trait CRegularFactory<'a, Ctx: Context<'a>>: { /// Concrete implementation of [`RegularFactory::rdeserialize`]. fn crdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>; + /// Concrete implementation of [`RegularFactory::rextend`]. 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`]. fn rdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>; + /// Same as [`FactoryModeParse::mextend`]. fn rextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self>; }