use core::marker::PhantomData;
use core::fmt;
#[cfg(feature = "std")]
use std::error::Error;
#[derive(Debug, Copy, Clone)]
pub struct WithoutWeight;
#[derive(Debug, Copy, Clone)]
pub struct WithWeight;
#[derive(Debug, Copy, Clone)]
pub struct Unknown;
#[cfg(feature = "bezier")]
#[derive(Debug, Copy, Clone)]
pub struct NormalizedInput<R = f64>(PhantomData<*const R>);
#[cfg(feature = "bezier")]
impl<R> NormalizedInput<R> {
pub const fn new() -> Self {
NormalizedInput(PhantomData)
}
}
#[cfg(feature = "bezier")]
#[derive(Debug, Copy, Clone)]
pub struct InputDomain<R = f64>{
pub start: R,
pub end: R,
}
#[cfg(feature = "bezier")]
impl<R> InputDomain<R>{
pub fn new(start: R, end: R) -> Self {
InputDomain{
start,
end
}
}
}
#[cfg(any(feature = "linear",feature = "bspline"))]
#[derive(Debug, Copy, Clone)]
pub struct Type<R = f64>(PhantomData<*const R>);
#[cfg(any(feature = "linear",feature = "bspline"))]
impl<R> Type<R> {
pub const fn new() -> Self {
Type(PhantomData)
}
}
#[cfg(feature = "bezier")]
#[derive(Debug, Copy, Clone)]
pub struct Empty {}
#[cfg(feature = "bezier")]
impl Empty {
pub const fn new() -> Self {
Empty{}
}
}
#[cfg(feature = "bezier")]
impl fmt::Display for Empty {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "No elements given, an empty generator is not allowed.")
}
}
#[cfg(all(feature = "std", feature = "bezier"))]
impl Error for Empty {}
#[cfg(any(feature = "linear", feature = "bspline"))]
#[derive(Debug, Copy, Clone)]
pub struct TooFewElements {
found: usize,
}
#[cfg(any(feature = "linear", feature = "bspline"))]
impl fmt::Display for TooFewElements {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "To few elements given for a linear interpolation. {} elements were given, but at least 2 are necessary.", self.found)
}
}
#[cfg(all(feature = "std",any(feature = "linear", feature = "bspline")))]
impl Error for TooFewElements {}
#[cfg(any(feature = "linear", feature = "bspline"))]
impl TooFewElements {
pub fn new(found: usize) -> Self {
TooFewElements{
found
}
}
}
#[cfg(any(feature = "bezier", feature = "bspline"))]
#[derive(Debug, Copy, Clone)]
pub struct TooSmallWorkspace {
found: usize,
necessary: usize,
}
#[cfg(any(feature = "bezier", feature = "bspline"))]
impl fmt::Display for TooSmallWorkspace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "The given workspace is too small with space for {} elements, at least {} have to fit.", self.found, self.necessary)
}
}
#[cfg(all(feature = "std",any(feature = "bezier", feature = "bspline")))]
impl Error for TooSmallWorkspace {}
#[cfg(any(feature = "bezier", feature = "bspline"))]
impl TooSmallWorkspace {
pub fn new(found: usize, necessary: usize) -> Self {
TooSmallWorkspace{
found,
necessary
}
}
}