This commit is contained in:
AF 2023-07-29 20:14:00 +00:00
parent bd62ae8dbb
commit 5a5f1f5199
13 changed files with 29 additions and 21 deletions

View File

@ -33,8 +33,8 @@ 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::{
ExtensionResultM, ExtensionSourceM, FactoryModeParse, FactoryModeProxy, Mode, ParseMode,
ParseResultM, RegularFactory, RegularMode, WithMode, WithParseMode,
ExtensionResultM, ExtensionSourceM, FactoryModeParse, FactoryModeProxy, ImplMode, Mode,
ParseMode, ParseResultM, RegularFactory, RegularMode, WithMode, WithParseMode,
};
pub use self::origin::{OFctr, Origin};
pub use self::point::Point;

View File

@ -42,7 +42,15 @@ pub trait WithParseMode: ParseMode {
type WithMode: ?Sized;
}
impl<T: ?Sized + ParseMode> WithParseMode for T {
pub trait ImplMode {
type Mode: ?Sized + Mode;
}
impl<T: ?Sized + ImplMode> ParseMode for T {
type Mode = <Self as ImplMode>::Mode;
}
impl<T: ?Sized + ImplMode> WithParseMode for T {
type WithMode = WithMode<Self, <Self as ParseMode>::Mode>;
}

View File

@ -38,7 +38,7 @@ impl<const N: usize> AtomicBase for [u8; N] {
type AParseError = ArrayParseError;
}
impl<const N: usize> ParseMode for [u8; N] {
impl<const N: usize> ImplMode for [u8; N] {
type Mode = InliningMode;
}

View File

@ -90,7 +90,7 @@ where
type ParseError = A::AParseError;
}
impl<A: ParseMode> ParseMode for AtomicFactory<A> {
impl<A: ParseMode> ImplMode for AtomicFactory<A> {
type Mode = A::Mode;
}

View File

@ -38,7 +38,7 @@ impl AtomicBase for u64 {
type AParseError = IntParseError;
}
impl ParseMode for u64 {
impl ImplMode for u64 {
type Mode = InliningMode;
}

View File

@ -45,7 +45,7 @@ impl AtomicBase for bool {
type AParseError = BooleanParseError;
}
impl ParseMode for bool {
impl ImplMode for bool {
type Mode = InliningMode;
}

View File

@ -20,7 +20,7 @@ where
}
}
pub trait RegularAtomic: AtomicBase + ParseMode<Mode = RegularMode> {
pub trait RegularAtomic: AtomicBase + ImplMode<Mode = RegularMode> {
fn ra_deserialize(inlining: impl Inlining) -> AParseResult<Self>;
fn ra_extend(self, tail: &[u8]) -> AParseResult<Self>;
}

View File

@ -32,7 +32,7 @@ impl AtomicBase for Plain {
type AParseError = PlainParseError;
}
impl ParseMode for Plain {
impl ImplMode for Plain {
type Mode = RegularMode;
}

View File

@ -113,11 +113,11 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Sta
type ParseError = StackParseError<ParseError<'a, Ctx, F>>;
}
impl<F: ParseMode> ParseMode for StackNodeFactory<F> {
impl<F: ParseMode> ImplMode for StackNodeFactory<F> {
type Mode = F::Mode;
}
impl<'a, Ctx: Context<'a>, F: RegularFactory<'a, Ctx>>
impl<'a, Ctx: Context<'a>, F: ImplMode + RegularFactory<'a, Ctx>>
ExternalPointsProxy<'a, Ctx, Stack<'a, Ctx, Mtbl<'a, Ctx, F>>> for WithMode<F, RegularMode>
where
F::Mtbl: MentionableTop<'a, Ctx>,
@ -130,7 +130,7 @@ where
}
}
impl<'a, Ctx: Context<'a>, F: RegularFactory<'a, Ctx>> RegularFactory<'a, Ctx>
impl<'a, Ctx: Context<'a>, F: ImplMode + RegularFactory<'a, Ctx>> RegularFactory<'a, Ctx>
for StackNodeFactory<F>
where
F::Mtbl: MentionableTop<'a, Ctx>,
@ -229,7 +229,7 @@ where
}
}
impl<'a, Ctx: Context<'a>, F: InlineableFactory<'a, Ctx>>
impl<'a, Ctx: Context<'a>, F: ImplMode + InlineableFactory<'a, Ctx>>
ExternalPointsProxy<'a, Ctx, Stack<'a, Ctx, Mtbl<'a, Ctx, F>>> for WithMode<F, InliningMode>
where
F::Mtbl: MentionableTop<'a, Ctx>,
@ -242,7 +242,7 @@ where
}
}
impl<'a, Ctx: Context<'a>, F: InlineableFactory<'a, Ctx>> InlineableFactory<'a, Ctx>
impl<'a, Ctx: Context<'a>, F: ImplMode + InlineableFactory<'a, Ctx>> InlineableFactory<'a, Ctx>
for StackNodeFactory<F>
where
F::Mtbl: MentionableTop<'a, Ctx>,
@ -261,7 +261,7 @@ where
}
}
impl<'a, Ctx: Context<'a>, F: FixedSizeFactory<'a, Ctx>> FixedSizeFactory<'a, Ctx>
impl<'a, Ctx: Context<'a>, F: ImplMode + FixedSizeFactory<'a, Ctx>> FixedSizeFactory<'a, Ctx>
for StackNodeFactory<F>
where
F::Mtbl: MentionableTop<'a, Ctx>,
@ -271,7 +271,7 @@ where
}
}
impl<'a, Ctx: Context<'a>, F: ConstSizeFactory<'a, Ctx>> ConstSizeFactory<'a, Ctx>
impl<'a, Ctx: Context<'a>, F: ImplMode + ConstSizeFactory<'a, Ctx>> ConstSizeFactory<'a, Ctx>
for StackNodeFactory<F>
where
F::Mtbl: MentionableTop<'a, Ctx>,

View File

@ -140,7 +140,7 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Nod
type ParseError = TreeParseError<F::ParseError>;
}
impl<F> ParseMode for NodeFactory<F> {
impl<F> ImplMode for NodeFactory<F> {
type Mode = RegularMode;
}
@ -168,7 +168,7 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Tre
type ParseError = TreeParseError<F::ParseError>;
}
impl<F> ParseMode for TreeFactory<F> {
impl<F> ImplMode for TreeFactory<F> {
type Mode = InliningMode;
}

View File

@ -53,7 +53,7 @@ pub trait ConstSizeObject<'a, Ctx: Context<'a>>: FixedSizeObject<'a, Ctx> {
pub type ADParseResult<A, D> = Result<(A, D), AParseError<A>>;
/// Atomic analogue of [`InlineableFactory`]/[`InlineableObject`].
pub trait InlineableAtomic: AtomicBase + ParseMode<Mode = InliningMode> {
pub trait InlineableAtomic: AtomicBase + ImplMode<Mode = InliningMode> {
fn a_extension_error(tail: &[u8]) -> Self::AParseError;
fn a_ideserialize<D: Inlining>(inlining: D) -> ADParseResult<Self, D>;

View File

@ -62,7 +62,7 @@ impl<'a, Ctx: Context<'a>, F: FactoryBase<'a, Ctx>> FactoryBase<'a, Ctx> for Nul
type ParseError = PointParseError;
}
impl<F> ParseMode for NullableFactory<F> {
impl<F> ImplMode for NullableFactory<F> {
type Mode = InliningMode;
}

View File

@ -95,7 +95,7 @@ impl<'a, Ctx: Context<'a>> FactoryBase<'a, Ctx> for TypelessFactory<'a, Ctx> {
type ParseError = TypelessError<'a>;
}
impl<'a, Ctx: Context<'a>> ParseMode for TypelessFactory<'a, Ctx> {
impl<'a, Ctx: Context<'a>> ImplMode for TypelessFactory<'a, Ctx> {
type Mode = RegularMode;
}