Struct rlua::String [−][src]
pub struct String<'lua>(_);
Handle to an internal Lua string.
Unlike Rust strings, Lua strings may not be valid UTF-8.
Methods
impl<'lua> String<'lua>
[src]
impl<'lua> String<'lua>
pub fn to_str(&self) -> Result<&str>
[src]
pub fn to_str(&self) -> Result<&str>
Get a &str
slice if the Lua string is valid UTF-8.
Examples
let lua = Lua::new(); let globals = lua.globals(); let version: String = globals.get("_VERSION")?; assert!(version.to_str().unwrap().contains("Lua")); let non_utf8: String = lua.eval(r#" "test\xff" "#, None)?; assert!(non_utf8.to_str().is_err());
pub fn as_bytes(&self) -> &[u8]
[src]
pub fn as_bytes(&self) -> &[u8]
Get the bytes that make up this string.
The returned slice will not contain the terminating nul byte, but will contain any nul bytes embedded into the Lua string.
Examples
let lua = Lua::new(); let non_utf8: String = lua.eval(r#" "test\xff" "#, None).unwrap(); assert!(non_utf8.to_str().is_err()); // oh no :( assert_eq!(non_utf8.as_bytes(), &b"test\xff"[..]);
pub fn as_bytes_with_nul(&self) -> &[u8]
[src]
pub fn as_bytes_with_nul(&self) -> &[u8]
Get the bytes that make up this string, including the trailing nul byte.
Trait Implementations
impl<'lua> ToLua<'lua> for String<'lua>
[src]
impl<'lua> ToLua<'lua> for String<'lua>
impl<'lua> FromLua<'lua> for String<'lua>
[src]
impl<'lua> FromLua<'lua> for String<'lua>
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<String<'lua>>
[src]
fn from_lua(value: Value<'lua>, lua: &'lua Lua) -> Result<String<'lua>>
Performs the conversion.
impl<'lua> Clone for String<'lua>
[src]
impl<'lua> Clone for String<'lua>
fn clone(&self) -> String<'lua>
[src]
fn clone(&self) -> String<'lua>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0
[src]Performs copy-assignment from source
. Read more
impl<'lua> Debug for String<'lua>
[src]
impl<'lua> Debug for String<'lua>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'lua> AsRef<[u8]> for String<'lua>
[src]
impl<'lua> AsRef<[u8]> for String<'lua>
impl<'lua, T> PartialEq<T> for String<'lua> where
T: AsRef<[u8]>,
[src]
impl<'lua, T> PartialEq<T> for String<'lua> where
T: AsRef<[u8]>,