Fix clippy lints in serde builtin

This commit is contained in:
Filip Tibell 2024-04-20 16:48:28 +02:00
parent 66ed1a0b72
commit 53463641b8
No known key found for this signature in database
2 changed files with 8 additions and 15 deletions

View file

@ -87,11 +87,7 @@ impl EncodeDecodeConfig {
lua.create_string(bytes) lua.create_string(bytes)
} }
pub fn deserialize_from_string<'lua>( pub fn deserialize_from_string(self, lua: &Lua, string: BString) -> LuaResult<LuaValue> {
self,
lua: &'lua Lua,
string: BString,
) -> LuaResult<LuaValue<'lua>> {
let bytes = string.as_bytes(); let bytes = string.as_bytes();
match self.format { match self.format {
EncodeDecodeFormat::Json => { EncodeDecodeFormat::Json => {

View file

@ -26,26 +26,23 @@ fn serde_encode<'lua>(
config.serialize_to_string(lua, val) config.serialize_to_string(lua, val)
} }
fn serde_decode<'lua>( fn serde_decode(lua: &Lua, (format, str): (EncodeDecodeFormat, BString)) -> LuaResult<LuaValue> {
lua: &'lua Lua,
(format, str): (EncodeDecodeFormat, BString),
) -> LuaResult<LuaValue<'lua>> {
let config = EncodeDecodeConfig::from(format); let config = EncodeDecodeConfig::from(format);
config.deserialize_from_string(lua, str) config.deserialize_from_string(lua, str)
} }
async fn serde_compress<'lua>( async fn serde_compress(
lua: &'lua Lua, lua: &Lua,
(format, str): (CompressDecompressFormat, BString), (format, str): (CompressDecompressFormat, BString),
) -> LuaResult<LuaString<'lua>> { ) -> LuaResult<LuaString> {
let bytes = compress(format, str).await?; let bytes = compress(format, str).await?;
lua.create_string(bytes) lua.create_string(bytes)
} }
async fn serde_decompress<'lua>( async fn serde_decompress(
lua: &'lua Lua, lua: &Lua,
(format, str): (CompressDecompressFormat, BString), (format, str): (CompressDecompressFormat, BString),
) -> LuaResult<LuaString<'lua>> { ) -> LuaResult<LuaString> {
let bytes = decompress(format, str).await?; let bytes = decompress(format, str).await?;
lua.create_string(bytes) lua.create_string(bytes)
} }