AtomicBase
This commit is contained in:
parent
f3eaccfa77
commit
ab5892f238
@ -13,14 +13,19 @@ use crate::rcore::*;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub type AParseResult<A> = Result<A, <A as Atomic>::AParseError>;
|
||||
pub type AParseError<A> = <A as AtomicBase>::AParseError;
|
||||
|
||||
pub type AParseResult<A> = Result<A, AParseError<A>>;
|
||||
|
||||
/// This trait combines functionality of [`Mentionable`] and [`Factory`],
|
||||
/// while limiting [`Mentionable::points_typed`] (and corresponding [`Mentionable::topology`])
|
||||
/// to an empty sequence.
|
||||
pub trait Atomic: 'static + Send + Sync + Send + Clone + Serializable {
|
||||
pub trait AtomicBase: 'static + Send + Sync + Send + Clone + Serializable {
|
||||
/// Equivalent of [`FactoryBase::ParseError`].
|
||||
type AParseError: Error;
|
||||
}
|
||||
|
||||
pub trait Atomic: AtomicBase {
|
||||
/// Static equivalent of [`Factory::deserialize`].
|
||||
fn a_deserialize(inlining: impl Inlining) -> AParseResult<Self>;
|
||||
/// Static equivalent of [`Factory::extend`].
|
||||
|
@ -34,9 +34,11 @@ impl From<&[u8]> for ArrayParseError {
|
||||
}
|
||||
}
|
||||
|
||||
impl<const N: usize> Atomic for [u8; N] {
|
||||
impl<const N: usize> AtomicBase for [u8; N] {
|
||||
type AParseError = ArrayParseError;
|
||||
}
|
||||
|
||||
impl<const N: usize> Atomic for [u8; N] {
|
||||
fn a_deserialize(inlining: impl Inlining) -> AParseResult<Self> {
|
||||
Self::a_ideserialize(inlining).seal()
|
||||
}
|
||||
|
@ -34,9 +34,11 @@ impl From<&[u8]> for IntParseError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Atomic for u64 {
|
||||
impl AtomicBase for u64 {
|
||||
type AParseError = IntParseError;
|
||||
}
|
||||
|
||||
impl Atomic for u64 {
|
||||
fn a_deserialize(inlining: impl Inlining) -> AParseResult<Self> {
|
||||
Self::a_ideserialize(inlining).seal()
|
||||
}
|
||||
|
@ -41,9 +41,11 @@ impl From<&[u8]> for BooleanParseError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Atomic for bool {
|
||||
impl AtomicBase for bool {
|
||||
type AParseError = BooleanParseError;
|
||||
}
|
||||
|
||||
impl Atomic for bool {
|
||||
fn a_deserialize(inlining: impl Inlining) -> AParseResult<Self> {
|
||||
Self::a_ideserialize(inlining).seal()
|
||||
}
|
||||
|
@ -28,9 +28,11 @@ impl Serializable for Plain {
|
||||
}
|
||||
}
|
||||
|
||||
impl Atomic for Plain {
|
||||
impl AtomicBase for Plain {
|
||||
type AParseError = PlainParseError;
|
||||
}
|
||||
|
||||
impl Atomic for Plain {
|
||||
fn a_deserialize(inlining: impl Inlining) -> AParseResult<Self> {
|
||||
Ok(inlining.iread_all(Plain::from_slice))
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ pub trait ConstSizeObject<'a, Ctx: Context<'a>>: FixedSizeObject<'a, Ctx> {
|
||||
const SIZE: usize;
|
||||
}
|
||||
|
||||
pub type ADParseResult<A, D> = Result<(A, D), <A as Atomic>::AParseError>;
|
||||
pub type ADParseResult<A, D> = Result<(A, D), AParseError<A>>;
|
||||
|
||||
/// Atomic analogue of [`InlineableFactory`]/[`InlineableObject`].
|
||||
pub trait InlineableAtomic: Atomic {
|
||||
|
Loading…
Reference in New Issue
Block a user