use crate::{AsEngineRef, Engine, EngineRef};
pub(crate) mod handle;
pub(crate) mod obj;
pub(crate) use handle::*;
pub(crate) use obj::*;
#[derive(Debug)]
pub(crate) struct Store {
pub(crate) engine: Engine,
}
impl Store {
pub(crate) fn new(engine: Engine) -> Self {
Self { engine }
}
pub(crate) fn engine(&self) -> &Engine {
&self.engine
}
pub(crate) fn engine_mut(&mut self) -> &mut Engine {
&mut self.engine
}
}
impl AsEngineRef for Store {
fn as_engine_ref(&self) -> EngineRef<'_> {
EngineRef::new(&self.engine)
}
}
impl crate::BackendStore {
pub fn into_js(self) -> crate::backend::js::store::Store {
match self {
Self::Js(s) => s,
_ => panic!("Not a `js` store!"),
}
}
pub fn as_js(&self) -> &crate::backend::js::store::Store {
match self {
Self::Js(s) => s,
_ => panic!("Not a `js` store!"),
}
}
pub fn as_js_mut(&mut self) -> &mut crate::backend::js::store::Store {
match self {
Self::Js(s) => s,
_ => panic!("Not a `js` store!"),
}
}
pub fn is_js(&self) -> bool {
matches!(self, Self::Js(_))
}
}
impl crate::Store {
pub(crate) fn into_js(self) -> crate::backend::js::store::Store {
self.inner.store.into_js()
}
pub(crate) fn as_js(&self) -> &crate::backend::js::store::Store {
self.inner.store.as_js()
}
pub(crate) fn as_js_mut(&mut self) -> &mut crate::backend::js::store::Store {
self.inner.store.as_js_mut()
}
pub fn is_js(&self) -> bool {
self.inner.store.is_js()
}
}