rcore::regular
This commit is contained in:
parent
09560ea690
commit
d4460ad880
@ -13,6 +13,7 @@ mod modes;
|
||||
mod origin;
|
||||
mod point;
|
||||
mod points;
|
||||
mod regular;
|
||||
mod resolution;
|
||||
mod resolver_origin;
|
||||
|
||||
@ -30,12 +31,12 @@ pub use self::diagnostic::Diagnostic;
|
||||
pub use self::hashing::{Hash, HASH_SIZE, HASH_ZEROS};
|
||||
pub use self::inctx::InCtx;
|
||||
pub use self::modes::{
|
||||
CRegularFactory, ExtensionResultM, ExtensionSourceM, FactoryModeParse, FactoryModeProxy,
|
||||
ModeResultM, RegularFactory,
|
||||
ExtensionResultM, ExtensionSourceM, FactoryModeParse, FactoryModeProxy, ModeResultM,
|
||||
};
|
||||
pub use self::origin::{OFctr, Origin};
|
||||
pub use self::point::Point;
|
||||
pub use self::points::PointsVisitor;
|
||||
pub use self::regular::{CRegularFactory, RegularFactory};
|
||||
pub use self::resolution::{
|
||||
Address, HashResolution, HashResolutionResult, LookupError, Resolution, ResolutionError,
|
||||
ResolutionFailure, ResolutionResult, Resolver, ResolverMap,
|
||||
|
@ -72,49 +72,3 @@ where
|
||||
<F::WithMode as FactoryModeProxy<'a, Ctx>>::pmextend(self, mentionable, tail)
|
||||
}
|
||||
}
|
||||
|
||||
/// For auto-deriving [`RegularFactory`] from concrete implementations.
|
||||
pub trait CRegularFactory<'a, Ctx: Context<'a>>:
|
||||
FactoryBase<'a, Ctx> + ImplMode<Mode = RegularMode>
|
||||
{
|
||||
/// 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>;
|
||||
}
|
||||
|
||||
/// Mostly same as [`FactoryModeParse`] but requires [`Mode`] to be [`RegularMode`].
|
||||
pub trait RegularFactory<'a, Ctx: Context<'a>>:
|
||||
FactoryBase<'a, Ctx> + ParseMode<Mode = RegularMode>
|
||||
{
|
||||
/// 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>;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryModeParse<'a, Ctx> + ParseMode<Mode = RegularMode>>
|
||||
RegularFactory<'a, Ctx> for F
|
||||
{
|
||||
fn rdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
self.mdeserialize(inctx)
|
||||
}
|
||||
|
||||
fn rextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||
self.mextend(mentionable, tail)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: CRegularFactory<'a, Ctx>> FactoryModeProxy<'a, Ctx>
|
||||
for WithMode<F, RegularMode>
|
||||
{
|
||||
type F = F;
|
||||
|
||||
fn pmdeserialize<I: InCtx<'a, Ctx>>(f: &Self::F, inctx: I) -> ModeResultM<'a, Ctx, F, I> {
|
||||
f.crdeserialize(inctx)
|
||||
}
|
||||
|
||||
fn pmextend(f: &F, mentionable: Mtbl<'a, Ctx, F>, tail: &[u8]) -> ExtensionResultM<'a, Ctx, F> {
|
||||
f.crextend(mentionable, tail)
|
||||
}
|
||||
}
|
||||
|
47
src/rcore/regular.rs
Normal file
47
src/rcore/regular.rs
Normal file
@ -0,0 +1,47 @@
|
||||
use super::*;
|
||||
|
||||
/// For auto-deriving [`RegularFactory`] from concrete implementations.
|
||||
pub trait CRegularFactory<'a, Ctx: Context<'a>>:
|
||||
FactoryBase<'a, Ctx> + ImplMode<Mode = RegularMode>
|
||||
{
|
||||
/// 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>;
|
||||
}
|
||||
|
||||
/// Mostly same as [`FactoryModeParse`] but requires [`Mode`] to be [`RegularMode`].
|
||||
pub trait RegularFactory<'a, Ctx: Context<'a>>:
|
||||
FactoryBase<'a, Ctx> + ParseMode<Mode = RegularMode>
|
||||
{
|
||||
/// 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>;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryModeParse<'a, Ctx> + ParseMode<Mode = RegularMode>>
|
||||
RegularFactory<'a, Ctx> for F
|
||||
{
|
||||
fn rdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||
self.mdeserialize(inctx)
|
||||
}
|
||||
|
||||
fn rextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||
self.mextend(mentionable, tail)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: CRegularFactory<'a, Ctx>> FactoryModeProxy<'a, Ctx>
|
||||
for WithMode<F, RegularMode>
|
||||
{
|
||||
type F = F;
|
||||
|
||||
fn pmdeserialize<I: InCtx<'a, Ctx>>(f: &Self::F, inctx: I) -> ModeResultM<'a, Ctx, F, I> {
|
||||
f.crdeserialize(inctx)
|
||||
}
|
||||
|
||||
fn pmextend(f: &F, mentionable: Mtbl<'a, Ctx, F>, tail: &[u8]) -> ExtensionResultM<'a, Ctx, F> {
|
||||
f.crextend(mentionable, tail)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user