use crate::json::JsonValueBudget;
use crate::resource::ResourceBudget;
use crate::resource::ResourceQuantity;
type DecodeStorageSplit<'a, R, Q> = (
Option<&'a mut ResourceBudget<R, Q>>,
Option<&'a mut ResourceBudget<R, Q>>,
&'a mut JsonValueBudget<R, Q>,
);
#[derive(Debug)]
pub(crate) enum DecodeStorage<'a, R, Q>
where
Q: ResourceQuantity,
{
Owned {
input: Option<ResourceBudget<R, Q>>,
normalized_input: Option<ResourceBudget<R, Q>>,
value: JsonValueBudget<R, Q>,
},
Borrowed {
input: Option<&'a mut ResourceBudget<R, Q>>,
normalized_input: Option<&'a mut ResourceBudget<R, Q>>,
value: &'a mut JsonValueBudget<R, Q>,
},
}
impl<R, Q> DecodeStorage<'_, R, Q>
where
Q: ResourceQuantity,
{
#[inline]
pub(crate) fn split(&mut self) -> DecodeStorageSplit<'_, R, Q> {
match self {
Self::Owned {
input,
normalized_input,
value,
} => (input.as_mut(), normalized_input.as_mut(), value),
Self::Borrowed {
input,
normalized_input,
value,
} => (input.as_deref_mut(), normalized_input.as_deref_mut(), value),
}
}
}