dcso3/env/
mod.rs

1/*
2Copyright 2024 Eric Stokes.
3
4This file is part of dcso3.
5
6dcso3 is free software: you can redistribute it and/or modify it under
7the terms of the MIT License.
8
9dcso3 is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11FITNESS FOR A PARTICULAR PURPOSE.
12*/
13
14use crate::{as_tbl, wrapped_table, LuaEnv, String};
15use anyhow::Result;
16use mlua::{prelude::*, Value};
17use serde_derive::Serialize;
18use std::ops::Deref;
19
20pub mod miz;
21pub mod warehouse;
22
23wrapped_table!(Env, None);
24
25impl<'lua> Env<'lua> {
26    pub fn singleton<L: LuaEnv<'lua>>(lua: L) -> Result<Self> {
27        Ok(lua.inner().globals().raw_get("env")?)
28    }
29
30    pub fn get_value_dict_by_key(&self, key: String) -> Result<String> {
31        Ok(self.t.call_function("getValueDictByKey", key)?)
32    }
33}