dcso3/
lfs.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 super::{as_tbl, String};
15use crate::{wrapped_table, LuaEnv};
16use anyhow::Result;
17use mlua::{prelude::*, Value};
18use serde_derive::Serialize;
19use std::ops::Deref;
20
21wrapped_table!(Lfs, None);
22
23impl<'lua> Lfs<'lua> {
24    pub fn singleton<L: LuaEnv<'lua>>(lua: L) -> Result<Self> {
25        Ok(lua.inner().globals().raw_get("lfs")?)
26    }
27
28    pub fn writedir(&self) -> Result<String> {
29        Ok(self.t.call_function("writedir", ())?)
30    }
31
32    pub fn tempdir(&self) -> Result<String> {
33        Ok(self.t.call_function("tempdir", ())?)
34    }
35}