topology -> topology_hash
All checks were successful
buildbot/cargo fmt (1.72) Build done.
buildbot/cargo clippy (1.65) Build done.
buildbot/cargo doc (1.72) Build done.
buildbot/cargo clippy (1.72) Build done.
buildbot/cargo test (1.65) Build done.

This commit is contained in:
AF 2023-09-03 20:12:58 +00:00
parent 116507fad8
commit 2b6b3ca547
9 changed files with 12 additions and 12 deletions

View File

@ -37,13 +37,13 @@ pub trait AtomicBase: 'static + Send + Sync + Clone + Serializable {
}
/// This trait combines functionality of [`Mentionable`] and [`Factory`],
/// while limiting [`MentionableTop::points_typed`] (and corresponding [`MentionableTop::topology`])
/// while limiting [`MentionableTop::points_typed`] (and corresponding [`MentionableTop::topology_hash`])
/// 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
/// [`MentionableTop::topology_hash`]: crate::rcore::MentionableTop::topology_hash
pub trait Atomic: AtomicModeParse {
/// Static equivalent of [`FactoryParse::deserialize`].
///

View File

@ -4,7 +4,7 @@ use super::*;
pub struct Point<'a, Ctx: Context<'a>, A: MentionableBase<'a>> {
/// Hash of the referred content.
/// Derived both from the serialised value ([`Serializable::serialize`])
/// and its topology ([`MentionableTop::topology`]).
/// and its topology ([`MentionableTop::topology_hash`]).
pub point: Hash,
/// [Origin] used in [`Point::resolve`].
pub origin: Arc<dyn Origin<'a, Ctx, Mtbl = A>>,

View File

@ -7,7 +7,7 @@ pub trait PointsVisitor<'a, Ctx: Context<'a>> {
}
impl<'a, Ctx: Context<'a>> PointsVisitor<'a, Ctx> for Vec<u8> {
/// The only natural implementation, as used in [`MentionableTop::topology`].
/// The only natural implementation, as used in [`MentionableTop::topology_hash`].
fn visit<A: Mentionable<'a, Ctx>>(&mut self, point: &Point<'a, Ctx, A>) {
self.extend(point.point)
}

View File

@ -50,7 +50,7 @@ pub struct Address {
/// Trait representing the "rainbow table" behaviour.
pub trait Resolver<'a, Ctx: Context<'a>>: 'a + Send + Sync {
/// Successfully returned value should be the inverse of the point passed
/// with topology header ([`MentionableTop::topology()`]) omitted.
/// with topology header ([`MentionableTop::topology_hash()`]) omitted.
fn resolve(self: Arc<Self>, address: Address) -> HashResolution<'a, Ctx>;
}

View File

@ -5,7 +5,7 @@ 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
fn topology_hash(&self) -> Hash
where
Self: Mentionable<'a, Ctx>,
{

View File

@ -47,7 +47,7 @@ impl<'a, A: AtomicBase> MentionableBase<'a> for AtomicObject<A> {
}
impl<'a, Ctx: Context<'a>, A: AtomicBase> MentionableTop<'a, Ctx> for AtomicObject<A> {
fn topology(&self) -> Hash {
fn topology_hash(&self) -> Hash {
Ctx::hash(b"")
}

View File

@ -8,7 +8,7 @@ use super::*;
impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Point<'a, Ctx, A> {
fn prepare_bytes_for_hashing(mentioned: &A) -> Vec<u8> {
let mut vec = mentioned.topology().to_vec();
let mut vec = mentioned.topology_hash().to_vec();
mentioned.serialize(&mut vec);
vec
}

View File

@ -31,7 +31,7 @@ impl<Ctx, F> PointFactory<Ctx, F> {
}
impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> MentionableTop<'a, Ctx> for Point<'a, Ctx, A> {
fn topology(&self) -> Hash {
fn topology_hash(&self) -> Hash {
Ctx::hash(&self.point)
}

View File

@ -60,7 +60,7 @@ impl<'a, Ctx: Context<'a>> MentionableBase<'a> for TypelessMentionable<'a, Ctx>
}
impl<'a, Ctx: Context<'a>> MentionableTop<'a, Ctx> for TypelessMentionable<'a, Ctx> {
fn topology(&self) -> Hash {
fn topology_hash(&self) -> Hash {
self.t_topology
}
@ -115,7 +115,7 @@ impl<'a, Ctx: Context<'a>> CRegularFactory<'a, Ctx> for TypelessFactory<'a, Ctx>
impl<'a, Ctx: SingularCtx<'a>> TypelessMentionable<'a, Ctx> {
pub fn from_typed<A: Mentionable<'a, Ctx>>(mentionable: Arc<A>) -> Self {
let factory = TypelessFactory::from_typed(mentionable.factory());
let topology = mentionable.topology();
let topology = mentionable.topology_hash();
let points = mentionable.points_vec();
TypelessMentionable {
t_serialize: Box::new(move |serializer| mentionable.serialize(serializer)),
@ -197,7 +197,7 @@ impl<'a, Ctx: SingularCtx<'a>, A: Mentionable<'a, Ctx>> Point<'a, Ctx, A> {
pub trait MentionableExt<'a, Ctx: Context<'a>>: Mentionable<'a, Ctx> {
/// References ([Point]s) to other objects. Typeless.
fn points_typeless(&self, points: &mut Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>);
/// [Vec] of [Point]s as used by [`MentionableTop::topology`].
/// [Vec] of [Point]s as used by [`MentionableTop::topology_hash`].
fn points_vec(&self) -> Vec<Point<'a, Ctx, TypelessMentionable<'a, Ctx>>>;
}