Add `FaceValidationError`

This commit is contained in:
Hanno Braun 2022-11-08 14:50:34 +01:00
parent fed6533f54
commit 8eb974b225
3 changed files with 15 additions and 5 deletions

View File

@ -103,7 +103,7 @@ use crate::{
path::GlobalPath, path::GlobalPath,
storage::{Handle, Store}, storage::{Handle, Store},
validate::{ validate::{
CycleValidationError, HalfEdgeValidationError, CycleValidationError, FaceValidationError, HalfEdgeValidationError,
SurfaceVertexValidationError, Validate2, VertexValidationError, SurfaceVertexValidationError, Validate2, VertexValidationError,
}, },
}; };
@ -204,7 +204,10 @@ pub struct Faces {
impl Faces { impl Faces {
/// Insert a [`Face`] into the store /// Insert a [`Face`] into the store
pub fn insert(&self, face: Face) -> Result<Handle<Face>, Infallible> { pub fn insert(
&self,
face: Face,
) -> Result<Handle<Face>, FaceValidationError> {
face.validate()?; face.validate()?;
Ok(self.store.insert(face)) Ok(self.store.insert(face))
} }

View File

@ -1,11 +1,9 @@
use std::convert::Infallible;
use crate::objects::Face; use crate::objects::Face;
use super::{Validate2, ValidationConfig}; use super::{Validate2, ValidationConfig};
impl Validate2 for Face { impl Validate2 for Face {
type Error = Infallible; type Error = FaceValidationError;
fn validate_with_config( fn validate_with_config(
&self, &self,
@ -14,3 +12,7 @@ impl Validate2 for Face {
Ok(()) Ok(())
} }
} }
/// [`Face`] validation error
#[derive(Debug, thiserror::Error)]
pub enum FaceValidationError {}

View File

@ -28,6 +28,7 @@ mod vertex;
pub use self::{ pub use self::{
cycle::CycleValidationError, cycle::CycleValidationError,
edge::HalfEdgeValidationError, edge::HalfEdgeValidationError,
face::FaceValidationError,
uniqueness::UniquenessIssues, uniqueness::UniquenessIssues,
vertex::{SurfaceVertexValidationError, VertexValidationError}, vertex::{SurfaceVertexValidationError, VertexValidationError},
}; };
@ -182,6 +183,10 @@ pub enum ValidationError {
#[error(transparent)] #[error(transparent)]
Cycle(#[from] CycleValidationError), Cycle(#[from] CycleValidationError),
/// `Face` validation error
#[error(transparent)]
Face(#[from] FaceValidationError),
/// `HalfEdge` validation error /// `HalfEdge` validation error
#[error(transparent)] #[error(transparent)]
HalfEdge(#[from] HalfEdgeValidationError), HalfEdge(#[from] HalfEdgeValidationError),