diff --git a/src/core.rs b/src/core.rs index dc737f0..3351038 100644 --- a/src/core.rs +++ b/src/core.rs @@ -4,6 +4,7 @@ mod addresses; mod hashing; +mod point; mod points; mod resolution; mod resolver_origin; @@ -16,6 +17,7 @@ use crate::func::*; pub use self::addresses::*; pub use self::hashing::*; +pub use self::point::*; pub use self::points::TakesPoints; pub use self::resolution::*; pub use self::serialization::*; @@ -105,32 +107,6 @@ pub trait Origin<'a, Ctx: 'a + Context>: 'a { fn resolve(self: Rc) -> Resolution<'a, Ctx, Self::Mtbl>; } -/// The main way to represent a reference in ADN. -pub struct Point<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> { - /// Hash of the referred content. - /// Derived both from the serialised value ([`Serializable::serialize`]) - /// and its topology ([`Mentionable::topology`]). - pub point: Hash, - /// [Origin] used in [`Point::resolve`]. - pub origin: Rc>, -} - -impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Clone for Point<'a, Ctx, A> { - fn clone(&self) -> Self { - Self { - point: self.point, - origin: self.origin.clone(), - } - } -} - -impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Point<'a, Ctx, A> { - /// See [`Origin::resolve`]. - pub fn resolve(&self) -> Resolution<'a, Ctx, A> { - self.origin.clone().resolve() - } -} - /// Extension trait for factories. pub trait ExtFactory<'a, Ctx: 'a + Context>: Factory<'a, Ctx> { /// Parse the object from a slice. diff --git a/src/core/point.rs b/src/core/point.rs new file mode 100644 index 0000000..c2beca4 --- /dev/null +++ b/src/core/point.rs @@ -0,0 +1,27 @@ +use super::*; + +/// The main way to represent a reference in ADN. +pub struct Point<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> { + /// Hash of the referred content. + /// Derived both from the serialised value ([`Serializable::serialize`]) + /// and its topology ([`Mentionable::topology`]). + pub point: Hash, + /// [Origin] used in [`Point::resolve`]. + pub origin: Rc>, +} + +impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Clone for Point<'a, Ctx, A> { + fn clone(&self) -> Self { + Self { + point: self.point, + origin: self.origin.clone(), + } + } +} + +impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> Point<'a, Ctx, A> { + /// See [`Origin::resolve`]. + pub fn resolve(&self) -> Resolution<'a, Ctx, A> { + self.origin.clone().resolve() + } +}