lune-std-net 0.3.5

Lune standard library - Net
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use mlua::prelude::*;

pub fn encode(lua_string: LuaString, as_binary: bool) -> LuaResult<Vec<u8>> {
    if as_binary {
        Ok(urlencoding::encode_binary(&lua_string.as_bytes())
            .into_owned()
            .into_bytes())
    } else {
        Ok(urlencoding::encode(&lua_string.to_str()?)
            .into_owned()
            .into_bytes())
    }
}