use std::fmt::{Display, Formatter};
use crate::param::PositionSize;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum AdjustmentOverflowError {
ArithmeticOverflow,
}
impl Display for AdjustmentOverflowError {
fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::ArithmeticOverflow => write!(formatter, "arithmetic overflow"),
}
}
}
impl std::error::Error for AdjustmentOverflowError {}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum HoldError {
InsufficientAvailable {
available: PositionSize,
requested: PositionSize,
},
ArithmeticOverflow,
}
impl Display for HoldError {
fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::InsufficientAvailable {
available,
requested,
} => write!(
formatter,
"insufficient available amount: available {available}, \
requested {requested}"
),
Self::ArithmeticOverflow => write!(formatter, "arithmetic overflow"),
}
}
}
impl std::error::Error for HoldError {}