use std::fmt::Debug;
use thiserror::Error;
use crate::resource::InsufficientBudgetError;
#[must_use]
#[derive(Debug, Error, Clone, PartialEq, Eq)]
#[error("budget group member {index} rejected consumption: {source}")]
pub struct BudgetGroupError<R, Q = u64>
where
Q: Copy + Debug,
{
index: usize,
#[source]
source: InsufficientBudgetError<R, Q>,
}
impl<R, Q> BudgetGroupError<R, Q>
where
Q: Copy + Debug,
{
pub(crate) const fn new(index: usize, source: InsufficientBudgetError<R, Q>) -> Self {
Self { index, source }
}
#[inline(always)]
#[must_use]
pub const fn index(&self) -> usize {
self.index
}
#[inline(always)]
pub const fn source_error(&self) -> &InsufficientBudgetError<R, Q> {
&self.source
}
#[inline(always)]
pub fn into_source_error(self) -> InsufficientBudgetError<R, Q> {
self.source
}
}