use std::error;
use crate::{PolygonList, TriangleWinding, TriangulationError, formats};
pub trait ListFormat<'p, P: PolygonList<'p> + ?Sized> {
type Builder: ListBuilder<'p, P> + Sized;
fn initialize(self, polygon_list: &'p P) -> Result<Self::Builder, <Self::Builder as ListBuilder<'p, P>>::Error>;
fn into_fan_format(self) -> formats::FanToListFormat<'p, P, Self>
where Self: Sized {
formats::FanToListFormat::new(self)
}
}
pub trait ListBuilder<'p, P: PolygonList<'p> + ?Sized> {
type Output;
type Error: error::Error;
const WINDING: TriangleWinding = TriangleWinding::Counterclockwise;
fn add_triangle(&mut self, vi0: P::Index, vi1: P::Index, vi2: P::Index) -> Result<(), Self::Error>;
fn build(self) -> Result<Self::Output, Self::Error>;
fn fail(self, error: &TriangulationError<Self::Error>);
}