pub struct LuaString { /* private fields */ }Expand description
A garbage-collected Lua string.
Mirrors mlua::String. Holds a registry reference to the underlying Lua
string so the bytes stay alive for the handle’s lifetime.
Under the send feature it is Send but never Sync — see
[crate::sync::NotSync].
Implementations§
Source§impl LuaString
impl LuaString
Sourcepub fn as_bytes(&self) -> Vec<u8> ⓘ
pub fn as_bytes(&self) -> Vec<u8> ⓘ
Get the raw bytes of the string (a copy).
Mirrors mlua::String::as_bytes (we return an owned Vec<u8> rather
than a borrowed guard — a deliberate simplification).
Sourcepub fn to_str(&self) -> Result<String>
pub fn to_str(&self) -> Result<String>
Get the string as a UTF-8 &str, erroring if it is not valid UTF-8.
Mirrors mlua::String::to_str (returns an owned String here).
Sourcepub fn to_string_lossy(&self) -> String
pub fn to_string_lossy(&self) -> String
Get the string lossily as a Rust String (invalid UTF-8 replaced).
Mirrors mlua::String::to_string_lossy.
Sourcepub fn as_bytes_with_nul(&self) -> Vec<u8> ⓘ
pub fn as_bytes_with_nul(&self) -> Vec<u8> ⓘ
The raw bytes with a trailing NUL appended (Lua strings are NUL
terminated). Mirrors mlua::String::as_bytes_with_nul.
Sourcepub fn to_pointer(&self) -> *const c_void
pub fn to_pointer(&self) -> *const c_void
A raw pointer identifying the interned string (for identity
comparison). Mirrors mlua::String::to_pointer.
Trait Implementations§
impl Eq for LuaString
Source§impl FromLua for LuaString
impl FromLua for LuaString
Source§fn from_lua_arg(
arg: Value,
_i: usize,
_to: Option<&str>,
lua: &Lua,
) -> Result<Self>
fn from_lua_arg( arg: Value, _i: usize, _to: Option<&str>, lua: &Lua, ) -> Result<Self>
i. The default forwards to
FromLua::from_lua; specific impls can produce nicer messages.
Mirrors mlua::FromLua::from_lua_arg.