use std::cell::{Ref, RefMut};
use crate::{
ad::dual::DualFwd,
core::{marketdatahandling::constructedelementstore::SharedElement, pillars::Pillars},
indices::marketindex::MarketIndex,
volatility::volatilitycube::VolatilityCube,
};
pub trait ADVolatilityCubeElement: VolatilityCube<DualFwd> + Pillars<DualFwd> + Send + Sync {}
#[derive(Clone)]
pub struct VolatilityCubeElement {
market_index: MarketIndex,
cube: SharedElement<dyn ADVolatilityCubeElement>,
}
impl VolatilityCubeElement {
#[must_use]
pub fn new(
market_index: MarketIndex,
cube: SharedElement<dyn ADVolatilityCubeElement>,
) -> Self {
Self { market_index, cube }
}
#[must_use]
pub const fn market_index(&self) -> &MarketIndex {
&self.market_index
}
#[must_use]
pub fn cube(&self) -> Ref<'_, dyn ADVolatilityCubeElement> {
self.cube.borrow()
}
pub fn cube_mut(&mut self) -> RefMut<'_, dyn ADVolatilityCubeElement> {
self.cube.borrow_mut()
}
}