fix: remove buffer returns, only accept buffers

This commit is contained in:
Erica Marigold 2024-04-20 14:25:45 +05:30
parent 8dbe5325ec
commit 39b8c89e8b
No known key found for this signature in database
GPG key ID: 2768CC0C23D245D1
2 changed files with 6 additions and 6 deletions

View file

@ -31,10 +31,10 @@ pub fn create(lua: &Lua) -> LuaResult<LuaTable> {
.build_readonly()
}
async fn fs_read_file(lua: &Lua, path: String) -> LuaResult<LuaAnyUserData> {
async fn fs_read_file(lua: &Lua, path: String) -> LuaResult<LuaString> {
let bytes = fs::read(&path).await.into_lua_err()?;
lua.create_buffer(bytes)
lua.create_string(bytes)
}
async fn fs_read_dir(_: &Lua, path: String) -> LuaResult<Vec<String>> {

View file

@ -37,15 +37,15 @@ fn serde_decode<'lua>(
async fn serde_compress<'lua>(
lua: &'lua Lua,
(format, str): (CompressDecompressFormat, BString),
) -> LuaResult<LuaAnyUserData<'lua>> {
) -> LuaResult<LuaString<'lua>> {
let bytes = compress(format, str).await?;
lua.create_buffer(bytes)
lua.create_string(bytes)
}
async fn serde_decompress<'lua>(
lua: &'lua Lua,
(format, str): (CompressDecompressFormat, BString),
) -> LuaResult<LuaAnyUserData<'lua>> {
) -> LuaResult<LuaString<'lua>> {
let bytes = decompress(format, str).await?;
lua.create_buffer(bytes)
lua.create_string(bytes)
}