Struct rcstring::CString
[−]
[src]
pub struct CString<'a> { // some fields omitted }
Type representing a C-compatible string.
Methods
impl<'a> CString<'a>
fn new(s: &'a str) -> Result<CString<'a>, Error>
Constructs a new CString from a string slice
The caller MUST ensure that there is a trailing NULL to terminate
the string. To make this easier, the cstr!
macro is provided.
CStrings MUST NOT have any non-ASCII characters, even extended ASCII characters aren't allowed.
Examples
use rcstring::CString; let cs = CString::new("foo\0").unwrap();
unsafe fn from_raw(ptr: *const c_char) -> Result<CString<'a>, Error>
Converts an exising raw pointer to a string and converts it to a
CString
with a length determined by an internal strlen
implementation.
unsafe fn into_raw(&self) -> *const c_char
Returns a mutable pointer to a CString for use in functions taking a classic C string
fn len(&self) -> usize
Returns length of string, including trailing NULL