rcore::modes::*
renaming
This commit is contained in:
parent
8015a9301b
commit
dd8e0322e8
@ -33,7 +33,7 @@ pub use self::hashing::{Hash, HASH_SIZE, HASH_ZEROS};
|
||||
pub use self::inctx::InCtx;
|
||||
pub use self::inlining::{Inlining, InliningExt, InliningResultExt};
|
||||
pub use self::modes::{
|
||||
FactoryProxy, FactoryWithMode, ModeFactory, RegularFactory, RegularFactoryMode, WithMode,
|
||||
FactoryProxy, ParseMode, RegularFactory, RegularMode, WithMode, WithParseMode,
|
||||
};
|
||||
pub use self::origin::{OFctr, Origin};
|
||||
pub use self::point::Point;
|
||||
@ -86,7 +86,7 @@ pub trait FactoryBase<'a, Ctx: Context<'a>>: 'a + Send + Sync + Clone {
|
||||
|
||||
/// Trait representing deserialisation rules for [Mentionable]s.
|
||||
/// Crucial for [`crate::rstd::typeless`].
|
||||
pub trait Factory<'a, Ctx: Context<'a>>: FactoryBase<'a, Ctx> + ModeFactory {
|
||||
pub trait Factory<'a, Ctx: Context<'a>>: FactoryBase<'a, Ctx> + ParseMode {
|
||||
/// See [`Deserializer`], [`Resolver`].
|
||||
fn deserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>;
|
||||
/// Called by finite stream parsers if there's any data left.
|
||||
|
@ -2,31 +2,31 @@ use std::marker::PhantomData;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub trait ModeFactory {
|
||||
pub trait ParseMode {
|
||||
type Mode: ?Sized;
|
||||
}
|
||||
|
||||
pub struct RegularFactoryMode;
|
||||
pub struct RegularMode;
|
||||
|
||||
pub trait RegularFactory<'a, Ctx: Context<'a>>:
|
||||
FactoryBase<'a, Ctx> + ModeFactory<Mode = RegularFactoryMode>
|
||||
FactoryBase<'a, Ctx> + ParseMode<Mode = RegularMode>
|
||||
{
|
||||
fn rdeserialize(&self, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self>;
|
||||
fn rextend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self>;
|
||||
}
|
||||
|
||||
pub trait FactoryWithMode: ModeFactory {
|
||||
pub trait WithParseMode: ParseMode {
|
||||
type WithMode: ?Sized;
|
||||
}
|
||||
|
||||
pub struct WithMode<F: ?Sized, M: ?Sized>(PhantomData<M>, F);
|
||||
|
||||
impl<F: ?Sized + ModeFactory> FactoryWithMode for F {
|
||||
type WithMode = WithMode<Self, <Self as ModeFactory>::Mode>;
|
||||
impl<F: ?Sized + ParseMode> WithParseMode for F {
|
||||
type WithMode = WithMode<Self, <Self as ParseMode>::Mode>;
|
||||
}
|
||||
|
||||
pub trait FactoryProxy<'a, Ctx: Context<'a>> {
|
||||
type F: FactoryBase<'a, Ctx> + ModeFactory;
|
||||
type F: FactoryBase<'a, Ctx> + ParseMode;
|
||||
|
||||
fn pdeserialize(f: &Self::F, inctx: impl InCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self::F>;
|
||||
fn pextend(
|
||||
@ -37,7 +37,7 @@ pub trait FactoryProxy<'a, Ctx: Context<'a>> {
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: RegularFactory<'a, Ctx>> FactoryProxy<'a, Ctx>
|
||||
for WithMode<F, RegularFactoryMode>
|
||||
for WithMode<F, RegularMode>
|
||||
{
|
||||
type F = F;
|
||||
|
||||
@ -54,7 +54,7 @@ impl<'a, Ctx: Context<'a>, F: RegularFactory<'a, Ctx>> FactoryProxy<'a, Ctx>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx> + FactoryWithMode> Factory<'a, Ctx> for F
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx> + WithParseMode> Factory<'a, Ctx> for F
|
||||
where
|
||||
F::WithMode: FactoryProxy<'a, Ctx, F = Self>,
|
||||
{
|
||||
|
@ -73,8 +73,8 @@ impl<'a, Ctx: Context<'a>, A: Atomic> FactoryBase<'a, Ctx> for AtomicFactory<A>
|
||||
type ParseError = A::AParseError;
|
||||
}
|
||||
|
||||
impl<A: Atomic> ModeFactory for AtomicFactory<A> {
|
||||
type Mode = RegularFactoryMode;
|
||||
impl<A: Atomic> ParseMode for AtomicFactory<A> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, A: Atomic> RegularFactory<'a, Ctx> for AtomicFactory<A> {
|
||||
|
@ -1,18 +1,18 @@
|
||||
use super::*;
|
||||
|
||||
pub trait RegularAtomic: AtomicBase + ModeFactory<Mode = RegularFactoryMode> {
|
||||
pub trait RegularAtomic: AtomicBase + ParseMode<Mode = RegularMode> {
|
||||
fn ra_deserialize(inlining: impl Inlining) -> AParseResult<Self>;
|
||||
fn ra_extend(self, tail: &[u8]) -> AParseResult<Self>;
|
||||
}
|
||||
|
||||
pub trait AtomicProxy {
|
||||
type A: AtomicBase + ModeFactory;
|
||||
type A: AtomicBase + ParseMode;
|
||||
|
||||
fn pa_deserialize(inlining: impl Inlining) -> AParseResult<Self::A>;
|
||||
fn pa_extend(a: Self::A, tail: &[u8]) -> AParseResult<Self::A>;
|
||||
}
|
||||
|
||||
impl<A: RegularAtomic> AtomicProxy for WithMode<A, RegularFactoryMode> {
|
||||
impl<A: RegularAtomic> AtomicProxy for WithMode<A, RegularMode> {
|
||||
type A = A;
|
||||
|
||||
fn pa_deserialize(inlining: impl Inlining) -> AParseResult<Self::A> {
|
||||
@ -24,7 +24,7 @@ impl<A: RegularAtomic> AtomicProxy for WithMode<A, RegularFactoryMode> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: AtomicBase + FactoryWithMode> Atomic for A
|
||||
impl<A: AtomicBase + WithParseMode> Atomic for A
|
||||
where
|
||||
A::WithMode: AtomicProxy<A = Self>,
|
||||
{
|
||||
|
@ -93,8 +93,8 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Sta
|
||||
type ParseError = StackParseError<ParseError<'a, Ctx, F>>;
|
||||
}
|
||||
|
||||
impl<F> ModeFactory for StackNodeFactory<F> {
|
||||
type Mode = RegularFactoryMode;
|
||||
impl<F> ParseMode for StackNodeFactory<F> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx>> RegularFactory<'a, Ctx> for StackNodeFactory<F> {
|
||||
|
@ -137,8 +137,8 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Nod
|
||||
type ParseError = TreeParseError<F::ParseError>;
|
||||
}
|
||||
|
||||
impl<F> ModeFactory for NodeFactory<F> {
|
||||
type Mode = RegularFactoryMode;
|
||||
impl<F> ParseMode for NodeFactory<F> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx>> RegularFactory<'a, Ctx> for NodeFactory<F> {
|
||||
@ -165,8 +165,8 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Tre
|
||||
type ParseError = TreeParseError<F::ParseError>;
|
||||
}
|
||||
|
||||
impl<F> ModeFactory for TreeFactory<F> {
|
||||
type Mode = RegularFactoryMode;
|
||||
impl<F> ParseMode for TreeFactory<F> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> RegularFactory<'a, Ctx> for TreeFactory<F> {
|
||||
|
@ -132,8 +132,8 @@ impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> FactoryBase<'a, Ctx>
|
||||
type ParseError = SP::ParseError;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> ModeFactory for StaticPairFactory<'a, Ctx, SP> {
|
||||
type Mode = RegularFactoryMode;
|
||||
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> ParseMode for StaticPairFactory<'a, Ctx, SP> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, SP: StaticPair<'a, Ctx>> RegularFactory<'a, Ctx>
|
||||
|
@ -56,8 +56,8 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Nul
|
||||
type ParseError = PointParseError;
|
||||
}
|
||||
|
||||
impl<F> ModeFactory for NullableFactory<F> {
|
||||
type Mode = RegularFactoryMode;
|
||||
impl<F> ParseMode for NullableFactory<F> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> RegularFactory<'a, Ctx> for NullableFactory<F> {
|
||||
|
@ -75,8 +75,8 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Poi
|
||||
type ParseError = PointParseError;
|
||||
}
|
||||
|
||||
impl<F> ModeFactory for PointFactory<F> {
|
||||
type Mode = RegularFactoryMode;
|
||||
impl<F> ParseMode for PointFactory<F> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> RegularFactory<'a, Ctx> for PointFactory<F> {
|
||||
|
@ -93,8 +93,8 @@ impl<'a, Ctx: Context<'a>> FactoryBase<'a, Ctx> for TypelessFactory<'a, Ctx> {
|
||||
type ParseError = TypelessError<'a>;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>> ModeFactory for TypelessFactory<'a, Ctx> {
|
||||
type Mode = RegularFactoryMode;
|
||||
impl<'a, Ctx: Context<'a>> ParseMode for TypelessFactory<'a, Ctx> {
|
||||
type Mode = RegularMode;
|
||||
}
|
||||
|
||||
impl<'a, Ctx: Context<'a>> RegularFactory<'a, Ctx> for TypelessFactory<'a, Ctx> {
|
||||
|
Loading…
Reference in New Issue
Block a user