#[cfg(any(feature = "linear", feature = "bezier", feature = "bspline"))]
use core::fmt;
#[cfg(any(feature = "linear", feature = "bezier", feature = "bspline"))]
use core::marker::PhantomData;
#[cfg(all(
feature = "std",
any(feature = "linear", feature = "bezier", feature = "bspline")
))]
use std::error::Error;
#[cfg(any(feature = "linear", feature = "bezier", feature = "bspline"))]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct WithoutWeight;
#[cfg(any(feature = "linear", feature = "bezier", feature = "bspline"))]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct WithWeight;
#[cfg(any(feature = "linear", feature = "bezier", feature = "bspline"))]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Unknown;
#[cfg(feature = "bezier")]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
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")]
impl<R> Default for NormalizedInput<R> {
fn default() -> Self {
Self(Default::default())
}
}
#[cfg(feature = "bezier")]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
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)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
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(any(feature = "linear", feature = "bspline"))]
impl<R> Default for Type<R> {
fn default() -> Self {
Self(Default::default())
}
}
#[cfg(feature = "bezier")]
#[derive(Debug, Default, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
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 signal is not allowed.")
}
}
#[cfg(all(feature = "std", feature = "bezier"))]
impl Error for Empty {}
#[cfg(any(feature = "linear", feature = "bspline"))]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
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 the 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(feature = "bspline")]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct TooFewKnots {
found: usize,
}
#[cfg(feature = "bspline")]
impl fmt::Display for TooFewKnots {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"To few knots given for the interpolation. {} knots were given, but at least 2 are necessary.",
self.found
)
}
}
#[cfg(all(feature = "std", feature = "bspline"))]
impl Error for TooFewKnots {}
#[cfg(feature = "bspline")]
impl TooFewKnots {
pub fn new(found: usize) -> Self {
TooFewKnots { found }
}
}
#[cfg(any(feature = "bezier", feature = "bspline"))]
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
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 }
}
}