diff --git a/src/rcore.rs b/src/rcore.rs index 80dae13..d257a36 100644 --- a/src/rcore.rs +++ b/src/rcore.rs @@ -43,7 +43,7 @@ pub use self::resolution::{ Address, HashResolution, HashResolutionResult, LookupError, Resolution, ResolutionError, ResolutionFailure, ResolutionResult, Resolver, ResolverMap, }; -pub use self::singular::SingularResolution; +pub use self::singular::{SingularError, SingularResolution}; pub use self::to_hex::hex; pub use self::topology::MentionableTop; diff --git a/src/rcore/singular.rs b/src/rcore/singular.rs index 81a44f0..4c6af2c 100644 --- a/src/rcore/singular.rs +++ b/src/rcore/singular.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + use super::*; pub trait SingularResolution<'a, Ctx: Context<'a>>: 'a + Send + Sync { @@ -17,3 +19,38 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> SingularResolution<'a, Ctx> self.point } } + +#[derive(Debug)] +pub enum SingularError { + OutOfBounds { + index: usize, + len: usize, + }, + Mismatch { + index: usize, + expected: Hash, + point: Hash, + }, +} + +impl Display for SingularError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::OutOfBounds { index, len } => { + write!(f, "singularity out-of-bounds: {index}/{len}") + } + Self::Mismatch { + index, + expected, + point, + } => write!( + f, + "address mismatch at index {index}: {}!={}", + hex(expected), + hex(point), + ), + } + } +} + +impl Error for SingularError {} diff --git a/src/rstd/singular.rs b/src/rstd/singular.rs index 1c45c81..69a2a0c 100644 --- a/src/rstd/singular.rs +++ b/src/rstd/singular.rs @@ -25,41 +25,6 @@ struct SingularRobust<'a, Ctx: Context<'a>> { resolver: Arc>, } -#[derive(Debug)] -pub enum SingularError { - OutOfBounds { - index: usize, - len: usize, - }, - Mismatch { - index: usize, - expected: Hash, - point: Hash, - }, -} - -impl Display for SingularError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::OutOfBounds { index, len } => { - write!(f, "singularity out-of-bounds: {index}/{len}") - } - Self::Mismatch { - index, - expected, - point, - } => write!( - f, - "address mismatch at index {index}: {}!={}", - hex(expected), - hex(point), - ), - } - } -} - -impl Error for SingularError {} - impl<'a, Ctx: Context<'a>> SingularResolver<'a, Ctx> { pub fn from_mentionable>(a: &A) -> Self { let mut points = Vec::new(); diff --git a/src/testing.rs b/src/testing.rs index 8659db8..4cd8aa0 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -7,7 +7,6 @@ use sha2::{Digest, Sha256}; use crate::func::{context::*, *}; use crate::rcore::*; -use crate::rstd::singular::*; use crate::rstd::{inject::*, typeless::*}; pub struct NoDiagnostic;