rcore::topology
This commit is contained in:
parent
01c9fd26ba
commit
116507fad8
21
src/rcore.rs
21
src/rcore.rs
@ -17,6 +17,7 @@ mod points;
|
|||||||
mod regular;
|
mod regular;
|
||||||
mod resolution;
|
mod resolution;
|
||||||
mod resolver_origin;
|
mod resolver_origin;
|
||||||
|
mod topology;
|
||||||
|
|
||||||
use std::{error::Error, sync::Arc};
|
use std::{error::Error, sync::Arc};
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ pub use self::resolution::{
|
|||||||
Address, HashResolution, HashResolutionResult, LookupError, Resolution, ResolutionError,
|
Address, HashResolution, HashResolutionResult, LookupError, Resolution, ResolutionError,
|
||||||
ResolutionFailure, ResolutionResult, Resolver, ResolverMap,
|
ResolutionFailure, ResolutionResult, Resolver, ResolverMap,
|
||||||
};
|
};
|
||||||
|
pub use self::topology::MentionableTop;
|
||||||
|
|
||||||
/// Helper alias for [`WeakFunctor::F`] of [`FunctorContext::T`].
|
/// Helper alias for [`WeakFunctor::F`] of [`FunctorContext::T`].
|
||||||
///
|
///
|
||||||
@ -55,25 +57,6 @@ pub trait MentionableBase<'a>: 'a + Send + Sync + Serializable + Sized {
|
|||||||
fn factory(&self) -> Self::Fctr;
|
fn factory(&self) -> Self::Fctr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Topological [Mentionable]. Allows iterating over [Point]s it references, if any;
|
|
||||||
pub trait MentionableTop<'a, Ctx: Context<'a>>: 'a {
|
|
||||||
/// See implementation for the definition.
|
|
||||||
/// Hash of all the references' points concatenated, ordered, non-unique.
|
|
||||||
/// Used for walking over object trees to ensure two objects with different references don't collide.
|
|
||||||
fn topology(&self) -> Hash
|
|
||||||
where
|
|
||||||
Self: Mentionable<'a, Ctx>,
|
|
||||||
{
|
|
||||||
let mut vec = Vec::new();
|
|
||||||
self.points_typed(&mut vec);
|
|
||||||
Ctx::hash(&vec)
|
|
||||||
}
|
|
||||||
/// References ([Point]s) to other objects. Typed.
|
|
||||||
fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>)
|
|
||||||
where
|
|
||||||
Self: Mentionable<'a, Ctx>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fundamental trait for ADN objects.
|
/// Fundamental trait for ADN objects.
|
||||||
pub trait Mentionable<'a, Ctx: Context<'a>>:
|
pub trait Mentionable<'a, Ctx: Context<'a>>:
|
||||||
MentionableBase<'a, Fctr = Self::_Fctr> + MentionableTop<'a, Ctx>
|
MentionableBase<'a, Fctr = Self::_Fctr> + MentionableTop<'a, Ctx>
|
||||||
|
21
src/rcore/topology.rs
Normal file
21
src/rcore/topology.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// Topological [Mentionable]. Allows iterating over [Point]s it references, if any;
|
||||||
|
pub trait MentionableTop<'a, Ctx: Context<'a>>: 'a {
|
||||||
|
/// See implementation for the definition.
|
||||||
|
/// Hash of all the references' points concatenated, ordered, non-unique.
|
||||||
|
/// Used for walking over object trees to ensure two objects with different references don't collide.
|
||||||
|
fn topology(&self) -> Hash
|
||||||
|
where
|
||||||
|
Self: Mentionable<'a, Ctx>,
|
||||||
|
{
|
||||||
|
let mut vec = Vec::new();
|
||||||
|
self.points_typed(&mut vec);
|
||||||
|
Ctx::hash(&vec)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// References ([Point]s) to other objects. Typed.
|
||||||
|
fn points_typed(&self, points: &mut impl PointsVisitor<'a, Ctx>)
|
||||||
|
where
|
||||||
|
Self: Mentionable<'a, Ctx>;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user