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