core::point
This commit is contained in:
parent
a90ea90529
commit
c8d7ce0f44
28
src/core.rs
28
src/core.rs
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
mod addresses;
|
mod addresses;
|
||||||
mod hashing;
|
mod hashing;
|
||||||
|
mod point;
|
||||||
mod points;
|
mod points;
|
||||||
mod resolution;
|
mod resolution;
|
||||||
mod resolver_origin;
|
mod resolver_origin;
|
||||||
@ -16,6 +17,7 @@ use crate::func::*;
|
|||||||
|
|
||||||
pub use self::addresses::*;
|
pub use self::addresses::*;
|
||||||
pub use self::hashing::*;
|
pub use self::hashing::*;
|
||||||
|
pub use self::point::*;
|
||||||
pub use self::points::TakesPoints;
|
pub use self::points::TakesPoints;
|
||||||
pub use self::resolution::*;
|
pub use self::resolution::*;
|
||||||
pub use self::serialization::*;
|
pub use self::serialization::*;
|
||||||
@ -105,32 +107,6 @@ pub trait Origin<'a, Ctx: 'a + Context>: 'a {
|
|||||||
fn resolve(self: Rc<Self>) -> Resolution<'a, Ctx, Self::Mtbl>;
|
fn resolve(self: Rc<Self>) -> 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<dyn Origin<'a, Ctx, Mtbl = A>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
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.
|
/// Extension trait for factories.
|
||||||
pub trait ExtFactory<'a, Ctx: 'a + Context>: Factory<'a, Ctx> {
|
pub trait ExtFactory<'a, Ctx: 'a + Context>: Factory<'a, Ctx> {
|
||||||
/// Parse the object from a slice.
|
/// Parse the object from a slice.
|
||||||
|
27
src/core/point.rs
Normal file
27
src/core/point.rs
Normal file
@ -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<dyn Origin<'a, Ctx, Mtbl = A>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user