move Atomic
to atomic
This commit is contained in:
parent
7a6765b80e
commit
ba402b62b5
@ -1 +1,38 @@
|
||||
use std::error::Error;
|
||||
|
||||
use crate::mode::*;
|
||||
|
||||
/// [`Atomic`] equivalent of [`ParseError`].
|
||||
///
|
||||
/// [`ParseError`]: crate::rcore::ParseError
|
||||
pub type AParseError<A> = <A as AtomicBase>::AParseError;
|
||||
|
||||
pub type AParseResult<A> = Result<A, AParseError<A>>;
|
||||
|
||||
/// [`Atomic`] base.
|
||||
pub trait AtomicBase: 'static + Send + Sync + Send + Clone + Serializable {
|
||||
/// Equivalent of [`FactoryBase::ParseError`].
|
||||
///
|
||||
/// [`FactoryBase::ParseError`]: crate::rcore::FactoryBase::ParseError
|
||||
type AParseError: Error;
|
||||
}
|
||||
|
||||
/// This trait combines functionality of [`Mentionable`] and [`Factory`],
|
||||
/// while limiting [`MentionableTop::points_typed`] (and corresponding [`MentionableTop::topology`])
|
||||
/// to an empty sequence.
|
||||
///
|
||||
/// [`Mentionable`]: crate::rcore::Mentionable
|
||||
/// [`Factory`]: crate::rcore::Factory
|
||||
/// [`MentionableTop::points_typed`]: crate::rcore::MentionableTop::points_typed
|
||||
/// [`MentionableTop::topology`]: crate::rcore::MentionableTop::topology
|
||||
pub trait Atomic: AtomicBase + ParseMode {
|
||||
/// Static equivalent of [`FactoryParse::deserialize`].
|
||||
///
|
||||
/// [`FactoryParse::deserialize`]: crate::rcore::FactoryParse::deserialize
|
||||
fn a_deserialize(stream: impl Stream) -> AParseResult<Self>;
|
||||
|
||||
/// Static equivalent of [`FactoryParse::extend`].
|
||||
///
|
||||
/// [`FactoryParse::extend`]: crate::rcore::FactoryParse::extend
|
||||
fn a_extend(self, tail: &[u8]) -> AParseResult<Self>;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ impl<F: ParseMode> ParseModeExt for F {}
|
||||
/// For auto-implementing [`FactoryParse`] and [`Atomic`].
|
||||
///
|
||||
/// [`FactoryParse`]: crate::rcore::FactoryParse
|
||||
/// [`Atomic`]: crate::rstd::atomic::Atomic
|
||||
/// [`Atomic`]: crate::atomic::Atomic
|
||||
pub trait ImplMode {
|
||||
/// Same as [`ParseMode::Mode`]
|
||||
type Mode: ?Sized + Mode;
|
||||
@ -214,7 +214,7 @@ pub trait ImplMode {
|
||||
/// Used with [`WithMode`] for linking [`ImplMode`] to [`FactoryParse`] and [`Atomic`].
|
||||
///
|
||||
/// [`FactoryParse`]: crate::rcore::FactoryParse
|
||||
/// [`Atomic`]: crate::rstd::atomic::Atomic
|
||||
/// [`Atomic`]: crate::atomic::Atomic
|
||||
pub trait WithParseMode: ImplMode {
|
||||
/// [`WithMode`] implementing [`FactoryModeProxy`] or [`AtomicModeProxy`].
|
||||
///
|
||||
|
@ -10,7 +10,7 @@ pub mod plain;
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::mode::*;
|
||||
use crate::{atomic::*, mode::*};
|
||||
|
||||
use super::*;
|
||||
|
||||
@ -19,27 +19,6 @@ pub use self::modes::{
|
||||
CRegularAtomic, RegularAtomic,
|
||||
};
|
||||
|
||||
/// [`Atomic`] equivalent of [`ParseError`].
|
||||
pub type AParseError<A> = <A as AtomicBase>::AParseError;
|
||||
|
||||
pub type AParseResult<A> = Result<A, AParseError<A>>;
|
||||
|
||||
/// [`Atomic`] base.
|
||||
pub trait AtomicBase: 'static + Send + Sync + Send + Clone + Serializable {
|
||||
/// Equivalent of [`FactoryBase::ParseError`].
|
||||
type AParseError: Error;
|
||||
}
|
||||
|
||||
/// This trait combines functionality of [`Mentionable`] and [`Factory`],
|
||||
/// while limiting [`MentionableTop::points_typed`] (and corresponding [`MentionableTop::topology`])
|
||||
/// to an empty sequence.
|
||||
pub trait Atomic: AtomicBase + ParseMode {
|
||||
/// Static equivalent of [`FactoryParse::deserialize`].
|
||||
fn a_deserialize(stream: impl Stream) -> AParseResult<Self>;
|
||||
/// Static equivalent of [`FactoryParse::extend`].
|
||||
fn a_extend(self, tail: &[u8]) -> AParseResult<Self>;
|
||||
}
|
||||
|
||||
fn _parse_slice<A: Atomic>(slice: &[u8]) -> AParseResult<A> {
|
||||
let mut deserializer = SliceDeserializer::from(slice);
|
||||
let atomic = A::a_deserialize(&mut deserializer)?;
|
||||
|
@ -3,6 +3,7 @@
|
||||
mod modes;
|
||||
pub mod static_pair;
|
||||
|
||||
use crate::atomic::*;
|
||||
use crate::mode::*;
|
||||
use crate::rcore::*;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user