mirror of https://github.com/hannobraun/Fornjot
Add `CycleValidationError`
This commit is contained in:
parent
b121f8a1e9
commit
7671353c50
|
@ -103,8 +103,8 @@ use crate::{
|
||||||
path::GlobalPath,
|
path::GlobalPath,
|
||||||
storage::{Handle, Store},
|
storage::{Handle, Store},
|
||||||
validate::{
|
validate::{
|
||||||
HalfEdgeValidationError, SurfaceVertexValidationError, Validate2,
|
CycleValidationError, HalfEdgeValidationError,
|
||||||
VertexValidationError,
|
SurfaceVertexValidationError, Validate2, VertexValidationError,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -187,7 +187,10 @@ pub struct Cycles {
|
||||||
|
|
||||||
impl Cycles {
|
impl Cycles {
|
||||||
/// Insert a [`Cycle`] into the store
|
/// Insert a [`Cycle`] into the store
|
||||||
pub fn insert(&self, cycle: Cycle) -> Result<Handle<Cycle>, Infallible> {
|
pub fn insert(
|
||||||
|
&self,
|
||||||
|
cycle: Cycle,
|
||||||
|
) -> Result<Handle<Cycle>, CycleValidationError> {
|
||||||
cycle.validate()?;
|
cycle.validate()?;
|
||||||
Ok(self.store.insert(cycle))
|
Ok(self.store.insert(cycle))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
use std::convert::Infallible;
|
|
||||||
|
|
||||||
use crate::objects::Cycle;
|
use crate::objects::Cycle;
|
||||||
|
|
||||||
use super::{Validate2, ValidationConfig};
|
use super::{Validate2, ValidationConfig};
|
||||||
|
|
||||||
impl Validate2 for Cycle {
|
impl Validate2 for Cycle {
|
||||||
type Error = Infallible;
|
type Error = CycleValidationError;
|
||||||
|
|
||||||
fn validate_with_config(
|
fn validate_with_config(
|
||||||
&self,
|
&self,
|
||||||
|
@ -14,3 +12,7 @@ impl Validate2 for Cycle {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// [`Cycle`] validation error
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub enum CycleValidationError {}
|
||||||
|
|
|
@ -26,6 +26,7 @@ mod uniqueness;
|
||||||
mod vertex;
|
mod vertex;
|
||||||
|
|
||||||
pub use self::{
|
pub use self::{
|
||||||
|
cycle::CycleValidationError,
|
||||||
edge::HalfEdgeValidationError,
|
edge::HalfEdgeValidationError,
|
||||||
uniqueness::UniquenessIssues,
|
uniqueness::UniquenessIssues,
|
||||||
vertex::{SurfaceVertexValidationError, VertexValidationError},
|
vertex::{SurfaceVertexValidationError, VertexValidationError},
|
||||||
|
@ -177,6 +178,10 @@ pub enum ValidationError {
|
||||||
#[error("Uniqueness validation failed")]
|
#[error("Uniqueness validation failed")]
|
||||||
Uniqueness(#[from] UniquenessIssues),
|
Uniqueness(#[from] UniquenessIssues),
|
||||||
|
|
||||||
|
/// `Cycle` validation error
|
||||||
|
#[error(transparent)]
|
||||||
|
Cycle(#[from] CycleValidationError),
|
||||||
|
|
||||||
/// `HalfEdge` validation error
|
/// `HalfEdge` validation error
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
HalfEdge(#[from] HalfEdgeValidationError),
|
HalfEdge(#[from] HalfEdgeValidationError),
|
||||||
|
|
Loading…
Reference in New Issue