pub trait CStrExt {
// Required method
fn as_string(&self) -> Result<String>;
}
Required Methods§
Implementations on Foreign Types§
Source§impl CStrExt for *const i8
impl CStrExt for *const i8
Source§fn as_string(&self) -> Result<String>
fn as_string(&self) -> Result<String>
Copy a C-style *const i8
string to a String
use switchtec_user_sys::CStrExt;
let cstr = CString::new(*b"hello")?;
// This is a type you might receive from an extern "C" function:
let str_value: *const i8 = cstr.as_ptr() as *const i8;
let rust_string: String = str_value.as_string()?;
assert_eq!(&rust_string, "hello");
Source§impl CStrExt for *mut i8
impl CStrExt for *mut i8
Source§fn as_string(&self) -> Result<String>
fn as_string(&self) -> Result<String>
Copy a C-style *mut i8
string to a String
use switchtec_user_sys::CStrExt;
let cstr = CString::new(*b"hello")?;
// This is a type you might receive from an extern "C" function:
let str_value: *mut i8 = cstr.as_ptr() as *mut i8;
let rust_string: String = str_value.as_string()?;
assert_eq!(&rust_string, "hello");